Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
thermalAirPollutantEmissions.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_thermalAirPollutantEmissions_H__
22#define __SOLVER_VARIABLE_ECONOMY_thermalAirPollutantEmissions_H__
23
24#include <antares/study/study.h>
25#include "antares/solver/variable/variable.h"
26
27namespace Antares::Solver::Variable::Economy
28{
30{
32 static std::string Caption()
33 {
34 return "";
35 }
36
38 static std::string Unit()
39 {
40 return "Tons";
41 }
42
44 static std::string Description()
45 {
46 return "Overall pollutant emissions expected from all the thermal clusters";
47 }
48
50 typedef Results<R::AllYears::Average< // The average values throughout all years
51 R::AllYears::StdDeviation< // The standard deviation values throughout all years
52 R::AllYears::Min< // The minimum values throughout all years
53 R::AllYears::Max< // The maximum values throughout all years
54 >>>>>
56
59
61 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
63 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
64 & (Category::FileLevel::id
65 | Category::FileLevel::va);
67 static constexpr uint8_t precision = Category::all;
69 static constexpr uint8_t nodeDepthForGUI = +0;
71 static constexpr uint8_t decimal = 0;
73 static constexpr int columnCount = Antares::Data::Pollutant::POLLUTANT_MAX;
75 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
76 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
77 static constexpr uint8_t spatialAggregatePostProcessing = 0;
79 static constexpr uint8_t hasIntermediateValues = 1;
81 static constexpr uint8_t isPossiblyNonApplicable = 0;
82
83 typedef IntermediateValues IntermediateValuesBaseType[columnCount];
84 typedef IntermediateValuesBaseType* IntermediateValuesType;
85
86 typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg;
87
88 struct Multiple
89 {
90 static std::string Caption(const unsigned int indx)
91 {
92 if (indx < Antares::Data::Pollutant::POLLUTANT_MAX)
93 {
94 return Antares::Data::Pollutant::getPollutantName(indx).c_str();
95 }
96
97 return "<unknown>";
98 }
99
100 static std::string Unit([[maybe_unused]] const unsigned int indx)
101 {
103 }
104 };
105}; // class VCard
106
110template<class NextT = Container::EndOfList>
111class ThermalAirPollutantEmissions: public Variable::IVariable<ThermalAirPollutantEmissions<NextT>,
112 NextT,
113 VCardThermalAirPollutantEmissions>
114{
115public:
117 typedef NextT NextType;
122
125
127
128 enum
129 {
131 count = 1 + NextT::count,
132 };
133
134 template<int CDataLevel, int CFile>
136 {
137 enum
138 {
139 count = ((VCardType::categoryDataLevel & CDataLevel
141 ? (NextType::template Statistics<CDataLevel, CFile>::count
143 : NextType::template Statistics<CDataLevel, CFile>::count),
144 };
145 };
146
147public:
149 {
150 delete[] pValuesForTheCurrentYear;
151 }
152
153 void initializeFromStudy(Data::Study& study)
154 {
155 pNbYearsParallel = study.maxNbYearsInParallel;
156
157 InitializeResultsFromStudy(AncestorType::pResults, study);
158
159 pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel];
160 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; ++numSpace)
161 {
162 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
163 {
164 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(study);
165 }
166 }
167
168 // Next
169 NextType::initializeFromStudy(study);
170 }
171
172 template<class R>
173 static void InitializeResultsFromStudy(R& results, Data::Study& study)
174 {
175 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
176 {
177 results[i].initializeFromStudy(study);
178 results[i].reset();
179 }
180 }
181
182 void initializeFromArea(Data::Study* study, Data::Area* area)
183 {
184 // Next
185 NextType::initializeFromArea(study, area);
186 }
187
188 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
189 {
190 // Next
191 NextType::initializeFromAreaLink(study, link);
192 }
193
194 void simulationBegin()
195 {
196 // Next
197 NextType::simulationBegin();
198 }
199
200 void simulationEnd()
201 {
202 NextType::simulationEnd();
203 }
204
205 void yearBegin(unsigned int year, unsigned int numSpace)
206 {
207 // Reset the values for the current year
208 for (unsigned int i = 0; i != VCardType::columnCount; ++i)
209 {
210 pValuesForTheCurrentYear[numSpace][i].reset();
211 }
212 // Next variable
213 NextType::yearBegin(year, numSpace);
214 }
215
216 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
217 {
218 // Next variable
219 NextType::yearEndBuild(state, year, numSpace);
220 }
221
222 void yearEnd(unsigned int year, unsigned int numSpace)
223 {
224 VariableAccessorType::template ComputeStatistics<VCardType>(
225 pValuesForTheCurrentYear[numSpace]);
226
227 // Next variable
228 NextType::yearEnd(year, numSpace);
229 }
230
231 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
232 unsigned int nbYearsForCurrentSummary)
233 {
234 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
235 {
236 VariableAccessorType::ComputeSummary(pValuesForTheCurrentYear[numSpace],
238 numSpaceToYear[numSpace]);
239 }
240 // Next variable
241 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
242 }
243
244 void hourBegin(unsigned int hourInTheYear)
245 {
246 // Next variable
247 NextType::hourBegin(hourInTheYear);
248 }
249
250 void hourForEachArea(State& state, unsigned int numSpace)
251 {
252 auto area = state.area;
253 auto& thermal = state.thermal;
254 for (auto& cluster: area->thermal.list.each_enabled())
255 {
256 // Multiply every pollutant factor with production
257 for (int pollutant = 0; pollutant < Antares::Data::Pollutant::POLLUTANT_MAX;
258 pollutant++)
259 {
260 pValuesForTheCurrentYear[numSpace][pollutant][state.hourInTheYear]
261 += cluster->emissions.factors[pollutant]
262 * thermal[state.area->index].thermalClustersProductions[cluster->enabledIndex];
263 }
264 }
265
266 // Next variable
267 NextType::hourForEachArea(state, numSpace);
268 }
269
270 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
271 unsigned int column,
272 unsigned int numSpace) const
273 {
274 return pValuesForTheCurrentYear[numSpace][column].hour;
275 }
276
277 void localBuildAnnualSurveyReport(SurveyResults& results,
278 int fileLevel,
279 int precision,
280 unsigned int numSpace) const
281 {
282 // The current variable is actually a multiple-variable.
283 results.isCurrentVarNA = AncestorType::isNonApplicable;
284
285 for (uint i = 0; i != VCardType::columnCount; ++i)
286 {
287 if (AncestorType::isPrinted[i])
288 {
289 // Write the data for the current year
290 results.variableCaption = VCardType::Multiple::Caption(i);
291 results.variableUnit = VCardType::Multiple::Unit(i);
292 pValuesForTheCurrentYear[numSpace][i]
293 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
294 }
295 results.isCurrentVarNA++;
296 }
297 }
298
299private:
301 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
302 unsigned int pNbYearsParallel;
303
304}; // class ThermalAirPollutantEmissions
305
306} // namespace Antares::Solver::Variable::Economy
307
308#endif // __SOLVER_VARIABLE_ECONOMY_thermalAirPollutantEmissions_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal ThermalAirPollutantEmissions.
Definition thermalAirPollutantEmissions.h:114
VCardThermalAirPollutantEmissions VCardType
VCard.
Definition thermalAirPollutantEmissions.h:119
NextT NextType
Type of the next static variable.
Definition thermalAirPollutantEmissions.h:117
VCardType::ResultsType ResultsType
List of expected results.
Definition thermalAirPollutantEmissions.h:124
@ count
How many items have we got.
Definition thermalAirPollutantEmissions.h:131
Variable::IVariable< ThermalAirPollutantEmissions< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition thermalAirPollutantEmissions.h:121
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
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition thermalAirPollutantEmissions.h:79
static std::string Description()
The short description of the variable.
Definition thermalAirPollutantEmissions.h:44
static std::string Unit()
Unit.
Definition thermalAirPollutantEmissions.h:38
static constexpr uint8_t precision
Precision (views)
Definition thermalAirPollutantEmissions.h:67
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition thermalAirPollutantEmissions.h:73
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition thermalAirPollutantEmissions.h:55
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition thermalAirPollutantEmissions.h:81
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition thermalAirPollutantEmissions.h:69
static constexpr uint8_t categoryDataLevel
Data Level.
Definition thermalAirPollutantEmissions.h:61
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition thermalAirPollutantEmissions.h:75
VCardThermalAirPollutantEmissions VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition thermalAirPollutantEmissions.h:58
static std::string Caption()
Caption not used: several columns.
Definition thermalAirPollutantEmissions.h:32
static constexpr uint8_t decimal
Decimal precision.
Definition thermalAirPollutantEmissions.h:71
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition thermalAirPollutantEmissions.h:63