44import numpy as np
55import numpy_financial as npf
66import geophires_x .Model as Model
7- from geophires_x .EconomicsSam import calculate_sam_economics
7+ from geophires_x .EconomicsSam import calculate_sam_economics , _SAM_CASH_FLOW_PROFILE_KEY
88from geophires_x .OptionList import Configuration , WellDrillingCostCorrelation , EconomicModel , EndUseOptions , PlantType , \
99 _WellDrillingCostCorrelationCitation
1010from geophires_x .Parameter import intParameter , floatParameter , OutputParameter , ReadParameter , boolParameter , \
@@ -472,7 +472,7 @@ def CalculateLCOELCOHLCOC(econ, model: Model) -> tuple:
472472 LCOH = LCOH * 2.931 # $/Million Btu
473473 elif econ .econmodel .value == EconomicModel .SAM_SINGLE_OWNER_PPA :
474474 # FIXME TODO designate nominal (as opposed to real) in client result
475- LCOE = calculate_sam_economics ( model ) ['LCOE (nominal)' ]['value' ]
475+ LCOE = econ . sam_economics . value ['LCOE (nominal)' ]['value' ]
476476 else :
477477 # must be BICYCLE
478478 # average return on investment (tax and inflation adjusted)
@@ -1858,6 +1858,14 @@ def __init__(self, model: Model):
18581858 PreferredUnits = TimeUnit .YEAR ,
18591859 CurrentUnits = TimeUnit .YEAR
18601860 )
1861+
1862+ # FIXME TODO/WIP representation in schema...
1863+ self .sam_economics = self .OutputParameterDict [self .sam_economics .Name ] = OutputParameter (
1864+ 'SAM Economics' ,
1865+ UnitType = Units .NONE ,
1866+ json_parameter_type = 'object' ,
1867+ )
1868+
18611869 self .RITCValue = self .OutputParameterDict [self .RITCValue .Name ] = OutputParameter (
18621870 Name = "Investment Tax Credit Value" ,
18631871 display_name = 'Investment Tax Credit' ,
@@ -2785,23 +2793,27 @@ def Calculate(self, model: Model) -> None:
27852793 )
27862794
27872795 if self .econmodel .value == EconomicModel .SAM_SINGLE_OWNER_PPA :
2788- sam_economics = calculate_sam_economics (model )
2789- self .ProjectNPV .value = sam_economics ['NPV' ]['value' ]
2790- self .ProjectIRR .value = sam_economics ['IRR' ]['value' ]
2796+ self . sam_economics . value = calculate_sam_economics (model )
2797+ self .ProjectNPV .value = self . sam_economics . value ['NPV' ]['value' ]
2798+ self .ProjectIRR .value = self . sam_economics . value ['IRR' ]['value' ]
27912799 # FIXME WIP VIR + MOIC
27922800 self .ProjectVIR .value , self .ProjectMOIC .value = - 1 , - 1
27932801
27942802 # Calculate the project payback period
2795- self .ProjectPaybackPeriod .value = 0.0 # start by assuming the project never pays back
2796- for i in range (0 , len (self .TotalCummRevenue .value ), 1 ):
2803+
2804+ if self .econmodel .value == EconomicModel .SAM_SINGLE_OWNER_PPA :
2805+ self .ProjectPaybackPeriod .value = - 1 # FIXME WIP
2806+ else :
2807+ self .ProjectPaybackPeriod .value = 0.0 # start by assuming the project never pays back
2808+ for i in range (0 , len (self .TotalCummRevenue .value ), 1 ):
27972809 # find out when the cumm cashflow goes from negative to positive
27982810 if self .TotalCummRevenue .value [i ] > 0 >= self .TotalCummRevenue .value [i - 1 ]:
2799- # we just crossed the threshold into positive project cummcashflow, so we can calculate payback period
2811+ # we just crossed the threshold into positive project cummcashflow,
2812+ # so we can calculate payback period
28002813 dFullDiff = self .TotalCummRevenue .value [i ] + math .fabs (self .TotalCummRevenue .value [(i - 1 )])
28012814 dPerc = math .fabs (self .TotalCummRevenue .value [(i - 1 )]) / dFullDiff
28022815 self .ProjectPaybackPeriod .value = i + dPerc
28032816
2804-
28052817 # Calculate LCOE/LCOH
28062818 self .LCOE .value , self .LCOH .value , self .LCOC .value = CalculateLCOELCOHLCOC (self , model )
28072819
@@ -2817,7 +2829,9 @@ def Calculate(self, model: Model) -> None:
28172829 def calculate_cashflow (self , model : Model ) -> None :
28182830 """
28192831 Calculate cashflow and cumulative cash flow
2832+ TODO/WIP adjust/skip for SAM economic model(s)
28202833 """
2834+
28212835 total_duration = model .surfaceplant .plant_lifetime .value + model .surfaceplant .construction_years .value
28222836 self .ElecRevenue .value = [0.0 ] * total_duration
28232837 self .ElecCummRevenue .value = [0.0 ] * total_duration
0 commit comments