From 2f820aba0f378d87fb8aa3c325b745fe5572ef38 Mon Sep 17 00:00:00 2001 From: payetvin <113102157+payetvin@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:27:52 +0100 Subject: [PATCH] cherry pick PR #1960 --- src/solver/ts-generator/thermal.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/solver/ts-generator/thermal.cpp b/src/solver/ts-generator/thermal.cpp index b0f069ea73..5ee965c913 100644 --- a/src/solver/ts-generator/thermal.cpp +++ b/src/solver/ts-generator/thermal.cpp @@ -94,7 +94,6 @@ class GeneratorTempData final private: uint nbHoursPerYear; - const uint daysPerYear; MersenneTwister& rndgenerator; @@ -125,9 +124,8 @@ class GeneratorTempData final double bp[366]; - double FPOW[366][102]; - - double PPOW[366][102]; + std::vector> FPOW; + std::vector> PPOW; String pTempFilename; @@ -141,7 +139,6 @@ GeneratorTempData::GeneratorTempData(Data::Study& study, IResultWriter::Ptr writer) : study(study), nbHoursPerYear(study.runtime->nbHoursPerYear), - daysPerYear(study.runtime->nbDaysPerYear), rndgenerator(study.runtime->random[Data::seedTsGenThermal]), pProgression(progr), pWriter(writer) @@ -153,6 +150,9 @@ GeneratorTempData::GeneratorTempData(Data::Study& study, nbThermalTimeseries = parameters.nbTimeSeriesThermal; derated = parameters.derated; + + FPOW.resize(DAYS_PER_YEAR); + PPOW.resize(DAYS_PER_YEAR); } void GeneratorTempData::writeResultsToDisk(const Data::Area& area, @@ -191,7 +191,7 @@ void GeneratorTempData::prepareIndispoFromLaw(Data::ThermalLaw law, { case Data::thermalLawUniform: { - for (uint d = 0; d < daysPerYear; ++d) + for (uint d = 0; d < DAYS_PER_YEAR; ++d) { double D = (double)duration[d]; double xtemp = volatility * (D - 1.); @@ -202,7 +202,7 @@ void GeneratorTempData::prepareIndispoFromLaw(Data::ThermalLaw law, } case Data::thermalLawGeometric: { - for (uint d = 0; d < daysPerYear; ++d) + for (uint d = 0; d < DAYS_PER_YEAR; ++d) { double D = (double)duration[d]; double xtemp = volatility * volatility * D * (D - 1.); @@ -312,8 +312,11 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust int FOD_reel = 0; int POD_reel = 0; - for (uint d = 0; d < daysPerYear; ++d) + for (uint d = 0; d < DAYS_PER_YEAR; ++d) { + FPOW[d].resize(cluster.unitCount + 1); + PPOW[d].resize(cluster.unitCount + 1); + PODOfTheDay = (int)POD[d]; FODOfTheDay = (int)FOD[d]; @@ -385,9 +388,8 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust if (tsIndex > 1) dstSeries = &cluster.series->timeSeries[tsIndex - 2]; - for (uint dayInTheYear = 0; dayInTheYear < daysPerYear; ++dayInTheYear) + for (uint dayInTheYear = 0; dayInTheYear < DAYS_PER_YEAR; ++dayInTheYear) { - assert(AUN <= 100 and "Thermal Prepro: AUN is out of bounds (>=100)"); assert(dayInTheYear < 366); assert(not(lf[dayInTheYear] < 0.)); assert(not(lp[dayInTheYear] < 0.));