Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
flowQuad.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_FlowQuad_H__
22#define __SOLVER_VARIABLE_ECONOMY_FlowQuad_H__
23
24#include "../../variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Economy
33{
35{
37 static std::string Caption()
38 {
39 return "FLOW QUAD.";
40 }
41
43 static std::string Unit()
44 {
45 return "MWh";
46 }
47
49 static std::string Description()
50 {
51 return "Flow (quad.)";
52 }
53
55 typedef Results<R::AllYears::Raw< // Raw values
56 >>
58
60 static constexpr uint8_t categoryDataLevel = Category::DataLevel::link;
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
84}; // class VCard
85
89template<class NextT = Container::EndOfList>
90class FlowQuad: public Variable::IVariable<FlowQuad<NextT>, NextT, VCardFlowQuad>
91{
92public:
94 typedef NextT NextType;
99
102
104
105 enum
106 {
108 count = 1 + NextT::count,
109 };
110
111 template<int CDataLevel, int CFile>
113 {
114 enum
115 {
116 count = ((VCardType::categoryDataLevel & CDataLevel
118 ? (NextType::template Statistics<CDataLevel, CFile>::count
120 : NextType::template Statistics<CDataLevel, CFile>::count),
121 };
122 };
123
124public:
125 ~FlowQuad()
126 {
127 }
128
129 void initializeFromStudy(Data::Study& study)
130 {
131 // Average on all years
132 pNbHours = study.runtime.rangeLimits.hour[Data::rangeEnd] + 1;
133 transitMoyenInterco_ = &study.runtime.transitMoyenInterconnexionsRecalculQuadratique;
134 AncestorType::pResults.initializeFromStudy(study);
136
137 // Intermediate values
138 pValuesForTheCurrentYear.initializeFromStudy(study);
139
140 // Next
141 NextType::initializeFromStudy(study);
142 }
143
144 void initializeFromArea(Data::Study* study, Data::Area* area)
145 {
146 // Next
147 NextType::initializeFromArea(study, area);
148 }
149
150 void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
151 {
152 assert(link && "invalid interconnection");
153 pLinkGlobalIndex = link->index;
154 // Next
155 NextType::initializeFromAreaLink(study, link);
156 }
157
158 void simulationBegin()
159 {
160 pValuesForTheCurrentYear.reset();
161
162 // Next
163 NextType::simulationBegin();
164 }
165
166 void simulationEnd()
167 {
168 // Flow assessed over all MC years (linear)
169 (void)::memcpy(pValuesForTheCurrentYear.hour,
170 (*transitMoyenInterco_)[pLinkGlobalIndex].data(),
171 sizeof(double) * pNbHours);
172
173 // Compute all statistics for the current year (daily,weekly,monthly)
174 pValuesForTheCurrentYear.computeStatisticsForTheCurrentYear();
175 // Merge all those values with the global results
176 AncestorType::pResults.merge(0, pValuesForTheCurrentYear);
177
178 // Next
179 NextType::simulationEnd();
180 }
181
182 void yearBegin(uint year, unsigned int numSpace)
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(uint year, unsigned int numSpace)
195 {
196 // Next variable
197 NextType::yearEnd(year, numSpace);
198 }
199
200 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
201 unsigned int nbYearsForCurrentSummary)
202 {
203 // Next variable
204 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
205 }
206
207 void hourBegin(uint hourInTheYear)
208 {
209 // Next variable
210 NextType::hourBegin(hourInTheYear);
211 }
212
213 void hourForEachArea(State& state, unsigned int numSpace)
214 {
215 // Next variable
216 NextType::hourForEachArea(state, numSpace);
217 }
218
219 void hourForEachLink(State& state, unsigned int numSpace)
220 {
221 // Next item in the list
222 NextType::hourForEachLink(state, numSpace);
223 }
224
225 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
226 {
227 if (dataLevel & Category::DataLevel::link)
228 {
229 if (digestLevel & Category::digestFlowQuad)
230 {
231 results.data.matrix
232 .entry[results.data.link->from->index][results.data.link->with->index]
233 = AncestorType::pResults.rawdata.allYears;
234 results.data.matrix
235 .entry[results.data.link->with->index][results.data.link->from->index]
236 = -AncestorType::pResults.rawdata.allYears;
237 }
238 }
239 // Next
240 NextType::buildDigest(results, digestLevel, dataLevel);
241 }
242
243 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
244 uint,
245 uint) const
246 {
247 return pValuesForTheCurrentYear.hour;
248 }
249
250 void localBuildAnnualSurveyReport(SurveyResults& results,
251 int fileLevel,
252 int precision,
253 uint) const
254 {
255 // Initializing external pointer on current variable non applicable status
256 results.isCurrentVarNA = AncestorType::isNonApplicable;
257
258 if (AncestorType::isPrinted[0])
259 {
260 // Write the data for the current year
261 results.variableCaption = VCardType::Caption();
262 results.variableUnit = VCardType::Unit();
263 pValuesForTheCurrentYear.template buildAnnualSurveyReport<VCardType>(results,
264 fileLevel,
265 precision);
266 }
267 }
268
269private:
270 uint pLinkGlobalIndex;
271 uint pNbHours;
272 std::vector<std::vector<double>>* transitMoyenInterco_;
273
275 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
276
277}; // class FlowQuad
278
279} // namespace Economy
280} // namespace Variable
281} // namespace Solver
282} // namespace Antares
283
284#endif // __SOLVER_VARIABLE_ECONOMY_FlowQuad_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal FlowQuad.
Definition flowQuad.h:91
Variable::IVariable< FlowQuad< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition flowQuad.h:98
@ count
How many items have we got.
Definition flowQuad.h:108
NextT NextType
Type of the next static variable.
Definition flowQuad.h:94
VCardFlowQuad VCardType
VCard.
Definition flowQuad.h:96
VCardType::ResultsType ResultsType
List of expected results.
Definition flowQuad.h:101
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
void reset()
Reset all values.
Definition intermediate.hxx:37
Antares::Memory::Stored< Type >::Type hour
Values for each hour in the year.
Definition intermediate.h:136
void computeStatisticsForTheCurrentYear()
Compute statistics for the current year.
Definition intermediate.cpp:70
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 flowQuad.h:43
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition flowQuad.h:80
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition flowQuad.h:72
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition flowQuad.h:78
Results< R::AllYears::Raw< > > ResultsType
The expecte results.
Definition flowQuad.h:57
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition flowQuad.h:74
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition flowQuad.h:68
static std::string Description()
The short description of the variable.
Definition flowQuad.h:49
static std::string Caption()
Caption.
Definition flowQuad.h:37
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition flowQuad.h:62
static constexpr uint8_t decimal
Decimal precision.
Definition flowQuad.h:70
static constexpr uint8_t categoryDataLevel
Data Level.
Definition flowQuad.h:60
static constexpr uint8_t precision
Precision (views)
Definition flowQuad.h:66