Skip to content

Commit

Permalink
update 2
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Jun 21, 2024
1 parent 2f49b87 commit c8d89e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/solver/application/ScenarioBuilderOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <antares/antares/fatal-error.h>
#include <antares/application/ScenarioBuilderOwner.h>
#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"
Expand Down Expand Up @@ -52,6 +53,7 @@ void Antares::Solver::ScenarioBuilderOwner::callScenarioBuilder() {
if (study_.parameters.useCustomScenario)
{
ApplyCustomScenario(study_);
CheckFinalReservoirLevelsConfiguration(study);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions src/solver/hydro/management/PrepareInflows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit c8d89e8

Please sign in to comment.