Skip to content

Commit 54aada1

Browse files
SUTRAEconomics enum read cleanup
1 parent 6b6b58a commit 54aada1

File tree

2 files changed

+13
-56
lines changed

2 files changed

+13
-56
lines changed

src/geophires_x/Economics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def __init__(self, model: Model):
614614
ValuesEnum=EconomicModel,
615615
Required=True,
616616
ErrMessage="assume default economic model (2)",
617-
ToolTipText="Specify the economic model to calculate the levelized cost of energy." +
617+
ToolTipText="Specify the economic model to calculate the levelized cost of energy. " +
618618
'; '.join([f'{it.int_value}: {it.value}' for it in EconomicModel])
619619
)
620620
self.ccstimfixed = self.ParameterDict[self.ccstimfixed.Name] = floatParameter(

src/geophires_x/SUTRAEconomics.py

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ def __init__(self, model: Model):
4949
"Economic Model",
5050
value=EconomicModel.STANDARDIZED_LEVELIZED_COST,
5151
DefaultValue=EconomicModel.STANDARDIZED_LEVELIZED_COST,
52+
ValuesEnum=EconomicModel,
5253
AllowableRange=[1, 2, 3],
5354
Required=True,
5455
ErrMessage="assume default economic model (2)",
55-
ToolTipText="Specify the economic model to calculate the levelized cost of energy."
56-
+ " 1: Fixed Charge Rate Model, 2: Standard Levelized Cost Model, 3: BICYCLE Levelized Cost Model, 4: CLGS",
56+
ToolTipText="Specify the economic model to calculate the levelized cost of energy. " +
57+
'; '.join([f'{it.int_value}: {it.value}' for it in EconomicModel])
5758
)
5859

5960
self.ccwellfixed = self.ParameterDict[self.ccwellfixed.Name] = floatParameter(
@@ -297,7 +298,7 @@ def __init__(self, model: Model):
297298
CurrentUnits=CurrencyFrequencyUnit.KDOLLARSPERYEAR,
298299
)
299300

300-
model.logger.info("Complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)
301+
model.logger.info(f'Complete {__class__!s}: {sys._getframe().f_code.co_name}')
301302

302303
def read_parameters(self, model: Model) -> None:
303304
"""
@@ -309,7 +310,7 @@ def read_parameters(self, model: Model) -> None:
309310
:type model: :class:`~geophires_x.Model.Model`
310311
:return: Nothing, but it does make calculations and set values in the model
311312
"""
312-
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
313+
model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}')
313314

314315
# Deal with all the parameter values that the user has provided. They should really only provide values
315316
# that they want to change from the default values, but they can provide a value that is already set
@@ -335,58 +336,14 @@ def read_parameters(self, model: Model) -> None:
335336
ReadParameter(ParameterReadIn, ParameterToModify, model)
336337

337338
# handle special cases
338-
if ParameterToModify.Name == "Economic Model":
339-
if ParameterReadIn.sValue == '1':
340-
self.econmodel.value = EconomicModel.FCR
341-
elif ParameterReadIn.sValue == '2':
342-
# use standard LCOE/LCOH calculation as found on wikipedia (requires an interest rate).
343-
self.econmodel.value = EconomicModel.STANDARDIZED_LEVELIZED_COST
344-
elif ParameterReadIn.sValue == '3':
345-
# use Bicycle LCOE/LCOH model (requires several financial input parameters)
346-
self.econmodel.value = EconomicModel.BICYCLE
347-
else:
348-
self.econmodel.value = EconomicModel.CLGS # CLGS
349-
elif ParameterToModify.Name == "Well Drilling Cost Correlation":
350-
if ParameterReadIn.sValue == '1':
351-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_SMALL
352-
elif ParameterReadIn.sValue == '2':
353-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_SMALL
354-
elif ParameterReadIn.sValue == '3':
355-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_LARGE
356-
elif ParameterReadIn.sValue == '4':
357-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_LARGE
358-
elif ParameterReadIn.sValue == '5':
359-
ParameterToModify.value = WellDrillingCostCorrelation.SIMPLE
360-
elif ParameterReadIn.sValue == '6':
361-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_SMALL_INT1
362-
elif ParameterReadIn.sValue == '7':
363-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_SMALL_INT2
364-
elif ParameterReadIn.sValue == '8':
365-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_SMALL_INT1
366-
elif ParameterReadIn.sValue == '9':
367-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_SMALL_INT2
368-
elif ParameterReadIn.sValue == '10':
369-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_LARGE_INT1
370-
elif ParameterReadIn.sValue == '11':
371-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_LARGE_INT2
372-
elif ParameterReadIn.sValue == '12':
373-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_LARGE_INT1
374-
elif ParameterReadIn.sValue == '13':
375-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_LARGE_INT2
376-
elif ParameterReadIn.sValue == '14':
377-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_SMALL_IDEAL
378-
elif ParameterReadIn.sValue == '15':
379-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_SMALL_IDEAL
380-
elif ParameterReadIn.sValue == '16':
381-
ParameterToModify.value = WellDrillingCostCorrelation.VERTICAL_LARGE_IDEAL
382-
elif ParameterReadIn.sValue == '17':
383-
ParameterToModify.value = WellDrillingCostCorrelation.DEVIATED_LARGE_IDEAL
384-
else:
385-
ParameterToModify.value = WellDrillingCostCorrelation.SIMPLE # Assuming 'SIMPLE' is still a valid option
339+
if ParameterToModify.Name == 'Economic Model':
340+
self.econmodel.value = EconomicModel.from_input_string(ParameterReadIn.sValue)
341+
elif ParameterToModify.Name == 'Well Drilling Cost Correlation':
342+
ParameterToModify.value = WellDrillingCostCorrelation.from_input_string(ParameterReadIn.sValue)
386343
else:
387-
model.logger.info("No parameters read because no content provided")
344+
model.logger.info('No parameters read because no content provided')
388345

389-
model.logger.info("complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)
346+
model.logger.info(f'Complete {__class__!s}: {sys._getframe().f_code.co_name}')
390347

391348
def Calculate(self, model: Model) -> None:
392349
"""
@@ -396,7 +353,7 @@ def Calculate(self, model: Model) -> None:
396353
:type model: :class:`~geophires_x.Model.Model`
397354
:return: Nothing, but it does make calculations and set values in the model
398355
"""
399-
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
356+
model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}')
400357

401358
# This is where all the calculations are made using all the values that have been set.
402359
# If you subclass this class, you can choose to run these calculations before (or after) your calculations,

0 commit comments

Comments
 (0)