Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
dispatchableGeneration.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __SOLVER_VARIABLE_ECONOMY_DispatchableGeneration_H__
22#define __SOLVER_VARIABLE_ECONOMY_DispatchableGeneration_H__
23
24#include "antares/solver/variable/variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Economy
33{
35{
37 static std::string Caption()
38 {
39 return "Dispatch. Gen.";
40 }
41
43 static std::string Unit()
44 {
45 return "MWh";
46 }
47
49 static std::string Description()
50 {
51 return "Value of all the dispatchable generation throughout all MC years";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 R::AllYears::StdDeviation< // The standard deviation values throughout all years
57 R::AllYears::Min< // The minimum values throughout all years
58 R::AllYears::Max< // The maximum values throughout all years
59 >>>>>
61
64
66 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
68 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
69 & (Category::FileLevel::id
70 | Category::FileLevel::va);
72 static constexpr uint8_t precision = Category::all;
74 static constexpr uint8_t nodeDepthForGUI = +0;
76 static constexpr uint8_t decimal = 0;
78 static constexpr int columnCount = 10;
80 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
81 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
82 static constexpr uint8_t spatialAggregatePostProcessing = 0;
84 static constexpr uint8_t hasIntermediateValues = 1;
86 static constexpr uint8_t isPossiblyNonApplicable = 0;
87
88 typedef IntermediateValues IntermediateValuesBaseType[columnCount];
89 typedef IntermediateValuesBaseType* IntermediateValuesType;
90
91 typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg;
92
93 struct Multiple
94 {
95 static std::string Caption(const unsigned int indx)
96 {
97 switch (indx)
98 {
99 case 0:
100 return "NUCLEAR";
101 case 1:
102 return "LIGNITE";
103 case 2:
104 return "COAL";
105 case 3:
106 return "GAS";
107 case 4:
108 return "OIL";
109 case 5:
110 return "MIX. FUEL";
111 case 6:
112 return "MISC. DTG";
113 case 7:
114 return "MISC. DTG 2";
115 case 8:
116 return "MISC. DTG 3";
117 case 9:
118 return "MISC. DTG 4";
119
120 default:
121 return "<unknown>";
122 }
123 }
124
125 static std::string Unit([[maybe_unused]] const unsigned int indx)
126 {
128 }
129 };
130}; // class VCard
131
135template<class NextT = Container::EndOfList>
137 : public Variable::IVariable<DispatchableGeneration<NextT>, NextT, VCardDispatchableGeneration>
138{
139public:
141 typedef NextT NextType;
146
149
151
152 enum
153 {
155 count = 1 + NextT::count,
156 };
157
158 template<int CDataLevel, int CFile>
160 {
161 enum
162 {
163 count = ((VCardType::categoryDataLevel & CDataLevel
165 ? (NextType::template Statistics<CDataLevel, CFile>::count
167 : NextType::template Statistics<CDataLevel, CFile>::count),
168 };
169 };
170
171public:
173 {
174 delete[] pValuesForTheCurrentYear;
175 }
176
177 void initializeFromStudy(Data::Study& study)
178 {
179 pNbYearsParallel = study.maxNbYearsInParallel;
180
181 InitializeResultsFromStudy(AncestorType::pResults, study);
182
183 pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel];
184 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; ++numSpace)
185 {
186 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
187 {
188 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(study);
189 }
190 }
191
192 // Next
193 NextType::initializeFromStudy(study);
194 }
195
196 template<class R>
197 static void InitializeResultsFromStudy(R& results, Data::Study& study)
198 {
199 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
200 {
201 results[i].initializeFromStudy(study);
202 results[i].reset();
203 }
204 }
205
206 void initializeFromArea(Data::Study* study, Data::Area* area)
207 {
208 // Next
209 NextType::initializeFromArea(study, area);
210 }
211
212 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
213 {
214 // Next
215 NextType::initializeFromAreaLink(study, link);
216 }
217
218 void simulationBegin()
219 {
220 // Next
221 NextType::simulationBegin();
222 }
223
224 void simulationEnd()
225 {
226 NextType::simulationEnd();
227 }
228
229 void yearBegin(unsigned int year, unsigned int numSpace)
230 {
231 // Reset the values for the current year
232 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
233 {
234 pValuesForTheCurrentYear[numSpace][i].reset();
235 }
236 // Next variable
237 NextType::yearBegin(year, numSpace);
238 }
239
240 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
241 {
242 // Next variable
243 NextType::yearEndBuild(state, year, numSpace);
244 }
245
246 void yearEnd(unsigned int year, unsigned int numSpace)
247 {
248 VariableAccessorType::template ComputeStatistics<VCardType>(
249 pValuesForTheCurrentYear[numSpace]);
250
251 // Next variable
252 NextType::yearEnd(year, numSpace);
253 }
254
255 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
256 unsigned int nbYearsForCurrentSummary)
257 {
258 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
259 {
260 VariableAccessorType::ComputeSummary(pValuesForTheCurrentYear[numSpace],
262 numSpaceToYear[numSpace]);
263 }
264 // Next variable
265 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
266 }
267
268 void hourBegin(unsigned int hourInTheYear)
269 {
270 // Next variable
271 NextType::hourBegin(hourInTheYear);
272 }
273
274 void hourForEachArea(State& state, unsigned int numSpace)
275 {
276 auto area = state.area;
277 auto& thermal = state.thermal;
278 for (auto& cluster: area->thermal.list.each_enabled())
279 {
280 pValuesForTheCurrentYear[numSpace][cluster->groupID][state.hourInTheYear]
281 += thermal[area->index].thermalClustersProductions[cluster->enabledIndex];
282 }
283
284 // Next variable
285 NextType::hourForEachArea(state, numSpace);
286 }
287
288 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
289 unsigned int column,
290 unsigned int numSpace) const
291 {
292 return pValuesForTheCurrentYear[numSpace][column].hour;
293 }
294
295 void localBuildAnnualSurveyReport(SurveyResults& results,
296 int fileLevel,
297 int precision,
298 unsigned int numSpace) const
299 {
300 // The current variable is actually a multiple-variable.
301 results.isCurrentVarNA = AncestorType::isNonApplicable;
302
303 for (uint i = 0; i != VCardType::columnCount; ++i)
304 {
305 if (AncestorType::isPrinted[i])
306 {
307 // Write the data for the current year
308 results.variableCaption = VCardType::Multiple::Caption(i);
309 results.variableUnit = VCardType::Multiple::Unit(i);
310 pValuesForTheCurrentYear[numSpace][i]
311 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
312 }
313 results.isCurrentVarNA++;
314 }
315 }
316
317private:
319 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
320 unsigned int pNbYearsParallel;
321
322}; // class DispatchableGeneration
323
324} // namespace Economy
325} // namespace Variable
326} // namespace Solver
327} // namespace Antares
328
329#endif // __SOLVER_VARIABLE_ECONOMY_DispatchableGeneration_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal DispatchableGeneration.
Definition dispatchableGeneration.h:138
@ count
How many items have we got.
Definition dispatchableGeneration.h:155
VCardType::ResultsType ResultsType
List of expected results.
Definition dispatchableGeneration.h:148
Variable::IVariable< DispatchableGeneration< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition dispatchableGeneration.h:145
VCardDispatchableGeneration VCardType
VCard.
Definition dispatchableGeneration.h:143
NextT NextType
Type of the next static variable.
Definition dispatchableGeneration.h:141
Interface for any variable.
Definition variable.h:51
StoredResultType pResults
All the results about this variable.
Definition variable.h:327
Temporary buffer for allocating results for a single year.
Definition intermediate.h:46
Definition results.h:48
@ count
The count if item in the list.
Definition results.h:56
Definition cbuilder.h:120
Definition variable.h:25
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition dispatchableGeneration.h:84
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition dispatchableGeneration.h:68
VCardDispatchableGeneration VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition dispatchableGeneration.h:63
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition dispatchableGeneration.h:86
static constexpr uint8_t precision
Precision (views)
Definition dispatchableGeneration.h:72
static constexpr uint8_t categoryDataLevel
Data Level.
Definition dispatchableGeneration.h:66
static std::string Description()
The short description of the variable.
Definition dispatchableGeneration.h:49
static std::string Unit()
Unit.
Definition dispatchableGeneration.h:43
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition dispatchableGeneration.h:60
static constexpr uint8_t decimal
Decimal precision.
Definition dispatchableGeneration.h:76
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition dispatchableGeneration.h:80
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition dispatchableGeneration.h:78
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition dispatchableGeneration.h:74
static std::string Caption()
Caption.
Definition dispatchableGeneration.h:37