Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
loopFlow.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_LoopFlow_H__
22#define __SOLVER_VARIABLE_ECONOMY_LoopFlow_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 "LOOP FLOW";
40 }
41
43 static std::string Unit()
44 {
45 return "MWh";
46 }
47
49 static std::string Description()
50 {
51 return "Loop flow";
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 LoopFlow: public Variable::IVariable<LoopFlow<NextT>, NextT, VCardLoopFlow>
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 ~LoopFlow()
126 {
127 }
128
129 void initializeFromStudy(Data::Study& study)
130 {
131 // Average on all years
132 InitializeResultsFromStudy(AncestorType::pResults, study);
133
134 // Intermediate values
135 pValuesForTheCurrentYear.initializeFromStudy(study);
136
137 // Next
138 NextType::initializeFromStudy(study);
139 }
140
141 template<class R>
142 static void InitializeResultsFromStudy(R& results, Data::Study& study)
143 {
144 VariableAccessorType::InitializeAndReset(results, study);
145 }
146
147 void initializeFromArea(Data::Study* study, Data::Area* area)
148 {
149 // Next
150 NextType::initializeFromArea(study, area);
151 }
152
153 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
154 {
155 // Next
156 NextType::initializeFromAreaLink(study, link);
157 }
158
159 void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
160 {
161 if (link->useLoopFlow)
162 {
163 // Flow assessed over all MC years (linear)
164 unsigned int height = link->parameters.height;
165 (void)::memcpy(pValuesForTheCurrentYear.hour,
166 link->parameters[Data::fhlLoopFlow],
167 sizeof(double) * height);
168 }
169
170 // Next
171 NextType::initializeFromAreaLink(study, link);
172 }
173
174 void simulationBegin()
175 {
176 // Next
177 NextType::simulationBegin();
178 }
179
180 void simulationEnd()
181 {
182 // Compute all statistics for the current year (daily,weekly,monthly)
183 pValuesForTheCurrentYear.computeStatisticsForTheCurrentYear();
184 // Merge all those values with the global results
185 AncestorType::pResults.merge(0, pValuesForTheCurrentYear);
186
187 // Next
188 NextType::simulationEnd();
189 }
190
191 void yearBegin(uint year, unsigned int numSpace)
192 {
193 // Next variable
194 NextType::yearBegin(year, numSpace);
195 }
196
197 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
198 {
199 // Next variable
200 NextType::yearEndBuild(state, year, numSpace);
201 }
202
203 void yearEnd(uint year, unsigned int numSpace)
204 {
205 // Next variable
206 NextType::yearEnd(year, numSpace);
207 }
208
209 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
210 unsigned int nbYearsForCurrentSummary)
211 {
212 // Next variable
213 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
214 }
215
216 void hourBegin(uint hourInTheYear)
217 {
218 // Next variable
219 NextType::hourBegin(hourInTheYear);
220 }
221
222 void hourForEachArea(State& state, unsigned int numSpace)
223 {
224 // Next variable
225 NextType::hourForEachArea(state, numSpace);
226 }
227
228 void hourForEachLink(State& state, unsigned int numSpace)
229 {
230 // Next item in the list
231 NextType::hourForEachLink(state, numSpace);
232 }
233
234 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
235 {
236 // Next
237 NextType::buildDigest(results, digestLevel, dataLevel);
238 }
239
240 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
241 uint,
242 uint) const
243 {
244 return pValuesForTheCurrentYear.hour;
245 }
246
247 void localBuildAnnualSurveyReport(SurveyResults& results,
248 int fileLevel,
249 int precision,
250 uint) const
251 {
252 // Initializing external pointer on current variable non applicable status
253 results.isCurrentVarNA = AncestorType::isNonApplicable;
254
255 if (AncestorType::isPrinted[0])
256 {
257 // Write the data for the current year
258 results.variableCaption = VCardType::Caption();
259 results.variableUnit = VCardType::Unit();
260 pValuesForTheCurrentYear.template buildAnnualSurveyReport<VCardType>(results,
261 fileLevel,
262 precision);
263 }
264 }
265
266private:
268 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
269
270}; // class LoopFlow
271
272} // namespace Economy
273} // namespace Variable
274} // namespace Solver
275} // namespace Antares
276
277#endif // __SOLVER_VARIABLE_ECONOMY_LoopFlow_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
LoopFlow.
Definition loopFlow.h:91
NextT NextType
Type of the next static variable.
Definition loopFlow.h:94
VCardLoopFlow VCardType
VCard.
Definition loopFlow.h:96
VCardType::ResultsType ResultsType
List of expected results.
Definition loopFlow.h:101
@ count
How many items have we got.
Definition loopFlow.h:108
Variable::IVariable< LoopFlow< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition loopFlow.h:98
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
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 constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition loopFlow.h:68
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition loopFlow.h:78
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition loopFlow.h:62
static std::string Unit()
Unit.
Definition loopFlow.h:43
static std::string Caption()
Caption.
Definition loopFlow.h:37
Results< R::AllYears::Raw< > > ResultsType
The expecte results.
Definition loopFlow.h:57
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition loopFlow.h:74
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition loopFlow.h:80
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition loopFlow.h:72
static std::string Description()
The short description of the variable.
Definition loopFlow.h:49
static constexpr uint8_t categoryDataLevel
Data Level.
Definition loopFlow.h:60
static constexpr uint8_t precision
Precision (views)
Definition loopFlow.h:66
static constexpr uint8_t decimal
Decimal precision.
Definition loopFlow.h:70