Antares Simulator
Power System Simulator
domesticUnsuppliedEnergy.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_DomesticUnsuppliedEnergy_H__
22 #define __SOLVER_VARIABLE_ECONOMY_DomesticUnsuppliedEnergy_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 "DENS";
34  }
35 
37  static std::string Unit()
38  {
39  return "MWh";
40  }
41 
43  static std::string Description()
44  {
45  return "Domestic Unsupplied Energy (demand that cannot be satisfied without "
46  "interconnections/links)";
47  }
48 
50  typedef Results<R::AllYears::Average< // The average values throughout all years
51  R::AllYears::StdDeviation< // The standard deviation values throughout all years
52  R::AllYears::Min< // The minimum values throughout all years
53  R::AllYears::Max< // The maximum values throughout all years
54  >>>>>
56 
59 
61  static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
63  static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
64  & (Category::FileLevel::id
65  | Category::FileLevel::va);
67  static constexpr uint8_t precision = Category::all;
69  static constexpr uint8_t nodeDepthForGUI = +0;
71  static constexpr uint8_t decimal = 0;
73  static constexpr int columnCount = 1;
75  static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
76  static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
77  static constexpr uint8_t spatialAggregatePostProcessing = 0;
79  static constexpr uint8_t hasIntermediateValues = 1;
81  static constexpr uint8_t isPossiblyNonApplicable = 0;
82 
84  typedef std::vector<IntermediateValues> IntermediateValuesType;
85 
86  using IntermediateValuesTypeForSpatialAg = std::unique_ptr<IntermediateValuesBaseType[]>;
87 
88 }; // class VCard
89 
94 template<class NextT = Container::EndOfList>
95 class DomesticUnsuppliedEnergy: public Variable::IVariable<DomesticUnsuppliedEnergy<NextT>,
96  NextT,
97  VCardDomesticUnsuppliedEnergy>
98 {
99 public:
101  typedef NextT NextType;
106 
109 
111 
112  enum
113  {
115  count = 1 + NextT::count,
116  };
117 
118  template<int CDataLevel, int CFile>
119  struct Statistics
120  {
121  enum
122  {
123  count = ((VCardType::categoryDataLevel & CDataLevel
124  && VCardType::categoryFileLevel & CFile)
125  ? (NextType::template Statistics<CDataLevel, CFile>::count
127  : NextType::template Statistics<CDataLevel, CFile>::count),
128  };
129  };
130 
131 public:
132  void initializeFromStudy(Data::Study& study)
133  {
134  pNbYearsParallel = study.maxNbYearsInParallel;
135 
136  // Intermediate values
137  InitializeResultsFromStudy(AncestorType::pResults, study);
138 
139  pValuesForTheCurrentYear.resize(pNbYearsParallel);
140  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
141  {
142  pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
143  }
144 
145  // Next
146  NextType::initializeFromStudy(study);
147  }
148 
149  template<class R>
150  static void InitializeResultsFromStudy(R& results, Data::Study& study)
151  {
152  VariableAccessorType::InitializeAndReset(results, study);
153  }
154 
155  void initializeFromArea(Data::Study* study, Data::Area* area)
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  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
170  {
171  pValuesForTheCurrentYear[numSpace].reset();
172  }
173  // Next
174  NextType::simulationBegin();
175  }
176 
177  void simulationEnd()
178  {
179  NextType::simulationEnd();
180  }
181 
182  void yearBegin(unsigned int year, unsigned int numSpace)
183  {
184  // Reset the values for the current year
185  pValuesForTheCurrentYear[numSpace].reset();
186 
187  // Next variable
188  NextType::yearBegin(year, numSpace);
189  }
190 
191  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
192  {
193  // Next variable
194  NextType::yearEndBuild(state, year, numSpace);
195  }
196 
197  void yearEnd(unsigned int year, unsigned int numSpace)
198  {
199  // Compute all statistics for the current year (daily,weekly,monthly)
200  pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
201 
202  // Next variable
203  NextType::yearEnd(year, numSpace);
204  }
205 
206  void computeSummary(unsigned int year, unsigned int numSpace)
207  {
208  // Merge all those values with the global results
209  AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);
210 
211  // Next variable
212  NextType::computeSummary(year, numSpace);
213  }
214 
215  void hourBegin(unsigned int hourInTheYear)
216  {
217  // Next variable
218  NextType::hourBegin(hourInTheYear);
219  }
220 
221  void hourForEachArea(State& state, unsigned int numSpace)
222  {
223  // Total DomesticUnsuppliedEnergy emissions
224  pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = state.hourlyResults
225  ->ValeursHorairesDENS
226  [state.hourInTheWeek];
227 
228  // Next variable
229  NextType::hourForEachArea(state, numSpace);
230  }
231 
232  Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
233  unsigned int,
234  unsigned int numSpace) const
235  {
236  return pValuesForTheCurrentYear[numSpace].hour;
237  }
238 
239  void localBuildAnnualSurveyReport(SurveyResults& results,
240  int fileLevel,
241  int precision,
242  unsigned int numSpace) const
243  {
244  // Initializing external pointer on current variable non applicable status
245  results.isCurrentVarNA = AncestorType::isNonApplicable;
246 
247  if (AncestorType::isPrinted[0])
248  {
249  // Write the data for the current year
250  results.variableCaption = VCardType::Caption();
251  results.variableUnit = VCardType::Unit();
252  pValuesForTheCurrentYear[numSpace]
253  .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
254  }
255  }
256 
257 private:
259  typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
260  unsigned int pNbYearsParallel;
261 
262 }; // class DomesticUnsuppliedEnergy
263 
264 } // namespace Antares::Solver::Variable::Economy
265 
266 #endif // __SOLVER_VARIABLE_ECONOMY_DomesticUnsuppliedEnergy_H__
Definition for a single area.
Definition: area.h:51
Definition: study.h:57
C02 Average value of the overrall DomesticUnsuppliedEnergy emissions expected from all the thermal di...
Definition: domesticUnsuppliedEnergy.h:98
VCardType::ResultsType ResultsType
List of expected results.
Definition: domesticUnsuppliedEnergy.h:108
Variable::IVariable< DomesticUnsuppliedEnergy< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: domesticUnsuppliedEnergy.h:105
@ count
How many items have we got.
Definition: domesticUnsuppliedEnergy.h:115
VCardDomesticUnsuppliedEnergy VCardType
VCard.
Definition: domesticUnsuppliedEnergy.h:103
NextT NextType
Type of the next static variable.
Definition: domesticUnsuppliedEnergy.h:101
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
VCardDomesticUnsuppliedEnergy VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition: domesticUnsuppliedEnergy.h:58
static constexpr uint8_t precision
Precision (views)
Definition: domesticUnsuppliedEnergy.h:67
static constexpr uint8_t decimal
Decimal precision.
Definition: domesticUnsuppliedEnergy.h:71
static std::string Caption()
Caption.
Definition: domesticUnsuppliedEnergy.h:31
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: domesticUnsuppliedEnergy.h:63
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: domesticUnsuppliedEnergy.h:81
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition: domesticUnsuppliedEnergy.h:55
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: domesticUnsuppliedEnergy.h:79
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: domesticUnsuppliedEnergy.h:73
static std::string Unit()
Unit.
Definition: domesticUnsuppliedEnergy.h:37
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: domesticUnsuppliedEnergy.h:61
static std::string Description()
The short description of the variable.
Definition: domesticUnsuppliedEnergy.h:43
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: domesticUnsuppliedEnergy.h:69
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: domesticUnsuppliedEnergy.h:75