Skip to content

Commit 74181aa

Browse files
Merge pull request NREL#116 from softwareengineerprogrammer/main
Monte Carlo modularization/standardization first pass
2 parents 4e47136 + c2f7e1e commit 74181aa

37 files changed

+923
-439
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.3.4
2+
current_version = 3.4.0
33
commit = True
44
tag = True
55

.cookiecutterrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ default_context:
5454
sphinx_doctest: "no"
5555
sphinx_theme: "sphinx-py3doc-enhanced-theme"
5656
test_matrix_separate_coverage: "no"
57-
version: 3.3.4
57+
version: 3.4.0
5858
version_manager: "bump2version"
5959
website: "https://github.com/NREL"
6060
year_from: "2023"

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Changelog
55
GEOPHIRES-X (2023-2024)
66
------------------------
77

8+
3.4
9+
^^^
10+
Monte Carlo moved to dedicated module
11+
12+
`diff <https://github.com/NREL/GEOPHIRES-X/compare/v3.3.0...v3.4.0>`__
13+
14+
815
3.3
916
^^^
1017

README.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Free software: `MIT license <LICENSE>`__
4747
:alt: Supported implementations
4848
:target: https://pypi.org/project/geophires-x
4949

50-
.. |commits-since| image:: https://img.shields.io/github/commits-since/NREL/GEOPHIRES-X/v3.3.4.svg
50+
.. |commits-since| image:: https://img.shields.io/github/commits-since/NREL/GEOPHIRES-X/v3.4.0.svg
5151
:alt: Commits since latest release
52-
:target: https://github.com/NREL/GEOPHIRES-X/compare/v3.3.4...main
52+
:target: https://github.com/NREL/GEOPHIRES-X/compare/v3.4.0...main
5353

5454
.. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat
5555
:target: https://nrel.github.io/GEOPHIRES-X
@@ -281,6 +281,11 @@ Extending GEOPHIRES-X
281281

282282
- `Extension example: SUTRA <https://github.com/NREL/GEOPHIRES-X/commit/984cb4da1505667adb2c45cb1297cab6550774bd#diff-5b1ea85ce061b9a1137a46c48d2d293126224d677d3ab38d9b2f4dcfc4e1674e>`__
283283

284+
Monte Carlo
285+
-----------
286+
287+
`Monte Carlo User Guide <https://softwareengineerprogrammer.github.io/GEOPHIRES-X/Monte-Carlo-User-Guide.html>`__
288+
284289
Other Documentation:
285290
--------------------
286291
The `GEOPHIRES v2.0 (previous version's) user manual <References/GEOPHIRES%20v2.0%20User%20Manual.pdf>`__ describes GEOPHIRES's high-level software architecture.

docs/Monte-Carlo-User-Guide.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# GEOPHIRES Monte Carlo User Guide
2+
3+
## Example Setup
4+
5+
Create a project with the following structure, including GEOPHIRES in `requirements.txt` and setting up `venv` with `virtualenv`:
6+
7+
```
8+
├── GEOPHIRES-example1.txt
9+
├── MC_GEOPHIRES_Settings_file.txt
10+
├── main.py
11+
├── requirements.txt
12+
└── venv/
13+
```
14+
15+
In `main.py`:
16+
17+
```python
18+
from pathlib import Path
19+
20+
from geophires_monte_carlo import GeophiresMonteCarloClient, MonteCarloResult, MonteCarloRequest, SimulationProgram
21+
22+
23+
def monte_carlo():
24+
client = GeophiresMonteCarloClient()
25+
26+
result: MonteCarloResult = client.get_monte_carlo_result(
27+
MonteCarloRequest(
28+
SimulationProgram.GEOPHIRES,
29+
30+
# Files from tests/geophires_monte_carlo_tests - copy these into the same directory as main.py
31+
Path('GEOPHIRES-example1.txt').absolute(),
32+
Path('MC_GEOPHIRES_Settings_file.txt').absolute(),
33+
output_file=Path('MC_GEOPHIRES_Result.txt').absolute()
34+
)
35+
)
36+
37+
with open(result.output_file_path, 'r') as result_output_file:
38+
result_display = result_output_file.read()
39+
print(f'MC result:\n{result_display}')
40+
41+
if __name__ == '__main__':
42+
monte_carlo()
43+
```
44+
45+
To run:
46+
```
47+
(venv) python main.py
48+
49+
[...]
50+
51+
[2024-02-09 07:47:18][INFO] Complete geophires_monte_carlo.MC_GeoPHIRES3: main
52+
MC result:
53+
Electricity breakeven price, Project NPV, Gradient 1, Reservoir Temperature, Utilization Factor, Ambient Temperature
54+
38.81, -42.59, (Gradient 1:30.09736131122952;Reservoir Temperature:320.2888549098197;Utilization Factor:0.9295528406892491;Ambient Temperature:20.684620766378806;)
55+
17.81, -42.76, (Gradient 1:39.47722802709689;Reservoir Temperature:306.71578141214087;Utilization Factor:0.7604874092668568;Ambient Temperature:20.39891267899405;)
56+
9.91, -41.95, (Gradient 1:50.24142993501238;Reservoir Temperature:311.3876336705825;Utilization Factor:0.8657162766204807;Ambient Temperature:20.205604589516913;)
57+
61.37, -43.34, (Gradient 1:28.230745766883796;Reservoir Temperature:324.25115143107104;Utilization Factor:0.8308351836890867;Ambient Temperature:20.615118153663598;)
58+
8.76, -41.76, (Gradient 1:54.66070153603035;Reservoir Temperature:319.6097066730564;Utilization Factor:0.855785650134492;Ambient Temperature:19.359218133245772;)
59+
7.58, -37.63, (Gradient 1:57.53774721757885;Reservoir Temperature:318.6354560118773;Utilization Factor:0.9305717468323405;Ambient Temperature:20.011047903204176;)
60+
9.35, -41.03, (Gradient 1:51.20593175130416;Reservoir Temperature:311.40737612727423;Utilization Factor:0.8876035819161642;Ambient Temperature:19.968497775278948;)
61+
18.11, -42.68, (Gradient 1:38.66016637029756;Reservoir Temperature:310.20708430352124;Utilization Factor:0.7640202889998118;Ambient Temperature:18.805190553693578;)
62+
10.07, -40.41, (Gradient 1:47.876595779164845;Reservoir Temperature:310.4061695000305;Utilization Factor:0.9228147348375185;Ambient Temperature:20.119411582814514;)
63+
23.08, -41.38, (Gradient 1:33.342513206728185;Reservoir Temperature:305.48937077249826;Utilization Factor:0.9361923986407424;Ambient Temperature:18.423715643246567;)
64+
Electricity breakeven price:
65+
minimum: 7.58
66+
maximum: 61.37
67+
median: 13.94
68+
average: 20.48
69+
mean: 20.48
70+
standard deviation: 16.36
71+
bin values (as percentage): [0.09295408 0.18590816 0.18590816 0. 0. 0.
72+
0. 0. 0. 0.18590816 0. 0.
73+
0. 0. 0.09295408 0. 0. 0.
74+
0. 0. 0. 0. 0. 0.
75+
0. 0. 0. 0. 0. 0.09295408
76+
0. 0. 0. 0. 0. 0.
77+
0. 0. 0. 0. 0. 0.
78+
0. 0. 0. 0. 0. 0.
79+
0. 0.09295408]
80+
bin edges: [ 7.58 8.6558 9.7316 10.8074 11.8832 12.959 14.0348 15.1106 16.1864
81+
17.2622 18.338 19.4138 20.4896 21.5654 22.6412 23.717 24.7928 25.8686
82+
26.9444 28.0202 29.096 30.1718 31.2476 32.3234 33.3992 34.475 35.5508
83+
36.6266 37.7024 38.7782 39.854 40.9298 42.0056 43.0814 44.1572 45.233
84+
46.3088 47.3846 48.4604 49.5362 50.612 51.6878 52.7636 53.8394 54.9152
85+
55.991 57.0668 58.1426 59.2184 60.2942 61.37 ]
86+
Project NPV:
87+
minimum: -43.34
88+
maximum: -37.63
89+
median: -41.86
90+
average: -41.55
91+
mean: -41.55
92+
standard deviation: 1.56
93+
bin values (as percentage): [0.87565674 0. 0. 0. 0. 1.75131349
94+
0.87565674 0. 0. 0. 0. 0.
95+
0.87565674 0.87565674 0. 0. 0. 0.87565674
96+
0. 0. 0.87565674 0. 0. 0.
97+
0. 0.87565674 0. 0. 0. 0.
98+
0. 0. 0. 0. 0. 0.
99+
0. 0. 0. 0. 0. 0.
100+
0. 0. 0. 0. 0. 0.
101+
0. 0.87565674]
102+
bin edges: [-43.34 -43.2258 -43.1116 -42.9974 -42.8832 -42.769 -42.6548 -42.5406
103+
-42.4264 -42.3122 -42.198 -42.0838 -41.9696 -41.8554 -41.7412 -41.627
104+
-41.5128 -41.3986 -41.2844 -41.1702 -41.056 -40.9418 -40.8276 -40.7134
105+
-40.5992 -40.485 -40.3708 -40.2566 -40.1424 -40.0282 -39.914 -39.7998
106+
-39.6856 -39.5714 -39.4572 -39.343 -39.2288 -39.1146 -39.0004 -38.8862
107+
-38.772 -38.6578 -38.5436 -38.4294 -38.3152 -38.201 -38.0868 -37.9726
108+
-37.8584 -37.7442 -37.63 ]
109+
110+
```
111+
112+
## Documentation
113+
114+
See [module documentation](reference/geophires_monte_carlo.html)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
year = '2023'
1919
author = 'NREL'
2020
copyright = f'{year}, {author}'
21-
version = release = '3.3.4'
21+
version = release = '3.4.0'
2222

2323
pygments_style = 'trac'
2424
templates_path = ['./templates']

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Contents
88
overview
99
parameters
1010
How-to-extend-GEOPHIRES-X
11+
Monte-Carlo-User-Guide
1112
.. reference/index
1213
1314
Indices and tables
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
geophires_monte_carlo
2+
=====================
3+
4+
.. testsetup::
5+
6+
from geophires_monte_carlo import *
7+
8+
.. automodule:: geophires_monte_carlo
9+
:members:
10+
11+
.. automodule:: geophires_monte_carlo.MC_GeoPHIRES3
12+
:members:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def read(*names, **kwargs):
1313

1414
setup(
1515
name='geophires-x',
16-
version='3.3.4',
16+
version='3.4.0',
1717
license='MIT',
1818
description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.',
1919
long_description='{}\n{}'.format(

src/geophires_monte_carlo/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/MC_GEOPHIRES_Result.txt
2+
/MC_HIP_Result.txt
3+
*.png

0 commit comments

Comments
 (0)