Skip to content

Commit 00f937c

Browse files
honor discount initial year cashflow in add-ons economics
1 parent b206bb5 commit 00f937c

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/geophires_x/Economics.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,22 @@ def CalculateCarbonRevenue(model, plant_lifetime: int, construction_years: int,
304304
return cash_flow_musd, cumm_cash_flow_musd, carbon_that_would_have_been_produced_annually_lbs, carbon_that_would_have_been_produced_total_lbs
305305

306306

307+
def calculate_npv(
308+
discount_rate_tenths: float,
309+
cashflow_series: list[float],
310+
discount_initial_year_cashflow: bool
311+
) -> float:
312+
# TODO warn/raise exception if discount rate > 1 (i.e. it's probably not converted from percent to tenths)
313+
314+
npv_cashflow_series = cashflow_series.copy() # Copy to guard against unintentional mutation of consumer field
315+
316+
if discount_initial_year_cashflow:
317+
# Enable Excel-style NPV calculation - see https://github.com/NREL/GEOPHIRES-X/discussions/344
318+
npv_cashflow_series = [0, *npv_cashflow_series]
319+
320+
return npf.npv(discount_rate_tenths, npv_cashflow_series)
321+
322+
307323
def CalculateFinancialPerformance(plantlifetime: int,
308324
FixedInternalRate: float,
309325
TotalRevenue: list,
@@ -341,13 +357,8 @@ def CalculateFinancialPerformance(plantlifetime: int,
341357
"""
342358
# Calculate financial performance values using numpy financials
343359

344-
cashflow_series = TotalRevenue.copy()
345-
346-
if discount_initial_year_cashflow:
347-
cashflow_series = [0, *cashflow_series]
348-
349-
NPV = npf.npv(FixedInternalRate / 100, cashflow_series)
350-
IRR = npf.irr(cashflow_series)
360+
NPV = calculate_npv(FixedInternalRate / 100, TotalRevenue.copy(), discount_initial_year_cashflow)
361+
IRR = npf.irr(TotalRevenue)
351362
if math.isnan(IRR):
352363
IRR = 0.0
353364
else:

src/geophires_x/EconomicsAddOns.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ def Calculate(self, model: Model) -> None:
347347

348348
# Now calculate a new "NPV", "IRR", "VIR", "Payback Period", and "MOIC"
349349
# Calculate more financial values using numpy financials
350-
self.ProjectNPV.value = npf.npv(self.FixedInternalRate.value / 100, self.ProjectCashFlow.value)
350+
self.ProjectNPV.value = Economics.calculate_npv(
351+
self.FixedInternalRate.value / 100,
352+
self.ProjectCashFlow.value.copy(),
353+
self.discount_initial_year_cashflow.value
354+
)
355+
351356
self.ProjectIRR.value = npf.irr(self.ProjectCashFlow.value)
352357
if math.isnan(self.ProjectIRR.value):
353358
self.ProjectIRR.value = 0.0

src/geophires_x/OutputsAddOns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def PrintOutputs(self, model) -> tuple:
4141
addon_results.append(OutputTableItem('Adjusted Project CAPEX (after incentives, grants, AddOns, etc)', '{0:10.2f}'.format(model.addeconomics.AdjustedProjectCAPEX.value), model.addeconomics.AdjustedProjectCAPEX.PreferredUnits.value))
4242
f.write(f" Adjusted Project OPEX (after incentives, grants, AddOns, etc): {model.addeconomics.AdjustedProjectOPEX.value:10.2f} " + model.addeconomics.AdjustedProjectOPEX.PreferredUnits.value + NL)
4343
addon_results.append(OutputTableItem('Adjusted Project OPEX (after incentives, grants, AddOns, etc)', '{0:10.2f}'.format(model.addeconomics.AdjustedProjectOPEX.value), model.addeconomics.AdjustedProjectOPEX.PreferredUnits.value))
44-
f.write(f" Project NPV (including AddOns): {model.addeconomics.ProjectNPV.value:10.2f} " + model.addeconomics.ProjectNPV.PreferredUnits.value + NL)
44+
f.write(f' Project NPV (including AddOns): {model.addeconomics.ProjectNPV.value:10.2f} {model.addeconomics.ProjectNPV.PreferredUnits.value}\n')
4545
addon_results.append(OutputTableItem('Project NPV (including AddOns)', '{0:10.2f}'.format(model.addeconomics.ProjectNPV.value), model.addeconomics.ProjectNPV.PreferredUnits.value))
4646
f.write(f" Project IRR (including AddOns): {model.addeconomics.ProjectIRR.value:10.2f} " + model.addeconomics.ProjectIRR.PreferredUnits.value + NL)
4747
addon_results.append(OutputTableItem('Project IRR (including AddOns)', '{0:10.2f}'.format(model.addeconomics.ProjectIRR.value), model.addeconomics.ProjectIRR.PreferredUnits.value))

0 commit comments

Comments
 (0)