From 07cd493d6e0c816422caf5a309c2b47cf96415d6 Mon Sep 17 00:00:00 2001 From: Le Courtois Florent Date: Tue, 5 Oct 2021 09:31:47 +0200 Subject: [PATCH] #216 Use new shunt API --- sources/Inputs/include/Node.h | 3 ++- sources/Inputs/src/NetworkManager.cpp | 2 +- tests/algo/TestAlgo.cpp | 30 ++++++++++++++------------- tests/algo/TestAlgoDynModel.cpp | 13 ++++++------ tests/inputs/TestNode.cpp | 6 ++---- tests/outputs/TestPar.cpp | 6 +++--- 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/sources/Inputs/include/Node.h b/sources/Inputs/include/Node.h index f635940e5..5cfd5c72d 100644 --- a/sources/Inputs/include/Node.h +++ b/sources/Inputs/include/Node.h @@ -147,13 +147,14 @@ struct Shunt { * * @param id the shunt id */ - explicit Shunt(const ShuntId& id) : id(id) {} + Shunt(const ShuntId& id, bool voltageRegulationOn) : id(id), voltageRegulationOn(voltageRegulationOn) {} bool operator==(const Shunt& other) const { return id == other.id; } const ShuntId id; ///< Shunt id + const bool voltageRegulationOn; }; /** diff --git a/sources/Inputs/src/NetworkManager.cpp b/sources/Inputs/src/NetworkManager.cpp index 110b83efc..aed2803be 100644 --- a/sources/Inputs/src/NetworkManager.cpp +++ b/sources/Inputs/src/NetworkManager.cpp @@ -75,7 +75,7 @@ NetworkManager::buildTree() { std::unordered_map> shuntsMap; for (const auto& shunt : shunts) { // We take into account even disconnected shunts as dynamic models may aim to connect them - (shuntsMap[shunt->getBusInterface()->getID()]).push_back(std::move(Shunt(shunt->getID()))); + (shuntsMap[shunt->getBusInterface()->getID()]).push_back(std::move(Shunt(shunt->getID(), shunt->isVoltageRegulationOn()))); } auto vl = std::make_shared(networkVL->getID()); diff --git a/tests/algo/TestAlgo.cpp b/tests/algo/TestAlgo.cpp index 8abeb291d..9578aa417 100644 --- a/tests/algo/TestAlgo.cpp +++ b/tests/algo/TestAlgo.cpp @@ -699,14 +699,15 @@ TEST(Shunts, base) { auto vl = std::make_shared("VL"); auto vl2 = std::make_shared("VL2"); auto vl3 = std::make_shared("VL3"); - std::vector shunts1 = {dfl::inputs::Shunt("1.1")}; - std::vector shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")}; - std::vector shunts3 = {dfl::inputs::Shunt("3.1"), dfl::inputs::Shunt("3.2"), dfl::inputs::Shunt("3.3")}; - std::vector shunts4 = {dfl::inputs::Shunt("4.1"), dfl::inputs::Shunt("4.2"), dfl::inputs::Shunt("4.3"), dfl::inputs::Shunt("4.4")}; - std::vector shunts5 = {dfl::inputs::Shunt("5.1"), dfl::inputs::Shunt("5.2"), dfl::inputs::Shunt("5.3"), dfl::inputs::Shunt("5.4"), - dfl::inputs::Shunt("5.5")}; - std::vector shunts6 = {dfl::inputs::Shunt("6.1"), dfl::inputs::Shunt("6.2"), dfl::inputs::Shunt("6.3"), - dfl::inputs::Shunt("6.4"), dfl::inputs::Shunt("6.5"), dfl::inputs::Shunt("6.6")}; + std::vector shunts1 = {dfl::inputs::Shunt("1.1", false)}; + std::vector shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)}; + std::vector shunts3 = {dfl::inputs::Shunt("3.1", false), dfl::inputs::Shunt("3.2", false), dfl::inputs::Shunt("3.3", false)}; + std::vector shunts4 = {dfl::inputs::Shunt("4.1", false), dfl::inputs::Shunt("4.2", false), dfl::inputs::Shunt("4.3", false), + dfl::inputs::Shunt("4.4", false)}; + std::vector shunts5 = {dfl::inputs::Shunt("5.1", false), dfl::inputs::Shunt("5.2", false), dfl::inputs::Shunt("5.3", false), + dfl::inputs::Shunt("5.4", false), dfl::inputs::Shunt("5.5", false)}; + std::vector shunts6 = {dfl::inputs::Shunt("6.1", false), dfl::inputs::Shunt("6.2", false), dfl::inputs::Shunt("6.3", false), + dfl::inputs::Shunt("6.4", false), dfl::inputs::Shunt("6.5", false), dfl::inputs::Shunt("6.6", false)}; std::vector> nodes{ dfl::inputs::Node::build("0", vl3, 0.0, {}), dfl::inputs::Node::build("1", vl, 1.0, shunts1), dfl::inputs::Node::build("2", vl, 2.0, shunts2), dfl::inputs::Node::build("3", vl, 3.0, shunts3), dfl::inputs::Node::build("4", vl2, 5.0, shunts4), dfl::inputs::Node::build("5", vl2, 5.0, shunts5), @@ -731,12 +732,13 @@ TEST(Shunts, base) { TEST(LinesByIds, base) { auto vl = std::make_shared("VL"); auto vl2 = std::make_shared("VLb"); - std::vector shunts1 = {dfl::inputs::Shunt("1.1")}; - std::vector shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")}; - std::vector shunts3 = {dfl::inputs::Shunt("3.1"), dfl::inputs::Shunt("3.2"), dfl::inputs::Shunt("3.3")}; - std::vector shunts4 = {dfl::inputs::Shunt("4.1"), dfl::inputs::Shunt("4.2"), dfl::inputs::Shunt("4.3"), dfl::inputs::Shunt("4.4")}; - std::vector shunts5 = {dfl::inputs::Shunt("5.1"), dfl::inputs::Shunt("5.2"), dfl::inputs::Shunt("5.3"), dfl::inputs::Shunt("5.4"), - dfl::inputs::Shunt("5.5")}; + std::vector shunts1 = {dfl::inputs::Shunt("1.1", false)}; + std::vector shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)}; + std::vector shunts3 = {dfl::inputs::Shunt("3.1", false), dfl::inputs::Shunt("3.2", false), dfl::inputs::Shunt("3.3", false)}; + std::vector shunts4 = {dfl::inputs::Shunt("4.1", false), dfl::inputs::Shunt("4.2", false), dfl::inputs::Shunt("4.3", false), + dfl::inputs::Shunt("4.4", false)}; + std::vector shunts5 = {dfl::inputs::Shunt("5.1", false), dfl::inputs::Shunt("5.2", false), dfl::inputs::Shunt("5.3", false), + dfl::inputs::Shunt("5.4", false), dfl::inputs::Shunt("5.5", false)}; std::vector> nodes{ dfl::inputs::Node::build("VL0", vl2, 0.0, {}), dfl::inputs::Node::build("VL1", vl, 1.0, shunts1), dfl::inputs::Node::build("VL2", vl, 2.0, shunts2), dfl::inputs::Node::build("VL3", vl, 3.0, shunts3), dfl::inputs::Node::build("VL4", vl, 4.0, shunts4), dfl::inputs::Node::build("VL5", vl, 5.0, shunts5), diff --git a/tests/algo/TestAlgoDynModel.cpp b/tests/algo/TestAlgoDynModel.cpp index 0b3ea2100..26a1e8663 100644 --- a/tests/algo/TestAlgoDynModel.cpp +++ b/tests/algo/TestAlgoDynModel.cpp @@ -35,12 +35,13 @@ TEST(TestAlgoDynModel, base) { auto vl = std::make_shared("VL"); auto vl2 = std::make_shared("VLb"); - std::vector shunts1 = {dfl::inputs::Shunt("1.1")}; - std::vector shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")}; - std::vector shunts3 = {dfl::inputs::Shunt("3.1"), dfl::inputs::Shunt("3.2"), dfl::inputs::Shunt("3.3")}; - std::vector shunts4 = {dfl::inputs::Shunt("4.1"), dfl::inputs::Shunt("4.2"), dfl::inputs::Shunt("4.3"), dfl::inputs::Shunt("4.4")}; - std::vector shunts5 = {dfl::inputs::Shunt("5.1"), dfl::inputs::Shunt("5.2"), dfl::inputs::Shunt("5.3"), dfl::inputs::Shunt("5.4"), - dfl::inputs::Shunt("5.5")}; + std::vector shunts1 = {dfl::inputs::Shunt("1.1", false)}; + std::vector shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)}; + std::vector shunts3 = {dfl::inputs::Shunt("3.1", false), dfl::inputs::Shunt("3.2", false), dfl::inputs::Shunt("3.3", false)}; + std::vector shunts4 = {dfl::inputs::Shunt("4.1", false), dfl::inputs::Shunt("4.2", false), dfl::inputs::Shunt("4.3", false), + dfl::inputs::Shunt("4.4", false)}; + std::vector shunts5 = {dfl::inputs::Shunt("5.1", false), dfl::inputs::Shunt("5.2", false), dfl::inputs::Shunt("5.3", false), + dfl::inputs::Shunt("5.4", false), dfl::inputs::Shunt("5.5", false)}; std::vector> nodes{ dfl::inputs::Node::build("VL0", vl2, 0.0, {}), dfl::inputs::Node::build("VL1", vl, 1.0, shunts1), dfl::inputs::Node::build("VL2", vl, 2.0, shunts2), dfl::inputs::Node::build("VL3", vl, 3.0, shunts3), dfl::inputs::Node::build("VL4", vl, 4.0, shunts4), dfl::inputs::Node::build("VL5", vl, 5.0, shunts5), diff --git a/tests/inputs/TestNode.cpp b/tests/inputs/TestNode.cpp index a5be85b16..ed0b818a7 100644 --- a/tests/inputs/TestNode.cpp +++ b/tests/inputs/TestNode.cpp @@ -31,8 +31,8 @@ TEST(TestNode, base) { TEST(TestNode, line) { auto vl = std::make_shared("VL"); - std::vector shunts1 = {dfl::inputs::Shunt("1.1")}; - std::vector shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")}; + std::vector shunts1 = {dfl::inputs::Shunt("1.1", false)}; + std::vector shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)}; auto node0 = dfl::inputs::Node::build("0", vl, 0.0, {}); auto node1 = dfl::inputs::Node::build("1", vl, 10., shunts1); auto node2 = dfl::inputs::Node::build("2", vl, 4.5, shunts2); @@ -49,8 +49,6 @@ TEST(TestNode, line) { TEST(TestNode, Tfo) { auto vl = std::make_shared("VL"); - std::vector shunts1 = {dfl::inputs::Shunt("1.1")}; - std::vector shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")}; auto node0 = dfl::inputs::Node::build("0", vl, 0.0, {}); auto node1 = dfl::inputs::Node::build("1", vl, 10., {}); diff --git a/tests/outputs/TestPar.cpp b/tests/outputs/TestPar.cpp index 95005fe66..560943c09 100644 --- a/tests/outputs/TestPar.cpp +++ b/tests/outputs/TestPar.cpp @@ -188,10 +188,10 @@ TEST(TestPar, DynModel) { dfl::algo::ShuntDefinitions shuntsDefinitions; shuntsDefinitions.shunts["VL"].shunts = { - dfl::inputs::Shunt("1"), - dfl::inputs::Shunt("1.1"), + dfl::inputs::Shunt("1", false), + dfl::inputs::Shunt("1.1", false), }; - shuntsDefinitions.shunts["VL2"].shunts = {dfl::inputs::Shunt("2")}; + shuntsDefinitions.shunts["VL2"].shunts = {dfl::inputs::Shunt("2", false)}; dfl::algo::DynamicModelDefinitions defs; dfl::algo::DynamicModelDefinition dynModel("DM_VL61", "DummyLib");