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