Skip to content

Commit 330c7f5

Browse files
add types to result schema
1 parent 5f62dab commit 330c7f5

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/geophires_x_schema_generator/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def generate_json_schema(self) -> Tuple[dict, dict]:
114114

115115
units_val = param['CurrentUnits'] if isinstance(param['CurrentUnits'], str) else None
116116
min_val, max_val = _get_min_and_max(param, default_val=None)
117+
117118
properties[param_name] = {
118119
'description': param['ToolTipText'],
119120
'type': param['json_parameter_type'],
@@ -179,6 +180,7 @@ def get_result_json_schema(self, output_params_json) -> dict:
179180

180181
if param_name in output_params:
181182
output_param = output_params[param_name]
183+
param['type'] = output_param['json_parameter_type']
182184
description = output_param['ToolTipText']
183185
if 'output_parameter_name' in output_param:
184186
description = f'{output_param["output_parameter_name"]}. {description}'

src/geophires_x_schema_generator/geophires-result.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@
3636
"Segment 3 Thickness": {},
3737
"Segment 4 Geothermal gradient": {},
3838
"LCOE": {
39+
"type": "number",
3940
"description": "",
4041
"units": "cents/kWh"
4142
},
4243
"LCOH": {
44+
"type": "number",
4345
"description": "",
4446
"units": "USD/MMBTU"
4547
},
@@ -52,29 +54,34 @@
5254
"properties": {
5355
"Economic Model": {},
5456
"Interest Rate": {
57+
"type": "number",
5558
"description": "",
5659
"units": "%"
5760
},
5861
"Accrued financing during construction": {},
5962
"Project lifetime": {},
6063
"Capacity factor": {},
6164
"Project NPV": {
65+
"type": "number",
6266
"description": "Project Net Present Value. NPV is calculated with cashflows lumped at the end of periods. See: Short W et al, 1995. \"A Manual for the Economic Evaluation of Energy Efficiency and Renewable Energy Technologies.\", p. 41. https://www.nrel.gov/docs/legosti/old/5173.pdf",
6367
"units": "MUSD"
6468
},
6569
"Project IRR": {},
6670
"Project VIR=PI=PIR": {},
6771
"Project MOIC": {
72+
"type": "number",
6873
"description": "Project Multiple of Invested Capital",
6974
"units": ""
7075
},
7176
"Fixed Charge Rate (FCR)": {},
7277
"Project Payback Period": {
78+
"type": "number",
7379
"description": "",
7480
"units": "yr"
7581
},
7682
"CHP: Percent cost allocation for electrical plant": {},
7783
"Estimated Jobs Created": {
84+
"type": "number",
7885
"description": "",
7986
"units": null
8087
}
@@ -137,6 +144,7 @@
137144
"Pump efficiency": {},
138145
"Injection temperature": {},
139146
"Injection Temperature": {
147+
"type": "array",
140148
"description": "",
141149
"units": "degC"
142150
},
@@ -176,6 +184,7 @@
176184
"Reservoir Model": {},
177185
"Fracture model": {},
178186
"Bottom-hole temperature": {
187+
"type": "number",
179188
"description": "",
180189
"units": "degC"
181190
},
@@ -191,6 +200,7 @@
191200
"Average reservoir pressure": {},
192201
"Plant outlet pressure": {},
193202
"Production wellhead pressure": {
203+
"type": "number",
194204
"description": "",
195205
"units": "kPa"
196206
},
@@ -208,6 +218,7 @@
208218
"properties": {
209219
"Maximum Production Temperature": {},
210220
"Average Production Temperature": {
221+
"type": "number",
211222
"description": "",
212223
"units": "degC"
213224
},
@@ -220,6 +231,7 @@
220231
"Total Average Pressure Drop": {},
221232
"Average Injection Well Pressure Drop": {},
222233
"Average Production Pressure": {
234+
"type": "number",
223235
"description": "",
224236
"units": "bar"
225237
},
@@ -251,6 +263,7 @@
251263
"type": "object",
252264
"properties": {
253265
"Drilling and completion costs": {
266+
"type": "number",
254267
"description": "Wellfield cost. Includes total drilling and completion cost of all injection and production wells and laterals, plus 5% indirect costs.",
255268
"units": "MUSD"
256269
},
@@ -260,6 +273,7 @@
260273
"Drilling and completion costs per vertical production well": {},
261274
"Drilling and completion costs per vertical injection well": {},
262275
"Drilling and completion costs per non-vertical section": {
276+
"type": "number",
263277
"description": "",
264278
"units": "MUSD"
265279
},
@@ -273,6 +287,7 @@
273287
"of which Peaking Boiler Cost": {},
274288
"Transmission pipeline cost": {},
275289
"District Heating System Cost": {
290+
"type": "number",
276291
"description": "",
277292
"units": "MUSD"
278293
},
@@ -301,10 +316,12 @@
301316
"Absorption Chiller O&M Cost": {},
302317
"Average Heat Pump Electricity Cost": {},
303318
"Annual District Heating O&M Cost": {
319+
"type": "number",
304320
"description": "",
305321
"units": "MUSD/yr"
306322
},
307323
"Average Annual Peaking Fuel Cost": {
324+
"type": "number",
308325
"description": "",
309326
"units": "MUSD/yr"
310327
},
@@ -354,6 +371,7 @@
354371
"Minimum Peaking Boiler Heat Production": {},
355372
"Initial pumping power/net installed power": {},
356373
"Heat to Power Conversion Efficiency": {
374+
"type": "object",
357375
"description": "First law efficiency average over project lifetime",
358376
"units": "%"
359377
},

tests/geophires_x_schema_generator_tests/test_geophires_x_schema_generator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ def test_get_json_schema(self):
2020

2121
print(f'Generated result schema: {json.dumps(result_schema, indent=2)}')
2222

23-
def get_prop(cat: str, name: str) -> dict[str, Any]:
23+
def get_result_prop(cat: str, name: str) -> dict[str, Any]:
2424
return result_schema['properties'][cat]['properties'][name]
2525

2626
self.assertIn(
27-
'multiple of invested capital', get_prop('ECONOMIC PARAMETERS', 'Project MOIC')['description'].lower()
27+
'multiple of invested capital',
28+
get_result_prop('ECONOMIC PARAMETERS', 'Project MOIC')['description'].lower(),
2829
)
2930

3031
self.assertIn(
31-
'Wellfield cost. ', get_prop('CAPITAL COSTS (M$)', 'Drilling and completion costs')['description']
32+
'Wellfield cost. ', get_result_prop('CAPITAL COSTS (M$)', 'Drilling and completion costs')['description']
3233
)
3334

3435

0 commit comments

Comments
 (0)