From c8d89e85c3736dcf8d4af4827979cba98f646b33 Mon Sep 17 00:00:00 2001 From: Abdoulbari Zakir Date: Fri, 21 Jun 2024 17:30:26 +0200 Subject: [PATCH] update 2 --- .../application/ScenarioBuilderOwner.cpp | 2 ++ .../solver/hydro/management/PrepareInflows.h | 4 +++ .../hydro/management/PrepareInflows.cpp | 30 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/solver/application/ScenarioBuilderOwner.cpp b/src/solver/application/ScenarioBuilderOwner.cpp index ef6084fed5e..02f9c7222d8 100644 --- a/src/solver/application/ScenarioBuilderOwner.cpp +++ b/src/solver/application/ScenarioBuilderOwner.cpp @@ -22,6 +22,7 @@ #include #include #include "antares/solver/simulation/apply-scenario.h" +#include "antares/solver/simulation/hydro-final-reservoir-level-functions.h" #include "antares/solver/simulation/timeseries-numbers.h" #include "antares/solver/ts-generator/generator.h" #include "antares/study/study.h" @@ -52,6 +53,7 @@ void Antares::Solver::ScenarioBuilderOwner::callScenarioBuilder() { if (study_.parameters.useCustomScenario) { ApplyCustomScenario(study_); + CheckFinalReservoirLevelsConfiguration(study); } } diff --git a/src/solver/hydro/include/antares/solver/hydro/management/PrepareInflows.h b/src/solver/hydro/include/antares/solver/hydro/management/PrepareInflows.h index 7e201ca2eca..6a615174dfc 100644 --- a/src/solver/hydro/include/antares/solver/hydro/management/PrepareInflows.h +++ b/src/solver/hydro/include/antares/solver/hydro/management/PrepareInflows.h @@ -35,6 +35,10 @@ class PrepareInflows private: Data::AreaList& areas_; const Date::Calendar& calendar_; + + void ComputeInflows(uint year); + //! prepare data for Final reservoir level + void ChangeInflowsToAccommodateFinalLevels(uint year); }; } // namespace Antares diff --git a/src/solver/hydro/management/PrepareInflows.cpp b/src/solver/hydro/management/PrepareInflows.cpp index 6ec6a169c1c..167306e8f85 100644 --- a/src/solver/hydro/management/PrepareInflows.cpp +++ b/src/solver/hydro/management/PrepareInflows.cpp @@ -11,6 +11,12 @@ PrepareInflows::PrepareInflows(Data::AreaList& areas, const Date::Calendar& cale } void PrepareInflows::Run(uint year) +{ + ComputeInflows(year); + ChangeInflowsToAccommodateFinalLevels(year); +} + +void PrepareInflows::ComputeInflows(uint year) { areas_.each( // un-const because now data is a member of area [&](const Data::Area& area) @@ -60,4 +66,28 @@ void PrepareInflows::Run(uint year) }); } +void PrepareInflows::ChangeInflowsToAccommodateFinalLevels(uint year) +{ + areas_.each( + [this, &year](Data::Area& area) + { + auto& data = area.hydro.managementData[year]; + + if (!area.hydro.deltaBetweenFinalAndInitialLevels[year].has_value()) + { + return; + } + + // Must be done before prepareMonthlyTargetGenerations + double delta = area.hydro.deltaBetweenFinalAndInitialLevels[year].value(); + if (delta < 0) + { + data.inflows[0] -= delta; + } + else if (delta > 0) + { + data.inflows[11] -= delta; + } + }); +} } // namespace Antares