Skip to content

Commit

Permalink
Add compatibility parameter for hydro pmax I/O
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes committed Nov 28, 2024
1 parent d4a660e commit 3712eaa
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,20 +950,29 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
ret = area.hydro.series->loadGenerationTS(area.id, hydroSeries, studyVersion) && ret;
}

if (studyVersion < StudyVersion(9, 1))
switch (study.parameters.compatibility.hydroPmax)
{
case Parameters::Compatibility::HydroPmax::Daily:
{
HydroMaxTimeSeriesReader reader(area.hydro,
area.id.to<std::string>(),
area.name.to<std::string>());
ret = reader.read(pathHydro.string(), study.usedByTheSolver) && ret;
break;
}
else
case Parameters::Compatibility::HydroPmax::Hourly:
{
ret = area.hydro.series->LoadMaxPower(area.id, hydroSeries) && ret;
break;
}
default:
throw std::invalid_argument(
"Value not supported for study.parameters.compatibility.hydroPmax");
}

area.hydro.series->resizeTSinDeratedMode(study.parameters.derated,
studyVersion,
study.parameters.compatibility.hydroPmax,
study.usedByTheSolver);
}

Expand Down
16 changes: 16 additions & 0 deletions src/libs/antares/study/include/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,18 @@ class Parameters final

} include;

struct Compatibility
{
enum class HydroPmax
{
Daily,
Hourly
};
HydroPmax hydroPmax = HydroPmax::Daily;
};

Compatibility compatibility;

// Shedding
struct
{
Expand Down Expand Up @@ -518,6 +530,10 @@ const char* SimulationModeToCString(SimulationMode mode);
*/
bool StringToSimulationMode(SimulationMode& mode, Yuni::CString<20, false> text);

const char* CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax);
bool StringToCompatibilityHydroPmax(Parameters::Compatibility::HydroPmax&,
Yuni::CString<20, false> text);

} // namespace Antares::Data

#endif // __ANTARES_LIBS_STUDY_PARAMETERS_H__
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <antares/array/matrix.h>
#include <antares/series/series.h>
#include <antares/study/parameters.h>
#include <antares/study/version.h>

#include "../../fwd.h"
Expand Down Expand Up @@ -137,7 +138,10 @@ class DataSeriesHydro
uint TScount() const;

// Setting TS's when derated mode is on
void resizeTSinDeratedMode(bool derated, StudyVersion version, bool useBySolver);
void resizeTSinDeratedMode(bool derated,
StudyVersion version,
Parameters::Compatibility::HydroPmax hydroPmax,
bool useBySolver);
}; // class DataSeriesHydro
} // namespace Data
} // namespace Antares
Expand Down
37 changes: 37 additions & 0 deletions src/libs/antares/study/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,39 @@ const char* SimulationModeToCString(SimulationMode mode)
}
}

const char* CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax mode)
{
switch (mode)
{
case Parameters::Compatibility::HydroPmax::Daily:
return "daily";
case Parameters::Compatibility::HydroPmax::Hourly:
return "hourly";
default:
return "Unknown";
}
}

bool StringToCompatibilityHydroPmax(Parameters::Compatibility::HydroPmax& mode,
Yuni::CString<20, false> text)
{
if (text.empty())
{
return false;
}
if (text == "daily")
{
mode = Parameters::Compatibility::HydroPmax::Daily;
return true;
}
if (text == "hourly")
{
mode = Parameters::Compatibility::HydroPmax::Hourly;
return true;
}
return false;
}

bool Parameters::economy() const
{
return mode == SimulationMode::Economy;
Expand Down Expand Up @@ -1967,6 +2000,10 @@ void Parameters::saveToINI(IniFile& ini) const
section->add(SeedToID((SeedIndex)sd), seed[sd]);
}
}
{
auto* section = ini.addSection("compatibility");
section->add("hydro-pmax", CompatibilityHydroPmaxToCString(compatibility.hydroPmax));
}
}

bool Parameters::loadFromFile(const std::filesystem::path& filename, const StudyVersion& version)
Expand Down
3 changes: 2 additions & 1 deletion src/libs/antares/study/parts/hydro/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ bool PartHydro::LoadFromFolder(Study& study, const fs::path& folder)
area.hydro.pumpingEfficiency = 1.;
area.hydro.deltaBetweenFinalAndInitialLevels.resize(study.parameters.nbYears);

if (study.header.version >= StudyVersion(9, 1))
if (study.parameters.compatibility.hydroPmax
== Parameters::Compatibility::HydroPmax::Hourly)
{
// GUI part patch :
// We need to know, when estimating the RAM required by the solver, if the current
Expand Down
3 changes: 2 additions & 1 deletion src/libs/antares/study/parts/hydro/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ uint DataSeriesHydro::TScount() const

void DataSeriesHydro::resizeTSinDeratedMode(bool derated,
StudyVersion studyVersion,
Parameters::Compatibility::HydroPmax hydroPmax,
bool usedBySolver)
{
if (!(derated && usedBySolver))
Expand All @@ -243,7 +244,7 @@ void DataSeriesHydro::resizeTSinDeratedMode(bool derated,
{
mingen.averageTimeseries();

if (studyVersion >= StudyVersion(9, 1))
if (hydroPmax == Parameters::Compatibility::HydroPmax::Hourly)
{
maxHourlyGenPower.averageTimeseries();
maxHourlyPumpPower.averageTimeseries();
Expand Down

0 comments on commit 3712eaa

Please sign in to comment.