Antares Simulator
Power System Simulator
hydro.h
Go to the documentation of this file.
1 /*
2  * Copyright 2007-2025, 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  * * You should have received a copy of the Mozilla Public Licence 2.0
18  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
19  */
20 
64 #pragma once
65 
66 #include <vector>
67 
68 #include "timeseries_base.h"
69 
70 namespace Antares::Solver::Variable::Economy
71 {
72 
80 {
82  inline static constexpr std::string_view kCaption = "H. ROR";
84  inline static constexpr std::string_view kDescription = "Hydro generation, thoughout all MC "
85  "years";
86 };
87 
89 
99 template<class NextT = Container::EndOfList>
101  : public TimeSeriesValuesBase<TimeSeriesValuesHydro<NextT>, NextT, VCardTimeSeriesValuesHydro>
102 {
103 public:
107  NextT,
109 
111 
112  void initializeDerivedFromStudy(Data::Study&)
113  {
114  // Initialize the vector for fatal values (modern C++ approach)
115  // This replaces the previous manual memory management with RAII
116  fatalValues.resize(BaseType::nbYearsParallel, nullptr);
117  }
118 
154  void yearBeginImpl(unsigned int year, unsigned int space)
155  {
156  // Access the run-of-river hydro time series data
157  auto& ror = BaseType::areaPtr->hydro.series->ror;
158  // Determine which time series to use for this simulation year
159  // This allows different hydrological scenarios across Monte Carlo years
160  const unsigned int nbchro = ror.getSeriesIndex(year);
161  // Cache pointer to the selected time series for efficient hourly access
162  // This avoids repeated index calculations during hourly processing
163  fatalValues[space] = &(ror.timeSeries.entry[nbchro]);
164  }
165 
176  void hourForEachAreaImpl(State& state, unsigned int space)
177  {
178  // Extract the hydro generation value for the current hour
179  // Uses the time series pointer cached during yearBeginImpl
180  BaseType::yearlyValues[space][state.hourInTheYear] = (*fatalValues[space])
181  [state.hourInTheYear];
182  }
183 
184 private:
187 
191  std::vector<Matrix<>::ColumnType*> fatalValues;
192 
194 };
195 
196 } // namespace Antares::Solver::Variable::Economy
Definition: study.h:57
Base implementation for time series variables using CRTP pattern.
Definition: timeseries_base.h:263
unsigned int nbYearsParallel
Number of parallel years (cached for performance)
Definition: timeseries_base.h:491
VCardType::IntermediateValuesType yearlyValues
Intermediate values for each parallel space.
Definition: timeseries_base.h:488
Hydro ROR time series implementation.
Definition: hydro.h:102
void hourForEachAreaImpl(State &state, unsigned int space)
Extract hourly hydro generation values during simulation.
Definition: hydro.h:176
void yearBeginImpl(unsigned int year, unsigned int space)
Setup hydro time series selection at the beginning of each year.
Definition: hydro.h:154
Definition: state.h:71
unsigned int hourInTheYear
Current hour in the year (zero-based)
Definition: state.h:148
Traits for hydro ROR time series variables.
Definition: hydro.h:80
static constexpr std::string_view kDescription
Descriptive text for hydro generation time series.
Definition: hydro.h:84
static constexpr std::string_view kCaption
Display name for hydro ROR in outputs and GUI.
Definition: hydro.h:82
VCard template providing variable metadata and configuration.
Definition: timeseries_base.h:147
Base classes and traits for time series variables in Antares Simulator.