Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
miscGenMinusRowPSP.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_MiscGenMinusRowPSP_H__
22#define __SOLVER_VARIABLE_ECONOMY_MiscGenMinusRowPSP_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 "MISC. NDG";
41 }
42
44 static std::string Unit()
45 {
46 return "MWh";
47 }
48
50 static std::string Description()
51 {
52 return "Non-dispatchable generation (not including wind and run-of-the-river)";
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>
97 : public Variable::IVariable<MiscGenMinusRowPSP<NextT>, NextT, VCardMiscGenMinusRowPSP>
98{
99public:
101 typedef NextT NextType;
106
109
111
112 enum
113 {
115 count = 1 + NextT::count,
116 };
117
118 template<int CDataLevel, int CFile>
120 {
121 enum
122 {
123 count = ((VCardType::categoryDataLevel & CDataLevel
125 ? (NextType::template Statistics<CDataLevel, CFile>::count
127 : NextType::template Statistics<CDataLevel, CFile>::count),
128 };
129 };
130
131public:
132 void initializeFromStudy(Data::Study& study)
133 {
134 pNbYearsParallel = study.maxNbYearsInParallel;
135
136 // Average on all years
137 InitializeResultsFromStudy(AncestorType::pResults, study);
138
139 // Intermediate values
140 pValuesForTheCurrentYear.resize(pNbYearsParallel);
141 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
142 {
143 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
144 }
145
146 // Next
147 NextType::initializeFromStudy(study);
148 }
149
150 void initializeFromArea(Data::Study* study, Data::Area* area)
151 {
152 // Copy raw values
153 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
154 {
155 // Memcpy for the first value
156 (void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
157 area->miscGen.entry[0],
158 sizeof(double) * area->miscGen.height);
159
160 {
161 // We must not include the CHP and the Solar. So we have to start from `2`
162 for (unsigned int x = 1; x != (unsigned int)Data::fhhPSP; ++x)
163 {
164 const Matrix<>::ColumnType& col = area->miscGen.entry[x];
165 for (unsigned int y = 0; y != area->miscGen.height; ++y)
166 {
167 pValuesForTheCurrentYear[numSpace].hour[y] += col[y];
168 }
169 }
170 }
171 }
172
173 // Next
174 NextType::initializeFromArea(study, area);
175 }
176
177 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
178 {
179 // Next
180 NextType::initializeFromAreaLink(study, link);
181 }
182
183 template<class R>
184 static void InitializeResultsFromStudy(R& results, Data::Study& study)
185 {
186 VariableAccessorType::InitializeAndReset(results, study);
187 }
188
189 void simulationBegin()
190 {
191 // Next
192 NextType::simulationBegin();
193 }
194
195 void simulationEnd()
196 {
197 NextType::simulationEnd();
198 }
199
200 void yearBegin(unsigned int year, unsigned int numSpace)
201 {
202 // Next variable
203 NextType::yearBegin(year, numSpace);
204 }
205
206 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
207 {
208 // Next variable
209 NextType::yearEndBuild(state, year, numSpace);
210 }
211
212 void yearEnd(unsigned int year, unsigned int numSpace)
213 {
214 // Compute all statistics for the current year (daily,weekly,monthly)
215 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
216
217 // Next variable
218 NextType::yearEnd(year, numSpace);
219 }
220
221 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
222 unsigned int nbYearsForCurrentSummary)
223 {
224 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
225 {
226 AncestorType::pResults.merge(numSpaceToYear[numSpace],
227 pValuesForTheCurrentYear[numSpace]);
228 }
229
230 // Next variable
231 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
232 }
233
234 void hourBegin(unsigned int hourInTheYear)
235 {
236 // Next variable
237 NextType::hourBegin(hourInTheYear);
238 }
239
240 void hourForEachArea(State& state, unsigned int numSpace)
241 {
242 // Next variable
243 NextType::hourForEachArea(state, numSpace);
244 }
245
246 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
247 unsigned int,
248 unsigned int numSpace) const
249 {
250 return pValuesForTheCurrentYear[numSpace].hour;
251 }
252
253 void localBuildAnnualSurveyReport(SurveyResults& results,
254 int fileLevel,
255 int precision,
256 unsigned int numSpace) const
257 {
258 // Initializing external pointer on current variable non applicable status
259 results.isCurrentVarNA = AncestorType::isNonApplicable;
260
261 if (AncestorType::isPrinted[0])
262 {
263 // Write the data for the current year
264 results.variableCaption = VCardType::Caption();
265 results.variableUnit = VCardType::Unit();
266 pValuesForTheCurrentYear[numSpace]
267 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
268 }
269 }
270
271private:
273 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
274 unsigned int pNbYearsParallel;
275
276}; // class MiscGenMinusRowPSP
277
278} // namespace Economy
279} // namespace Variable
280} // namespace Solver
281} // namespace Antares
282
283#endif // __SOLVER_VARIABLE_ECONOMY_MiscGenMinusRowPSP_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
typename Antares::Memory::Stored< T >::Type ColumnType
Column type.
Definition matrix.h:62
Marginal MiscGenMinusRowPSP.
Definition miscGenMinusRowPSP.h:98
VCardMiscGenMinusRowPSP VCardType
VCard.
Definition miscGenMinusRowPSP.h:103
@ count
How many items have we got.
Definition miscGenMinusRowPSP.h:115
NextT NextType
Type of the next static variable.
Definition miscGenMinusRowPSP.h:101
VCardType::ResultsType ResultsType
List of expected results.
Definition miscGenMinusRowPSP.h:108
Variable::IVariable< MiscGenMinusRowPSP< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition miscGenMinusRowPSP.h:105
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 Description()
The short description of the variable.
Definition miscGenMinusRowPSP.h:50
static constexpr uint8_t decimal
Decimal precision.
Definition miscGenMinusRowPSP.h:74
Results< R::AllYears::Average< > > ResultsType
The expecte results.
Definition miscGenMinusRowPSP.h:58
static constexpr uint8_t precision
Precision (views)
Definition miscGenMinusRowPSP.h:70
static constexpr uint8_t categoryDataLevel
Data Level.
Definition miscGenMinusRowPSP.h:64
VCardMiscGenMinusRowPSP VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition miscGenMinusRowPSP.h:61
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition miscGenMinusRowPSP.h:78
static std::string Caption()
Caption.
Definition miscGenMinusRowPSP.h:38
static std::string Unit()
Unit.
Definition miscGenMinusRowPSP.h:44
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition miscGenMinusRowPSP.h:76
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition miscGenMinusRowPSP.h:82
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition miscGenMinusRowPSP.h:66
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition miscGenMinusRowPSP.h:84
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition miscGenMinusRowPSP.h:72