Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
psp.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_PSP_H__
22#define __SOLVER_VARIABLE_ECONOMY_PSP_H__
23
24#include <antares/study/area/constants.h>
25#include "antares/solver/variable/variable.h"
26
27namespace Antares
28{
29namespace Solver
30{
31namespace Variable
32{
33namespace Economy
34{
36{
38 static std::string Caption()
39 {
40 return "PSP";
41 }
42
44 static std::string Unit()
45 {
46 return "MWh";
47 }
48
50 static std::string Description()
51 {
52 return "PSP";
53 }
54
56 typedef Results<R::AllYears::Average< // The average values throughout all years
57 >>
59
62
64 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
66 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
67 & (Category::FileLevel::id
68 | Category::FileLevel::va);
70 static constexpr uint8_t precision = Category::all;
72 static constexpr uint8_t nodeDepthForGUI = +0;
74 static constexpr uint8_t decimal = 0;
76 static constexpr int columnCount = 1;
78 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
79 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
80 static constexpr uint8_t spatialAggregatePostProcessing = 0;
82 static constexpr uint8_t hasIntermediateValues = 1;
84 static constexpr uint8_t isPossiblyNonApplicable = 0;
85
87 typedef std::vector<IntermediateValues> IntermediateValuesType;
89
90}; // class VCard
91
95template<class NextT = Container::EndOfList>
96class PSP: public Variable::IVariable<PSP<NextT>, NextT, VCardPSP>
97{
98public:
100 typedef NextT NextType;
105
108
110
111 enum
112 {
114 count = 1 + NextT::count,
115 };
116
117 template<int CDataLevel, int CFile>
119 {
120 enum
121 {
122 count = ((VCardType::categoryDataLevel & CDataLevel
124 ? (NextType::template Statistics<CDataLevel, CFile>::count
126 : NextType::template Statistics<CDataLevel, CFile>::count),
127 };
128 };
129
130public:
131 void initializeFromStudy(Data::Study& study)
132 {
133 pNbYearsParallel = study.maxNbYearsInParallel;
134
135 // Average on all years
136 InitializeResultsFromStudy(AncestorType::pResults, study);
137
138 // Intermediate values
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 void initializeFromArea(Data::Study* study, Data::Area* area)
150 {
151 // Copy raw values
152 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
153 {
154 (void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
155 area->miscGen.entry[Data::fhhPSP],
156 sizeof(double) * area->miscGen.height);
157 }
158
159 // Next
160 NextType::initializeFromArea(study, area);
161 }
162
163 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
164 {
165 // Next
166 NextType::initializeFromAreaLink(study, link);
167 }
168
169 template<class R>
170 static void InitializeResultsFromStudy(R& results, Data::Study& study)
171 {
172 VariableAccessorType::InitializeAndReset(results, study);
173 }
174
175 void simulationBegin()
176 {
177 // Next
178 NextType::simulationBegin();
179 }
180
181 void simulationEnd()
182 {
183 NextType::simulationEnd();
184 }
185
186 void yearBegin(unsigned int year, unsigned int numSpace)
187 {
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 AncestorType::pResults.merge(numSpaceToYear[numSpace],
213 pValuesForTheCurrentYear[numSpace]);
214 }
215
216 // Next variable
217 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
218 }
219
220 void hourBegin(unsigned int hourInTheYear)
221 {
222 // Next variable
223 NextType::hourBegin(hourInTheYear);
224 }
225
226 void hourForEachArea(State& state, unsigned int numSpace)
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
257private:
259 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
260 unsigned int pNbYearsParallel;
261
262}; // class PSP
263
264} // namespace Economy
265} // namespace Variable
266} // namespace Solver
267} // namespace Antares
268
269#endif // __SOLVER_VARIABLE_ECONOMY_PSP_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal PSP.
Definition psp.h:97
VCardType::ResultsType ResultsType
List of expected results.
Definition psp.h:107
NextT NextType
Type of the next static variable.
Definition psp.h:100
@ count
How many items have we got.
Definition psp.h:114
Variable::IVariable< PSP< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition psp.h:104
VCardPSP VCardType
VCard.
Definition psp.h:102
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 psp.h:44
static std::string Description()
The short description of the variable.
Definition psp.h:50
static constexpr uint8_t precision
Precision (views)
Definition psp.h:70
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition psp.h:84
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition psp.h:66
VCardPSP VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition psp.h:61
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition psp.h:78
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition psp.h:82
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition psp.h:72
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition psp.h:76
Results< R::AllYears::Average< > > ResultsType
The expecte results.
Definition psp.h:58
static constexpr uint8_t categoryDataLevel
Data Level.
Definition psp.h:64
static constexpr uint8_t decimal
Decimal precision.
Definition psp.h:74
static std::string Caption()
Caption.
Definition psp.h:38