Skip to content

Commit

Permalink
New hydro remix : adding a test on influence of Pmin
Browse files Browse the repository at this point in the history
  • Loading branch information
guilpier-code committed Dec 16, 2024
1 parent a52aa7b commit 52b04e0
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions src/tests/src/solver/simulation/test-hydro-remix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(hydro_increases_and_pmax_40mwh___H_is_smoothed_to_mean_H_20
std::vector<double> P_max(5, 40.);
std::vector<double> P_min(5, 0.);
std::vector<double> G(5, 100.);
std::vector<double> H = {0., 10., 20., 30., 40.}; // H <= Pmax everywhere
std::vector<double> H = {0., 10., 20., 30., 40.}; // we have Pmin <= H <= Pmax
std::vector<double> D = {80.0, 60., 40., 20., 0.};
double initial_level = 500.;
double capa = 1000.;
Expand All @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(Pmax_does_not_impact_results_when_greater_than_40mwh)
std::vector<double> P_max(5, 50.);
std::vector<double> P_min(5, 0.);
std::vector<double> G(5, 100.);
std::vector<double> H = {0., 10., 20., 30., 40.}; // H <= Pmax everywhere
std::vector<double> H = {0., 10., 20., 30., 40.};
std::vector<double> D = {80.0, 60., 40., 20., 0.};
double initial_level = 500.;
double capa = 1000.;
Expand All @@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(hydro_decreases_and_pmax_40mwh___H_is_smoothed_to_mean_H_20
std::vector<double> P_max(5, 40.);
std::vector<double> P_min(5, 0.);
std::vector<double> G(5, 100.);
std::vector<double> H = {40., 30., 20., 10., 0.}; // H <= Pmax everywhere
std::vector<double> H = {40., 30., 20., 10., 0.};
std::vector<double> D = {0., 20., 40., 60., 80.};
double initial_level = 500.;
double capa = 1000.;
Expand All @@ -178,14 +178,14 @@ BOOST_AUTO_TEST_CASE(influence_of_pmax)
std::vector<double> G = {100., 80., 60., 40., 20.};

// H is flat and must respect H <= Pmax everywhere
std::vector<double> H = {20., 20., 20., 20., 20.}; // H <= Pmax everywhere
std::vector<double> H = {20., 20., 20., 20., 20.};
std::vector<double> D = {50., 50., 50., 50., 50.};
double initial_level = 500.;
double capa = 1000.;
std::vector<double> inflows(5, 0.);

// What we expect to happen :
// Algorithm tends to flatten G + H, so it would require to increase H.
// Algorithm tends to flatten G + H, so it would require H to increase.
// But H is limited by P_max. So Algo does nothing in the end.
auto [new_H, new_D] = new_remix_hydro(G, H, D, P_max, P_min, initial_level, capa, inflows);

Expand All @@ -195,6 +195,32 @@ BOOST_AUTO_TEST_CASE(influence_of_pmax)
BOOST_CHECK(new_D == expected_D);
}

BOOST_AUTO_TEST_CASE(influence_of_pmin)
{
std::vector<double> P_max(5, std::numeric_limits<double>::max());
std::vector<double> P_min(5, 20.);

// G decreases
std::vector<double> G = {100., 80., 60., 40., 20.};

// H is flat and must respect Pmin <= H <= Pmax everywhere
std::vector<double> H = {20., 20., 20., 20., 20.};
std::vector<double> D = {50., 50., 50., 50., 50.};
double initial_level = 500.;
double capa = 1000.;
std::vector<double> inflows(5, 0.);

// What we expect to happen :
// Algorithm tends to flatten G + H, so it would require H to decrease.
// But H is low bounded by P_min. So Algo does nothing in the end.
auto [new_H, new_D] = new_remix_hydro(G, H, D, P_max, P_min, initial_level, capa, inflows);

std::vector<double> expected_H = {20., 20., 20., 20., 20.};
std::vector<double> expected_D = {50., 50., 50., 50., 50.};
BOOST_CHECK(new_H == expected_H);
BOOST_CHECK(new_D == expected_D);
}

// Ideas for building further tests :
// ================================
// - Remix hydro algorithm seems symmetrical (if we have input vectors and corresponding output
Expand Down

0 comments on commit 52b04e0

Please sign in to comment.