Skip to content

Commit ee1b321

Browse files
Unit test verifying NREL#234 fix in previous commit
1 parent ff1f5ea commit ee1b321

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/geophires_x/Outputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ def o(output_param: OutputParameter):
20432043
if output_param.Name in econ.OutputParameterDict:
20442044
return econ.OutputParameterDict[output_param.Name]
20452045
else:
2046-
return o
2046+
return output_param
20472047

20482048
f.write('Start ('
20492049
+ o(econ.ElecPrice).CurrentUnits.value +

tests/test_geophires_x.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,37 @@ def test_vapor_pressure_above_critical_temperature(self):
366366
result = GeophiresXClient().get_geophires_result(input_params)
367367
self.assertIsNotNone(result)
368368
self.assertIn('SUMMARY OF RESULTS', result.result)
369+
370+
def test_heat_price(self):
371+
def input_for_heat_prices(params) -> GeophiresInputParameters:
372+
return GeophiresInputParameters(
373+
from_file_path=self._get_test_file_path('examples/example1.txt'), params=params
374+
)
375+
376+
result_escalating = GeophiresXClient().get_geophires_result(
377+
input_for_heat_prices({'Starting Heat Sale Price': 0.015, 'Ending Heat Sale Price': 0.015})
378+
)
379+
self.assertIsNotNone(result_escalating)
380+
cashflow_constant = result_escalating.result['REVENUE & CASHFLOW PROFILE']
381+
self.assertEqual(cashflow_constant[0][4], 'Heat Price (cents/kWh)')
382+
383+
# First entry (index 1 - header is index 0) is hardcoded to zero per
384+
# https://github.com/NREL/GEOPHIRES-X/blob/becec79cc7510a35f7a9cb01127dabc829720015/src/geophires_x/Economics.py#L2920-L2925
385+
# so start test at index 2.
386+
for i in range(2, len(cashflow_constant[0])):
387+
self.assertEqual(cashflow_constant[i][4], 1.5)
388+
389+
result_escalating = GeophiresXClient().get_geophires_result(
390+
input_for_heat_prices(
391+
{
392+
'Starting Heat Sale Price': 0.015,
393+
'Ending Heat Sale Price': 0.030,
394+
'Heat Escalation Rate Per Year': 0.005,
395+
'Heat Escalation Start Year': 0,
396+
}
397+
)
398+
)
399+
cashflow_escalating = result_escalating.result['REVENUE & CASHFLOW PROFILE']
400+
401+
self.assertEqual(cashflow_escalating[2][4], 1.5)
402+
self.assertEqual(cashflow_escalating[-1][4], 3.0)

0 commit comments

Comments
 (0)