TNO Intern

Commit 031f8a80 authored by Jan Diederik van Wees's avatar Jan Diederik van Wees Committed by Hen Brett
Browse files

examples for jupyter notebook, modified pytoml and input_data

parent f8d440f4
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -55,6 +55,22 @@ pixi install

---

## Running the Jupyter notebook examples

Examples showing what you can do with pythermogis can be found in the `examples` directory. To run these examples, you need to download some extra dependencies, using UV this can be done with:

```bash
uv sync --group notebooks
```

To open the jupyter notebook application you can run:

```bash
uv run --with jupyter jupyter lab
```

From there navigate to the `examples` directory and open the notebooks you want to run.

## Contributing

If you have questions or feature requests send them via the [thermogis contact form](https://www.thermogis.nl/contact) and state that the question is about pythermogis.
+62 −0
Original line number Diff line number Diff line
%% Cell type:code id:initial_id tags:

``` python
from pythermogis import calculate_doublet_performance
import xarray as xr
```

%% Cell type:code id:23cd5a9471611a5c tags:

``` python
input_data = xr.Dataset({
    "thickness": 300,
    "ntg": 0.5,
    "porosity": 0.2,
    "depth": 2000,
    "permeability": 300,
})
```

%% Cell type:code id:3c92c4f9d5890229 tags:

``` python
results = calculate_doublet_performance(input_data)
```

%% Cell type:code id:4f81387037e4ce1e tags:

``` python
print(results.data_vars.keys())
```

%% Output

    KeysView(Data variables:
        thickness                int64 8B 300
        ntg                      float64 8B 0.5
        porosity                 float64 8B 0.2
        depth                    int64 8B 2000
        permeability             int64 8B 300
        mask                     float64 8B nan
        temperature              float64 8B 76.65
        transmissivity           int64 8B 90000
        transmissivity_with_ntg  float64 8B 45.0
        power                    float64 8B 19.75
        heat_pump_power          float64 8B 0.0
        capex                    float64 8B 19.65
        opex                     float64 8B -3.127
        utc                      float64 8B 4.872
        npv                      float64 8B 1.536
        hprod                    float64 8B 2.5e+06
        cop                      float64 8B 18.01
        cophp                    float64 8B 0.0
        pres                     float64 8B 60.0
        flow_rate                float64 8B 394.9
        welld                    float64 8B 1.193e+03
        inj_temp                 float64 8B 30.0
        prd_temp                 float64 8B 75.84)

%% Cell type:code id:e5e069faebb99ebd tags:

``` python
```
+95 −0
Original line number Diff line number Diff line
%% Cell type:code id:initial_id tags:

``` python
from pythermogis import calculate_doublet_performance
import xarray as xr
import numpy as np
```

%% Cell type:code id:5eeb6f3673a3b7f1 tags:

``` python
input_data = xr.Dataset({
    "thickness": (("x", "y"), np.array([[300, 300], [200, 200]])),
    "ntg": (("x", "y"), np.array([[0.5, 0.5], [0.25, 0.25]])),
    "porosity": (("x", "y"), np.array([[0.2, 0.2], [0.3, 0.3]])),
    "depth": (("x", "y"), np.array([[5000, 5000], [4500, 4500]])),
    "permeability": (("x", "y"), np.array([[300, 300], [450, 450]])),
}, coords={"x": [0, 1], "y": [10, 20]})
```

%% Cell type:code id:a166bdda1620353d tags:

``` python
results = calculate_doublet_performance(input_data)
```

%% Cell type:code id:c0e146c5398a6e52 tags:

``` python
print(results.coords)
print(results.data_vars.keys())
```

%% Output

    Coordinates:
      * x        (x) int64 16B 0 1
      * y        (y) int64 16B 10 20
    KeysView(Data variables:
        thickness                (x, y) int64 32B 300 300 200 200
        ntg                      (x, y) float64 32B 0.5 0.5 0.25 0.25
        porosity                 (x, y) float64 32B 0.2 0.2 0.3 0.3
        depth                    (x, y) int64 32B 5000 5000 4500 4500
        permeability             (x, y) int64 32B 300 300 450 450
        mask                     float64 8B nan
        temperature              (x, y) float64 32B 169.7 169.7 152.6 152.6
        transmissivity           (x, y) int64 32B 90000 90000 90000 90000
        transmissivity_with_ntg  (x, y) float64 32B 45.0 45.0 22.5 22.5
        power                    (x, y) float64 32B 48.42 48.42 49.34 49.34
        heat_pump_power          (x, y) float64 32B 0.0 0.0 0.0 0.0
        capex                    (x, y) float64 32B 53.33 53.33 49.56 49.56
        opex                     (x, y) float64 32B -6.998 -6.998 -7.835 -7.835
        utc                      (x, y) float64 32B 4.814 4.814 4.9 4.9
        npv                      (x, y) float64 32B 27.89 27.89 26.97 26.97
        hprod                    (x, y) float64 32B 6.127e+06 ... 6.243e+06
        cop                      (x, y) float64 32B 37.34 37.34 17.69 17.69
        cophp                    (x, y) float64 32B 0.0 0.0 0.0 0.0
        pres                     (x, y) float64 32B 56.02 56.02 120.5 120.5
        flow_rate                (x, y) float64 32B 500.0 500.0 500.0 500.0
        welld                    (x, y) float64 32B 1.306e+03 ... 2.224e+03
        inj_temp                 (x, y) float64 32B 69.65 69.65 52.6 52.6
        prd_temp                 (x, y) float64 32B 166.1 166.1 149.7 149.7)

%% Cell type:code id:147a4b3a919f8486 tags:

``` python
print(results.sel(x=1, y=10))
```

%% Output

    <xarray.Dataset> Size: 200B
    Dimensions:                  ()
    Coordinates:
        x                        int64 8B 1
        y                        int64 8B 10
    Data variables: (12/23)
        thickness                int64 8B 200
        ntg                      float64 8B 0.25
        porosity                 float64 8B 0.3
        depth                    int64 8B 4500
        permeability             int64 8B 450
        mask                     float64 8B nan
        ...                       ...
        cophp                    float64 8B 0.0
        pres                     float64 8B 120.5
        flow_rate                float64 8B 500.0
        welld                    float64 8B 2.224e+03
        inj_temp                 float64 8B 52.6
        prd_temp                 float64 8B 149.7

%% Cell type:code id:6885ec69a2f8d52d tags:

``` python
```
+72 −0
Original line number Diff line number Diff line
%% Cell type:code id:initial_id tags:

``` python
from pythermogis import calculate_doublet_performance
from pythermogis import instantiate_thermogis_parameters
import xarray as xr
```

%% Cell type:code id:d78e3e6f8909074d tags:

``` python
input_data = xr.Dataset({
    "thickness": 300,
    "ntg": 0.5,
    "porosity": 0.2,
    "depth": 2000,
    "permeability": 300,
})
```

%% Cell type:code id:59bb4943298aecec tags:

``` python
tg_properties = instantiate_thermogis_parameters()
tg_properties.setUseHeatpump(True)
tg_properties.setOpexPower(100)
tg_properties.setOpexBase(0)
tg_properties.setGoalTemperature(100)
tg_properties.setDhReturnTemp(50)
tg_properties.setUseKestinViscosity(True)

utc_properties = tg_properties.setupUTCParameters()
```

%% Cell type:code id:8a75abccf9d7e13e tags:

``` python
results = calculate_doublet_performance(input_data, utc_properties=utc_properties)
```

%% Cell type:code id:a01bab0bd12b4a7b tags:

``` python
print(results.data_vars.keys())
```

%% Output

    KeysView(Data variables:
        thickness                int64 8B 300
        ntg                      float64 8B 0.5
        porosity                 float64 8B 0.2
        depth                    int64 8B 2000
        permeability             int64 8B 300
        mask                     float64 8B nan
        temperature              float64 8B 76.65
        transmissivity           int64 8B 90000
        transmissivity_with_ntg  float64 8B 45.0
        power                    float64 8B 22.12
        heat_pump_power          float64 8B 10.56
        capex                    float64 8B 28.09
        opex                     float64 8B -6.133
        utc                      float64 8B 7.634
        npv                      float64 8B -19.15
        hprod                    float64 8B 2.799e+06
        cop                      float64 8B 4.053
        cophp                    float64 8B 2.844
        pres                     float64 8B 60.0
        flow_rate                float64 8B 411.9
        welld                    float64 8B 1.216e+03
        inj_temp                 float64 8B 26.65
        prd_temp                 float64 8B 75.87)
+58 −0
Original line number Diff line number Diff line
%% Cell type:code id:initial_id tags:

``` python
from pythermogis import calculate_doublet_performance_stochastic
import xarray as xr
```

%% Cell type:code id:537f0f900884962f tags:

``` python
input_data = xr.Dataset({
    "thickness_mean": 300,
    "thickness_sd": 50,
    "ntg": 0.5,
    "porosity": 0.2,
    "depth": 2000,
    "ln_permeability_mean": 4,
    "ln_permeability_sd": 0.5,
})
```

%% Cell type:code id:97c7b6db1a1d78a0 tags:

``` python
results = calculate_doublet_performance_stochastic(input_data)
```

%% Cell type:code id:2aaa8a00cde80f7c tags:

``` python
print(results.coords)
print(results.data_vars.keys())
```

%% Output

    Coordinates:
      * p_value  (p_value) float64 8B 50.0
    KeysView(Data variables:
        temperature              (p_value) float64 8B 76.65
        thickness                (p_value) int64 8B 300
        permeability             (p_value) float64 8B 54.6
        transmissivity           (p_value) float64 8B 1.638e+04
        transmissivity_with_ntg  (p_value) float64 8B 8.19
        power                    (p_value) float64 8B 4.751
        heat_pump_power          (p_value) float64 8B 0.0
        capex                    (p_value) float64 8B 14.11
        opex                     (p_value) float64 8B -0.7586
        utc                      (p_value) float64 8B 8.646
        npv                      (p_value) float64 8B -5.756
        hprod                    (p_value) float64 8B 6.012e+05
        cop                      (p_value) float64 8B 17.14
        cophp                    (p_value) float64 8B 0.0
        pres                     (p_value) float64 8B 60.0
        flow_rate                (p_value) float64 8B 99.78
        welld                    (p_value) float64 8B 592.8
        inj_temp                 (p_value) float64 8B 30.0
        prd_temp                 (p_value) float64 8B 73.61)
Loading