Skip to content

Commit ba94b45

Browse files
unit test add-ons/extended economics npv with/without discount initial year
1 parent 00f937c commit ba94b45

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

src/geophires_x/Outputs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,12 @@ def PrintOutputs(self, model: Model):
16431643
f.write(f' Accrued financing during construction: {model.economics.inflrateconstruction.value*100:10.2f} ' + model.economics.inflrateconstruction.CurrentUnits.value + NL)
16441644
f.write(f' Project lifetime: {model.surfaceplant.plant_lifetime.value:10.0f} ' + model.surfaceplant.plant_lifetime.CurrentUnits.value + NL)
16451645
f.write(f' Capacity factor: {model.surfaceplant.utilization_factor.value * 100:10.1f} %' + NL)
1646-
f.write(f' Project NPV: {model.economics.ProjectNPV.value:10.2f} ' + model.economics.ProjectNPV.PreferredUnits.value + NL)
1646+
1647+
e_npv = model.economics.ProjectNPV
1648+
npv_field_label = Outputs._field_label('Project NPV', 49)
1649+
# TODO should use CurrentUnits instead of PreferredUnits
1650+
f.write(f' {npv_field_label}{e_npv.value:10.2f} {e_npv.PreferredUnits.value}\n')
1651+
16471652
f.write(f' Project IRR: {model.economics.ProjectIRR.value:10.2f} ' + model.economics.ProjectIRR.PreferredUnits.value + NL)
16481653
f.write(f' Project VIR=PI=PIR: {model.economics.ProjectVIR.value:10.2f}' + NL)
16491654
f.write(f' {model.economics.ProjectMOIC.Name}: {model.economics.ProjectMOIC.value:10.2f}' + NL)

src/geophires_x/WellBores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def ProdPressureDropAndPumpingPowerUsingIndexes(
537537
pumpdepthfinal_m = np.max(pumpdepth_m)
538538
if pumpdepthfinal_m < 0.0:
539539
pumpdepthfinal_m = 0.0
540-
msg = (f'GEOPHIRES calculates negative production well pumping depth. ({pumpdepthfinal_m:.2f}m)'
540+
msg = (f'GEOPHIRES calculates negative production well pumping depth. ({pumpdepthfinal_m:.2f}m). '
541541
f'No production well pumps will be assumed')
542542
print(f'Warning: {msg}')
543543
model.logger.warning(msg)

tests/test_geophires_x.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ def assertHasLogRecordWithMessage(logs_, message):
591591
)
592592

593593
def test_discount_initial_year_cashflow(self):
594-
def _get_result(do_discount: bool) -> GeophiresXResult:
594+
def _get_result(base_example: str, do_discount: bool) -> GeophiresXResult:
595595
return GeophiresXClient().get_geophires_result(
596596
GeophiresInputParameters(
597597
# TODO switch over to generic EGS case to avoid thrash from example updates
598598
# from_file_path=self._get_test_file_path('geophires_x_tests/generic-egs-case.txt'),
599-
from_file_path=self._get_test_file_path('examples/Fervo_Project_Cape-3.txt'),
599+
from_file_path=self._get_test_file_path(f'examples/{base_example}.txt'),
600600
params={
601601
'Discount Initial Year Cashflow': do_discount,
602602
},
@@ -606,8 +606,28 @@ def _get_result(do_discount: bool) -> GeophiresXResult:
606606
def _npv(r: GeophiresXResult) -> dict:
607607
return r.result['ECONOMIC PARAMETERS']['Project NPV']['value']
608608

609-
self.assertEqual(4580.36, _npv(_get_result(False)))
610-
self.assertEqual(4280.71, _npv(_get_result(True)))
609+
self.assertEqual(4580.36, _npv(_get_result('Fervo_Project_Cape-3', False)))
610+
self.assertEqual(4280.71, _npv(_get_result('Fervo_Project_Cape-3', True)))
611+
612+
def _extended_economics_npv(r: GeophiresXResult) -> dict:
613+
return r.result['EXTENDED ECONOMICS']['Project NPV (including AddOns)']['value']
614+
615+
add_ons_result_without_discount = _get_result('example1_addons', False)
616+
add_ons_result_with_discount = _get_result('example1_addons', True)
617+
618+
self.assertGreater(_npv(add_ons_result_without_discount), _npv(add_ons_result_with_discount))
619+
620+
ee_npv_without_discount = _extended_economics_npv(add_ons_result_without_discount)
621+
assert ee_npv_without_discount < 0, (
622+
'Test is expecting example1_addons extended economics NPV to be negative '
623+
'as a precondition - if this error is encountered, '
624+
'create a test-only copy of the previous version of example1_addons and '
625+
'use it in this test (like geophires_x_tests/generic-egs-case.txt).'
626+
)
627+
628+
# Discounting first year causes negative NPVs to be less negative (according to Google Sheets,
629+
# which was used to manually validate the expected NPVs here).
630+
self.assertLess(ee_npv_without_discount, _extended_economics_npv(add_ons_result_with_discount))
611631

612632
def test_transmission_pipeline_cost(self):
613633
result = GeophiresXClient().get_geophires_result(

0 commit comments

Comments
 (0)