TNO Intern

Commit 8a3b7338 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

separating the doublet simulation into deterministic and stochastic

parent 2791e941
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ Here is an example, where the default utc_properties is used, but the UseHeatPum
`utc_properties` themselves, with the `.build()` method of the `utc_properties_builder`.

```python
from src.pythermogis import calculate_doublet_performance, instantiate_utc_properties_builder
from src.pythermogis import calculate_doublet_performance_probabilistic, instantiate_utc_properties_builder
import xarray as xr

input_data = xr.Dataset({
@@ -53,7 +53,7 @@ input_data = xr.Dataset({
})

utc_properties = instantiate_utc_properties_builder().setUseHeatPump(True).build()
results = calculate_doublet_performance(input_data, utc_properties=utc_properties)
results = calculate_doublet_performance_probabilistic(input_data, utc_properties=utc_properties)
print(results)
```

@@ -67,7 +67,7 @@ The vast majority of the parameters in the xml are not used by this python API;
unfortunately they are still needed in the xml file to enable parsing.

```python
from src.pythermogis import calculate_doublet_performance, instantiate_utc_properties_from_xml
from src.pythermogis import calculate_doublet_performance_probabilistic, instantiate_utc_properties_from_xml
import xarray as xr

input_data = xr.Dataset({
@@ -81,7 +81,7 @@ input_data = xr.Dataset({
})

utc_properties = instantiate_utc_properties_from_xml("path/to/valid/xml/file")
results = calculate_doublet_performance(input_data, utc_properties=utc_properties)
results = calculate_doublet_performance_probabilistic(input_data, utc_properties=utc_properties)
print(results)
```
+7 −9
Original line number Diff line number Diff line
@@ -16,11 +16,9 @@ for a single location. The outcomes correspond to the mean values of the input p
and the results are printed to the console.

```python 
from src.pythermogis import calculate_doublet_performance
from src.pythermogis import calculate_doublet_performance_probabilistic
import xarray as xr



input_data = xr.Dataset({
    "thickness_mean": ((), 300),
    "thickness_sd": ((), 50),
@@ -31,7 +29,7 @@ input_data = xr.Dataset({
    "ln_permeability_sd": ((), 0.5),
})

results = calculate_doublet_performance(input_data)
results = calculate_doublet_performance_probabilistic(input_data)
print(results)
```

@@ -44,7 +42,7 @@ for a user defined 2-d grid of locations. The outcomes correspond to the mean va
and the results are printed to the console

```python
from src.pythermogis import calculate_doublet_performance
from src.pythermogis import calculate_doublet_performance_probabilistic
import xarray as xr
import numpy as np

@@ -58,7 +56,7 @@ input_data = xr.Dataset({
    "ln_permeability_sd": (("x", "y"), np.array([[0.5, 0.5], [0.75, 0.75]])),
}, coords={"x": [0, 1], "y": [10, 20]})

results = calculate_doublet_performance(input_data)
results = calculate_doublet_performance_probabilistic(input_data)
print(results)
```

@@ -73,7 +71,7 @@ run a deterministic doublet simulation using the `calculate_doublet_performance`
    Example input data for some of these examples is available in the `/resources/example_data` directory

```python
from src.pythermogis import calculate_doublet_performance
from src.pythermogis import calculate_doublet_performance_probabilistic
from pygridsio import read_grid

input_grids = read_grid("thickness.zmap").to_dataset(name="thickness_mean")
@@ -85,7 +83,7 @@ input_grids["mask"] = read_grid("hydrocarbons.zmap")
input_grids["ln_permeability_mean"] = read_grid("ln_perm.zmap")
input_grids["ln_permeability_sd"] = read_grid("ln_perm_sd.zmap")

results = calculate_doublet_performance(input_grids)
results = calculate_doublet_performance_probabilistic(input_grids)
print(results)
x, y = 125e3, 525e3  # define location
results_loc = results.sel(x=x, y=y, method="nearest")
+17 −17
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ This example corresponds to test case `test_example5` in `test_doc_examples.py`
directory of the repository.

```python
from pythermogis import calculate_doublet_performance, calculate_pos
from pythermogis import calculate_doublet_performance_probabilistic, calculate_pos
from pygridsio import read_grid, plot_grid, resample_xarray_grid
from matplotlib import pyplot as plt
import xarray as xr
@@ -64,7 +64,7 @@ reservoir_properties["ln_permeability_sd"] = resample_xarray_grid(read_grid(inpu
if (output_data_path / "output_results.nc").exists and not run_simulation:
    results = xr.load_dataset(output_data_path / "output_results.nc")
else:
  results = calculate_doublet_performance(reservoir_properties, p_values=[10,20,30,40,50,60,70,80,90])
    results = calculate_doublet_performance_probabilistic(reservoir_properties, p_values=[10, 20, 30, 40, 50, 60, 70, 80, 90])
    results.to_netcdf(output_data_path / "output_results.nc")  # write doublet simulation results to file

# plot results as maps
+56 −57
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ This example corresponds to test case `test_example6` in `test_doc_examples.py`
directory of the repository.

```python
from pythermogis import calculate_doublet_performance, calculate_pos
from pythermogis import calculate_doublet_performance_probabilistic, calculate_pos
from pygridsio import read_grid
from matplotlib import pyplot as plt
import xarray as xr
@@ -65,7 +65,7 @@ for i, (x, y) in enumerate(portfolio_coords):
    locations.append(point)
portfolio_reservoir_properties = xr.concat(locations, dim="location")

results_portfolio = calculate_doublet_performance(portfolio_reservoir_properties, p_values=[10, 20, 30, 40, 50, 60, 70, 80, 90])
results_portfolio = calculate_doublet_performance_probabilistic(portfolio_reservoir_properties, p_values=[10, 20, 30, 40, 50, 60, 70, 80, 90])

# post process: clip the npv and calculate the probability of success
AEC = -3.5
@@ -76,7 +76,6 @@ results_portfolio["pos"] = calculate_pos(results_portfolio)
fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(10, 10))
colors = plt.cm.tab10.colors
for i_loc, loc in enumerate(portfolio_coords):

    # select single portfolio location to plot
    results_loc = results_portfolio.isel(location=i_loc)
    pos = results_loc.pos.data
+5 −4
Original line number Diff line number Diff line
@@ -17,11 +17,12 @@ This example corresponds to test case `test_example4` in `test_doc_examples.py`
directory of the repository.

```python
from pythermogis import calculate_doublet_performance
from pythermogis import calculate_doublet_performance_probabilistic
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({
@@ -33,7 +34,7 @@ input_data = xr.Dataset({
    "ln_permeability_mean": ((), 5),
    "ln_permeability_sd": ((), 0.5),
})
results = calculate_doublet_performance(input_data,p_values=[1,10, 20, 30, 40, 50, 60, 70, 80, 90,99])
results = calculate_doublet_performance_probabilistic(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)
Loading