"- Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences (GFZ, https://www.gfz-potsdam.de)\n",
"\n",
"Licensed under the EUPL-1.2 or later"
"Licensed under the EUPL-1.2 or later\n",
"```"
]
},
{
...
...
%% Cell type:markdown id: tags:
# Py4HIP: Python tool for Heat In Place calculations
**Py4HIP** is a **Py**thon tool **for****H**eat **I**n **P**lace calculations.
This tool was created to perform **Heat In Place (HIP)** calculations for your region of choice.
%% Cell type:raw id: tags:
%% Cell type:markdown id: tags:
```
Copyright 2022
- Judith Bott (judith.bott@gfz-potsdam.de)
- Laureen Benoit (laureen.benoit@gfz-potsdam.de)
- Nora Koltzer (nora.koltzer@gfz-potsdam.de)
- Denis Anikiev (denis.anikiev@gfz-potsdam.de)
- Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences (GFZ, https://www.gfz-potsdam.de)
Licensed under the EUPL-1.2 or later
```
%% Cell type:markdown id: tags:
Calculating the Heat In Place (HIP) for certain geological units or confined reservoirs is a standard method performed in various regions to assess the spatial variability of geothermal potential ([Nathenson, 1975](#Nathenson1975); [Muffler and Cataldi, 1978](#MufflerCataldi1978); [Garg and Combs, 2015](#GargCombs2015)).
The respective implementation in **Py4HIP** is based on a volumetric ($V$) quantification of contained energy ($H$) after [Muffler and Cataldi (1978)](#MufflerCataldi1978), where the geological unit at hand is considered as spatially variable in terms of its thickness ($M$), porosity ($\phi$), as well as density ($\rho$) and specific heat capacity ($c_p$) (for the solid rock ($m$) and brine ($brine$)).
Finally, $H$ represents (i) the excess energy stored under mean temperature ($T_{mean}$) conditions with respect to a reference temperature ($T_{ref}$, here taken as the temperature at the Earth's surface ($Z_{topo}$)); (ii) the sum of stored heat in the solid and fluid parts of the rock:
<aid='eq1'></a>
$$ H = V ((1 - \phi) \rho_{m} c_{p,m} + \phi \rho_{brine} c_{p, brine}) (T_r - T_{ref}) $$
%% Cell type:markdown id: tags:
<aid='fig1'></a>

%% Cell type:markdown id: tags:
The mean (or reservoir) temperature ($T_r$) is defined as the temperature measured or modelled at the mean depth ($Z_{mean, XY}$) of the geological unit at position XY ([Fig. 1](#fig1)).
This depth is obtained ([van Wees et al., 2012](#WeesKronimusEtAl2012)) by subtracting half of the unit’s thickness ($\frac{M_{XY}}{2}$) from the top of the layer ($Z_{min, XY}$):
Due to its strong temperature dependency, the specific heat capacity of the solid rock components ($c_{p,m}$) at reservoir conditions is calculated using an empirical formulation ([Bär, 2012](#Baer2012); modified after [Vosteen and Schellschmidt, 2003](#VosteenSchellschmidt2003)) and considering the respective reservoir temperature ($T_r$):
As the density of the pore fluid $\rho_{brine}$ is controlled by salinity $S$, temperature $T$, and pressure $p$, the following two empirical formulas of [Batzle and Wang (1992)](#BatzleWang1992) are used to correct the density values at standard conditions.
First one accounts for the effects of adjusted state parameters (obtaining the density of fresh water, $\rho_{fw}$, at reservoir conditions):
$$ \rho_{fw} = 1 + 10^{-6} \cdot ( -80 T - 3.3 T^2 + 0.00175 T^3 + 489p - 2Tp + 0.016 T^2 p - 1.3 \cdot 10^{-5} T^3 p - 0.333 p^2 - 0.002 T p^2)$$
where $p$ is calculated as the hydrostatic pressure.
Finally, **Py4HIP** accounts for the salinity effect ($\rho_{brine}$):
$$ \rho_{brine} = \rho_{fw} + S \cdot (0.668 + 0.44 S + 10^{-6} \cdot (300p - 2400pS + T \cdot (80 + 3T - 3300S - 13p + 47pS)))$$
The volume of rock ($V$) required to calculate the stored thermal energy ($H$; [eq. 1](#eq1)) is equal to the product of the total thickness of the reservoir unit ($M$) at the respective location ($XY$) and one square meter.
Hence, the energy values provided by **Py4HIP** as ASCII lists (and optionally as map representations, see below) correspond to the stored energy in $J/m^2$.
%% Cell type:markdown id: tags:
## Getting started
Before you can run the Heat-In-Place calculations, you need to undertake the following steps:
- Import relevant python packages
- Define your folder locations (paths)
- Ensure your files are in correct format
- Define steady parameters
%% Cell type:markdown id: tags:
### Import python packages
Before you can run the calculation you need to import the following python packages into your python environment:
-`input_file` represents the file name to be loaded
-`output_path` is the folder to store the results
-`output_path_fig` is the folder to store the resulting figures
Both `output_path` and `output_path_fig` are created after first execution of the script.
By default the script does not save the figures, in case you want to generate figures as well, enable it in the checkbox further down in this notebook.
User is free to adjust this script to its own needs.
%% Cell type:code id: tags:
``` python
input_path='./data/'# this folder contains test files
input_file='test_dataset.csv'# name of the file to load
output_path='./results/'# this folder will be created and will contain results
output_path_fig=output_path+'figures/'# this folder will be created and will contain figures
# Create paths:
Path(output_path_fig).mkdir(parents=True,exist_ok=True)# this creates both output paths at once
```
%% Cell type:markdown id: tags:
### File setup
In order to run the caculation smooothly, your input files should follow a specific structure that goes well with the formulas used in this tool.
The desirable file structure of your input data table must contain the columns shown here:
Now, with all preparations done, you should be able to smoothly run the calculation by running the following cells.
<divclass="alert alert-block alert-warning">
<b>Note:</b> There is an option to generate figures in addition to the output implemented in the script. You can decide whether executing or skipping the option by ticking or unticking the checker box 'Want to generate figures?' below.</div>
%% Cell type:markdown id: tags:
### Load files
Firstly, load your file into the script.
%% Cell type:markdown id: tags:
You have to assign the correct header manually in `line 6`, as this is dependant on your personal input table. Here, we assigned the header of the test-dataset.
Use `line 3` (by uncommenting it) if you want to load a `.txt` or `.dat` file and assign the correct delimiter (test-dataset uses space). Use `line 5` if you want to load a `.csv` file. (If your input file is an excel table, save it as Comma Seperated Values file `.csv` first.)
You should see your input data displayed correctly below, if everything has loaded without errors. Make sure to check for correctness here!
%% Cell type:code id: tags:
``` python
# Load data files
# line 3 is to load data files in .txt or .dat format:
Lastly, save your freshly generated dataset to your output folder, which you have chosen in the beginning.
%% Cell type:markdown id: tags:
<divclass="alert alert-block alert-success"><b>Save dataset:</b> Save the data in required format by uncommenting the respective line of which format you'd like to save your data in.
One also needs to assign the correct header (which is the same as in section Load files above) AND the new, just generated columns.</div>
%% Cell type:code id: tags:
``` python
# Save generated dataset to the desired output folder
<b>This is optional:</b> You can decide whether executing or skipping the option by ticking or unticking the checker box 'Want to generate figures?'.</div>
%% Cell type:code id: tags:
``` python
checker1=widgets.Checkbox(
value=False,
description='Want to generate figures?',
disabled=False,
indent=False
)
display(checker1)
#hide this
```
%% Output
%% Cell type:markdown id: tags:
If you wish to have some nice figures of your just generated Heat In Place dataset, after ticking the checkbox above rerun the code cell below by clicking on its triangle (below left) or pressing <kbd>SHIFT</kbd> + <kbd>ENTER</kbd> when the code cell below has a blue or green frame.
Additionally, here is a short explanation of code lines below in which you **might** need to adjust something for your personal data set:
-`line 2` add .reshape(x, y) for reshaping the array into your model extend/format
-`line 5` replace 0.1 with your default thickness value for non-deposited lithology
-`line 18/19` replace 500 by your chosen resolution for interpolation
-`line 21/22` replace linear by your chosen type of interpolation
-`line 25` set the title of your figure by replacing `'Example'`
<divclass="alert alert-block alert-success"><b>Save figure:</b> Set the name of the figure file and desired DPI in the last line.</div>
%% Cell type:code id: tags:
``` python
ifchecker1.value==True:
HIP_array=df_test['H'].values# 210, 250 is this test model extend .reshape(210, 250)
HIP_array=HIP_array/10**9# for pic in [PJ]
Mtotal_array=df_test['Mtotal'].values
HIP_array[Mtotal_array<=0.1]=np.nan# replace not deposited lithology points as NAN values only for pics
# minimum and maximum extent of model
xmin=np.min(df_test['x'])
xmax=np.max(df_test['x'])
ymin=np.min(df_test['y'])
ymax=np.max(df_test['y'])
# variables for interpolation (question: What?)
x=df_test['x']
y=df_test['y']
z=HIP_array
z_M=Mtotal_array
# define axes for interpolation grid (question: Where?):
xi=np.linspace(xmin,xmax,500)# 500 as chosen resolution
Bär, K. M. (2012). Untersuchung der tiefengeothermischen Potenziale von Hessen. (Ph.D. Thesis). TU Darmstadt, Darmstadt. https://tuprints.ulb.tu-darmstadt.de/3067/
<aid='BatzleWang1992'></a>
Batzle, M., & Wang, Z. (1992). Seismic properties of pore fluids. Geophysics, 57(11), 1396-1408. https://www.doi.org/10.1190/1.1443207
<aid='GargCombs2015'></a>
Garg, S. K., & Combs, J. (2015). A reformulation of USGS volumetric “heat in place” resource estimation method. Geothermics, 55, 150-158.
Muffler, P., & Cataldi, R. (1978). Methods for regional assessment of geothermal resources. Geothermics, 7(2-4), 53-89.
https://www.doi.org/10.1016/0375-6505(78)90002-0
<aid='Nathenson1975'></a>
Nathenson, M. (1975). Physical factors determining the fraction of stored energy recoverable from hydrothermal convection systems and conduction-dominated areas (No. USGS-OFR-75-525). Geological Survey, Menlo Park, Calif.(USA). https://www.doi.org/10.2172/7348122
<aid='WeesKronimusEtAl2012'></a>
Van Wees, J.-D., Kronimus, A., Van Putten, M., Pluymaekers, M., Mijnlieff, H., Van Hooff, P., Obdam, A., Kramers, L. (2012). Geothermal aquifer performance
assessment for direct heat production–Methodology and application to Rotliegend aquifers. Netherlands Journal of Geosciences, 91(4), 651-665.
https://doi.org/10.1017/S0016774600000433
<aid='VosteenSchellschmidt2003'></a>
Vosteen, H.-D., & Schellschmidt, R. (2003). Influence of temperature on thermal conductivity, thermal capacity and thermal diffusivity for different types of rock. Physics and Chemistry of the Earth, Parts A/B/C, 28(9-11), 499-509.