Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
productionByDispatchablePlant.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_ProductionByDispatchablePlant_H__
22#define __SOLVER_VARIABLE_ECONOMY_ProductionByDispatchablePlant_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 "DTG 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 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);
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>
95 : public Variable::
96 IVariable<ProductionByDispatchablePlant<NextT>, NextT, VCardProductionByDispatchablePlant>
97{
98public:
100 typedef NextT NextType;
106
109
111
112 enum
113 {
115 count = 1 + NextT::count,
116 };
117
118 template<int CDataLevel, int CFile>
120 {
121 enum
122 {
123 count = ((VCardType::categoryDataLevel & CDataLevel
125 ? (NextType::template Statistics<CDataLevel, CFile>::count
127 : NextType::template Statistics<CDataLevel, CFile>::count),
128 };
129 };
130
131public:
133 pminOfTheClusterForYear(nullptr),
134 pSize(0)
135 {
136 }
137
139 {
140 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
141 {
142 delete[] pminOfTheClusterForYear[numSpace];
143 }
144 delete[] pminOfTheClusterForYear;
145 }
146
147 void initializeFromStudy(Data::Study& study)
148 {
149 // Next
150 NextType::initializeFromStudy(study);
151 }
152
153 void initializeFromArea(Data::Study* study, Data::Area* area)
154 {
155 // Get the number of years in parallel
156 pNbYearsParallel = study->maxNbYearsInParallel;
157 pValuesForTheCurrentYear.resize(pNbYearsParallel);
158 pminOfTheClusterForYear = new double*[pNbYearsParallel];
159
160 // Get the area
161 pSize = area->thermal.list.enabledCount();
162 if (pSize)
163 {
164 AncestorType::pResults.resize(pSize);
165
166 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
167 {
168 pValuesForTheCurrentYear[numSpace].resize(pSize);
169 }
170
171 // Minimum power values of the cluster for the whole year - from the solver in the
172 // accurate mode not to be displayed in the output \todo think of a better place like
173 // the DispatchableMarginForAllAreas done at the beginning of the year
174
175 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
176 {
177 pminOfTheClusterForYear[numSpace] = new double[pSize * HOURS_PER_YEAR];
178 }
179
180 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
181 {
182 for (unsigned int i = 0; i != pSize; ++i)
183 {
184 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study);
185 }
186 }
187
188 for (unsigned int i = 0; i != pSize; ++i)
189 {
190 AncestorType::pResults[i].initializeFromStudy(*study);
191 AncestorType::pResults[i].reset();
192 }
193 }
194 else
195 {
196 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
197 {
198 pminOfTheClusterForYear[numSpace] = nullptr;
199 }
200
202 }
203 // Next
204 NextType::initializeFromArea(study, area);
205 }
206
207 size_t getMaxNumberColumns() const
208 {
209 return pSize * ResultsType::count;
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 != pSize; ++i)
233 {
234 pValuesForTheCurrentYear[numSpace][i].reset();
235
236 for (unsigned int j = 0; j != HOURS_PER_YEAR; ++j)
237 {
238 pminOfTheClusterForYear[numSpace][i * HOURS_PER_YEAR + j] = 0;
239 }
240 }
241 // Next variable
242 NextType::yearBegin(year, numSpace);
243 }
244
245 void yearEndBuildPrepareDataForEachThermalCluster(State& state,
246 uint year,
247 unsigned int numSpace)
248 {
249 for (unsigned int i = 0; i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd]; ++i)
250 {
251 state.thermalClusterProductionForYear[i] += pValuesForTheCurrentYear
252 [numSpace]
253 [state.thermalCluster->enabledIndex]
254 .hour[i];
255 state.thermalClusterPMinOfTheClusterForYear[i] += pminOfTheClusterForYear
256 [numSpace][(state.thermalCluster->enabledIndex * HOURS_PER_YEAR) + i];
257 }
258
259 // Next variable
260 NextType::yearEndBuildPrepareDataForEachThermalCluster(state, year, numSpace);
261 }
262
263 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
264 {
265 // Next variable
266 NextType::yearEndBuild(state, year, numSpace);
267 }
268
269 void yearEnd(unsigned int year, unsigned int numSpace)
270 {
271 // Merge all results for all thermal clusters
272 {
273 for (unsigned int i = 0; i < pSize; ++i)
274 {
275 // Compute all statistics for the current year (daily,weekly,monthly)
276 pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear();
277 }
278 }
279 // Next variable
280 NextType::yearEnd(year, numSpace);
281 }
282
283 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
284 unsigned int nbYearsForCurrentSummary)
285 {
286 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
287 {
288 for (unsigned int i = 0; i < pSize; ++i)
289 {
290 // Merge all those values with the global results
291 AncestorType::pResults[i].merge(numSpaceToYear[numSpace],
292 pValuesForTheCurrentYear[numSpace][i]);
293 }
294 }
295
296 // Next variable
297 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
298 }
299
300 void hourBegin(unsigned int hourInTheYear)
301 {
302 // Next variable
303 NextType::hourBegin(hourInTheYear);
304 }
305
306 void hourForEachArea(State& state, unsigned int numSpace)
307 {
308 auto& area = state.area;
309 auto& thermal = state.thermal;
310 for (auto& cluster: area->thermal.list.each_enabled())
311 {
312 // Production for this hour
313 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[state.hourInTheYear]
314 += thermal[area->index].thermalClustersProductions[cluster->enabledIndex];
315
316 pminOfTheClusterForYear[numSpace]
317 [(cluster->enabledIndex * HOURS_PER_YEAR) + state.hourInTheYear]
318 = thermal[area->index].PMinOfClusters[cluster->enabledIndex];
319 }
320
321 // Next variable
322 NextType::hourForEachArea(state, numSpace);
323 }
324
325 inline void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
326 {
327 // Ask to build the digest to the next variable
328 NextType::buildDigest(results, digestLevel, dataLevel);
329 }
330
331 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
332 unsigned int column,
333 unsigned int numSpace) const
334 {
335 return pValuesForTheCurrentYear[numSpace][column].hour;
336 }
337
338 void localBuildAnnualSurveyReport(SurveyResults& results,
339 int fileLevel,
340 int precision,
341 unsigned int numSpace) const
342 {
343 // Initializing external pointer on current variable non applicable status
344 results.isCurrentVarNA = AncestorType::isNonApplicable;
345
346 if (AncestorType::isPrinted[0])
347 {
348 assert(NULL != results.data.area);
349 const auto& thermal = results.data.area->thermal;
350
351 // Write the data for the current year
352 for (auto& cluster: thermal.list.each_enabled())
353 {
354 // Write the data for the current year
355 results.variableCaption = cluster->name(); // VCardType::Caption();
356 results.variableUnit = VCardType::Unit();
357 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
358 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
359 }
360 }
361 }
362
363private:
365 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
366 double** pminOfTheClusterForYear;
367 size_t pSize;
368 unsigned int pNbYearsParallel;
369
370}; // class ProductionByDispatchablePlant
371
372} // namespace Economy
373} // namespace Variable
374} // namespace Solver
375} // namespace Antares
376
377#endif // __SOLVER_VARIABLE_ECONOMY_ProductionByDispatchablePlant_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Energy generated by all thermal dispatchable clusters.
Definition productionByDispatchablePlant.h:97
VCardProductionByDispatchablePlant VCardType
VCard.
Definition productionByDispatchablePlant.h:102
@ count
How many items have we got.
Definition productionByDispatchablePlant.h:115
VCardType::ResultsType ResultsType
List of expected results.
Definition productionByDispatchablePlant.h:108
NextT NextType
Type of the next static variable.
Definition productionByDispatchablePlant.h:100
Variable::IVariable< ProductionByDispatchablePlant< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition productionByDispatchablePlant.h:105
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 std::string Description()
The short description of the variable.
Definition productionByDispatchablePlant.h:49
static constexpr uint8_t categoryDataLevel
Data Level.
Definition productionByDispatchablePlant.h:63
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition productionByDispatchablePlant.h:65
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition productionByDispatchablePlant.h:82
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition productionByDispatchablePlant.h:80
static std::string Caption()
Caption.
Definition productionByDispatchablePlant.h:37
static constexpr uint8_t precision
Precision (views)
Definition productionByDispatchablePlant.h:68
static constexpr uint8_t decimal
Decimal precision.
Definition productionByDispatchablePlant.h:72
VCardProductionByDispatchablePlant VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition productionByDispatchablePlant.h:60
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition productionByDispatchablePlant.h:76
static constexpr int columnCount
Number of columns used by the variable.
Definition productionByDispatchablePlant.h:74
Results< R::AllYears::Average< > > ResultsType
The expecte results.
Definition productionByDispatchablePlant.h:57
static std::string Unit()
Unit.
Definition productionByDispatchablePlant.h:43
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition productionByDispatchablePlant.h:70