Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
hydro.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_TimeSeriesValuesHydro_H__
22#define __SOLVER_VARIABLE_ECONOMY_TimeSeriesValuesHydro_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 "H. ROR";
40 }
41
43 static std::string Unit()
44 {
45 return "MWh";
46 }
47
49 static std::string Description()
50 {
51 return "Hydro generation, thoughout all MC years";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 R::AllYears::StdDeviation< // The standard deviation values throughout all years
57 R::AllYears::Min< // The minimum values throughout all years
58 R::AllYears::Max< // The maximum values throughout all years
59 >>>>>
61
64
66 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
68 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
69 & (Category::FileLevel::id
70 | Category::FileLevel::va);
72 static constexpr uint8_t precision = Category::all;
74 static constexpr uint8_t nodeDepthForGUI = +0;
76 static constexpr uint8_t decimal = 0;
78 static constexpr int columnCount = 1;
80 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
81 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
82 static constexpr uint8_t spatialAggregatePostProcessing = 0;
84 static constexpr uint8_t hasIntermediateValues = 1;
86 static constexpr uint8_t isPossiblyNonApplicable = 0;
87
89 typedef std::vector<IntermediateValues> IntermediateValuesType;
90
92
93}; // class VCard
94
98template<class NextT = Container::EndOfList>
100 : public Variable::IVariable<TimeSeriesValuesHydro<NextT>, NextT, VCardTimeSeriesValuesHydro>
101{
102public:
104 typedef NextT NextType;
109
112
114
115 enum
116 {
118 count = 1 + NextT::count,
119 };
120
121 template<int CDataLevel, int CFile>
123 {
124 enum
125 {
126 count = ((VCardType::categoryDataLevel & CDataLevel
128 ? (NextType::template Statistics<CDataLevel, CFile>::count
130 : NextType::template Statistics<CDataLevel, CFile>::count),
131 };
132 };
133
134public:
136 {
137 delete[] pFatalValues;
138 }
139
140 void initializeFromStudy(Data::Study& study)
141 {
142 pNbYearsParallel = study.maxNbYearsInParallel;
143
144 pFatalValues = new Matrix<>::ColumnType*[pNbYearsParallel];
145 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
146 {
147 pFatalValues[numSpace] = NULL;
148 }
149
150 InitializeResultsFromStudy(AncestorType::pResults, study);
151
152 pValuesForTheCurrentYear.resize(pNbYearsParallel);
153 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
154 {
155 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
156 }
157
158 // Next
159 NextType::initializeFromStudy(study);
160 }
161
162 template<class R>
163 static void InitializeResultsFromStudy(R& results, Data::Study& study)
164 {
165 VariableAccessorType::InitializeAndReset(results, study);
166 }
167
168 void initializeFromArea(Data::Study* study, Data::Area* area)
169 {
170 pArea = area;
171 // Next
172 NextType::initializeFromArea(study, area);
173 }
174
175 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
176 {
177 // Next
178 NextType::initializeFromAreaLink(study, link);
179 }
180
181 void simulationBegin()
182 {
183 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
184 {
185 pValuesForTheCurrentYear[numSpace].reset();
186 }
187 // Next
188 NextType::simulationBegin();
189 }
190
191 void simulationEnd()
192 {
193 NextType::simulationEnd();
194 }
195
196 void yearBegin(unsigned int year, unsigned int numSpace)
197 {
198 // The current time-series
199 auto& ror = pArea->hydro.series->ror;
200 const unsigned int nbchro = ror.getSeriesIndex(year);
201 pFatalValues[numSpace] = &(ror.timeSeries.entry[nbchro]);
202
203 // Next variable
204 NextType::yearBegin(year, numSpace);
205 }
206
207 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
208 {
209 // Next variable
210 NextType::yearEndBuild(state, year, numSpace);
211 }
212
213 void yearEnd(unsigned int year, unsigned int numSpace)
214 {
215 // Compute all statistics for the current year (daily,weekly,monthly)
216 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
217
218 // Next variable
219 NextType::yearEnd(year, numSpace);
220 }
221
222 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
223 unsigned int nbYearsForCurrentSummary)
224 {
225 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
226 {
227 // Merge all those values with the global results
228 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
229 pValuesForTheCurrentYear[numSpace]);
230 }
231
232 // Next variable
233 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
234 }
235
236 void hourBegin(unsigned int hourInTheYear)
237 {
238 // Next variable
239 NextType::hourBegin(hourInTheYear);
240 }
241
242 void hourForEachArea(State& state, unsigned int numSpace)
243 {
244 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = (*pFatalValues[numSpace])
245 [state.hourInTheYear];
246 // Next variable
247 NextType::hourForEachArea(state, numSpace);
248 }
249
250 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
251 unsigned int,
252 unsigned int numSpace) const
253 {
254 return pValuesForTheCurrentYear[numSpace].hour;
255 }
256
257 void localBuildAnnualSurveyReport(SurveyResults& results,
258 int fileLevel,
259 int precision,
260 unsigned int numSpace) const
261 {
262 // Initializing external pointer on current variable non applicable status
263 results.isCurrentVarNA = AncestorType::isNonApplicable;
264
265 if (AncestorType::isPrinted[0])
266 {
267 // Write the data for the current year
268 results.variableCaption = VCardType::Caption();
269 results.variableUnit = VCardType::Unit();
270 pValuesForTheCurrentYear[numSpace]
271 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
272 }
273 }
274
275private:
277 Data::Area* pArea;
279 Matrix<>::ColumnType** pFatalValues;
280
282 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
283 unsigned int pNbYearsParallel;
284
285}; // class TimeSeriesValuesHydro
286
287} // namespace Economy
288} // namespace Variable
289} // namespace Solver
290} // namespace Antares
291
292#endif // __SOLVER_VARIABLE_ECONOMY_TimeSeriesValuesHydro_H__
Definition for a single area.
Definition area.h:52
std::unique_ptr< DataSeriesHydro > series
Data for time-series.
Definition container.h:224
Definition study.h:61
typename Antares::Memory::Stored< T >::Type ColumnType
Column type.
Definition matrix.h:62
Marginal TimeSeriesValuesHydro.
Definition hydro.h:101
VCardTimeSeriesValuesHydro VCardType
VCard.
Definition hydro.h:106
Variable::IVariable< TimeSeriesValuesHydro< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition hydro.h:108
@ count
How many items have we got.
Definition hydro.h:118
VCardType::ResultsType ResultsType
List of expected results.
Definition hydro.h:111
NextT NextType
Type of the next static variable.
Definition hydro.h:104
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 Unit()
Unit.
Definition hydro.h:43
static constexpr uint8_t decimal
Decimal precision.
Definition hydro.h:76
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition hydro.h:74
VCardTimeSeriesValuesHydro VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition hydro.h:63
static constexpr uint8_t precision
Precision (views)
Definition hydro.h:72
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition hydro.h:68
static std::string Caption()
Caption.
Definition hydro.h:37
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition hydro.h:80
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition hydro.h:86
static std::string Description()
The short description of the variable.
Definition hydro.h:49
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition hydro.h:78
static constexpr uint8_t categoryDataLevel
Data Level.
Definition hydro.h:66
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition hydro.h:60
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition hydro.h:84