Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
productionByRenewablePlant.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_ProductionByRenewablePlant_H__
22#define __SOLVER_VARIABLE_ECONOMY_ProductionByRenewablePlant_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 "RES generation by plant";
40 }
41
43 static std::string Unit()
44 {
45 return "MWh";
46 }
47
49 static std::string Description()
50 {
51 return "Energy generated by all the RES clusters";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 >>
58
61
63 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
65 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
66 & (Category::FileLevel::de_res);
68 static constexpr uint8_t precision = Category::all;
70 static constexpr uint8_t nodeDepthForGUI = +0;
72 static constexpr uint8_t decimal = 0;
74 static constexpr int columnCount = Category::dynamicColumns;
76 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
77 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
78 static constexpr uint8_t spatialAggregatePostProcessing = 0;
80 static constexpr uint8_t hasIntermediateValues = 1;
82 static constexpr uint8_t isPossiblyNonApplicable = 0;
83
85 typedef std::vector<IntermediateValues> IntermediateValuesBaseType;
86 typedef std::vector<IntermediateValuesBaseType> IntermediateValuesType;
87
88}; // class VCard
89
93template<class NextT = Container::EndOfList>
94class ProductionByRenewablePlant: public Variable::IVariable<ProductionByRenewablePlant<NextT>,
95 NextT,
96 VCardProductionByRenewablePlant>
97{
98public:
100 typedef NextT NextType;
105
108
110
111 enum
112 {
114 count = 1 + NextT::count,
115 };
116
117 template<int CDataLevel, int CFile>
119 {
120 enum
121 {
122 count = ((VCardType::categoryDataLevel & CDataLevel
124 ? (NextType::template Statistics<CDataLevel, CFile>::count
126 : NextType::template Statistics<CDataLevel, CFile>::count),
127 };
128 };
129
130public:
132 pSize(0)
133 {
134 }
135
136 void initializeFromStudy(Data::Study& study)
137 {
138 // Next
139 NextType::initializeFromStudy(study);
140 }
141
142 void initializeFromArea(Data::Study* study, Data::Area* area)
143 {
144 // Get the number of years in parallel
145 pNbYearsParallel = study->maxNbYearsInParallel;
146 pValuesForTheCurrentYear.resize(pNbYearsParallel);
147
148 // Get the area
149 pSize = area->renewable.list.enabledCount();
150 if (pSize)
151 {
152 AncestorType::pResults.resize(pSize);
153
154 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
155 {
156 pValuesForTheCurrentYear[numSpace].resize(pSize);
157 }
158
159 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
160 {
161 for (unsigned int i = 0; i != pSize; ++i)
162 {
163 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study);
164 }
165 }
166
167 for (unsigned int i = 0; i != pSize; ++i)
168 {
169 AncestorType::pResults[i].initializeFromStudy(*study);
170 AncestorType::pResults[i].reset();
171 }
172 }
173 else
174 {
176 }
177 // Next
178 NextType::initializeFromArea(study, area);
179 }
180
181 size_t getMaxNumberColumns() const
182 {
183 return pSize * ResultsType::count;
184 }
185
186 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
187 {
188 // Next
189 NextType::initializeFromAreaLink(study, link);
190 }
191
192 void simulationBegin()
193 {
194 // Next
195 NextType::simulationBegin();
196 }
197
198 void simulationEnd()
199 {
200 NextType::simulationEnd();
201 }
202
203 void yearBegin(unsigned int year, unsigned int numSpace)
204 {
205 // Reset the values for the current year
206 for (unsigned int i = 0; i != pSize; ++i)
207 {
208 pValuesForTheCurrentYear[numSpace][i].reset();
209 }
210 // Next variable
211 NextType::yearBegin(year, numSpace);
212 }
213
214 void yearEndBuildPrepareDataForEachThermalCluster(State& state,
215 uint year,
216 unsigned int numSpace)
217 {
218 // Next variable
219 NextType::yearEndBuildPrepareDataForEachThermalCluster(state, year, numSpace);
220 }
221
222 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
223 {
224 // Next variable
225 NextType::yearEndBuild(state, year, numSpace);
226 }
227
228 void yearEnd(unsigned int year, unsigned int numSpace)
229 {
230 // Merge all results for all renewable clusters
231 {
232 for (unsigned int i = 0; i < pSize; ++i)
233 {
234 // Compute all statistics for the current year (daily,weekly,monthly)
235 pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear();
236 }
237 }
238 // Next variable
239 NextType::yearEnd(year, numSpace);
240 }
241
242 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
243 unsigned int nbYearsForCurrentSummary)
244 {
245 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
246 {
247 for (unsigned int i = 0; i < pSize; ++i)
248 {
249 // Merge all those values with the global results
250 AncestorType::pResults[i].merge(numSpaceToYear[numSpace],
251 pValuesForTheCurrentYear[numSpace][i]);
252 }
253 }
254
255 // Next variable
256 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
257 }
258
259 void hourBegin(unsigned int hourInTheYear)
260 {
261 // Next variable
262 NextType::hourBegin(hourInTheYear);
263 }
264
265 void hourForEachArea(State& state, unsigned int numSpace)
266 {
267 for (const auto& renewableCluster: state.area->renewable.list.each_enabled())
268 {
269 double renewableClusterProduction = renewableCluster->valueAtTimeStep(
270 state.year,
271 state.hourInTheYear);
272
273 pValuesForTheCurrentYear[numSpace][renewableCluster->enabledIndex]
274 .hour[state.hourInTheYear]
275 += renewableClusterProduction;
276 }
277
278 // Next variable
279 NextType::hourForEachArea(state, numSpace);
280 }
281
282 inline void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
283 {
284 // Ask to build the digest to the next variable
285 NextType::buildDigest(results, digestLevel, dataLevel);
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 // Initializing external pointer on current variable non applicable status
301 results.isCurrentVarNA = AncestorType::isNonApplicable;
302
303 if (AncestorType::isPrinted[0])
304 {
305 assert(NULL != results.data.area);
306 const auto& renewable = results.data.area->renewable;
307 // Write the data for the current year
308 for (auto& cluster: renewable.list.each_enabled())
309 {
310 // Write the data for the current year
311 results.variableCaption = cluster->name();
312 results.variableUnit = VCardType::Unit();
313 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
314 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
315 }
316 }
317 }
318
319private:
321 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
322 size_t pSize;
323 unsigned int pNbYearsParallel;
324}; // class ProductionByRenewablePlant
325
326} // namespace Economy
327} // namespace Variable
328} // namespace Solver
329} // namespace Antares
330
331#endif // __SOLVER_VARIABLE_ECONOMY_ProductionByRenewablePlant_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Energy generated by all renewable clusters.
Definition productionByRenewablePlant.h:97
NextT NextType
Type of the next static variable.
Definition productionByRenewablePlant.h:100
VCardType::ResultsType ResultsType
List of expected results.
Definition productionByRenewablePlant.h:107
Variable::IVariable< ProductionByRenewablePlant< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition productionByRenewablePlant.h:104
VCardProductionByRenewablePlant VCardType
VCard.
Definition productionByRenewablePlant.h:102
@ count
How many items have we got.
Definition productionByRenewablePlant.h:114
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 categoryDataLevel
Data Level.
Definition productionByRenewablePlant.h:63
static constexpr uint8_t precision
Precision (views)
Definition productionByRenewablePlant.h:68
VCardProductionByRenewablePlant VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition productionByRenewablePlant.h:60
Results< R::AllYears::Average< > > ResultsType
The expecte results.
Definition productionByRenewablePlant.h:57
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition productionByRenewablePlant.h:80
static std::string Unit()
Unit.
Definition productionByRenewablePlant.h:43
static constexpr uint8_t decimal
Decimal precision.
Definition productionByRenewablePlant.h:72
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition productionByRenewablePlant.h:70
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition productionByRenewablePlant.h:76
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition productionByRenewablePlant.h:82
static std::string Description()
The short description of the variable.
Definition productionByRenewablePlant.h:49
static std::string Caption()
Caption.
Definition productionByRenewablePlant.h:37
static constexpr int columnCount
Number of columns used by the variable.
Definition productionByRenewablePlant.h:74
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition productionByRenewablePlant.h:65