16 package emlab.gen.role.market;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.transaction.annotation.Transactional;
21 import agentspring.role.Role;
22 import agentspring.role.RoleComponent;
32 import emlab.gen.role.AbstractEnergyProducerRole;
53 logger.info(
"Process electricity revenues");
56 for (
Segment segment : reps.genericRepository.findAll(
Segment.class)) {
57 for (
LongTermContract longTermContract : reps.contractRepository.findLongTermContractsForEnergyProducerForSegmentActiveAtTime(
58 producer, segment, getCurrentTick())) {
61 double basePrice = longTermContract.getCapacity() * longTermContract.getPricePerUnit() * segment.getLengthInHours();
62 double co2PassThrough = longTermContract.getCo2PassThroughFactor();
63 double co2PriceStart = longTermContract.getCo2PriceStart();
64 double currentCo2Price = findLastKnownCO2Price(getCurrentTick());
65 double fuelPassThrough = longTermContract.getFuelPassThroughFactor();
66 double fuelPriceStart = longTermContract.getFuelPriceStart();
67 double currentFuelPrice = 0d;
68 Substance mainFuel = longTermContract.getMainFuel();
69 if (mainFuel != null) {
70 currentFuelPrice = findLastKnownPriceForSubstance(mainFuel, getCurrentTick());
74 if (fuelPriceStart == 0) {
75 fuelPriceStart = 1e-8;
77 if (co2PriceStart == 0) {
81 double updatedPrice = basePrice * (1 + fuelPassThrough * (currentFuelPrice / fuelPriceStart - 1))
82 * (1 + co2PassThrough * (currentCo2Price / co2PriceStart - 1));
84 reps.nonTransactionalCreateRepository.createCashFlow(longTermContract.getTo(), longTermContract.getFrom(), updatedPrice,
85 CashFlow.ELECTRICITY_LONGTERM, getCurrentTick(), null);
88 for (
Segment s : longTermContract.getLongTermContractType().getSegments()) {
89 hours += s.getLengthInHours();
92 double pricePerMWh = updatedPrice / (longTermContract.getCapacity() * hours);
93 logger.info(
"Revenue from long term contract @ {} euro/MWh", pricePerMWh);