Skip to content

Commit e91a37c

Browse files
Validate only electricity is allowed for SAM econ model (for now)
1 parent dcb9cd8 commit e91a37c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/geophires_x/Economics.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,16 @@ def _warn(_msg: str) -> None:
19361936

19371937
# handle special cases
19381938
if ParameterToModify.Name == "Economic Model":
1939-
self.econmodel.value = EconomicModel.from_input_string(ParameterReadIn.sValue)
1939+
em: EconomicModel = EconomicModel.from_input_string(ParameterReadIn.sValue)
1940+
1941+
if (em == EconomicModel.SAM_SINGLE_OWNER_PPA
1942+
and model.surfaceplant.enduse_option.value != EndUseOptions.ELECTRICITY):
1943+
raise RuntimeError(f'Invalid End-Use Option ({em.name}) for '
1944+
f'{EconomicModel.SAM_SINGLE_OWNER_PPA.name} economic model. '
1945+
f'{EconomicModel.SAM_SINGLE_OWNER_PPA.name} only supports '
1946+
f'{EndUseOptions.ELECTRICITY.name} End-Use Option.')
1947+
1948+
self.econmodel.value = em
19401949

19411950
elif ParameterToModify.Name == "Well Drilling Cost Correlation":
19421951
ParameterToModify.value = WellDrillingCostCorrelation.from_input_string(ParameterReadIn.sValue)

tests/test_geophires_x.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,3 +936,6 @@ def _npv(r: GeophiresXResult) -> float:
936936
npvs = [_npv(_get_result({'Starting Electricity Sale Price': x / 100.0})) for x in range(1, 20, 2)]
937937
for i in range(len(npvs) - 1):
938938
self.assertLess(npvs[i], npvs[i + 1])
939+
940+
with self.assertRaises(RuntimeError):
941+
_get_result({'End-Use Option': 2})

0 commit comments

Comments
 (0)