Skip to content

Commit 619fd5f

Browse files
Define separate output parameter for Interest Rate instead of setting discountrate's preferred units to percent, addressing FIXME in outputs re: discount rate's unit discrepancy
1 parent d367286 commit 619fd5f

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

src/geophires_x/Economics.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def __init__(self, model: Model):
846846
Min=0.0,
847847
Max=1.0,
848848
UnitType=Units.PERCENT,
849-
PreferredUnits=PercentUnit.PERCENT,
849+
PreferredUnits=PercentUnit.TENTH,
850850
CurrentUnits=PercentUnit.TENTH,
851851
ErrMessage=f'assume default discount rate ({discount_rate_default_val})',
852852
ToolTipText="Discount rate used in the Standard Levelized Cost Model"
@@ -1712,6 +1712,12 @@ def __init__(self, model: Model):
17121712
PreferredUnits=MassUnit.LB,
17131713
CurrentUnits=MassUnit.LB
17141714
)
1715+
self.interest_rate = self.OutputParameterDict[self.interest_rate.Name] = OutputParameter(
1716+
Name='Interest Rate',
1717+
UnitType=Units.PERCENT,
1718+
PreferredUnits=PercentUnit.PERCENT,
1719+
CurrentUnits=PercentUnit.PERCENT
1720+
)
17151721
self.TotalRevenue = self.OutputParameterDict[self.TotalRevenue.Name] = OutputParameter(
17161722
Name="Annual Revenue from Project",
17171723
UnitType=Units.CURRENCYFREQUENCY,
@@ -2155,11 +2161,11 @@ def read_parameters(self, model: Model) -> None:
21552161
break
21562162

21572163
coerce_int_params_to_enum_values(self.ParameterDict)
2158-
self.sync_discount_rate_and_fixed_internal_rate(model)
2164+
self.sync_interest_rate(model)
21592165

21602166
model.logger.info(f'complete {__class__!s}: {sys._getframe().f_code.co_name}')
21612167

2162-
def sync_discount_rate_and_fixed_internal_rate(self, model):
2168+
def sync_interest_rate(self, model):
21632169
if self.discountrate.Provided ^ self.FixedInternalRate.Provided:
21642170
if self.discountrate.Provided:
21652171
self.FixedInternalRate.value = self.discountrate.quantity().to(
@@ -2180,6 +2186,8 @@ def sync_discount_rate_and_fixed_internal_rate(self, model):
21802186
f'values ({self.discountrate.value}; {self.FixedInternalRate.quantity()}). '
21812187
f'It is recommended to only provide one of these values.')
21822188

2189+
self.interest_rate.value = self.discountrate.quantity().to(convertible_unit(self.interest_rate.CurrentUnits)).magnitude
2190+
21832191
def Calculate(self, model: Model) -> None:
21842192
"""
21852193
The Calculate function is where all the calculations are done.

src/geophires_x/Outputs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
PlantType
2424
from geophires_x.GeoPHIRESUtils import UpgradeSymbologyOfUnits, render_default, InsertImagesIntoHTML
2525
from geophires_x.Parameter import Parameter
26+
from geophires_x.Units import convertible_unit, Units, PercentUnit
2627

2728
NL = '\n'
2829
validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits)
@@ -1637,10 +1638,7 @@ def PrintOutputs(self, model: Model):
16371638
f.write(f' Fixed Charge Rate (FCR): {model.economics.FCR.value*100.0:10.2f} ' + model.economics.FCR.CurrentUnits.value + NL)
16381639
elif model.economics.econmodel.value == EconomicModel.STANDARDIZED_LEVELIZED_COST:
16391640
f.write(' Economic Model = ' + model.economics.econmodel.value.value + NL)
1640-
1641-
# FIXME discountrate should not be multiplied by 100 here -
1642-
# it appears to be incorrectly claiming its units are percent when the actual value is in tenths.
1643-
f.write(f' Interest Rate: {model.economics.discountrate.value*100.0:10.2f} {model.economics.discountrate.CurrentUnits.value}\n')
1641+
f.write(f' {model.economics.interest_rate.Name}: {model.economics.interest_rate.value:10.2f} {model.economics.interest_rate.CurrentUnits.value}\n')
16441642

16451643
elif model.economics.econmodel.value == EconomicModel.BICYCLE:
16461644
f.write(' Economic Model = ' + model.economics.econmodel.value.value + NL)

src/geophires_x/SUTRAEconomics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ def read_parameters(self, model: Model) -> None:
330330
else:
331331
model.logger.info('No parameters read because no content provided')
332332

333+
self.sync_interest_rate(model)
334+
333335
model.logger.info(f'Complete {__class__!s}: {sys._getframe().f_code.co_name}')
334336

335337
def Calculate(self, model: Model) -> None:

src/geophires_x/SUTRAOutputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def PrintOutputs(self, model: Model):
8888

8989
# FIXME discountrate should not be multiplied by 100 here -
9090
# it appears to be incorrectly claiming its units are percent when the actual value is in tenths.
91-
f.write(f" Interest Rate: {model.economics.discountrate.value*100.0:10.2f} {model.economics.discountrate.CurrentUnits.value}\n")
91+
f.write(f' {model.economics.interest_rate.Name}: {model.economics.interest_rate.value:10.2f} {model.economics.interest_rate.CurrentUnits.value}\n')
9292

9393
elif model.economics.econmodel.value == EconomicModel.BICYCLE:
9494
f.write(" Economic Model = " + model.economics.econmodel.value.value + NL)

tests/examples/SUTRAExample1.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.6.0
8-
Simulation Date: 2024-10-15
9-
Simulation Time: 13:07
10-
Calculation Time: 0.507 sec
7+
GEOPHIRES Version: 3.6.2
8+
Simulation Date: 2024-10-18
9+
Simulation Time: 10:43
10+
Calculation Time: 0.516 sec
1111

1212
***SUMMARY OF RESULTS***
1313

@@ -23,7 +23,7 @@ Simulation Metadata
2323
***ECONOMIC PARAMETERS***
2424

2525
Economic Model = Standard Levelized Cost
26-
Interest Rate: 7.00
26+
Interest Rate: 7.00 %
2727
Accrued financing during construction: 0.00 %
2828
Project lifetime: 30 yr
2929

0 commit comments

Comments
 (0)