Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Final reservoir level implementation - cr25 #1564

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ FinalLevelInflowsModifier::FinalLevelInflowsModifier(const PartHydro& hydro,
bool FinalLevelInflowsModifier::CheckInfeasibility(unsigned int year)
{
ComputeDelta(year);
logInfoFinLvlNotApplicable(year);

if (!isActive())
return true;
Expand Down Expand Up @@ -147,6 +148,20 @@ bool FinalLevelInflowsModifier::isActive()
isValidLevel(initialReservoirLevel_);
}

// if the user specifies the final reservoir level, but does not specifies initial reservoir level
// or uses wrong hydro options
// we should inform the user that the final reservoir level wont be reached
void FinalLevelInflowsModifier::logInfoFinLvlNotApplicable(unsigned int year)
{
if (isValidLevel(finalReservoirLevel_)
&& (!hydro_.reservoirManagement || hydro_.useWaterValue
|| !isValidLevel(initialReservoirLevel_)))
logs.info() << "Final reservoir level not applicable! Year:" << year + 1
<< ", Area:" << areaName_
<< ". Check: Reservoir management = Yes, Use water values = No and proper initial "
"reservoir level is provided ";
}

bool FinalLevelInflowsModifier::makeChecks(unsigned int year)
{
// Simulation must end on day 365 and reservoir level must be initiated in January
Expand All @@ -169,7 +184,7 @@ bool FinalLevelInflowsModifier::isApplicable(unsigned int year)
{
// If isApplicable_.size() == 0, then instance was not properly initialized
// and is not applicable.
return isActive() && isApplicable_.size() && isApplicable_.at(year);
return !isApplicable_.empty() && isApplicable_.at(year);
}

} // namespace Antares::Data
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class FinalLevelInflowsModifier

private:
bool isActive();
void logInfoFinLvlNotApplicable(uint year);
void ComputeDelta(unsigned int year);
bool makeChecks(unsigned int year);
void storeDeltaLevels(unsigned int year);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ void CheckFinalReservoirLevelsForYear(const Data::Study& study, uint year)
void CheckFinalReservoirLevelsConfiguration(const Data::Study& study)
{
initializeFinalLevelData(study);

uint nbYears = study.parameters.nbYears;

for (uint year = 0; year != nbYears; ++year)
{
CheckFinalReservoirLevelsForYear(study, year);
if (study.parameters.yearsFilter.at(year))
CheckFinalReservoirLevelsForYear(study, year);
Comment on lines +64 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking only active years is good I think

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct Fixture
// -------------------------------------------------------
uint areasCount = study->areas.size();

study->parameters.yearsFilter.assign(2, true);

study->scenarioInitialHydroLevels.resize(nbYears, areasCount);
study->scenarioFinalHydroLevels.resize(nbYears, areasCount);

Expand Down