diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000000..ad1bb40801 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1 @@ +read the instructions from file 6-Contributing.md \ No newline at end of file diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e6f1cf608f..39b83be616 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -103,7 +103,7 @@ jobs: - name: Init submodule run: | - git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests + git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests_NR - name: Configure run: | diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d0d55b1481..5af937ceff 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -142,10 +142,6 @@ jobs: run: | echo "SIMTEST=${{ fromJson(env.SIMTEST_JSON).version }}" >> $GITHUB_ENV - - name: Init submodule Antares_Simulator_Tests - run: | - git submodule update --init --remote --recursive src/tests/resources/Antares_Simulator_Tests - - name: Init submodule Antares_Simulator_Tests_NR run: | git submodule update --init --remote --recursive src/tests/resources/Antares_Simulator_Tests_NR diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index 7f382d8be8..0fda647b68 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -144,10 +144,6 @@ jobs: run: | echo "SIMTEST=${{ fromJson(env.SIMTEST_JSON).version }}" >> $GITHUB_ENV - - name: Init submodule Antares_Simulator_Tests - run: | - git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests - - name: Init submodule Antares_Simulator_Tests_NR run: | git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests_NR diff --git a/.gitmodules b/.gitmodules index 0b11b7d0b3..24b229c190 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "src/tests/resources/Antares_Simulator_Tests"] - path = src/tests/resources/Antares_Simulator_Tests - url = https://github.com/AntaresSimulatorTeam/Antares_Simulator_Tests.git - branch = master [submodule "vcpkg"] path = vcpkg url = https://github.com/microsoft/vcpkg.git diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 3f0cb4a12a..3114ed7480 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -192,9 +192,12 @@ static bool AreaListSaveThermalDataToFile(const AreaList& list, const AnyString& return ini.save(filename); } -static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const AnyString& folder) +static bool AreaListSaveToFolderSingleArea(const Area& area, + const AnyString& folder, + const Parameters::Compatibility::HydroPmax hydroPmax) { bool ret = true; + Clob buffer; // A specific folder for general data buffer.clear() << folder << SEP << "input" << SEP << "areas" << SEP << area.id; @@ -273,7 +276,7 @@ static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const if (area.hydro.series) // Series { buffer.clear() << folder << SEP << "input" << SEP << "hydro" << SEP << "series"; - ret = area.hydro.series->saveToFolder(area.id, buffer) && ret; + ret = area.hydro.series->saveToFolder(area.id, buffer, hydroPmax) && ret; } } @@ -762,13 +765,16 @@ bool AreaList::saveToFolder(const AnyString& folder) const { logs.info() << "Exporting the area " << (area.index + 1) << '/' << areas.size() << ": " << area.name; - ret = AreaListSaveToFolderSingleArea(area, buffer, folder) && ret; + ret = AreaListSaveToFolderSingleArea(area, + folder, + pStudy.parameters.compatibility.hydroPmax) + && ret; }); // Hydro // The hydro files must be saved after the area has been invalidated buffer.clear() << folder << SEP << "input" << SEP << "hydro"; - ret = PartHydro::SaveToFolder(*this, buffer) && ret; + ret = PartHydro::SaveToFolder(*this, buffer, pStudy.parameters.compatibility.hydroPmax) && ret; // update nameid set updateNameIDSet(); diff --git a/src/libs/antares/study/include/antares/study/parameters.h b/src/libs/antares/study/include/antares/study/parameters.h index 664d574b32..410f89ae6c 100644 --- a/src/libs/antares/study/include/antares/study/parameters.h +++ b/src/libs/antares/study/include/antares/study/parameters.h @@ -531,7 +531,7 @@ const char* SimulationModeToCString(SimulationMode mode); */ bool StringToSimulationMode(SimulationMode& mode, Yuni::CString<20, false> text); -const char* CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax); +const char* CompatibilityHydroPmaxToCString(const Parameters::Compatibility::HydroPmax); bool StringToCompatibilityHydroPmax(Parameters::Compatibility::HydroPmax&, const std::string& text); } // namespace Antares::Data diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/container.h b/src/libs/antares/study/include/antares/study/parts/hydro/container.h index 91b668ba6a..ceb9319814 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/container.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/container.h @@ -131,7 +131,9 @@ class PartHydro ** \param folder The targer folder ** \return A non-zero value if the operation succeeded, 0 otherwise */ - static bool SaveToFolder(const AreaList& areas, const AnyString& folder); + static bool SaveToFolder(const AreaList& areas, + const AnyString& folder, + const Parameters::Compatibility::HydroPmax hydroPmax); /*! ** \brief Default Constructor @@ -195,6 +197,9 @@ class PartHydro double leewayUpperBound; //! Puming efficiency double pumpingEfficiency; + //! Daily max power ({generating max Power, generating max energy, pumping max power, pumping + //! max energy}x365) + Matrix dailyMaxPumpAndGen; //! Credit Modulation (default 0, 101 * 2) Matrix creditModulation; diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h b/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h index f1c4cb8e36..6191cc509c 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h @@ -58,8 +58,6 @@ class HydroMaxTimeSeriesReader }; private: - Matrix dailyMaxPumpAndGen; - PartHydro& hydro_; std::string areaID_; std::string areaName_; diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/series.h b/src/libs/antares/study/include/antares/study/parts/hydro/series.h index c3b587c0de..3c28e84d04 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/series.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/series.h @@ -91,7 +91,9 @@ class DataSeriesHydro ** \param folder The target folder ** \return A non-zero value if the operation succeeded, 0 otherwise */ - bool saveToFolder(const AreaName& areaID, const AnyString& folder) const; + bool saveToFolder(const AreaName& areaID, + const AnyString& folder, + Parameters::Compatibility::HydroPmax hydroPmax) const; //@} TimeSeriesNumbers timeseriesNumbers; diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 60a3781bd2..27fe1e11df 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -208,7 +208,7 @@ const char* SimulationModeToCString(SimulationMode mode) } } -const char* CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax mode) +const char* CompatibilityHydroPmaxToCString(const Parameters::Compatibility::HydroPmax mode) { switch (mode) { diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index 52e6ef1d83..3a99c6b146 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -465,7 +465,9 @@ bool PartHydro::validate(Study& study) return checkProperties(study) && ret; } -bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) +bool PartHydro::SaveToFolder(const AreaList& areas, + const AnyString& folder, + const Parameters::Compatibility::HydroPmax hydroPmax) { if (!folder) { @@ -524,7 +526,7 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) // Add all alpha values for each area areas.each( - [&allSections, &buffer, &folder, &ret](const Data::Area& area) + [&allSections, &buffer, &folder, &hydroPmax, &ret](const Data::Area& area) { allSections.s->add(area.id, area.hydro.interDailyBreakdown); allSections.smod->add(area.id, area.hydro.intraDailyModulation); @@ -568,13 +570,23 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) } // max hours gen - buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP - << "maxDailyGenEnergy_" << area.id << ".txt"; - ret = area.hydro.dailyNbHoursAtGenPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; - // max hours pump - buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP - << "maxDailyPumpEnergy_" << area.id << ".txt"; - ret = area.hydro.dailyNbHoursAtPumpPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + if (hydroPmax == Parameters::Compatibility::HydroPmax::Hourly) + { + buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP + << "maxDailyGenEnergy_" << area.id << ".txt"; + ret = area.hydro.dailyNbHoursAtGenPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + + buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP + << "maxDailyPumpEnergy_" << area.id << ".txt"; + ret = area.hydro.dailyNbHoursAtPumpPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + } + else + { + buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxpower_" + << area.id << ".txt"; + ret = area.hydro.dailyMaxPumpAndGen.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + } + // credit modulations buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "creditmodulations_" << area.id << ".txt"; diff --git a/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp b/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp index fa2827fc88..910fb6e236 100644 --- a/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp +++ b/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp @@ -44,7 +44,7 @@ HydroMaxTimeSeriesReader::HydroMaxTimeSeriesReader(PartHydro& hydro, areaID_(areaID), areaName_(areaName) { - dailyMaxPumpAndGen.reset(4U, DAYS_PER_YEAR, true); + hydro_.dailyMaxPumpAndGen.reset(4U, DAYS_PER_YEAR, true); } static bool checkPower(const Matrix<>& dailyMaxPumpAndGen, const std::string& areaName) @@ -88,12 +88,15 @@ bool HydroMaxTimeSeriesReader::loadDailyMaxPowersAndEnergies(const AnyString& fo enabledModeIsChanged = true; } - ret = dailyMaxPumpAndGen.loadFromCSVFile(filePath, - 4U, - DAYS_PER_YEAR, - Matrix<>::optFixedSize, - &fileContent) + ret = hydro_.dailyMaxPumpAndGen.loadFromCSVFile(filePath, + 4U, + DAYS_PER_YEAR, + Matrix<>::optFixedSize, + &fileContent) && ret; + // Allowing the daily power matrix to be printed in case of 'save as' (even if its content + // hasn't changed since it was loaded). + hydro_.dailyMaxPumpAndGen.markAsModified(); if (enabledModeIsChanged) { @@ -102,11 +105,11 @@ bool HydroMaxTimeSeriesReader::loadDailyMaxPowersAndEnergies(const AnyString& fo } else { - ret = dailyMaxPumpAndGen.loadFromCSVFile(filePath, - 4U, - DAYS_PER_YEAR, - Matrix<>::optFixedSize, - &fileContent) + ret = hydro_.dailyMaxPumpAndGen.loadFromCSVFile(filePath, + 4U, + DAYS_PER_YEAR, + Matrix<>::optFixedSize, + &fileContent) && ret; } return ret; @@ -121,7 +124,7 @@ void HydroMaxTimeSeriesReader::copyDailyMaxEnergy() const void HydroMaxTimeSeriesReader::copyDailyMaxGenerationEnergy() const { auto& dailyNbHoursAtGenPmax = hydro_.dailyNbHoursAtGenPmax; - const auto& dailyMaxGenE = dailyMaxPumpAndGen[genMaxE]; + const auto& dailyMaxGenE = hydro_.dailyMaxPumpAndGen[genMaxE]; dailyNbHoursAtGenPmax.reset(1U, DAYS_PER_YEAR, true); @@ -131,7 +134,7 @@ void HydroMaxTimeSeriesReader::copyDailyMaxGenerationEnergy() const void HydroMaxTimeSeriesReader::copyDailyMaxPumpingEnergy() const { auto& dailyNbHoursAtPumpPmax = hydro_.dailyNbHoursAtPumpPmax; - const auto& dailyMaxPumpE = dailyMaxPumpAndGen[pumpMaxE]; + const auto& dailyMaxPumpE = hydro_.dailyMaxPumpAndGen[pumpMaxE]; dailyNbHoursAtPumpPmax.reset(1U, DAYS_PER_YEAR, true); @@ -141,10 +144,10 @@ void HydroMaxTimeSeriesReader::copyDailyMaxPumpingEnergy() const bool HydroMaxTimeSeriesReader::read(const AnyString& folder, bool usedBySolver) { bool ret = loadDailyMaxPowersAndEnergies(folder, usedBySolver); - ret = checkPower(dailyMaxPumpAndGen, areaName_) && ret; + ret = checkPower(hydro_.dailyMaxPumpAndGen, areaName_) && ret; copyDailyMaxEnergy(); - hydro_.series->buildHourlyMaxPowerFromDailyTS(dailyMaxPumpAndGen[genMaxP], - dailyMaxPumpAndGen[pumpMaxP]); + hydro_.series->buildHourlyMaxPowerFromDailyTS(hydro_.dailyMaxPumpAndGen[genMaxP], + hydro_.dailyMaxPumpAndGen[pumpMaxP]); return ret; } diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index 2ae774fbdf..998f85a1e0 100644 --- a/src/libs/antares/study/parts/hydro/series.cpp +++ b/src/libs/antares/study/parts/hydro/series.cpp @@ -191,7 +191,9 @@ void DataSeriesHydro::buildHourlyMaxPowerFromDailyTS( ConvertDailyTSintoHourlyTS(DailyMaxPumpPower, maxHourlyPumpPower.timeSeries[0]); } -bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& folder) const +bool DataSeriesHydro::saveToFolder(const AreaName& areaID, + const AnyString& folder, + Parameters::Compatibility::HydroPmax hydroPmax) const { String buffer; buffer.clear() << folder << SEP << areaID; @@ -207,10 +209,14 @@ bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& fold ret = storage.timeSeries.saveToCSVFile(buffer, 0) && ret; buffer.clear() << folder << SEP << areaID << SEP << "mingen.txt"; ret = mingen.timeSeries.saveToCSVFile(buffer, 0) && ret; - buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyGenPower.txt"; - ret = maxHourlyGenPower.timeSeries.saveToCSVFile(buffer, 0) && ret; - buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyPumpPower.txt"; - ret = maxHourlyPumpPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + + if (hydroPmax == Parameters::Compatibility::HydroPmax::Hourly) + { + buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyGenPower.txt"; + ret = maxHourlyGenPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyPumpPower.txt"; + ret = maxHourlyPumpPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + } return ret; } diff --git a/src/libs/antares/study/study.importprepro.cpp b/src/libs/antares/study/study.importprepro.cpp index 3cf520c5eb..9c76418b3d 100644 --- a/src/libs/antares/study/study.importprepro.cpp +++ b/src/libs/antares/study/study.importprepro.cpp @@ -82,7 +82,10 @@ bool Study::importTimeseriesIntoInput() { logs.info() << "Importing hydro timeseries : " << areaName; buffer.clear() << folderInput << SEP << "hydro" << SEP << "series"; - ret = area->hydro.series->saveToFolder(area->id, buffer) && ret; + ret = area->hydro.series->saveToFolder(area->id, + buffer, + parameters.compatibility.hydroPmax) + && ret; ++progression; } } diff --git a/src/tests/resources/Antares_Simulator_Tests b/src/tests/resources/Antares_Simulator_Tests deleted file mode 160000 index 2d79167609..0000000000 --- a/src/tests/resources/Antares_Simulator_Tests +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2d79167609fc15497085aaa7311698adb63222a2