Skip to content

Keep only important integration tests: step 1 #833

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

Merged
merged 16 commits into from
Nov 25, 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
417 changes: 64 additions & 353 deletions tests/cpp_integration_tests/test_main_model.cpp

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions tests/cpp_integration_tests/test_main_model_sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ using enum CalculationSymmetry;
TEST_CASE("Test main model - short circuit") {
MainModel main_model{50.0, meta_data::meta_data_gen::meta_data};

SUBCASE("Single node + source") {
SUBCASE("Single node + source") { // TODO(mgovers): existing validation case for this is too difficult. we may want
// to keep this. Also should not live here but in SC solver
double const u_rated = 10e3;
double const u_ref = 1.0;
double const sk = 100e6;
Expand Down Expand Up @@ -127,7 +128,8 @@ TEST_CASE("Test main model - short circuit") {
}
}

SUBCASE("Two nodes + branch + source") {
SUBCASE("Two nodes + branch + source") { // TODO(mgovers): existing validation case for this is too difficult. we
// may want to keep this
ShortCircuitVoltageScaling const voltage_scaling = ShortCircuitVoltageScaling::maximum;
constexpr double voltage_scaling_c = 1.1;

Expand Down Expand Up @@ -163,7 +165,9 @@ TEST_CASE("Test main model - short circuit") {
}
}

TEST_CASE("Test main model - short circuit - Dataset input") {
TEST_CASE("Test main model - short circuit - Dataset input") { // TODO(mgovers): same logic as above but different input
// type. maybe make a validation case for this; otherwise
// may be removed
SUBCASE("Two nodes + branch + source") {
std::vector<NodeInput> node_input{{1, 10e4}, {2, 10e4}};
std::vector<LineInput> line_input{{3, 1, 2, 1, 1, 10.0, 0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 1e3}};
Expand Down
15 changes: 10 additions & 5 deletions tests/cpp_integration_tests/test_main_model_se.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ TEST_CASE_TEMPLATE("Test main model - state estimation", CalcMethod, IterativeLi
.max_iter = 20};

SUBCASE("State Estimation") {
SUBCASE("Single Node + Source") {
SUBCASE("Single Node + Source") { // TODO(mgovers): these are so simple, they may be API tests, but that would
// just be moving the problem around.
main_model.add_component<Node>({{1, 10e3}});
main_model.add_component<Source>({{2, 1, 1, 1.0, nan, nan, nan, nan}});
SUBCASE("Symmetric Voltage Sensor") {
Expand Down Expand Up @@ -141,7 +142,8 @@ TEST_CASE_TEMPLATE("Test main model - state estimation", CalcMethod, IterativeLi
}
}

SUBCASE("Node Injection") {
SUBCASE("Node Injection") { // TODO(mgovers): these are so simple, they may be API tests, but that would just be
// moving the problem around.
main_model.add_component<Node>({{1, 10e3}, {2, 10e3}});
main_model.add_component<Link>({{3, 1, 2, 1, 1}});
main_model.add_component<Source>({{4, 1, 1, 1.0, nan, nan, nan, nan}});
Expand Down Expand Up @@ -220,7 +222,8 @@ TEST_CASE_TEMPLATE("Test main model - state estimation", CalcMethod, IterativeLi
}
}
}
SUBCASE("Line power sensor") {
SUBCASE("Line power sensor") { // TODO(mgovers): these are so simple, they may be API tests, but that would just
// be moving the problem around.
main_model.add_component<Node>({{1, 10e3}, {2, 10e3}});
main_model.add_component<Line>({{3, 1, 2, 1, 1, 0.01, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e3}});
main_model.add_component<Source>({{4, 1, 1, 1.0, nan, nan, nan, nan}});
Expand Down Expand Up @@ -265,7 +268,8 @@ TEST_CASE_TEMPLATE("Test main model - state estimation", CalcMethod, IterativeLi
}
}
}
SUBCASE("Forbid Link Power Measurements") {
SUBCASE("Forbid Link Power Measurements") { // TODO(mgovers): This should be tested. maybe API test or in an
// isolated environment
main_model.add_component<Node>({{1, 10e3}, {2, 10e3}});
main_model.add_component<Link>({{3, 1, 2, 1, 1}});
CHECK_THROWS_AS(main_model.add_component<SymPowerSensor>(
Expand Down Expand Up @@ -298,7 +302,8 @@ TEST_CASE_TEMPLATE("Test main model - state estimation", CalcMethod, IterativeLi
}
}

SUBCASE("Test incomplete input but complete update dataset") {
SUBCASE(
"Test incomplete input but complete update dataset") { // TODO(mgovers): this tests the same as the PF version
std::vector<NodeInput> node_input{{1, 10e3}};

std::vector<SourceInput> incomplete_source_input{{2, 1, 1, nan, nan, nan, nan, nan}};
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp_integration_tests/test_math_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ void assert_sc_output(ShortCircuitSolverOutput<sym> const& output, ShortCircuitS

} // namespace

TEST_CASE("Test math solver") {
TEST_CASE(
"Test math solver") { // most of these should be template test cases with instantiations for the individual solvers
/*
network, v means voltage measured, p means power measured, pp means double measured
variance always 1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"calculation_method": "linear",
"calculation_method": [
"linear",
"newton_raphson",
"iterative_current",
"linear_current"
],
"rtol": 1e-5,
"atol": 1e-5
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,29 @@
{
"sym_load": [
{
"id": 7,
"q_specified": 2.5
},
{
"id": 8,
"q_specified": 7.5
}
]
},
{
"sym_load": [
{
"id": 7,
"q_specified": 15.0
},
{
"id": 8,
"q_specified": 5.0
}
]
},
{
"sym_load": [
{
"id": 7,
"q_specified": 21.0
},
{
"id": 8,
"q_specified": 9.0
}
]
Expand Down
60 changes: 60 additions & 0 deletions tests/data/power_flow/dummy-test-batch-optional-id/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{
"id": 1,
"u_rated": 10.0
},
{
"id": 2,
"u_rated": 10.0
}
],
"line": [
{
"id": 4,
"from_node": 1,
"to_node": 2,
"from_status": 1,
"to_status": 1,
"r1": 0.0,
"x1": 1.0,
"c1": 0.0,
"tan1": 0.0,
"i_n": 1e3
}
],
"source": [
{
"id": 6,
"node": 1,
"status": 1,
"u_ref": 1.0,
"sk": 100.0,
"rx_ratio": 0.0
}
],
"sym_load": [
{
"id": 7,
"node": 2,
"status": 1,
"type": 2,
"p_specified": 0.0,
"q_specified": 0.0
},
{
"id": 8,
"node": 2,
"status": 1,
"type": 2,
"p_specified": 0.0,
"q_specified": 0.0
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"calculation_method": ["newton_raphson", "iterative_current"],
"rtol": 1e-5,
"atol": 1e-5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
16 changes: 16 additions & 0 deletions tests/data/power_flow/dummy-test-batch-optional-id/sym_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{
"u": 10.0
},
{
"u": 10.0
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": true,
"attributes": {},
"data": [
{
"node": [
{
"u": 9.0
},
{
"u": 8.0
}
]
},
{
"node": [
{
"u": 8.0
},
{
"u": 6.0
}
]
},
{
"node": [
{
"u": 7.0
},
{
"u": 4.0
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "1.0",
"type": "update",
"is_batch": true,
"attributes": {},
"data": [
{
"sym_load": [
{
"q_specified": 2.5
},
{
"q_specified": 7.5
}
]
},
{
"sym_load": [
{
"q_specified": 15.0
},
{
"q_specified": 5.0
}
]
},
{
"sym_load": [
{
"q_specified": 21.0
},
{
"q_specified": 9.0
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
7 changes: 6 additions & 1 deletion tests/data/power_flow/dummy-test-batch/params.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"calculation_method": "linear",
"calculation_method": [
"linear",
"newton_raphson",
"iterative_current",
"linear_current"
],
"rtol": 1e-5,
"atol": 1e-5
}
Loading
Loading