Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Jun 6, 2024
1 parent 376df5c commit 7c6c47b
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
namespace Antares::Data
{

// TODO remove _

enum dayYearCount_
enum dayYearCount
{
//! The maximum number of days in a year
dayYearCount = 366
};

// TODO remove _
//! Temporary data
struct TmpDataByArea
{
Expand Down
1 change: 0 additions & 1 deletion src/solver/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ target_link_libraries(application
Antares::signal-handling
Antares::resources
Antares::file-tree-study-loader
Antares::hydro
)

target_include_directories(application
Expand Down
2 changes: 0 additions & 2 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ void Application::readDataForTheStudy(Data::StudyLoadOptions& options)
study.performTransformationsBeforeLaunchingSimulation();

ScenarioBuilderOwner(study).callScenarioBuilder();
const auto endYear = 1 + study.runtime->rangeLimits.year[Data::rangeEnd];
// HydroInputsChecker(study, *resultWriter).Execute();

// alloc global vectors
SIM_AllocationTableaux(study);
Expand Down
1 change: 0 additions & 1 deletion src/solver/hydro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ target_link_libraries(antares-solver-hydro
sirius_solver
Antares::date
Antares::result_writer
antares-solver-ts-generator

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace Antares
{

//! Prepare minimum generation scaling for each area
class MinGenerationScaling
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
namespace Antares
{

//! Prepare inflows scaling for each area
class PrepareInflows
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,50 +47,6 @@ double GammaVariable(double a, MersenneTwister& random);

} // namespace Solver

// TODO remove enum::dayYearCount and TmpDataByArea
enum
{
//! The maximum number of days in a year
dayYearCount = 366
};

//! Temporary data
struct TmpDataByArea
{
//! Monthly local effective demand
double MLE[12];
//! Monthly optimal generation
double MOG[12];
//! Monthly optimal level
double MOL[12];
//! Monthly target generations
double MTG[12];
//! inflows
double inflows[12];
//! monthly minimal generation
std::array<double, 12> mingens;

//! Net demand, for each day of the year, for each area
double DLN[dayYearCount];
//! Daily local effective load
double DLE[dayYearCount];
//! Daily optimized Generation
double DOG[dayYearCount];
//! daily minimal generation
std::array<double, dayYearCount> dailyMinGen;

// Data for minGen<->inflows preChecks
//! monthly total mingen
std::array<double, 12> totalMonthMingen;
//! monthly total inflows
std::array<double, 12> totalMonthInflows;
//! yearly total mingen
double totalYearMingen;
//! yearly total inflows
double totalYearInflows;

}; // struct TmpDataByArea

typedef struct
{
std::vector<double> HydrauliqueModulableQuotidien; /* indice par jour */
Expand Down Expand Up @@ -123,10 +79,6 @@ class HydroManagement final
}

private:
//! Prepare inflows scaling for each area
void prepareInflowsScaling(uint year);
//! Prepare minimum generation scaling for each area
void minGenerationScaling(uint year);
//! check Monthly minimum generation is lower than available inflows
bool checkMonthlyMinGeneration(uint year, const Data::Area& area) const;
//! check Yearly minimum generation is lower than available inflows
Expand Down Expand Up @@ -163,7 +115,6 @@ class HydroManagement final
Antares::Data::Area::ScratchMap& scratchmap);

private:
std::unordered_map<const Data::Area*, TmpDataByArea> tmpDataByArea_;
const Data::AreaList& areas_;
const Date::Calendar& calendar_;
const Data::Parameters& parameters_;
Expand Down
20 changes: 1 addition & 19 deletions src/solver/hydro/management/HydroInputsChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "antares/solver/hydro/monthly/h2o_m_donnees_annuelles.h"
#include "antares/solver/hydro/monthly/h2o_m_fonctions.h"
#include "antares/solver/simulation/common-eco-adq.h"
#include "antares/solver/ts-generator/generator.h"

namespace Antares
{
Expand All @@ -49,25 +48,8 @@ HydroInputsChecker::HydroInputsChecker(Antares::Data::Study& study,

void HydroInputsChecker::Execute()
{
Antares::Data::Area::ScratchMap scratchmap;
unsigned int numSpace = 999999;
uint nbPerformedYears = 0;
for (auto year = firstYear_; year < endYear_; ++year)
{
// Antares::TSGenerator::GenerateTimeSeries<Data::timeSeriesHydro>(study_,
// year,
// resultWriter_);
// performCalculations
// if (parameters_.yearsFilter[year])
// {
// // not good missing info about buildnewSet which re-init nbPerformedYears = 0
// nbPerformedYears++;
// // Index of the MC year's space (useful if this year is actually run)
// numSpace = nbPerformedYears - 1;
// scratchmap = areas_.buildScratchMap(numSpace);

// PrepareDataFromClustersInMustrunMode(scratchmap, year);

prepareInflows_.Run(year);
minGenerationScaling_.Run(year);
if (!checksOnGenerationPowerBounds(year))
Expand All @@ -82,7 +64,7 @@ void HydroInputsChecker::Execute()
// prepareEffectiveDemand();
// prepareMonthlyOptimalGenerations(randomReservoirLevel,
// year);
// }
//-----------------------------
}
}

Expand Down
118 changes: 0 additions & 118 deletions src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,117 +142,6 @@ HydroManagement::HydroManagement(const Data::AreaList& areas,
}
}

void HydroManagement::prepareInflowsScaling(uint year)
{
areas_.each(
// [&](const Data::Area& area)
[&](Data::Area& area)
{
const auto& srcinflows = area.hydro.series->storage.getColumn(year);

// auto& data = tmpDataByArea_[&area];
auto& data = area.hydro.hydro_management_data[year];
double totalYearInflows = 0.0;

for (uint month = 0; month != 12; ++month)
{
uint realmonth = calendar_.months[month].realmonth;

double totalMonthInflows = 0.0;

uint firstDayOfMonth = calendar_.months[month].daysYear.first;

uint firstDayOfNextMonth = calendar_.months[month].daysYear.end;

for (uint d = firstDayOfMonth; d != firstDayOfNextMonth; ++d)
{
totalMonthInflows += srcinflows[d];
}

data.totalMonthInflows[realmonth] = totalMonthInflows;
totalYearInflows += totalMonthInflows;

if (not(area.hydro.reservoirCapacity < 1e-4))
{
if (area.hydro.reservoirManagement)
{
data.inflows[realmonth] = totalMonthInflows / (area.hydro.reservoirCapacity);
assert(!std::isnan(data.inflows[month]) && "nan value detect in inflows");
}
else
{
data.inflows[realmonth] = totalMonthInflows;
}
}
else
{
data.inflows[realmonth] = totalMonthInflows;
}
}
data.totalYearInflows = totalYearInflows;
});
}

void HydroManagement::minGenerationScaling(uint year)
{
areas_.each(
// [this, &year](const Data::Area& area)
[this, &year](Data::Area& area)
{
const auto& srcmingen = area.hydro.series->mingen.getColumn(year);

// auto& data = tmpDataByArea_[&area];
auto& data = area.hydro.hydro_management_data[year];
double totalYearMingen = 0.0;

for (uint month = 0; month != 12; ++month)
{
uint realmonth = calendar_.months[month].realmonth;
uint firstDayOfMonth = calendar_.months[month].daysYear.first;
uint firstDayOfNextMonth = calendar_.months[month].daysYear.end;

double totalMonthMingen = std::accumulate(srcmingen + firstDayOfMonth * 24,
srcmingen + firstDayOfNextMonth * 24,
0.);

data.totalMonthMingen[realmonth] = totalMonthMingen;
totalYearMingen += totalMonthMingen;

if (!(area.hydro.reservoirCapacity < 1e-4))
{
if (area.hydro.reservoirManagement)
{
// Set monthly mingen, used later for h2o_m
data.mingens[realmonth] = totalMonthMingen / (area.hydro.reservoirCapacity);
assert(!std::isnan(data.mingens[month]) && "nan value detect in mingen");
}
else
{
data.mingens[realmonth] = totalMonthMingen;
}
}
else
{
data.mingens[realmonth] = totalMonthMingen;
}

// Set daily mingen, used later for h2o_d
uint simulationMonth = calendar_.mapping.months[realmonth];
auto daysPerMonth = calendar_.months[simulationMonth].days;
uint firstDay = calendar_.months[simulationMonth].daysYear.first;
uint endDay = firstDay + daysPerMonth;

for (uint day = firstDay; day != endDay; ++day)
{
data.dailyMinGen[day] = std::accumulate(srcmingen + day * 24,
srcmingen + day * 24 + 24,
0.);
}
}
data.totalYearMingen = totalYearMingen;
});
}

bool HydroManagement::checkMonthlyMinGeneration(uint year, const Data::Area& area) const
{
// const auto& data = tmpDataByArea_.at(&area);
Expand Down Expand Up @@ -532,13 +421,6 @@ void HydroManagement::makeVentilation(double* randomReservoirLevel,
uint y,
Antares::Data::Area::ScratchMap& scratchmap)
{
// prepareInflowsScaling(y);
// minGenerationScaling(y);
// if (!checksOnGenerationPowerBounds(y))
// {
// throw FatalError("hydro management: invalid minimum generation");
// }

prepareNetDemand(y, parameters_.mode, scratchmap);
prepareEffectiveDemand(y);

Expand Down

0 comments on commit 7c6c47b

Please sign in to comment.