Skip to content

Commit

Permalink
Renaming matrices from PartHydro and DataTransfer classes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaredstork committed Sep 23, 2023
1 parent 033807c commit cddc46e
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions docs/reference-guide/13-file-format.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Study format changes
This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts.
## v8.8.0
For each area, new files are added **input/hydro/series/<area>/maxgen.txt** and **input/hydro/series/<area>/maxpump.txt**. These files have one or more columns, and 8760 rows. The number of columns in these two files must be the same, if there is more than one column in each file, but if there is just one column for example in maxgen.txt file, maxpump.txt file can have more than one column and vice versa. For old studies, file **input/hydro/common/capacity/maxpower_<area>** will be deleted after upgrading the study and corresponding data from that file will be copied to already mentioned new files, even if study is upgraded or not. In that case maxgen.txt and maxpump.txt files will have just one column and 8760 rows.
For each area, new files are added **input/hydro/series/<area>/maxHourlyGenPower.txt** and **input/hydro/series/<area>/maxHourlyPumpPower.txt**. These files have one or more columns, and 8760 rows. The number of columns in these two files must be the same, if there is more than one column in each file, but if there is just one column for example in maxHourlyGenPower.txt file, maxHourlyPumpPower.txt file can have more than one column and vice versa. For old studies, file **input/hydro/common/capacity/maxpower_<area>** will be deleted after upgrading the study and corresponding data from that file will be copied to already mentioned new files, even if study is upgraded or not. In that case maxHourlyGenPower.txt and maxHourlyPumpPower.txt files will have just one column and 8760 rows.

Also for each area, new files are added **input/hydro/common/capacity/maxhoursGen_<area>** and **input/hydro/common/capacity/maxhoursPump_<area>**. These files have just one column and 365 rows. For old studies, file **input/hydro/common/capacity/maxpower_<area>** will be deleted after upgrading the study and corresponding data from that file will be copied to already mentioned new files, even if study is upgraded or not.
Also for each area, new files are added **input/hydro/common/capacity/maxHourlyGenEnergy_<area>** and **input/hydro/common/capacity/maxHourlyPumpEnergy_<area>**. These files have just one column and 365 rows. For old studies, file **input/hydro/common/capacity/maxpower_<area>** will be deleted after upgrading the study and corresponding data from that file will be copied to already mentioned new files, even if study is upgraded or not.
### Input
Under `Configure/MC Scenario Builder` new section added `Hydro Max Power`
In the existing file **settings/scenariobuilder.dat**, under **<ruleset>** section following properties added:
Expand Down
8 changes: 4 additions & 4 deletions src/libs/antares/study/area/scratchpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area) : ts

// ... Getting hydro max power
auto const& maxPower = area.hydro.series->maxgen;
auto const& maxGenHours = area.hydro.maxHoursGen[0];
auto const& maxHourlyGenEnergy = area.hydro.maxHourlyGenEnergy[0];

hydroGenerationPermission = CheckForPositiveEnergy(maxPower, maxGenHours);
hydroGenerationPermission = CheckForPositiveEnergy(maxPower, maxHourlyGenEnergy);

// ---------------------
// Hydro has inflows
Expand Down Expand Up @@ -128,10 +128,10 @@ AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area) : ts

// ... Hydro max pumping power and energy
auto const& maxPumpingP = area.hydro.series->maxpump;
auto const& maxPumpHours = area.hydro.maxHoursPump[0];
auto const& maxHourlyPumpEnergy = area.hydro.maxHourlyPumpEnergy[0];

// If pumping energy is nil over the whole year, pumpHasMod is false, true otherwise.
pumpHasMod = CheckForPositiveEnergy(maxPumpingP, maxPumpHours);
pumpHasMod = CheckForPositiveEnergy(maxPumpingP, maxHourlyPumpEnergy);
}

AreaScratchpad::~AreaScratchpad() = default;
Expand Down
8 changes: 4 additions & 4 deletions src/libs/antares/study/cleaner/cleaner-v20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ static void listOfFilesAnDirectoriesToKeepForArea(PathList& e, PathList& p, cons
e.add(buffer);
buffer.clear() << "input/hydro/common/capacity/maxpower_" << id << ".txt";
e.add(buffer);
buffer.clear() << "input/hydro/common/capacity/maxhoursGen_" << id << ".txt";
buffer.clear() << "input/hydro/common/capacity/maxHourlyGenEnergy_" << id << ".txt";
e.add(buffer);
buffer.clear() << "input/hydro/common/capacity/maxhoursPump_" << id << ".txt";
buffer.clear() << "input/hydro/common/capacity/maxHourlyPumpEnergy_" << id << ".txt";
e.add(buffer);
buffer.clear() << "input/hydro/common/capacity/reservoir_" << id << ".txt";
e.add(buffer);
Expand All @@ -103,9 +103,9 @@ static void listOfFilesAnDirectoriesToKeepForArea(PathList& e, PathList& p, cons
e.add(buffer);
buffer.clear() << "input/hydro/series/" << id << "/mingen.txt";
e.add(buffer);
buffer.clear() << "input/hydro/series/" << id << "/maxgen.txt";
buffer.clear() << "input/hydro/series/" << id << "/maxHourlyGenEnergy.txt";
e.add(buffer);
buffer.clear() << "input/hydro/series/" << id << "/maxpump.txt";
buffer.clear() << "input/hydro/series/" << id << "/maxHourlyPumpEnergy.txt";
e.add(buffer);
buffer.clear() << "input/hydro/allocation/" << id << ".ini";
p.add(buffer);
Expand Down
48 changes: 24 additions & 24 deletions src/libs/antares/study/parts/hydro/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ void PartHydro::reset()
reservoirLevel.fillColumn(average, 0.5);
reservoirLevel.fillColumn(maximum, 1.);
waterValues.reset(101, DAYS_PER_YEAR, true);
maxHoursGen.reset(1, DAYS_PER_YEAR, true);
maxHoursGen.fillColumn(0, 24.);
maxHoursPump.reset(1, DAYS_PER_YEAR, true);
maxHoursPump.fillColumn(0, 24.);
maxHourlyGenEnergy.reset(1, DAYS_PER_YEAR, true);
maxHourlyGenEnergy.fillColumn(0, 24.);
maxHourlyPumpEnergy.reset(1, DAYS_PER_YEAR, true);
maxHourlyPumpEnergy.fillColumn(0, 24.);
creditModulation.reset(101, 2, true);
creditModulation.fill(1);
// reset of the hydro allocation - however we don't have any information
Expand Down Expand Up @@ -223,8 +223,8 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder)
}

bool errorHours = false;
auto& colGen = area.hydro.maxHoursGen[0];
auto& colPump = area.hydro.maxHoursPump[0];
auto& colGen = area.hydro.maxHourlyGenEnergy[0];
auto& colPump = area.hydro.maxHourlyPumpEnergy[0];

for (int day = 0; day < DAYS_PER_YEAR; day++)
{
Expand Down Expand Up @@ -707,13 +707,13 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder)
sPowerToLevel->add(area.id, true);

// max hours gen
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxhoursGen_"
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxHourlyGenEnergy_"
<< area.id << ".txt";
ret = area.hydro.maxHoursGen.saveToCSVFile(buffer, /*decimal*/ 2) && ret;
ret = area.hydro.maxHourlyGenEnergy.saveToCSVFile(buffer, /*decimal*/ 2) && ret;
// max hours pump
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxhoursPump_"
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxHourlyPumpEnergy_"
<< area.id << ".txt";
ret = area.hydro.maxHoursPump.saveToCSVFile(buffer, /*decimal*/ 2) && ret;
ret = area.hydro.maxHourlyPumpEnergy.saveToCSVFile(buffer, /*decimal*/ 2) && ret;
// credit modulations
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP
<< "creditmodulations_" << area.id << ".txt";
Expand Down Expand Up @@ -743,8 +743,8 @@ bool PartHydro::forceReload(bool reload) const
ret = inflowPattern.forceReload(reload) && ret;
ret = reservoirLevel.forceReload(reload) && ret;
ret = waterValues.forceReload(reload) && ret;
ret = maxHoursGen.forceReload(reload) && ret;
ret = maxHoursPump.forceReload(reload) && ret;
ret = maxHourlyGenEnergy.forceReload(reload) && ret;
ret = maxHourlyPumpEnergy.forceReload(reload) && ret;

if (series)
ret = series->forceReload(reload) && ret;
Expand All @@ -760,8 +760,8 @@ void PartHydro::markAsModified() const
reservoirLevel.markAsModified();
waterValues.markAsModified();
creditModulation.markAsModified();
maxHoursGen.markAsModified();
maxHoursPump.markAsModified();
maxHourlyGenEnergy.markAsModified();
maxHourlyPumpEnergy.markAsModified();

if (series)
series->markAsModified();
Expand Down Expand Up @@ -816,16 +816,16 @@ void PartHydro::copyFrom(const PartHydro& rhs)

// max hours gen
{
maxHoursGen = rhs.maxHoursGen;
maxHoursGen.unloadFromMemory();
rhs.maxHoursGen.unloadFromMemory();
maxHourlyGenEnergy = rhs.maxHourlyGenEnergy;
maxHourlyGenEnergy.unloadFromMemory();
rhs.maxHourlyGenEnergy.unloadFromMemory();
}

// max hours pump
{
maxHoursPump = rhs.maxHoursPump;
maxHoursPump.unloadFromMemory();
rhs.maxHoursPump.unloadFromMemory();
maxHourlyPumpEnergy = rhs.maxHourlyPumpEnergy;
maxHourlyPumpEnergy.unloadFromMemory();
rhs.maxHourlyPumpEnergy.unloadFromMemory();
}
}

Expand All @@ -834,17 +834,17 @@ bool PartHydro::LoadHours(Study& study, Area& area, const AnyString& folder)
auto& buffer = study.bufferLoadingTS;
bool ret = true;

buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxhoursGen_"
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxHourlyPumpEnergy_"
<< area.id << '.' << study.inputExtension;

ret = area.hydro.maxHoursGen.loadFromCSVFile(
ret = area.hydro.maxHourlyGenEnergy.loadFromCSVFile(
buffer, 1, DAYS_PER_YEAR, Matrix<>::optFixedSize, &study.dataBuffer)
&& ret;

buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxhoursPump_"
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxHourlyPumpEnergy_"
<< area.id << '.' << study.inputExtension;

ret = area.hydro.maxHoursPump.loadFromCSVFile(
ret = area.hydro.maxHourlyPumpEnergy.loadFromCSVFile(
buffer, 1, DAYS_PER_YEAR, Matrix<>::optFixedSize, &study.dataBuffer)
&& ret;

Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/parts/hydro/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class PartHydro
//! Data for time-series
DataSeriesHydro* series;

Matrix<double, double> maxHoursGen;
Matrix<double, double> maxHoursPump;
Matrix<double, double> maxHourlyGenEnergy;
Matrix<double, double> maxHourlyPumpEnergy;

}; // class PartHydro

Expand Down
40 changes: 20 additions & 20 deletions src/libs/antares/study/parts/hydro/datatransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Antares::Data

DataTransfer::DataTransfer()
{
maxPower.reset(4, DAYS_PER_YEAR, true);
dailyMaxPumpAndGen.reset(4, DAYS_PER_YEAR, true);
}

bool DataTransfer::LoadFromFolder(Study& study, const AnyString& folder, Area& area)
Expand All @@ -63,7 +63,7 @@ bool DataTransfer::LoadFromFolder(Study& study, const AnyString& folder, Area& a
enabledModeIsChanged = true;
}

ret = maxPower.loadFromCSVFile(
ret = dailyMaxPumpAndGen.loadFromCSVFile(
buffer, 4, DAYS_PER_YEAR, Matrix<>::optFixedSize, &study.dataBuffer)
&& ret;

Expand All @@ -72,14 +72,14 @@ bool DataTransfer::LoadFromFolder(Study& study, const AnyString& folder, Area& a
}
else
{
ret = maxPower.loadFromCSVFile(
ret = dailyMaxPumpAndGen.loadFromCSVFile(
buffer, 4, DAYS_PER_YEAR, Matrix<>::optFixedSize, &study.dataBuffer)
&& ret;

bool errorPowers = false;
for (uint i = 0; i < 4; ++i)
{
auto& col = maxPower[i];
auto& col = dailyMaxPumpAndGen[i];
for (uint day = 0; day < DAYS_PER_YEAR; ++day)
{
if (!errorPowers && (col[day] < 0 || (i % 2 /*column hours*/ && col[day] > 24)))
Expand All @@ -100,28 +100,28 @@ bool DataTransfer::AutoTransferHours(Study& study, const AnyString& folder, Area
auto& buffer = study.bufferLoadingTS;
bool ret = true;

auto& maxHoursGen = area.hydro.maxHoursGen;
auto& maxHoursPump = area.hydro.maxHoursPump;
auto& maxHourlyGenEnergy = area.hydro.maxHourlyGenEnergy;
auto& maxHourlyPumpEnergy = area.hydro.maxHourlyPumpEnergy;

maxHoursGen.reset(1, DAYS_PER_YEAR, true);
maxHoursGen.fillColumn(0, 24.);
maxHourlyGenEnergy.reset(1, DAYS_PER_YEAR, true);
maxHourlyGenEnergy.fillColumn(0, 24.);

maxHoursPump.reset(1, DAYS_PER_YEAR, true);
maxHoursPump.fillColumn(0, 24.);
maxHourlyPumpEnergy.reset(1, DAYS_PER_YEAR, true);
maxHourlyPumpEnergy.fillColumn(0, 24.);

for (uint day = 0; day < DAYS_PER_YEAR; ++day)
{
maxHoursGen[0][day] = maxPower[genMaxE][day];
maxHoursPump[0][day] = maxPower[pumpMaxE][day];
maxHourlyGenEnergy[0][day] = dailyMaxPumpAndGen[genMaxE][day];
maxHourlyPumpEnergy[0][day] = dailyMaxPumpAndGen[pumpMaxE][day];
}

buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxhoursGen_"
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxHourlyGenEnergy_"
<< area.id << ".txt";
ret = maxHoursGen.saveToCSVFile(buffer, /*decimal*/ 2) && ret;
ret = maxHourlyGenEnergy.saveToCSVFile(buffer, /*decimal*/ 2) && ret;

buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxhoursPump_"
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxHourlyPumpEnergy_"
<< area.id << ".txt";
ret = maxHoursPump.saveToCSVFile(buffer, /*decimal*/ 2) && ret;
ret = maxHourlyPumpEnergy.saveToCSVFile(buffer, /*decimal*/ 2) && ret;

return ret;
}
Expand All @@ -133,14 +133,14 @@ bool DataTransfer::SupportForOldStudies(Study& study, const AnyString& folder, A
auto& maxgen = area.hydro.series->maxgen;
auto& maxpump = area.hydro.series->maxpump;

auto& MaxPowerGen = maxPower[genMaxP];
auto& MaxPowerPump = maxPower[pumpMaxP];
auto& dailyMaxGen = dailyMaxPumpAndGen[genMaxP];
auto& dailyMaxPump = dailyMaxPumpAndGen[pumpMaxP];

maxgen.reset(1, HOURS_PER_YEAR);
maxpump.reset(1, HOURS_PER_YEAR);

AutoTransferPower(maxgen, MaxPowerGen);
AutoTransferPower(maxpump, MaxPowerPump);
AutoTransferPower(maxgen, dailyMaxGen);
AutoTransferPower(maxpump, dailyMaxPump);

buffer.clear() << folder << SEP << "series" << SEP << area.id << SEP << "maxgen." << study.inputExtension;
ret = maxgen.saveToCSVFile(buffer, 1, HOURS_PER_YEAR, &study.dataBuffer) && ret;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/parts/hydro/datatransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DataTransfer
pumpMaxE,
};

Matrix<double, double> maxPower;
Matrix<double, double> dailyMaxPumpAndGen;

bool LoadFromFolder(Study& study, const AnyString& folder, Area& area);
bool AutoTransferHours(Study& study, const AnyString& folder, Area& area);
Expand Down
2 changes: 1 addition & 1 deletion src/solver/hydro/management/daily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ inline void HydroManagement::prepareDailyOptimalGenerations(Solver::Variable::St

uint dayYear = 0;

auto const& maxPowerHours = area.hydro.maxHoursGen;
auto const& maxPowerHours = area.hydro.maxHourlyGenEnergy;
auto const& maxPower = area.hydro.series->maxgen;

uint tsIndexMaxPower
Expand Down
10 changes: 5 additions & 5 deletions src/solver/simulation/sim_calcul_economique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ void SIM_RenseignementProblemeHebdo(const Study& study,
= 0.;
problem.CaracteristiquesHydrauliques[k]
.MaxEnergieHydrauParIntervalleOptimise[j]
= meanPower * area.hydro.maxHoursGen[0][day]
= meanPower * area.hydro.maxHourlyGenEnergy[0][day]
* problem.CaracteristiquesHydrauliques[k]
.WeeklyGeneratingModulation;
}
Expand Down Expand Up @@ -732,7 +732,7 @@ void SIM_RenseignementProblemeHebdo(const Study& study,
uint day = study.calendar.hours[PasDeTempsDebut + j * 24].dayYear;
auto meanPower = CalculateDailyMeanPower(day, srcmaxgen);

double DGC = meanPower * area.hydro.maxHoursGen[0][day];
double DGC = meanPower * area.hydro.maxHourlyGenEnergy[0][day];

DGU_tmp[j] = DNT[day] * LUB;
DGL_tmp[j] = DNT[day] * LLB;
Expand Down Expand Up @@ -841,7 +841,7 @@ void SIM_RenseignementProblemeHebdo(const Study& study,

problem.CaracteristiquesHydrauliques[k]
.MaxEnergiePompageParIntervalleOptimise[j]
= meanPump * area.hydro.maxHoursPump[0][day]
= meanPump * area.hydro.maxHourlyPumpEnergy[0][day]
* problem.CaracteristiquesHydrauliques[k]
.WeeklyPumpingModulation;
}
Expand Down Expand Up @@ -875,7 +875,7 @@ void SIM_RenseignementProblemeHebdo(const Study& study,
auto meanPump = CalculateDailyMeanPower(day, srcmaxpump);

double DPC
= meanPump * area.hydro.maxHoursPump[0][day];
= meanPump * area.hydro.maxHourlyPumpEnergy[0][day];

WPU += DPC;
}
Expand All @@ -887,7 +887,7 @@ void SIM_RenseignementProblemeHebdo(const Study& study,
uint day = study.calendar.hours[PasDeTempsDebut + j * 24].dayYear;
auto meanPump = CalculateDailyMeanPower(day, srcmaxpump);
double DPC
= meanPump * area.hydro.maxHoursPump[0][day];
= meanPump * area.hydro.maxHourlyPumpEnergy[0][day];
double rc = area.hydro.reservoirCapacity;

if (not area.hydro.hardBoundsOnRuleCurves)
Expand Down
Loading

0 comments on commit cddc46e

Please sign in to comment.