Skip to content

Commit fc7b3d3

Browse files
miscellaneous minor code cleanup
1 parent baff81b commit fc7b3d3

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pre-commit install --install-hooks
33
# To update the versions:
44
# pre-commit autoupdate
5-
exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg|src/geophires_x(?!/(GEOPHIRESv3|EconomicsSam|EconomicsSamCashFlow|EconomicsUtils|EconomicsSamPreRevenue)\.py))(/|$)'
5+
exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg|src/geophires_x(?!/(GEOPHIRESv3|EconomicsSam|EconomicsSamCashFlow|EconomicsUtils|EconomicsSamPreRevenue|SurfacePlantUtils)\.py))(/|$)'
66
# Note the order is intentional to avoid multiple passes of the hooks
77
repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit

src/geophires_x/EconomicsSam.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
from tabulate import tabulate
2828

2929
from geophires_x import Model as Model
30-
from geophires_x.EconomicsSamCashFlow import _calculate_sam_economics_cash_flow, _SAM_CASH_FLOW_NAN_STR
30+
from geophires_x.EconomicsSamCashFlow import (
31+
_calculate_sam_economics_cash_flow_operational_years,
32+
_SAM_CASH_FLOW_NAN_STR,
33+
)
3134
from geophires_x.EconomicsUtils import (
3235
BuildPricingModel,
3336
wacc_output_parameter,
@@ -106,7 +109,7 @@ def sam_cash_flow_profile(self) -> list[list[Any]]:
106109
ret: list[list[Any]] = self._sam_cash_flow_profile_operational_years.copy()
107110
col_count = len(self._sam_cash_flow_profile_operational_years[0])
108111

109-
# TODO support/insert calendar year line item
112+
# TODO support/insert calendar year line item https://github.com/NREL/GEOPHIRES-X/issues/439
110113

111114
pre_revenue_years_to_insert = self._pre_revenue_years_count - 1
112115

@@ -148,7 +151,6 @@ def _get_row(row_name__: str) -> list[Any]:
148151
raise ValueError(f'Could not find row with name {row_name__}')
149152

150153
after_tax_cash_flow: list[float] = (
151-
# _get_row('After-tax net cash flow [construction] ($)')
152154
self.pre_revenue_costs_and_cash_flow.pre_revenue_cash_flow_profile_dict[_AFTER_TAX_NET_CASH_FLOW_ROW_NAME]
153155
+ _get_row('Total after-tax returns ($)')[self._pre_revenue_years_count :]
154156
)
@@ -330,7 +332,7 @@ def calculate_sam_economics(model: Model) -> SamEconomicsCalculations:
330332
for module in modules:
331333
module.execute()
332334

333-
cash_flow_operational_years = _calculate_sam_economics_cash_flow(model, single_owner)
335+
cash_flow_operational_years = _calculate_sam_economics_cash_flow_operational_years(model, single_owner)
334336

335337
def sf(_v: float, num_sig_figs: int = 5) -> float:
336338
return sig_figs(_v, num_sig_figs)

src/geophires_x/EconomicsSamCashFlow.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@
1818

1919

2020
@lru_cache(maxsize=12)
21-
def _calculate_sam_economics_cash_flow(model: Model, single_owner: Singleowner) -> list[list[Any]]:
21+
def _calculate_sam_economics_cash_flow_operational_years(model: Model, single_owner: Singleowner) -> list[list[Any]]:
2222
log = model.logger
2323

2424
_soo = single_owner.Outputs
2525

2626
profile = []
2727

28-
# TODO this and/or related logic will need to be adjusted when multiple construction years are supported
29-
# https://github.com/NREL/GEOPHIRES-X/issues/406
30-
# FIXME WIP update above comment for impl
31-
total_duration = model.surfaceplant.plant_lifetime.value + 1 # + model.surfaceplant.construction_years.value
28+
total_duration = model.surfaceplant.plant_lifetime.value + 1
29+
# Note we do not include construction years in total_duration because we only calculating cash flow for operational
30+
# years.
3231

3332
# Prefix with 'Year ' partially as workaround for tabulate applying float formatting to ints, possibly related
3433
# to https://github.com/astanin/python-tabulate/issues/18

src/geophires_x/EconomicsUtils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def project_payback_period_parameter() -> OutputParameter:
8282
CurrentUnits=TimeUnit.YEAR,
8383
ToolTipText='The time at which cumulative cash flow reaches zero. '
8484
'For projects that never pay back, the calculated value will be "N/A". '
85-
'For SAM Economic Models, total after-tax returns are used to calculate cumulative cash flow.',
85+
'For SAM Economic Models, after-tax net cash flow is used to calculate the cumulative cash flow.',
8686
)
8787

8888

@@ -94,9 +94,8 @@ def after_tax_irr_parameter() -> OutputParameter:
9494
PreferredUnits=PercentUnit.PERCENT,
9595
ToolTipText='The After-tax IRR (internal rate of return) is the nominal discount rate that corresponds to '
9696
'a net present value (NPV) of zero for PPA SAM Economic models. '
97-
'See https://samrepo.nrelcloud.org/help/mtf_irr.html. If SAM calculates After-tax IRR as NaN, '
98-
'numpy-financial.irr (https://numpy.org/numpy-financial/latest/irr.html) '
99-
'is used to calculate the value from SAM\'s total after-tax returns.',
97+
# TODO describe backfilled calculation using After-tax net cash flow
98+
'See https://samrepo.nrelcloud.org/help/mtf_irr.html.',
10099
)
101100

102101

src/geophires_x/Parameter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ def _is_int(o: Any) -> bool:
438438
return float_n == int_n
439439

440440
is_positional_parameter = ' ' in ParameterReadIn.Name and _is_int(ParamToModify.Name.split(' ')[-1])
441-
#if ' ' in ParamToModify.Name:
442441
if is_positional_parameter:
443442
New_val = float(ParameterReadIn.sValue)
444443
# Some list parameters are read in with enumerated parameter names; in these cases we use the last

src/geophires_x_schema_generator/geophires-result.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124
"After-tax IRR": {
125125
"type": "number",
126-
"description": "The After-tax IRR (internal rate of return) is the nominal discount rate that corresponds to a net present value (NPV) of zero for PPA SAM Economic models. See https://samrepo.nrelcloud.org/help/mtf_irr.html. If SAM calculates After-tax IRR as NaN, numpy-financial.irr (https://numpy.org/numpy-financial/latest/irr.html) is used to calculate the value from SAM's total after-tax returns.",
126+
"description": "The After-tax IRR (internal rate of return) is the nominal discount rate that corresponds to a net present value (NPV) of zero for PPA SAM Economic models. See https://samrepo.nrelcloud.org/help/mtf_irr.html.",
127127
"units": "%"
128128
},
129129
"Project VIR=PI=PIR": {
@@ -139,7 +139,7 @@
139139
"Fixed Charge Rate (FCR)": {},
140140
"Project Payback Period": {
141141
"type": "number",
142-
"description": "The time at which cumulative cash flow reaches zero. For projects that never pay back, the calculated value will be \"N/A\". For SAM Economic Models, total after-tax returns are used to calculate cumulative cash flow.",
142+
"description": "The time at which cumulative cash flow reaches zero. For projects that never pay back, the calculated value will be \"N/A\". For SAM Economic Models, after-tax net cash flow is used to calculate the cumulative cash flow.",
143143
"units": "yr"
144144
},
145145
"CHP: Percent cost allocation for electrical plant": {},

0 commit comments

Comments
 (0)