TNO Intern

Commit 52e09451 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Updating the documentation

parent 3d0d255c
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2,12 +2,13 @@

The ThermoGIS methodology `calculate_doublet_performance_stochastic` assumes that we know the net-to-gross, porosity and depth of the aquifer and simulates doublets over a range of values for transmissivity (calculated from permeability and thickness).
There are two main reasons for selecting this statistical framework:

1. It is fast as we only sample over one parameter (and for the ThermoGIS website we have to run a lot of simulations)
2. Transmissivity is usually the most important reservoir property when determining performance
3. 
However, if conducting a local study you may well want to also incorporate statistical uncertainties across other reservoir properties, it is easy (and insightful) to use pythermogis to generate samples and make your own stochastic framework.
2. Transmissivity affects doublet performance significantly while often having a relatively high uncertainty

Here is a simple example where you define probability distributions on your input parameters and then run simulations across random combinations of those input parameters before deriving statistics from those samples:
However, if conducting a local study you may well want to explore a model space across other reservoir properties, or develop your own statistical framework.
Luckily, it is easy (and insightful) to use pythermogis to generate samples and make your own stochastic framework.
Here is a simple example where you define probability distributions on your input parameters and then run simulations across random combinations of those input parameters before deriving statistics from those simulations:

```python
from pythermogis import calculate_doublet_performance, calculate_pos, plot_exceedance

docs/usage/pvalues_doublet.md

deleted100644 → 0
+0 −61
Original line number Diff line number Diff line

##  p-values Stochastic Performance Calculations

This is a very simple example of how to use the `calculate_doublet_performance_stochastic` function from 
the `pythermogis` package to run the simulation for a set of p-values for the transmissivity of the reservoir,
which is the main source of uncertainty in the doublet simulation.

To that end the simulation is run for a range of p-values, which are the percentiles of the transmissivity distribution.

### 🧪 P-values Example

This example is an extension of the deterministic doublet simulation using the `calculate_doublet_performance_stochastic` function 
for a single location. The outcomes correspond to the p-value range of the transmissivity are presented as an expectation curve of transmissivity.

This example corresponds to test case `test_example5` in `test_doc_examples.py` in the `tests` 
directory of the repository.

```python
from pythermogis import calculate_doublet_performance_stochastic
from matplotlib import pyplot as plt
from pathlib import Path
from os import path
import xarray as xr

output_data_path = Path(path.dirname(__file__), "resources") / "test_output" / "example_data"

input_data = xr.Dataset({
    "thickness_mean": ((), 300),
    "thickness_sd": ((), 50),
    "ntg": ((), 0.5),
    "porosity": ((), 0.5),
    "depth": ((), 2000),
    "ln_permeability_mean": ((), 5),
    "ln_permeability_sd": ((), 0.5),
})
results = calculate_doublet_performance_stochastic(input_data, p_values=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99])
fig, axe = plt.subplots(figsize=(10, 5))
kh = results.transmissivity_with_ntg * 1.0
kh.plot(y="p_value", ax=axe)
axe.set_title(f"Aquifer Net transmissivity\n kH")
temp = input_data.temperature
inj_temp = results.inj_temp.sel(p_value=50, method="nearest")
prd_temp = results.prd_temp.sel(p_value=50, method="nearest")
axe.axhline(50.0, label=f"TEMP res: {temp:.1f} inj: {inj_temp:.1f} prd: {prd_temp:.1f} ",
            ls="--", c="tab:orange")
# axes.axhline(pos, label=f"probability of success: {pos:.1f}%",ls="--", c="tab:orange")
kh50 = kh.sel(p_value=50, method="nearest")
axe.axvline(kh50, ls="--", c="tab:orange")
axe.legend()
axe.set_xlabel("kH [Dm]")
axe.set_ylabel("p-value [%]")
plt.savefig(output_data_path / "kh.png")

```

---

![Example of p-values](../images/kh.png)

*Figure: Example of p-values for transmissivity in a doublet simulation*
+11 −11
Original line number Diff line number Diff line
@@ -49,21 +49,21 @@ This example corresponds to test case `test_example5` in `test_doc_examples.py`

```python
from pythermogis import calculate_doublet_performance_stochastic
import xarray as xr
from matplotlib import pyplot as plt
from pathlib import Path
from os import path
import xarray as xr

output_data_path = Path(path.dirname(__file__), "resources") / "test_output" / "example_data"
output_data_path.mkdir(parents=True, exist_ok=True)

input_data = xr.Dataset({
    "thickness_mean": ((), 300),
    "thickness_sd": ((), 50),
    "ntg": ((), 0.5),
    "porosity": ((), 0.5),
    "depth": ((), 2000),
    "ln_permeability_mean": ((), 5),
    "ln_permeability_sd": ((), 0.5),
    "thickness_mean": 300,
    "thickness_sd": 50,
    "ntg": 0.5,
    "porosity": 0.5,
    "depth": 2000,
    "ln_permeability_mean": 5,
    "ln_permeability_sd": 0.5,
})
results = calculate_doublet_performance_stochastic(input_data, p_values=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99])
fig, axe = plt.subplots(figsize=(10, 5))
+7 −7
Original line number Diff line number Diff line
@@ -73,13 +73,13 @@ def test_example_5():
    output_data_path.mkdir(parents=True, exist_ok=True)

    input_data = xr.Dataset({
        "thickness_mean": ((), 300),
        "thickness_sd": ((), 50),
        "ntg": ((), 0.5),
        "porosity": ((), 0.5),
        "depth": ((), 2000),
        "ln_permeability_mean": ((), 5),
        "ln_permeability_sd": ((), 0.5),
        "thickness_mean": 300,
        "thickness_sd": 50,
        "ntg": 0.5,
        "porosity": 0.5,
        "depth": 2000,
        "ln_permeability_mean": 5,
        "ln_permeability_sd": 0.5,
    })
    results = calculate_doublet_performance_stochastic(input_data, p_values=[1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99])
    fig, axe = plt.subplots(figsize=(10, 5))