Skip to content

Commit bf3113c

Browse files
Merge branch 'hip-ra-x-schema'
2 parents 600bb7d + c0c1b5d commit bf3113c

File tree

10 files changed

+255
-44
lines changed

10 files changed

+255
-44
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ requirements.txt
1313
.DS_Store
1414
*.lock
1515
*.json
16+
all_messages_conf.log
1617

1718
# C extensions
1819
*.so
@@ -81,6 +82,8 @@ docs/reference/geophires-request.json
8182
docs/reference/parameters.rst
8283
docs/geophires-request.json
8384
docs/parameters.rst
85+
docs/hip-ra-x-request.json
86+
docs/hip_ra_x_parameters.rst
8487
_site/
8588
/docs/geophires_x.rstx
8689
/docs/temperature.txt

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ Extending GEOPHIRES-X
349349

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

352+
353+
HIP-RA: Heat in Place - Resource Assessment
354+
-------------------------------------------
355+
356+
* `HIP-RA-X README <src/hip_ra_x/README.md>`__
357+
* `HIP-RA-X Parameters Reference <https://softwareengineerprogrammer.github.io/GEOPHIRES-X/hip_ra_x_parameters.html>`__
358+
.. TODO switch over to https://nrel.github.io/GEOPHIRES-X/hip_ra_x_parameters.html once merged
359+
352360
Monte Carlo
353361
-----------
354362

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+
hip_ra_x_parameters
1112
Monte-Carlo-User-Guide
1213
.. reference/index
1314
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
parameters.rst
1+
*parameters.rst
2+
all_messages_conf.log
3+
!geophires-request.json
4+
!hip-ra-x-request.json

src/geophires_x_schema_generator/__init__.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from geophires_x.SUTRAReservoir import SUTRAReservoir
2525
from geophires_x.SUTRAWellBores import SUTRAWellBores
2626
from geophires_x.TDPReservoir import TDPReservoir
27+
from hip_ra_x.hip_ra_x import HIP_RA_X
2728

2829

2930
class GeophiresXSchemaGenerator:
@@ -41,17 +42,9 @@ def _get_dummy_model(self):
4142
sys.argv = stash_sys_argv
4243
os.chdir(stash_cwd)
4344

44-
def get_parameters_json(self) -> Tuple[str, str]:
45+
def get_parameter_sources(self) -> list[Tuple[Any, str]]:
4546
dummy_model = self._get_dummy_model()
46-
47-
def with_category(param_dict: dict, category: str):
48-
def _with_cat(p: Parameter, cat: str):
49-
p.parameter_category = cat
50-
return p
51-
52-
return {k: _with_cat(v, category) for k, v in param_dict.items()}
53-
54-
parameter_sources = [
47+
return [
5548
(dummy_model.reserv, 'Reservoir'),
5649
(TDPReservoir(dummy_model), 'Reservoir'),
5750
(LHSReservoir(dummy_model), 'Reservoir'),
@@ -72,6 +65,19 @@ def _with_cat(p: Parameter, cat: str):
7265
(EconomicsAddOns(dummy_model), 'Economics'),
7366
]
7467

68+
def get_schema_title(self) -> str:
69+
return 'GEOPHIRES-X'
70+
71+
def get_parameters_json(self) -> Tuple[str, str]:
72+
73+
def with_category(param_dict: dict, category: str):
74+
def _with_cat(p: Parameter, cat: str):
75+
p.parameter_category = cat
76+
return p
77+
78+
return {k: _with_cat(v, category) for k, v in param_dict.items()}
79+
80+
parameter_sources = self.get_parameter_sources()
7581
output_params = {}
7682
input_params = {}
7783
for param_source in parameter_sources:
@@ -112,7 +118,7 @@ def generate_json_schema(self) -> dict:
112118
'definitions': {},
113119
'$schema': 'http://json-schema.org/draft-04/schema#',
114120
'type': 'object',
115-
'title': 'GEOPHIRES Schema',
121+
'title': f'{self.get_schema_title()} Schema',
116122
'required': required,
117123
'properties': properties,
118124
}
@@ -132,10 +138,11 @@ def generate_parameters_reference_rst(self) -> str:
132138
input_params_by_category[category][input_param_name] = input_param
133139

134140
def get_input_params_table(category_params, category_name) -> str:
141+
category_display = category_name if category_name is not None else ''
135142
input_rst = f"""
136-
{category_name}
137-
{'-' * len(category_name)}
138-
.. list-table:: {category_name} Parameters
143+
{category_display}
144+
{'-' * len(category_display)}
145+
.. list-table:: {category_display}{' ' if len(category_display) > 0 else ''}Parameters
139146
:header-rows: 1
140147
141148
* - Name
@@ -170,7 +177,7 @@ def get_input_params_table(category_params, category_name) -> str:
170177

171178
output_rst = self.get_output_params_table_rst(output_params_json)
172179

173-
rst = f"""Parameters
180+
rst = f"""{self.get_schema_title()} Parameters
174181
==========
175182
176183
.. contents::
@@ -230,3 +237,12 @@ def _get_min_and_max(param: dict, default_val='') -> Tuple:
230237
max_val = max(param['AllowableRange'])
231238

232239
return (min_val, max_val)
240+
241+
242+
class HipRaXSchemaGenerator(GeophiresXSchemaGenerator):
243+
def get_parameter_sources(self) -> list[Tuple[Any, str]]:
244+
dummy_model = HIP_RA_X()
245+
return [(dummy_model, None)]
246+
247+
def get_schema_title(self) -> str:
248+
return 'HIP-RA-X'

src/geophires_x_schema_generator/geophires-request.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"definitions": {},
33
"$schema": "http://json-schema.org/draft-04/schema#",
44
"type": "object",
5-
"title": "GEOPHIRES Schema",
5+
"title": "GEOPHIRES-X Schema",
66
"required": [
77
"Reservoir Model",
88
"Reservoir Depth",
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
"definitions": {},
3+
"$schema": "http://json-schema.org/draft-04/schema#",
4+
"type": "object",
5+
"title": "HIP-RA-X Schema",
6+
"required": [
7+
"Reservoir Temperature",
8+
"Rejection Temperature",
9+
"Reservoir Porosity",
10+
"Reservoir Area",
11+
"Reservoir Thickness",
12+
"Reservoir Life Cycle",
13+
"Rock Heat Capacity",
14+
"Fluid Specific Heat Capacity",
15+
"Density Of Reservoir Fluid",
16+
"Density Of Reservoir Rock"
17+
],
18+
"properties": {
19+
"Reservoir Temperature": {
20+
"description": "Reservoir Temperature [150 degC]",
21+
"type": "number",
22+
"units": "degC",
23+
"category": null,
24+
"default": 0.0,
25+
"minimum": 50,
26+
"maximum": 1000
27+
},
28+
"Rejection Temperature": {
29+
"description": "Rejection Temperature [25 degC]",
30+
"type": "number",
31+
"units": "degC",
32+
"category": null,
33+
"default": 0.0,
34+
"minimum": 0.1,
35+
"maximum": 200
36+
},
37+
"Reservoir Porosity": {
38+
"description": "Reservoir Porosity [18%]",
39+
"type": "number",
40+
"units": "%",
41+
"category": null,
42+
"default": 0.0,
43+
"minimum": 0.0,
44+
"maximum": 100.0
45+
},
46+
"Reservoir Area": {
47+
"description": "Reservoir Area [81 km2]",
48+
"type": "number",
49+
"units": "km**2",
50+
"category": null,
51+
"default": 0.0,
52+
"minimum": 0.0,
53+
"maximum": 10000.0
54+
},
55+
"Reservoir Thickness": {
56+
"description": "Reservoir Thickness [0.286 km]",
57+
"type": "number",
58+
"units": "kilometer",
59+
"category": null,
60+
"default": 0.0,
61+
"minimum": 0.0,
62+
"maximum": 10000.0
63+
},
64+
"Reservoir Life Cycle": {
65+
"description": "Reservoir Life Cycle [30 years]",
66+
"type": "integer",
67+
"units": "yr",
68+
"category": null,
69+
"default": null,
70+
"minimum": 1,
71+
"maximum": 100
72+
},
73+
"Rock Heat Capacity": {
74+
"description": "Rock Heat Capacity [2.84E+12 kJ/km3C]",
75+
"type": "number",
76+
"units": "kJ/km**3C",
77+
"category": null,
78+
"default": 0.0,
79+
"minimum": 0.0,
80+
"maximum": 100000000000000.0
81+
},
82+
"Fluid Specific Heat Capacity": {
83+
"description": "Specific Heat Capacity Of Water [4.18 kJ/kgC]",
84+
"type": "number",
85+
"units": "kJ/kgC",
86+
"category": null,
87+
"default": 0.0,
88+
"minimum": 3.0,
89+
"maximum": 10.0
90+
},
91+
"Density Of Reservoir Fluid": {
92+
"description": "Density Of Water [1.0E+12 kg/km3]",
93+
"type": "number",
94+
"units": "kg/km**3",
95+
"category": null,
96+
"default": 0.0,
97+
"minimum": 100000000000.0,
98+
"maximum": 10000000000000.0
99+
},
100+
"Density Of Reservoir Rock": {
101+
"description": "Density Of Rock [2.55E+12 kg/km3]",
102+
"type": "number",
103+
"units": "kg/km**3",
104+
"category": null,
105+
"default": 0.0,
106+
"minimum": 100000000000.0,
107+
"maximum": 10000000000000.0
108+
},
109+
"Rock Recoverable Heat": {
110+
"description": "percent of heat that is recoverable from the rock in the reservoir 0.66 for high-T reservoirs, 0.43 for low-T reservoirs (Garg and Combs (2011)",
111+
"type": "number",
112+
"units": "",
113+
"category": null,
114+
"default": 0.0,
115+
"minimum": 0.0,
116+
"maximum": 1.0
117+
},
118+
"Fluid Recoverable Heat": {
119+
"description": "percent of heat that is recoverable from the fluid in the reservoir 0.66 for high-T reservoirs, 0.43 for low-T reservoirs (Garg and Combs (2011)",
120+
"type": "number",
121+
"units": "",
122+
"category": null,
123+
"default": 0.0,
124+
"minimum": 0.0,
125+
"maximum": 1.0
126+
},
127+
"Recoverable Fluid Factor": {
128+
"description": "percent of fluid that is recoverable from the reservoir (0.5 = 50%)",
129+
"type": "number",
130+
"units": "",
131+
"category": null,
132+
"default": 0.0,
133+
"minimum": 0.0,
134+
"maximum": 1.0
135+
},
136+
"Reservoir Depth": {
137+
"description": "depth to top of reservoir (km). Calculated based on an assumed gradient and the reservoir temperature if no value given",
138+
"type": "number",
139+
"units": "kilometer",
140+
"category": null,
141+
"default": 0.0,
142+
"minimum": 0.001,
143+
"maximum": 15.0
144+
},
145+
"Reservoir Pressure": {
146+
"description": "pressure of the of reservoir (in mPa). Calculated assuming hydrostatic pressure and reservoir depth & water density if no value given",
147+
"type": "number",
148+
"units": "mPa",
149+
"category": null,
150+
"default": 0.0,
151+
"minimum": 0.0,
152+
"maximum": 10000.0
153+
},
154+
"Recoverable Heat from Rock": {
155+
"description": "percent of fluid that is recoverable from the reservoir (0.75 = 75%)",
156+
"type": "number",
157+
"units": "",
158+
"category": null,
159+
"default": 0.0,
160+
"minimum": 0.0,
161+
"maximum": 1.0
162+
},
163+
"HTML Output File": {
164+
"description": "Provide a HTML output name if you want to have HTML output (no output if not provided)",
165+
"type": "string",
166+
"units": null,
167+
"category": null,
168+
"default": null,
169+
"minimum": null,
170+
"maximum": null
171+
}
172+
}
173+
}

src/geophires_x_schema_generator/main.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
from geophires_x_schema_generator import GeophiresXSchemaGenerator
6+
from geophires_x_schema_generator import HipRaXSchemaGenerator
67

78
if __name__ == '__main__':
89
parser = argparse.ArgumentParser()
@@ -20,18 +21,20 @@
2021

2122
build_dir.mkdir(exist_ok=True)
2223

23-
build_path = Path(build_dir, 'geophires-request.json')
24+
def build(json_file_name: str, generator: GeophiresXSchemaGenerator, rst_file_name: str):
25+
build_path = Path(build_dir, json_file_name)
26+
schema_json = generator.generate_json_schema()
2427

25-
generator = GeophiresXSchemaGenerator()
28+
with open(build_path, 'w') as f:
29+
f.write(json.dumps(schema_json, indent=2))
30+
print(f'Wrote JSON schema file to {build_path}.')
2631

27-
schema_json = generator.generate_json_schema()
32+
rst = generator.generate_parameters_reference_rst()
2833

29-
with open(build_path, 'w') as f:
30-
f.write(json.dumps(schema_json, indent=2))
31-
print(f'Wrote schema file to {build_path}.')
34+
build_path_rst = Path(build_dir, rst_file_name)
35+
with open(build_path_rst, 'w') as f:
36+
f.write(rst)
37+
print(f'Wrote RST file to {build_path_rst}.')
3238

33-
rst = generator.generate_parameters_reference_rst()
34-
35-
build_path_rst = Path(build_dir, 'parameters.rst')
36-
with open(build_path_rst, 'w') as f:
37-
f.write(rst)
39+
build('geophires-request.json', GeophiresXSchemaGenerator(), 'parameters.rst')
40+
build('hip-ra-x-request.json', HipRaXSchemaGenerator(), 'hip_ra_x_parameters.rst')

src/hip_ra_x/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ See:
77

88
## HIP-RA-X
99
HIP-RA-X is the successor version to HIP-RA.
10+
11+
## Parameters
12+
13+
[Parameters Reference](https://softwareengineerprogrammer.github.io/GEOPHIRES-X/hip_ra_x_parameters.html)

0 commit comments

Comments
 (0)