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