Antares Simulator
Power System Simulator
pumping.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_Pumping_H__
22 #define __SOLVER_VARIABLE_ECONOMY_Pumping_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 "H. PUMP";
34  }
35 
37  static std::string Unit()
38  {
39  return "MWh";
40  }
41 
43  static std::string Description()
44  {
45  return "Hydraulic pumping";
46  }
47 
49  typedef Results<R::AllYears::Average< // The average values throughout all years
50  R::AllYears::StdDeviation< // The standard deviation values throughout all years
51  R::AllYears::Min< // The minimum values throughout all years
52  R::AllYears::Max< // The maximum values throughout all years
53  >>>>>
55 
58 
60  static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
62  static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
63  & (Category::FileLevel::id
64  | Category::FileLevel::va);
66  static constexpr uint8_t precision = Category::all;
68  static constexpr uint8_t nodeDepthForGUI = +0;
70  static constexpr uint8_t decimal = 0;
72  static constexpr int columnCount = 1;
74  static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
75  static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
76  static constexpr uint8_t spatialAggregatePostProcessing = 0;
78  static constexpr uint8_t hasIntermediateValues = 1;
80  static constexpr uint8_t isPossiblyNonApplicable = 0;
81 
83  typedef std::vector<IntermediateValues> IntermediateValuesType;
84 
85  using IntermediateValuesTypeForSpatialAg = std::unique_ptr<IntermediateValuesBaseType[]>;
86 
87 }; // class VCard
88 
92 template<class NextT = Container::EndOfList>
93 class Pumping: public Variable::IVariable<Pumping<NextT>, NextT, VCardPumping>
94 {
95 public:
97  typedef NextT NextType;
102 
105 
107 
108  enum
109  {
111  count = 1 + NextT::count,
112  };
113 
114  template<int CDataLevel, int CFile>
115  struct Statistics
116  {
117  enum
118  {
119  count = ((VCardType::categoryDataLevel & CDataLevel
120  && VCardType::categoryFileLevel & CFile)
121  ? (NextType::template Statistics<CDataLevel, CFile>::count
123  : NextType::template Statistics<CDataLevel, CFile>::count),
124  };
125  };
126 
127 public:
128  void initializeFromStudy(Data::Study& study)
129  {
130  pNbYearsParallel = study.maxNbYearsInParallel;
131 
132  InitializeResultsFromStudy(AncestorType::pResults, study);
133 
134  pValuesForTheCurrentYear.resize(pNbYearsParallel);
135  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
136  {
137  pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
138  }
139 
140  // Next
141  NextType::initializeFromStudy(study);
142  }
143 
144  template<class R>
145  static void InitializeResultsFromStudy(R& results, Data::Study& study)
146  {
147  VariableAccessorType::InitializeAndReset(results, study);
148  }
149 
150  void initializeFromArea(Data::Study* study, Data::Area* area)
151  {
152  pArea = area;
153  // Next
154  NextType::initializeFromArea(study, area);
155  }
156 
157  void initializeFromLink(Data::Study* study, Data::AreaLink* link)
158  {
159  // Next
160  NextType::initializeFromAreaLink(study, link);
161  }
162 
163  void simulationBegin()
164  {
165  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
166  {
167  pValuesForTheCurrentYear[numSpace].reset();
168  }
169  // Next
170  NextType::simulationBegin();
171  }
172 
173  void simulationEnd()
174  {
175  // Next
176  NextType::simulationEnd();
177  }
178 
179  void yearBegin(unsigned int year, unsigned int numSpace)
180  {
181  // Reset the values for the current year
182  pValuesForTheCurrentYear[numSpace].reset();
183 
184  // Next variable
185  NextType::yearBegin(year, numSpace);
186  }
187 
188  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
189  {
190  // Next variable
191  NextType::yearEndBuild(state, year, numSpace);
192  }
193 
194  void yearEnd(unsigned int year, unsigned int numSpace)
195  {
196  // Compute all statistics for the current year (daily, weekly, monthly, annual).
197  pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
198 
199  // Next variable
200  NextType::yearEnd(year, numSpace);
201  }
202 
203  void computeSummary(unsigned int year, unsigned int numSpace)
204  {
205  // Merge all those values with the global results
206  AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);
207 
208  // Next variable
209  NextType::computeSummary(year, numSpace);
210  }
211 
212  void hourBegin(unsigned int hourInTheYear)
213  {
214  // Next variable
215  NextType::hourBegin(hourInTheYear);
216  }
217 
218  void hourForEachArea(State& state, unsigned int numSpace)
219  {
220  // Retrieving the hourly pumping energy
221  pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear] = state.hourlyResults
222  ->PompageHoraire
223  [state.hourInTheWeek];
224 
225  // Next variable
226  NextType::hourForEachArea(state, numSpace);
227  }
228 
229  Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
230  unsigned int,
231  unsigned int numSpace) const
232  {
233  return pValuesForTheCurrentYear[numSpace].hour;
234  }
235 
236  void localBuildAnnualSurveyReport(SurveyResults& results,
237  int fileLevel,
238  int precision,
239  unsigned int numSpace) const
240  {
241  // Initializing external pointer on current variable non applicable status
242  results.isCurrentVarNA = AncestorType::isNonApplicable;
243 
244  if (AncestorType::isPrinted[0])
245  {
246  // Write the data for the current year
247  results.variableCaption = VCardType::Caption();
248  results.variableUnit = VCardType::Unit();
249  pValuesForTheCurrentYear[numSpace]
250  .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
251  }
252  }
253 
254 private:
256  Antares::Data::Area* pArea;
258  typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
259  unsigned int pNbYearsParallel;
260 
261 }; // class Pumping
262 
263 } // namespace Antares::Solver::Variable::Economy
264 
265 #endif // __SOLVER_VARIABLE_ECONOMY_Pumping_H__
Definition for a single area.
Definition: area.h:51
Definition: study.h:57
Reservoir level.
Definition: pumping.h:94
VCardPumping VCardType
VCard.
Definition: pumping.h:99
@ count
How many items have we got.
Definition: pumping.h:111
NextT NextType
Type of the next static variable.
Definition: pumping.h:97
Variable::IVariable< Pumping< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: pumping.h:101
VCardType::ResultsType ResultsType
List of expected results.
Definition: pumping.h:104
Interface for any variable.
Definition: variable.h:47
const StoredResultType & results() const
The results.
Definition: variable.hxx:544
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 std::string Unit()
Unit.
Definition: pumping.h:37
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: pumping.h:80
static std::string Description()
The short description of the variable.
Definition: pumping.h:43
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expected results.
Definition: pumping.h:54
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: pumping.h:62
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: pumping.h:60
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: pumping.h:74
static constexpr uint8_t decimal
Decimal precision.
Definition: pumping.h:70
VCardPumping VCardForSpatialAggregate
The VCard to look for calculating spatial aggregates.
Definition: pumping.h:57
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: pumping.h:78
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: pumping.h:68
static std::string Caption()
Caption.
Definition: pumping.h:31
static constexpr uint8_t precision
Precision (views)
Definition: pumping.h:66
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: pumping.h:72