Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #17 #77

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/CashFlows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,11 +1101,19 @@ def calculateCashflow(self, variables, lifetimeCashflows, lifetime, verbosity):
## FIXME what if I have set the values already?
# get variable values, if needed
need = {'alpha': self._alpha, 'driver': self._driver}

# load alpha, driver from variables if need be
need = self.loadFromVariables(need, variables, lifetimeCashflows, lifetime)
# for Capex, use m * alpha * (D/D')^X
alpha = need['alpha']
driver = need['driver']
# check if not-zero alpha > 1
maskAlpha = np.where(alpha != 0.0, )[0]
if len(maskAlpha) > 1:
if len(np.where(driver != 0.0, )[0]) == 1:
val = driver[np.where(driver != 0.0, )]
driver[maskAlpha] = val

reference = self.getParam('reference')
if reference is None:
reference = 1.0
Expand Down
77 changes: 77 additions & 0 deletions tests/CashFlow_test_NPV_delayed_construction.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<Simulation verbosity="debug">
<TestInfo>
<name>CashFlow_test_delayed_contruction_time</name>
<author>A. Alfonsi</author>
<created>2023-10-10</created>
<description>
This test tests the possibility to allow for CAPEX construction times spanning on multiple years (not only in the first one).

</description>
<classesTested>Models.ExternalModel.TEAL</classesTested>
<revisions>
<revision author="alfoa" date="2023-10-10">Addressed issue #17</revision>
</revisions>
</TestInfo>

<RunInfo>
<WorkingDir>.</WorkingDir>
<Sequence>MCrun,printTOfile</Sequence>
</RunInfo>

<VariableGroups>
<Group name="GRO_CashFlow_in">BOP_capacity, BOP_TOT_revenueEL, IP_capacity, IP_TOT_revenueBY, Multiplier</Group>
<Group name="GRO_CashFlow_out">NPV</Group>
</VariableGroups>

<Models>
<ExternalModel name="Cash_Flow" subType="TEAL.CashFlow">
<variables> GRO_CashFlow_in, GRO_CashFlow_out</variables>
<ExternalXML node="Economics" xmlToLoad="Cash_Flow_input_NPV_delayed_construction.xml"/>
</ExternalModel>
</Models>

<Samplers>
<MonteCarlo name="test_MC">
<samplerInit>
<limit>1</limit>
</samplerInit>
<constant name="BOP_capacity">300.0E6</constant>
<constant name="BOP_TOT_revenueEL">350.0E6</constant>
<constant name="IP_capacity">51.0E6</constant>
<constant name="IP_TOT_revenueBY">31.5E6</constant>
<constant name="Multiplier">1.0</constant>
</MonteCarlo>
</Samplers>

<DataObjects>
<PointSet name="SET_CashFlow_in">
<Input>GRO_CashFlow_in</Input>
<Output>OutputPlaceHolder</Output>
</PointSet>
<PointSet name="SET_CashFlow_out">
<Input>GRO_CashFlow_in</Input>
<Output>GRO_CashFlow_out</Output>
</PointSet>
</DataObjects>

<Steps>
<MultiRun name="MCrun" pauseAtEnd="True">
<Input class="DataObjects" type="PointSet">SET_CashFlow_in</Input>
<Model class="Models" type="ExternalModel">Cash_Flow</Model>
<Sampler class="Samplers" type="MonteCarlo">test_MC</Sampler>
<Output class="DataObjects" type="PointSet">SET_CashFlow_out</Output>
</MultiRun>
<IOStep name="printTOfile">
<Input class="DataObjects" type="PointSet">SET_CashFlow_out</Input>
<Output class="OutStreams" type="Print">dumpNPVDelay</Output>
</IOStep>
</Steps>

<OutStreams>
<Print name="dumpNPVDelay">
<type>csv</type>
<source>SET_CashFlow_out</source>
<what>input,output</what>
</Print>
</OutStreams>
</Simulation>
56 changes: 56 additions & 0 deletions tests/Cash_Flow_input_NPV_delayed_construction.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Economics verbosity="0"> <!-- "0" all debug output, "1" some output, "100" only errors -->
<Global>
<DiscountRate>0.05</DiscountRate> <!-- %/100 -->
<tax>0.392</tax> <!-- %/100 -->
<inflation>0.04</inflation> <!-- %/100 -->
<Indicator name='NPV' target='0'>
BOP|CA
BOP|RE
IP|CA
IP|RE
</Indicator>
</Global>

<Component name="BOP">
<Life_time>15</Life_time> <!-- years -->
<CashFlows>
<!-- Capital Cost -->
<!-- alpha in $ for the <reference> MW plant -->
<Capex name="CA" tax="false" inflation="none" mult_target="false" multiply="Multiplier">
<driver>BOP_capacity</driver>
<alpha>-4510000000 -4510000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0</alpha>
<reference>1100000000</reference>
<X>0.64</X>
<depreciation scheme='custom'>5. 9.50 8.55 7.70 6.93 6.23 5.90 5.90 5.91 5.90 5.91 5.90 5.91 5.90 5.91</depreciation>
</Capex>

<!-- Electric Revenue -->
<!-- alpha is 1.0 -->
<Recurring name="RE" tax="true" inflation="none" mult_target="true">
<driver>BOP_TOT_revenueEL</driver>
<alpha>1.0</alpha>
</Recurring>
</CashFlows>
</Component>

<Component name="IP">
<Life_time>15</Life_time> <!-- years -->
<CashFlows>
<!-- Capital Cost -->
<!-- alpha in $ for the <reference> MW plant, i.e. $/W(th)h -->
<Capex name="CA" tax="false" inflation="none" mult_target="false">
<alpha>-153000000</alpha>
<driver>IP_capacity</driver>
<reference>231000000</reference>
<X>1.0</X>
</Capex>

<!-- Non electric Revenue -->
<!-- alpha is 1.0 -->
<Recurring name="RE" tax="true" inflation="none" mult_target="true">
<driver>IP_TOT_revenueBY</driver>
<alpha>1.0</alpha>
</Recurring>
</CashFlows>
</Component>
</Economics>
2 changes: 2 additions & 0 deletions tests/gold/dumpNPVDelay.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BOP_capacity,BOP_TOT_revenueEL,IP_capacity,IP_TOT_revenueBY,Multiplier,NPV
300000000.0,350000000.0,51000000.0,31500000.0,1.0,-1049009630.29
8 changes: 8 additions & 0 deletions tests/tests
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@
rel_err = 0.001
[../]

[./CashFlow_test_delayed_contruction_time]
type = 'RavenFramework'
input = 'CashFlow_test_NPV_delayed_construction.xml'
UnorderedCsv = 'dumpNPVDelay.csv'
max_time = 500
rel_err = 0.001
[../]

[]
Loading