Skip to content

Commit 1d0554b

Browse files
generate params table from baseline txt input file
1 parent 8345113 commit 1d0554b

5 files changed

Lines changed: 53 additions & 16 deletions

File tree

docs/Fervo_Project_Cape_HIIP_Analysis.md.jinja

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ All modeling assumptions represent the independent interpretation of the author
2323

2424
**HIP-RA-X Evaluation:**
2525
HIP-RA-X mathematically aligns perfectly with the SEC's thermal energy physics. Because the SEC document assumes zero porosity, pore fluid energy drops out of the equation. To mirror this exact state, we calibrated the base GEOPHIRES model with the following parameters derived from the filing:
26-
* **Reservoir Temperature:** 199.0 °C (Explicitly cited as the ORC design intake temperature).
27-
* **Rejection Temperature:** 80.0 °C (Fixed by D&M to match the produced water injection temperature).
28-
* **Reservoir Porosity:** 0.0 % (Matches the "little to no porosity" description).
29-
* **Reservoir Area:** 48.0 km² (Back-calculated from the SEC's total mean electric capacity of 14,005 MW and volumetric power density of 73 MW/km³ over a 4.0 km depth range).
30-
* **Reservoir Thickness:** 4.0 km (Matches the base accumulation depth bound).
31-
* **Density Of Reservoir Rock:** 2.8e12 kg/km³ (GEOPHIRES Cape Station baseline).
32-
* **Rock Heat Capacity:** 2.212e12 kJ/km³°C (GEOPHIRES Cape Station baseline).
26+
27+
{{ baseline_input_params_table_md }}
28+
29+
{#* **Reservoir Temperature:** 199.0 °C (Explicitly cited as the ORC design intake temperature).#}
30+
{#* **Rejection Temperature:** 80.0 °C (Fixed by D&M to match the produced water injection temperature).#}
31+
{#* **Reservoir Porosity:** 0.0 % (Matches the "little to no porosity" description).#}
32+
{#* **Reservoir Area:** 48.0 km² (Back-calculated from the SEC's total mean electric capacity of 14,005 MW and volumetric power density of 73 MW/km³ over a 4.0 km depth range).#}
33+
{#* **Reservoir Thickness:** 4.0 km (Matches the base accumulation depth bound).#}
34+
{#* **Density Of Reservoir Rock:** 2.8e12 kg/km³ (GEOPHIRES Cape Station baseline).#}
35+
{#* **Rock Heat Capacity:** 2.212e12 kJ/km³°C (GEOPHIRES Cape Station baseline).#}
3336

3437
### Estimation Methodology
3538

src/geophires_docs/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from geophires_x_client import GeophiresInputParameters
1212
from geophires_x_client import GeophiresXClient
1313
from geophires_x_client import GeophiresXResult
14+
from hip_ra import HipRaInputParameters
1415

1516
_NON_BREAKING_SPACE = '\xa0'
1617

@@ -63,7 +64,9 @@ def error(self, msg):
6364

6465

6566
def _get_input_parameters_dict( # TODO consolidate with FervoProjectCape5TestCase._get_input_parameters
66-
_params: GeophiresInputParameters, include_parameter_comments: bool = False, include_line_comments: bool = False
67+
_params: GeophiresInputParameters | HipRaInputParameters,
68+
include_parameter_comments: bool = False,
69+
include_line_comments: bool = False,
6770
) -> dict[str, Any]:
6871
comment_idx = 0
6972
ret: dict[str, Any] = {}
@@ -85,7 +88,7 @@ def _get_input_parameters_dict( # TODO consolidate with FervoProjectCape5TestCa
8588
return ret
8689

8790

88-
def _get_input_parameters_comments_dict(_params: GeophiresInputParameters) -> dict[str, str]:
91+
def _get_input_parameters_comments_dict(_params: GeophiresInputParameters | HipRaInputParameters) -> dict[str, str]:
8992
ret: dict[str, str] = {}
9093

9194
with open(_get_file_path('../geophires_x_schema_generator/geophires-request.json'), encoding='utf-8') as f:

src/geophires_docs/generate_fpc_hiip_analysis_doc.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from jinja2 import Environment
66
from jinja2 import FileSystemLoader
7+
from tabulate import tabulate
78

9+
from geophires_docs import _get_input_parameters_dict
10+
from geophires_docs import _get_logger
811
from geophires_monte_carlo import GeophiresMonteCarloClient
912
from geophires_monte_carlo import MonteCarloRequest
1013
from geophires_monte_carlo import MonteCarloResult
@@ -13,13 +16,35 @@
1316
from hip_ra_x import HipRaXClient
1417
from hip_ra_x import HipRaXResult
1518

16-
_log = logging.getLogger(__name__)
19+
_log = _get_logger(__name__)
1720

1821
_PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent
1922
_BUILD_DIR = _PROJECT_ROOT / 'build' / 'fpc_hiip_analysis'
2023
_IMAGES_DIR = _PROJECT_ROOT / 'docs' / '_images'
2124

2225

26+
def _get_baseline_input_params_table_md(baseline_input_params):
27+
params_dict = _get_input_parameters_dict(baseline_input_params, include_parameter_comments=True)
28+
29+
table = []
30+
31+
for k, v_c in params_dict.items():
32+
v = v_c.split(',')[0].strip()
33+
c = v_c.split(',')[1].replace(' -- ', '').strip()
34+
35+
# Prevent tabulate from trying to convert boolean strings to float
36+
if v.lower() in ('true', 'false'):
37+
v = f' {v}'
38+
39+
if c == '':
40+
# c = ' .. N/A'
41+
continue # omit commentless params for now
42+
43+
table.append([k, v, c])
44+
45+
return tabulate(table, ['Parameter', 'Value', 'Comment'], tablefmt='github', floatfmt='')
46+
47+
2348
def generate_fpc_hiip_analysis_doc():
2449
_BUILD_DIR.mkdir(parents=True, exist_ok=True)
2550
_IMAGES_DIR.mkdir(parents=True, exist_ok=True)
@@ -30,9 +55,8 @@ def generate_fpc_hiip_analysis_doc():
3055

3156
_log.info('Running deterministic HIP-RA-X baseline...')
3257
client = HipRaXClient()
33-
det_result: HipRaXResult = client.get_hip_ra_x_result(
34-
HipRaInputParameters(file_path_or_params_dict=base_input_path)
35-
)
58+
det_input_params: HipRaInputParameters = HipRaInputParameters(file_path_or_params_dict=base_input_path)
59+
det_result: HipRaXResult = client.get_hip_ra_x_result(det_input_params)
3660

3761
det_stored_heat_kj = det_result.result['SUMMARY OF RESULTS']['Stored Heat (reservoir)']['value']
3862
det_elec_mw = det_result.result['SUMMARY OF RESULTS']['Producible Electricity (reservoir)']['value']
@@ -94,7 +118,10 @@ def generate_fpc_hiip_analysis_doc():
94118
_log.info('Rendering Markdown documentation...')
95119
docs_dir = _PROJECT_ROOT / 'docs'
96120

121+
baseline_input_params_table_md = _get_baseline_input_params_table_md(det_input_params)
122+
97123
template_values = {
124+
'baseline_input_params_table_md': baseline_input_params_table_md,
98125
'det_stored_heat_15j': f'{det_stored_heat_15j:,.0f}',
99126
'det_elec_mw': f'{det_elec_mw:,.0f}',
100127
'mc_stored_heat_mean_15j': f'{mc_stored_heat_mean_15j:,.0f}',

src/hip_ra/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def as_file_path(self) -> Path:
3636
def output_file_path(self) -> Path:
3737
return self._output_file_path
3838

39+
def as_text(self):
40+
with open(self.as_file_path(), encoding='UTF-8') as f:
41+
return f.read()
42+
3943

4044
class HipRaResult:
4145
def __init__(self, output_file_path):

tests/hip_ra_x_tests/test_hip_ra_x.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def get_output_file_for_example(example_file: Path):
5858
expected_result = HipRaResult(expected_result_output_file_path)
5959
self.assertDictEqual(expected_result.result, result.result)
6060

61+
# TODO
62+
# self.assertFileContentsEqual(expected_result_output_file_path, result.output_file_path)
63+
6164
x_result = client.get_hip_ra_x_result(HipRaInputParameters(input_file_path))
6265
expected_x_result = HipRaXResult.from_hip_ra_result(expected_result)
6366
self.assertDictEqual(expected_x_result.result, x_result.result)
6467

65-
# TODO
66-
# self.assertFileContentsEqual(expected_result_output_file_path, result.output_file_path)
67-
6868
def test_print_output_to_console(self):
6969
def get_stdout_from_running(print_output_to_console: bool | int) -> str:
7070
params = {

0 commit comments

Comments
 (0)