EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
CreatingFinancialReports.java
1 /*******************************************************************************
2  * Copyright 2013 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package emlab.gen.role.market;
17 
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.transaction.annotation.Transactional;
20 
21 import agentspring.role.RoleComponent;
28 
37 @RoleComponent
38 public class CreatingFinancialReports extends AbstractClearElectricitySpotMarketRole<DecarbonizationModel> {
39 
40  @Autowired
41  private Reps reps;
42 
43 
44  @Transactional
45  public void act(DecarbonizationModel model) {
46 
47  createFinancialReportsForPowerPlantsAndTick(
48  reps.powerPlantRepository.findAllPowerPlantsWhichAreNotDismantledBeforeTick(getCurrentTick() - 2),
49  getCurrentTick());
50 
51  }
52 
53  public void createFinancialReportsForNewInvestments(DecarbonizationModel model) {
54  createFinancialReportsForPowerPlantsAndTick(
55  reps.powerPlantRepository.findAllPowerPlantsWithConstructionStartTimeInTick(getCurrentTick()),
56  getCurrentTick());
57  }
58 
59  void createFinancialReportsForPowerPlantsAndTick(Iterable<PowerPlant> plants, long tick) {
60 
61  for (PowerPlant plant : plants) {
62 
63  FinancialPowerPlantReport financialPowerPlantReport = new FinancialPowerPlantReport();
64  financialPowerPlantReport.setTime(tick);
65  financialPowerPlantReport.setFullLoadHours(0);
66  financialPowerPlantReport.setPowerPlant(plant);
67  financialPowerPlantReport.setCommodityCosts(0);
68  financialPowerPlantReport.persist();
69 
70 
71  // Determining variable and CO2 costs in current time step.
72  double totalSupply = plant.calculateElectricityOutputAtTime(tick, false);
73  financialPowerPlantReport.setProduction(totalSupply);
74 
75  for (SubstanceShareInFuelMix share : plant.getFuelMix()) {
76 
77  double amount = share.getShare() * totalSupply;
78  Substance substance = share.getSubstance();
79  double substanceCost = findLastKnownPriceForSubstance(substance) * amount;
80  financialPowerPlantReport.setCommodityCosts(financialPowerPlantReport.getCommodityCosts()
81  + substanceCost);
82 
83 
84  }
85  financialPowerPlantReport.setCo2Costs(reps.powerPlantRepository.calculateCO2CostsOfPowerPlant(plant,
86  tick));
87  financialPowerPlantReport.setVariableCosts(financialPowerPlantReport.getCommodityCosts()+financialPowerPlantReport.getCo2Costs());
88 
89  //Determine fixed costs
90  financialPowerPlantReport.setFixedCosts(reps.powerPlantRepository
91  .calculateFixedCostsOfPowerPlant(plant,
92  tick));
93 
94  //Calculate overall revenue
95  financialPowerPlantReport.setSpotMarketRevenue(reps.powerPlantRepository
96  .calculateSpotMarketRevenueOfPowerPlant(plant, tick));
97 
98  financialPowerPlantReport.setStrategicReserveRevenue(reps.powerPlantRepository
99  .calculateStrategicReserveRevenueOfPowerPlant(plant, tick));
100 
101  financialPowerPlantReport.setCapacityMarketRevenue(reps.powerPlantRepository
102  .calculateCapacityMarketRevenueOfPowerPlant(plant, tick));
103 
104  financialPowerPlantReport.setCo2HedgingRevenue(reps.powerPlantRepository
105  .calculateCO2HedgingRevenueOfPowerPlant(plant, tick));
106 
107 
108  financialPowerPlantReport.setOverallRevenue(financialPowerPlantReport.getCapacityMarketRevenue() + financialPowerPlantReport.getCo2HedgingRevenue() + financialPowerPlantReport.getSpotMarketRevenue() + financialPowerPlantReport
109  .getStrategicReserveRevenue());
110 
111  // Calculate Full load hours
112  financialPowerPlantReport.setFullLoadHours(reps.powerPlantRepository.calculateFullLoadHoursOfPowerPlant(
113  plant, tick));
114 
115  int operationalStatus;
116  if (plant.isOperational(tick))
117  operationalStatus = 1;
118  else if (plant.isInPipeline(tick))
119  operationalStatus = 0;
120  else
121  operationalStatus = 2;
122 
123  financialPowerPlantReport.setPowerPlantStatus(operationalStatus);
124 
125 
126 
127  }
128 
129  }
130 
131 }