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