Skip to content

Commit

Permalink
Move data validation to specialized functions [ANT-1213] (#2149)
Browse files Browse the repository at this point in the history
The goal of this PR is to separate loading and validation of data.
This separation will allow to have a modular loading.

Slight change for admissible values of reservoir capacity (from ]1e-6, +oo[ to ]0, +oo[).

---------

Co-authored-by: Florian Omnès <florian.omnes@rte-france.com>
Co-authored-by: Florian OMNES <26088210+flomnes@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 17, 2024
1 parent 6edcad8 commit 08003e3
Show file tree
Hide file tree
Showing 6 changed files with 270 additions and 490 deletions.
2 changes: 2 additions & 0 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
// if changes are required, please update reloadXCastData()
buffer.clear() << study.folderInput << SEP << "hydro" << SEP << "prepro";
ret = area.hydro.prepro->loadFromFolder(study, area.id, buffer.c_str()) && ret;
ret = area.hydro.prepro->validate(area.id) && ret;
}

auto* hydroSeries = area.hydro.series;
Expand Down Expand Up @@ -1160,6 +1161,7 @@ bool AreaList::loadFromFolder(const StudyLoadOptions& options)
logs.info() << "Loading global hydro data...";
buffer.clear() << pStudy.folderInput << SEP << "hydro";
ret = PartHydro::LoadFromFolder(pStudy, buffer) && ret;
ret = PartHydro::validate(pStudy) && ret;
}

// Thermal data, specific to areas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class PartHydro
pumpMod,
};

public:
/*!
** \brief Load data for hydro container from a folder
**
Expand All @@ -61,6 +60,13 @@ class PartHydro
*/
static bool LoadFromFolder(Study& study, const AnyString& folder);

/*!
** \brief Check and validate the loaded datas
**
** \return A non-zero value if the operation succeeded, 0 otherwise
*/
static bool validate(Study& study);

/*!
** \brief Save data from several containers to a folder (except data for the prepro and
*time-series)
Expand All @@ -71,7 +77,6 @@ class PartHydro
*/
static bool SaveToFolder(const AreaList& areas, const AnyString& folder);

public:
/*!
** \brief Default Constructor
*/
Expand Down Expand Up @@ -100,7 +105,6 @@ class PartHydro

bool CheckDailyMaxEnergy(const AnyString& areaName);

public:
//! Inter-daily breakdown (previously called Smoothing Factor or alpha)
double interDailyBreakdown;
//! Intra-daily modulation
Expand Down Expand Up @@ -161,6 +165,10 @@ class PartHydro
Matrix<double, double> dailyNbHoursAtGenPmax;
Matrix<double, double> dailyNbHoursAtPumpPmax;

private:
static bool checkReservoirLevels(const Study& study);
static bool checkProperties(Study& study);

}; // class PartHydro

// Interpolates a water value from a table according to a level and a day.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ class PreproHydro
** \param folder The source folder (ex: `input/hydro/prepro`)
** \return A non-zero value if the operation succeeded, 0 otherwise
*/
bool loadFromFolder(Study& s, const AreaName& areaID, const char folder[]);
bool loadFromFolder(Study& s, const AreaName& areaID, const std::string& folder);

bool validate(const std::string& areaID);
/*!
** \brief Save hydro settings for the prepro into a folder
**
Expand Down
Loading

0 comments on commit 08003e3

Please sign in to comment.