Skip to content

Commit 7e3c639

Browse files
break singh et al. simulation out in preparation to more fully document it
1 parent 7cbf3bb commit 7e3c639

File tree

5 files changed

+82
-38
lines changed

5 files changed

+82
-38
lines changed

src/geophires_docs/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
_PROJECT_ROOT = Path(__file__).parent.parent.parent

src/geophires_docs/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
if __name__ == '__main__':
2-
from geophires_docs import generate_fervo_project_cape_4_md
2+
from geophires_docs import generate_fervo_project_cape_4_docs
33

4-
generate_fervo_project_cape_4_md.main()
4+
generate_fervo_project_cape_4_docs.generate_fervo_project_cape_4_docs()
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from __future__ import annotations
2+
3+
from geophires_docs import _PROJECT_ROOT
4+
from geophires_docs import generate_fervo_project_cape_4_md
5+
from geophires_docs.generate_fervo_project_cape_4_graphs import generate_fervo_project_cape_4_graphs
6+
from geophires_x_client import GeophiresInputParameters
7+
from geophires_x_client import GeophiresXClient
8+
from geophires_x_client import GeophiresXResult
9+
from geophires_x_client import ImmutableGeophiresInputParameters
10+
11+
12+
# fmt:off
13+
def get_singh_et_al_base_simulation_result(base_input_params: GeophiresInputParameters) \
14+
-> tuple[GeophiresInputParameters,GeophiresXResult]:
15+
singh_et_al_base_simulation_input_params = ImmutableGeophiresInputParameters(
16+
from_file_path=base_input_params.as_file_path(),
17+
params={
18+
'Number of Production Wells': 4,
19+
'Maximum Drawdown': 1,
20+
'Plant Lifetime': 15,
21+
},
22+
)
23+
# fmt:on
24+
25+
singh_et_al_base_simulation_result = GeophiresXClient().get_geophires_result(
26+
singh_et_al_base_simulation_input_params
27+
)
28+
29+
return singh_et_al_base_simulation_input_params, singh_et_al_base_simulation_result
30+
31+
32+
def generate_fervo_project_cape_4_docs():
33+
input_params: GeophiresInputParameters = ImmutableGeophiresInputParameters(
34+
from_file_path=_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.txt'
35+
)
36+
result = GeophiresXResult(_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.out')
37+
38+
singh_et_al_base_simulation:tuple[GeophiresInputParameters,GeophiresXResult] = get_singh_et_al_base_simulation_result(input_params)
39+
40+
generate_fervo_project_cape_4_graphs(
41+
(input_params, result),
42+
singh_et_al_base_simulation,
43+
_PROJECT_ROOT / 'docs/_images'
44+
)
45+
46+
generate_fervo_project_cape_4_md.generate_fervo_project_cape_4_md(input_params,result)
47+
48+
49+
if __name__ == '__main__':
50+
generate_fervo_project_cape_4_docs()

src/geophires_docs/generate_fervo_project_cape_4_graphs.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import numpy as np
66
from matplotlib import pyplot as plt
77

8+
from geophires_docs import _PROJECT_ROOT
89
from geophires_x_client import GeophiresInputParameters
9-
from geophires_x_client import GeophiresXClient
1010
from geophires_x_client import GeophiresXResult
1111
from geophires_x_client import ImmutableGeophiresInputParameters
1212

@@ -134,25 +134,18 @@ def generate_production_temperature_graph(
134134

135135

136136
def generate_fervo_project_cape_4_graphs(
137-
input_params: GeophiresInputParameters, result: GeophiresXResult, output_dir: Path
137+
base_case: tuple[GeophiresInputParameters, GeophiresXResult],
138+
singh_et_al_base_simulation: tuple[GeophiresInputParameters, GeophiresXResult],
139+
output_dir: Path,
138140
) -> None:
141+
# base_case_input_params: GeophiresInputParameters = base_case[0]
142+
# result:GeophiresXResult = base_case[1]
143+
139144
# generate_net_power_graph(result, output_dir)
140145
# generate_production_temperature_graph(result, output_dir)
141146

142-
# fmt:off
143-
singh_et_al_base_simulation_input_params = ImmutableGeophiresInputParameters(
144-
from_file_path=input_params.as_file_path(),
145-
params={
146-
'Number of Production Wells': 4,
147-
'Maximum Drawdown': 1,
148-
'Plant Lifetime': 15,
149-
},
150-
)
151-
# fmt:on
147+
singh_et_al_base_simulation_result: GeophiresXResult = singh_et_al_base_simulation[1]
152148

153-
singh_et_al_base_simulation_result = GeophiresXClient().get_geophires_result(
154-
singh_et_al_base_simulation_input_params
155-
)
156149
# generate_net_power_graph(
157150
# singh_et_al_base_simulation_result, output_dir, filename='singh_et_al_base_simulation-net-power-production.png'
158151
# )
@@ -164,14 +157,13 @@ def generate_fervo_project_cape_4_graphs(
164157

165158

166159
if __name__ == '__main__':
167-
project_root = Path(__file__).parent.parent
168-
docs_dir = project_root / 'docs'
160+
docs_dir = _PROJECT_ROOT / 'docs'
169161
images_dir = docs_dir / '_images'
170162

171163
input_params_: GeophiresInputParameters = ImmutableGeophiresInputParameters(
172-
from_file_path=project_root / 'tests/examples/Fervo_Project_Cape-4.txt'
164+
from_file_path=_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.txt'
173165
)
174166

175-
result_ = GeophiresXResult(project_root / 'tests/examples/Fervo_Project_Cape-4.out')
167+
result_ = GeophiresXResult(_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.out')
176168

177169
generate_fervo_project_cape_4_graphs(input_params_, result_, images_dir)

src/geophires_docs/generate_fervo_project_cape_4_md.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,21 @@
77
from __future__ import annotations
88

99
import json
10-
from pathlib import Path
1110
from typing import Any
1211

1312
import numpy as np
1413
from jinja2 import Environment
1514
from jinja2 import FileSystemLoader
1615
from pint.facets.plain import PlainQuantity
1716

18-
from geophires_docs.generate_fervo_project_cape_4_graphs import generate_fervo_project_cape_4_graphs
17+
from geophires_docs import _PROJECT_ROOT
1918
from geophires_x.GeoPHIRESUtils import is_int
2019
from geophires_x.GeoPHIRESUtils import sig_figs
2120
from geophires_x_client import GeophiresInputParameters
2221
from geophires_x_client import GeophiresXResult
2322
from geophires_x_client import ImmutableGeophiresInputParameters
2423

2524
# Add project root to path to import GEOPHIRES and docs modules
26-
_PROJECT_ROOT = Path(__file__).parent.parent.parent
27-
# sys.path.insert(0, str(_PROJECT_ROOT / 'src'))
28-
# sys.path.insert(0, Path(__file__).parent)
2925

3026

3127
def _get_input_parameters_dict( # TODO consolidate with FervoProjectCape4TestCase._get_input_parameters
@@ -376,16 +372,7 @@ def _total_fracture_surface_area_per_well_m2(result: GeophiresXResult) -> float:
376372
)
377373

378374

379-
def main():
380-
"""
381-
Generate Fervo_Project_Cape-4.md (markdown documentation) from the Jinja template.
382-
"""
383-
384-
input_params: GeophiresInputParameters = ImmutableGeophiresInputParameters(
385-
from_file_path=_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.txt'
386-
)
387-
result = GeophiresXResult(_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.out')
388-
375+
def generate_fervo_project_cape_4_md(input_params: GeophiresInputParameters, result: GeophiresXResult) -> None:
389376
# noinspection PyDictCreation
390377
template_values = {**get_fpc4_input_parameter_values(input_params, result), **get_result_values(result)}
391378

@@ -395,8 +382,6 @@ def main():
395382
template_values['economics_parameters_table_md'] = generate_fpc4_economics_parameters_table_md(input_params)
396383

397384
docs_dir = _PROJECT_ROOT / 'docs'
398-
images_dir = docs_dir / '_images'
399-
generate_fervo_project_cape_4_graphs(input_params, result, images_dir)
400385

401386
# Set up Jinja environment
402387
env = Environment(loader=FileSystemLoader(docs_dir), autoescape=True)
@@ -417,5 +402,17 @@ def main():
417402
print(f"\tTotal CAPEX: ${template_values['total_capex_gusd']}B")
418403

419404

405+
def main():
406+
"""
407+
Generate Fervo_Project_Cape-4.md (markdown documentation) from the Jinja template.
408+
"""
409+
410+
input_params: GeophiresInputParameters = ImmutableGeophiresInputParameters(
411+
from_file_path=_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.txt'
412+
)
413+
result = GeophiresXResult(_PROJECT_ROOT / 'tests/examples/Fervo_Project_Cape-4.out')
414+
generate_fervo_project_cape_4_md(input_params, result)
415+
416+
420417
if __name__ == '__main__':
421418
main()

0 commit comments

Comments
 (0)