Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
renewableGeneration.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_RenewableGeneration_H__
22#define __SOLVER_VARIABLE_ECONOMY_RenewableGeneration_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 "Renewable 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 renewable 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 = 9;
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 "WIND OFFSHORE";
101 case 1:
102 return "WIND ONSHORE";
103 case 2:
104 return "SOLAR CONCRT.";
105 case 3:
106 return "SOLAR PV";
107 case 4:
108 return "SOLAR ROOFT";
109 case 5:
110 return "RENW. 1";
111 case 6:
112 return "RENW. 2";
113 case 7:
114 return "RENW. 3";
115 case 8:
116 return "RENW. 4";
117 default:
118 return "<unknown>";
119 }
120 }
121
122 static std::string Unit([[maybe_unused]] const unsigned int indx)
123 {
125 }
126 };
127}; // class VCard
128
132template<class NextT = Container::EndOfList>
134 : public Variable::IVariable<RenewableGeneration<NextT>, NextT, VCardRenewableGeneration>
135{
136public:
138 typedef NextT NextType;
143
146
148
149 enum
150 {
152 count = 1 + NextT::count,
153 };
154
155 template<int CDataLevel, int CFile>
157 {
158 enum
159 {
160 count = ((VCardType::categoryDataLevel & CDataLevel
162 ? (NextType::template Statistics<CDataLevel, CFile>::count
164 : NextType::template Statistics<CDataLevel, CFile>::count),
165 };
166 };
167
168public:
170 {
171 delete[] pValuesForTheCurrentYear;
172 }
173
174 void initializeFromStudy(Data::Study& study)
175 {
176 pNbYearsParallel = study.maxNbYearsInParallel;
177
178 InitializeResultsFromStudy(AncestorType::pResults, study);
179
180 pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel];
181 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; ++numSpace)
182 {
183 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
184 {
185 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(study);
186 }
187 }
188
189 // Next
190 NextType::initializeFromStudy(study);
191 }
192
193 template<class R>
194 static void InitializeResultsFromStudy(R& results, Data::Study& study)
195 {
196 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
197 {
198 results[i].initializeFromStudy(study);
199 results[i].reset();
200 }
201 }
202
203 void initializeFromArea(Data::Study* study, Data::Area* area)
204 {
205 // Next
206 NextType::initializeFromArea(study, area);
207 }
208
209 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
210 {
211 // Next
212 NextType::initializeFromAreaLink(study, link);
213 }
214
215 void simulationBegin()
216 {
217 // Next
218 NextType::simulationBegin();
219 }
220
221 void simulationEnd()
222 {
223 NextType::simulationEnd();
224 }
225
226 void yearBegin(unsigned int year, unsigned int numSpace)
227 {
228 // Reset the values for the current year
229 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
230 {
231 pValuesForTheCurrentYear[numSpace][i].reset();
232 }
233 // Next variable
234 NextType::yearBegin(year, numSpace);
235 }
236
237 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
238 {
239 // Next variable
240 NextType::yearEndBuild(state, year, numSpace);
241 }
242
243 void yearEnd(unsigned int year, unsigned int numSpace)
244 {
245 VariableAccessorType::template ComputeStatistics<VCardType>(
246 pValuesForTheCurrentYear[numSpace]);
247
248 // Next variable
249 NextType::yearEnd(year, numSpace);
250 }
251
252 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
253 unsigned int nbYearsForCurrentSummary)
254 {
255 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
256 {
257 VariableAccessorType::ComputeSummary(pValuesForTheCurrentYear[numSpace],
259 numSpaceToYear[numSpace]);
260 }
261 // Next variable
262 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
263 }
264
265 void hourBegin(unsigned int hourInTheYear)
266 {
267 // Next variable
268 NextType::hourBegin(hourInTheYear);
269 }
270
271 void hourForEachArea(State& state, unsigned int numSpace)
272 {
273 for (const auto& renewableCluster: state.area->renewable.list.each_enabled())
274 {
275 double renewableClusterProduction = renewableCluster->valueAtTimeStep(
276 state.year,
277 state.hourInTheYear);
278
279 pValuesForTheCurrentYear[numSpace][renewableCluster->groupID][state.hourInTheYear]
280 += renewableClusterProduction;
281 }
282
283 // Next variable
284 NextType::hourForEachArea(state, numSpace);
285 }
286
287 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
288 unsigned int column,
289 unsigned int numSpace) const
290 {
291 return pValuesForTheCurrentYear[numSpace][column].hour;
292 }
293
294 void localBuildAnnualSurveyReport(SurveyResults& results,
295 int fileLevel,
296 int precision,
297 unsigned int numSpace) const
298 {
299 // The current variable is actually a multiple-variable.
300 results.isCurrentVarNA = AncestorType::isNonApplicable;
301
302 for (uint i = 0; i != VCardType::columnCount; ++i)
303 {
304 if (AncestorType::isPrinted[i])
305 {
306 // Write the data for the current year
307 results.variableCaption = VCardType::Multiple::Caption(i);
308 results.variableUnit = VCardType::Multiple::Unit(i);
309 pValuesForTheCurrentYear[numSpace][i]
310 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
311 }
312 results.isCurrentVarNA++;
313 }
314 }
315
316private:
318 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
319 unsigned int pNbYearsParallel;
320
321}; // class RenewableGeneration
322
323} // namespace Economy
324} // namespace Variable
325} // namespace Solver
326} // namespace Antares
327
328#endif // __SOLVER_VARIABLE_ECONOMY_RenewableGeneration_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal RenewableGeneration.
Definition renewableGeneration.h:135
@ count
How many items have we got.
Definition renewableGeneration.h:152
VCardType::ResultsType ResultsType
List of expected results.
Definition renewableGeneration.h:145
VCardRenewableGeneration VCardType
VCard.
Definition renewableGeneration.h:140
Variable::IVariable< RenewableGeneration< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition renewableGeneration.h:142
NextT NextType
Type of the next static variable.
Definition renewableGeneration.h:138
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 decimal
Decimal precision.
Definition renewableGeneration.h:76
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition renewableGeneration.h:84
static std::string Caption()
Caption.
Definition renewableGeneration.h:37
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition renewableGeneration.h:68
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition renewableGeneration.h:78
static std::string Unit()
Unit.
Definition renewableGeneration.h:43
VCardRenewableGeneration VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition renewableGeneration.h:63
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition renewableGeneration.h:86
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition renewableGeneration.h:60
static std::string Description()
The short description of the variable.
Definition renewableGeneration.h:49
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition renewableGeneration.h:74
static constexpr uint8_t categoryDataLevel
Data Level.
Definition renewableGeneration.h:66
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition renewableGeneration.h:80
static constexpr uint8_t precision
Precision (views)
Definition renewableGeneration.h:72