Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.8: Don't apply reverse spinning if the cluster is no force gen [ANT-2293] #2468

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libs/antares/study/parts/thermal/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ double Data::ThermalCluster::computeMarketBidCost(double fuelCost,

void Data::ThermalCluster::reverseCalculationOfSpinning()
{
if (tsGenBehavior == LocalTSGenerationBehavior::forceNoGen)
return;

// Nothing to do if the spinning is equal to zero
// because it will the same multiply all entries of the matrix by 1.
if (not Math::Zero(spinning))
Expand Down
2 changes: 2 additions & 0 deletions src/tests/src/libs/antares/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ target_link_libraries(test-study
)

add_test(NAME test-study COMMAND test-study)

set_property(TEST test-study PROPERTY LABELS unit)
41 changes: 27 additions & 14 deletions src/tests/src/libs/antares/study/test_study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,39 @@ struct OneAreaStudy
{
OneAreaStudy()
{
areaA = study.areaAdd("A");
study = std::make_unique<Study>();
areaA = study->areaAdd("A");
study->parameters.simulationDays.first = 0;
study->parameters.simulationDays.end = 7;
}

Study study;
std::unique_ptr<Study> study;
Area* areaA;
};

BOOST_AUTO_TEST_SUITE(areas_operations)

BOOST_AUTO_TEST_CASE(area_add)
{
Study study;
const auto areaA = study.areaAdd("A");
auto study = std::make_unique<Study>() ;
const auto areaA = study->areaAdd("A");
BOOST_CHECK(areaA != nullptr);
BOOST_CHECK_EQUAL(areaA->name, "A");
BOOST_CHECK_EQUAL(areaA->id, "a");
}

BOOST_FIXTURE_TEST_CASE(area_rename, OneAreaStudy)
{
BOOST_CHECK(study.areaRename(areaA, "B"));
BOOST_CHECK(study->areaRename(areaA, "B"));
BOOST_CHECK(areaA->name == "B");
BOOST_CHECK(areaA->id == "b");
}

BOOST_FIXTURE_TEST_CASE(area_delete, OneAreaStudy)
{
BOOST_CHECK_EQUAL(study.areas.size(), 1);
BOOST_CHECK(study.areaDelete(areaA));
BOOST_CHECK(study.areas.empty());
BOOST_CHECK_EQUAL(study->areas.size(), 1);
BOOST_CHECK(study->areaDelete(areaA));
BOOST_CHECK(study->areas.empty());
}

BOOST_AUTO_TEST_SUITE_END() //areas
Expand All @@ -87,7 +90,7 @@ BOOST_FIXTURE_TEST_CASE(thermal_cluster_delete, OneAreaStudy)
// Check that "Cluster1" is found
BOOST_CHECK_EQUAL(areaA->thermal.list.find("cluster1"), disabledCluster.get());

study.initializeRuntimeInfos(); // This should remove all disabled thermal clusters
study->initializeRuntimeInfos(); // This should remove all disabled thermal clusters
// Check that "Cluster1" isn't found
BOOST_CHECK_EQUAL(areaA->thermal.list.find("cluster1"), nullptr);
}
Expand All @@ -102,7 +105,7 @@ BOOST_FIXTURE_TEST_CASE(renewable_cluster_delete, OneAreaStudy)
// Check that "Cluster1" is found
BOOST_CHECK_EQUAL(areaA->renewable.list.find("cluster1"), disabledCluster.get());

study.initializeRuntimeInfos(); // This should remove all disabled renewable clusters
study->initializeRuntimeInfos(); // This should remove all disabled renewable clusters
// Check that "Cluster1" isn't found
BOOST_CHECK_EQUAL(areaA->renewable.list.find("cluster1"), nullptr);
}
Expand Down Expand Up @@ -137,7 +140,7 @@ BOOST_FIXTURE_TEST_CASE(short_term_storage_delete, OneAreaStudy)
BOOST_CHECK(findDisabledCluster("Cluster1") != sts.end());
BOOST_CHECK(findDisabledCluster("Cluster2") != sts.end());

study.initializeRuntimeInfos(); // This should remove all disabled short-term storages
study->initializeRuntimeInfos(); // This should remove all disabled short-term storages

// Check that only "Cluster1" is found
BOOST_CHECK(findDisabledCluster("Cluster1") != sts.end());
Expand Down Expand Up @@ -183,7 +186,7 @@ struct ThermalClusterStudy: public OneAreaStudy

BOOST_FIXTURE_TEST_CASE(thermal_cluster_rename, ThermalClusterStudy)
{
BOOST_CHECK(study.clusterRename(cluster, "Renamed"));
BOOST_CHECK(study->clusterRename(cluster, "Renamed"));
BOOST_CHECK(cluster->name() == "Renamed");
BOOST_CHECK(cluster->id() == "renamed");
}
Expand All @@ -196,6 +199,16 @@ BOOST_FIXTURE_TEST_CASE(thermal_cluster_delete, ThermalClusterStudy)
BOOST_CHECK(areaA->thermal.list.empty());
}

BOOST_FIXTURE_TEST_CASE(thermal_cluster_forceNoGen, ThermalClusterStudy)
{
cluster->tsGenBehavior = LocalTSGenerationBehavior::forceNoGen;
cluster->series.timeSeries.resize(1, 8760);
cluster->series.timeSeries.fill(100);
cluster->reverseCalculationOfSpinning();

BOOST_CHECK_EQUAL(cluster->series[0][0], 100);
}

BOOST_AUTO_TEST_SUITE_END() // thermal clusters

BOOST_AUTO_TEST_SUITE(renewable_clusters_operations)
Expand All @@ -222,7 +235,7 @@ struct RenewableClusterStudy : public OneAreaStudy
{
RenewableClusterStudy()
{
areaA = study.areaAdd("A");
areaA = study->areaAdd("A");
auto newCluster = std::make_shared<RenewableCluster>(areaA);
newCluster->setName("WindCluster");
areaA->renewable.list.add(newCluster);
Expand All @@ -234,7 +247,7 @@ struct RenewableClusterStudy : public OneAreaStudy

BOOST_FIXTURE_TEST_CASE(renewable_cluster_rename, RenewableClusterStudy)
{
BOOST_CHECK(study.clusterRename(cluster, "Renamed"));
BOOST_CHECK(study->clusterRename(cluster, "Renamed"));
BOOST_CHECK(cluster->name() == "Renamed");
BOOST_CHECK(cluster->id() == "renamed");
}
Expand Down
Loading