Skip to content

Commit

Permalink
[DEV] replace tsindex with year in hydro/management
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Oct 19, 2023
1 parent bd505c8 commit 18e8760
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void HydroManagement::minGenerationScaling(uint numSpace, uint year) const
});
}

bool HydroManagement::checkMonthlyMinGeneration(uint numSpace, uint tsIndex, const Data::Area& area) const
bool HydroManagement::checkMonthlyMinGeneration(uint numSpace, uint year, const Data::Area& area) const
{
const auto& data = tmpDataByArea_[numSpace][area.index];
for (uint month = 0; month != 12; ++month)
Expand All @@ -239,32 +239,32 @@ bool HydroManagement::checkMonthlyMinGeneration(uint numSpace, uint tsIndex, con
{
logs.error() << "In Area " << area.name << " the minimum generation of "
<< data.totalMonthMingen[realmonth] << " MW in month " << month + 1
<< " of TS-" << tsIndex + 1 << " is incompatible with the inflows of "
<< " of TS-" << year + 1 << " is incompatible with the inflows of "
<< data.totalMonthInflows[realmonth] << " MW.";
return false;
}
}
return true;
}

bool HydroManagement::checkYearlyMinGeneration(uint numSpace, uint tsIndex, const Data::Area& area) const
bool HydroManagement::checkYearlyMinGeneration(uint numSpace, uint year, const Data::Area& area) const
{
const auto& data = tmpDataByArea_[numSpace][area.index];
if (data.totalYearMingen > data.totalYearInflows)
{
// Yearly minimum generation <= Yearly inflows
logs.error() << "In Area " << area.name << " the minimum generation of "
<< data.totalYearMingen << " MW of TS-" << tsIndex + 1
<< data.totalYearMingen << " MW of TS-" << year + 1
<< " is incompatible with the inflows of " << data.totalYearInflows << " MW.";
return false;
}
return true;
}

bool HydroManagement::checkWeeklyMinGeneration(uint tsIndex, Data::Area& area) const
bool HydroManagement::checkWeeklyMinGeneration(uint year, Data::Area& area) const
{
auto const& srcinflows = area.hydro.series->storage.getColumn(tsIndex);
auto const& srcmingen = area.hydro.series->mingen.getColumn(tsIndex);
auto const& srcinflows = area.hydro.series->storage.getColumn(year);
auto const& srcmingen = area.hydro.series->mingen.getColumn(year);
// Weekly minimum generation <= Weekly inflows for each week
for (uint week = 0; week < calendar_.maxWeeksInYear - 1; ++week)
{
Expand All @@ -287,18 +287,18 @@ bool HydroManagement::checkWeeklyMinGeneration(uint tsIndex, Data::Area& area) c
{
logs.error() << "In Area " << area.name << " the minimum generation of "
<< totalWeekMingen << " MW in week " << week + 1 << " of TS-"
<< tsIndex + 1 << " is incompatible with the inflows of "
<< year + 1 << " is incompatible with the inflows of "
<< totalWeekInflows << " MW.";
return false;
}
}
return true;
}

bool HydroManagement::checkHourlyMinGeneration(uint tsIndex, Data::Area& area) const
bool HydroManagement::checkHourlyMinGeneration(uint year, Data::Area& area) const
{
// Hourly minimum generation <= hourly inflows for each hour
auto const& srcmingen = area.hydro.series->mingen.getColumn(tsIndex);
auto const& srcmingen = area.hydro.series->mingen.getColumn(year);
auto const& maxPower = area.hydro.maxPower;
auto const& maxP = maxPower[Data::PartHydro::genMaxP];

Expand All @@ -319,7 +319,7 @@ bool HydroManagement::checkHourlyMinGeneration(uint tsIndex, Data::Area& area) c
logs.error()
<< "In area: " << area.name << " [hourly] minimum generation of "
<< srcmingen[day * 24 + h] << " MW in timestep " << day * 24 + h + 1
<< " of TS-" << tsIndex + 1
<< " of TS-" << year + 1
<< " is incompatible with the maximum generation of " << maxP[day]
<< " MW.";
return false;
Expand All @@ -335,28 +335,26 @@ bool HydroManagement::checkMinGeneration(uint numSpace, uint year) const
bool ret = true;
areas_.each([this, &numSpace, &ret, &year](Data::Area& area)
{
auto tsIndex = area.hydro.series->getIndex(year);

bool useHeuristicTarget = area.hydro.useHeuristicTarget;
bool followLoadModulations = area.hydro.followLoadModulations;
bool reservoirManagement = area.hydro.reservoirManagement;

if (!reservoirManagement)
ret = checkHourlyMinGeneration(tsIndex, area) && ret;
ret = checkHourlyMinGeneration(year, area) && ret;

if (!useHeuristicTarget)
return;

if (!followLoadModulations)
{
ret = checkWeeklyMinGeneration(tsIndex, area) && ret;
ret = checkWeeklyMinGeneration(year, area) && ret;
return;
}

if (reservoirManagement)
ret = checkYearlyMinGeneration(numSpace, tsIndex, area) && ret;
ret = checkYearlyMinGeneration(numSpace, year, area) && ret;
else
ret = checkMonthlyMinGeneration(numSpace, tsIndex, area) && ret;
ret = checkMonthlyMinGeneration(numSpace, year, area) && ret;
});
return ret;
}
Expand Down

0 comments on commit 18e8760

Please sign in to comment.