@@ -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+
307323def 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 :
0 commit comments