Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
hydroLevelsData.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 __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
22#define __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
23
24#include <functional>
25
26#include "scBuilderDataInterface.h"
27
28namespace Antares
29{
30namespace Data
31{
32namespace ScenarioBuilder
33{
37class hydroLevelsData final: public dataInterface
38{
39public:
42
43public:
44 // Constructor
45
46 hydroLevelsData(const std::string& iniFilePrefix,
47 std::function<void(Study&, MatrixType&)> applyToTarget);
48
50
51
54 bool reset(const Study& study) override;
55
59 void saveToINIFile(const Study& study, Yuni::IO::File::Stream& file) const override;
60
68 void setTSnumber(uint index, uint year, double value);
70
71 uint width() const override;
72
73 uint height() const override;
74
75 double get_value(uint x, uint y) const;
76
77 void set_value(uint x, uint y, double value);
78
79 bool apply(Study& study) override;
80
81private:
83 MatrixType pHydroLevelsRules;
84 // prefix to be added when calling saveToINIFileHydroLevel
85 const std::string addToPrefix_;
86
87 std::function<void(Study&, MatrixType&)> applyToTarget_;
88
89}; // class hydroLevelsData
90
91// class hydroLevelsData : inline functions
92
93inline void hydroLevelsData::setTSnumber(uint areaindex, uint year, double value)
94{
95 assert(areaindex < pHydroLevelsRules.width);
96 if (year < pHydroLevelsRules.height)
97 {
98 pHydroLevelsRules[areaindex][year] = value;
99 }
100}
101
102inline uint hydroLevelsData::width() const
103{
104 return pHydroLevelsRules.width;
105}
106
107inline uint hydroLevelsData::height() const
108{
109 return pHydroLevelsRules.height;
110}
111
112inline double hydroLevelsData::get_value(uint x, uint y) const
113{
114 return pHydroLevelsRules.entry[y][x];
115}
116
117inline void initLevelApply(Study& study, Matrix<double>& matrix)
118{
119 study.scenarioInitialHydroLevels.copyFrom(matrix);
120}
121
122inline void finalLevelApply(Study& study, Matrix<double>& matrix)
123{
124 study.scenarioFinalHydroLevels.copyFrom(matrix);
125}
126
127} // namespace ScenarioBuilder
128} // namespace Data
129} // namespace Antares
130
131#endif // __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
Interface for scenario builder data (time series, hydro levels, ...)
Definition scBuilderDataInterface.h:41
Rules for hydro levels, for all years and areas.
Definition hydroLevelsData.h:38
void saveToINIFile(const Study &study, Yuni::IO::File::Stream &file) const override
Export the data into a mere INI file.
Definition hydroLevelsData.cpp:48
bool apply(Study &study) override
Apply the changes to the study corresponding data (time series, hydro levels, ...)
Definition hydroLevelsData.cpp:83
void setTSnumber(uint index, uint year, double value)
Assign a single value.
Definition hydroLevelsData.h:93
bool reset(const Study &study) override
Reset data from the study.
Definition hydroLevelsData.cpp:38
Definition study.h:61
ColumnType * entry
All entries of the matrix (bidimensional array)
Definition matrix.h:445
uint width
Width of the matrix.
Definition matrix.h:441
uint height
Height of the matrix.
Definition matrix.h:443