Skip to content

Commit

Permalink
cherry pick PR #1969
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Mar 18, 2024
1 parent fb24345 commit bc8a318
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/libs/antares/study/scenario-builder/TSnumberData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,20 @@ bool thermalTSNumberData::apply(Study& study)
// WARNING: We may have some thermal clusters with the `mustrun` option
auto clusterCount = (uint)area.thermal.clusterCount();

const uint tsGenCountThermal = get_tsGenCount(study);

for (uint clusterIndex = 0; clusterIndex != clusterCount; ++clusterIndex)
{
auto& cluster = *(area.thermal.clusters[clusterIndex]);
// alias to the current column
assert(clusterIndex < pTSNumberRules.width);
const auto& col = pTSNumberRules[clusterIndex];

logprefix.clear() << "Thermal: Area '" << area.name << "', cluster: '" << cluster.name()
uint tsGenCount = cluster.tsGenBehavior == LocalTSGenerationBehavior::forceNoGen ?
cluster.series.timeSeries.width : get_tsGenCount(study);

logprefix.clear() << "Thermal: area '" << area.name << "', cluster: '" << cluster.name()
<< "': ";
ret = ApplyToMatrix(errors, logprefix, *cluster.series, col, tsGenCountThermal) && ret;
ret = ApplyToMatrix(errors, logprefix, cluster.series, col, tsGenCount) && ret;

}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,25 @@ BOOST_AUTO_TEST_CASE(on_link_area2_area3_and_on_year_19__ntc_TS_number_6_is_chos
BOOST_CHECK_EQUAL(link_23->timeseriesNumbers[0][yearNumber.to<uint>()], tsNumber.to<uint>() - 1);
}

// ========================
// Tests on TSNumberData
// ========================
BOOST_FIXTURE_TEST_CASE(thermalTSNumberData, Fixture)
{
ScenarioBuilder::thermalTSNumberData tsdata;
tsdata.attachArea(area_1);
tsdata.reset(*study);
tsdata.setTSnumber(thCluster_12.get(), 2, 22);
tsdata.setTSnumber(thCluster_12.get(), 5, 32); //out of bounds

study->parameters.nbTimeSeriesThermal = 1;
thCluster_12->tsGenBehavior = LocalTSGenerationBehavior::forceNoGen;
thCluster_12->series.timeSeries.resize(30, 8760);

tsdata.apply(*study);

BOOST_CHECK_EQUAL(thCluster_12->series.timeseriesNumbers[0][2], 21);
BOOST_CHECK_EQUAL(thCluster_12->series.timeseriesNumbers[0][5], 0);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit bc8a318

Please sign in to comment.