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