Skip to content

Commit f0cb15e

Browse files
S-DAC Economics: throw runtime error if range check fails instead of sys.exit; FIXME TODO re: NREL#341
1 parent 6a42b25 commit f0cb15e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/geophires_x/EconomicsS_DAC_GT.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, model: Model):
4141
:type model: :class:`~geophires_x.Model.Model`
4242
:return: Nothing, and is used to initialize the class
4343
"""
44-
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
44+
model.logger.info(f"Init {str(__class__)}: {sys._getframe().f_code.co_name}")
4545

4646
# These dictionaries contains a list of all the parameters set in this object, stored as "Parameter" and
4747
# OutputParameter Objects. This will allow us later to access them in a user interface and get that list,
@@ -335,7 +335,7 @@ def __init__(self, model: Model):
335335
CurrentUnits=CostPerMassUnit.DOLLARSPERTONNE
336336
)
337337

338-
model.logger.info("Complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)
338+
model.logger.info(f"Complete {str(__class__)}: {sys._getframe().f_code.co_name}")
339339

340340
def __str__(self):
341341
return "EconomicsS_DAC_GT"
@@ -349,7 +349,7 @@ def read_parameters(self, model: Model) -> None:
349349
:type model: :class:`~geophires_x.Model.Model`
350350
:return: None
351351
"""
352-
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
352+
model.logger.info(f"Init {str(__class__)}: {sys._getframe().f_code.co_name}")
353353

354354
# Deal with all the parameter values that the user has provided. They should really only provide values
355355
# that they want to change from the default values, but they can provide a value that is already set because it
@@ -374,7 +374,7 @@ def read_parameters(self, model: Model) -> None:
374374
# none in this case so far
375375
else:
376376
model.logger.info("No parameters read becuase no content provided")
377-
model.logger.info("read parameters complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)
377+
model.logger.info(f"read parameters complete {str(__class__)}: {sys._getframe().f_code.co_name}")
378378

379379
def calculate_CRF(self, wacc: float, num_years: float) -> float:
380380
"""
@@ -579,9 +579,10 @@ def Calculate(self, model: Model) -> None:
579579
# Ensure parameters are within range. If not, exit function without completing calculation or generating charts
580580
err_state, err_message = self.range_check()
581581
if err_state:
582-
model.logger.fatal(err_message + " Exiting....")
583-
print(err_message + " Exiting....")
584-
sys.exit()
582+
msg = f'{err_message}. Exiting...'
583+
model.logger.fatal(msg)
584+
print(msg)
585+
raise RuntimeError(err_message)
585586

586587
# Calculate initial CRF value based on default inputs
587588
self.CRF = self.calculate_CRF(self.wacc.value, model.surfaceplant.plant_lifetime.value)
@@ -666,6 +667,7 @@ def Calculate(self, model: Model) -> None:
666667
model.surfaceplant.HeatkWhProduced.value[i] = (model.surfaceplant.HeatkWhProduced.value[i] -
667668
(self.CarbonExtractedAnnually.value[i] * self.therm.value))
668669

670+
# FIXME TODO https://github.com/NREL/GEOPHIRES-X/issues/341?title=S-DAC+does+not+calculate+carbon+revenue
669671
# Build a revenue generation model for the carbon capture, assuming the capture is being sequestered and that
670672
# there is some sort of credit involved for doing that sequestering
671673
# note that there may already be values in the CarbonRevenue array, so we need to
@@ -674,8 +676,8 @@ def Calculate(self, model: Model) -> None:
674676
#for i in range(0, total_duration, 1):
675677
# model.sdacgteconomics.CarbonRevenue.value[i] = (model.sdacgteconomics.CarbonRevenue.value[i] +
676678
# (self.CarbonExtractedAnnually.value[i] * model.economics.CarbonPrice.value[i]))
677-
# if i > 0:
678-
# model.economics.CarbonCummCashFlow.value[i] = model.economics.CarbonCummCashFlow.value[i - 1] + model.economics.CarbonRevenue.value[i]
679+
# if i > 0:
680+
# model.economics.CarbonCummCashFlow.value[i] = model.economics.CarbonCummCashFlow.value[i - 1] + model.economics.CarbonRevenue.value[i]
679681

680682
self._calculate_derived_outputs(model)
681683
model.logger.info(f'Complete {str(__class__)}: {sys._getframe().f_code.co_name}')

0 commit comments

Comments
 (0)