Skip to content

Commit

Permalink
#216 Use new shunt API
Browse files Browse the repository at this point in the history
  • Loading branch information
Le Courtois Florent committed Oct 5, 2021
1 parent 4c9824b commit 07cd493
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
3 changes: 2 additions & 1 deletion sources/Inputs/include/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion sources/Inputs/src/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ NetworkManager::buildTree() {
std::unordered_map<Node::NodeId, std::vector<Shunt>> 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<VoltageLevel>(networkVL->getID());
Expand Down
30 changes: 16 additions & 14 deletions tests/algo/TestAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,15 @@ TEST(Shunts, base) {
auto vl = std::make_shared<dfl::inputs::VoltageLevel>("VL");
auto vl2 = std::make_shared<dfl::inputs::VoltageLevel>("VL2");
auto vl3 = std::make_shared<dfl::inputs::VoltageLevel>("VL3");
std::vector<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1")};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")};
std::vector<dfl::inputs::Shunt> shunts3 = {dfl::inputs::Shunt("3.1"), dfl::inputs::Shunt("3.2"), dfl::inputs::Shunt("3.3")};
std::vector<dfl::inputs::Shunt> shunts4 = {dfl::inputs::Shunt("4.1"), dfl::inputs::Shunt("4.2"), dfl::inputs::Shunt("4.3"), dfl::inputs::Shunt("4.4")};
std::vector<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1", false)};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)};
std::vector<dfl::inputs::Shunt> shunts3 = {dfl::inputs::Shunt("3.1", false), dfl::inputs::Shunt("3.2", false), dfl::inputs::Shunt("3.3", false)};
std::vector<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> 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<std::shared_ptr<dfl::inputs::Node>> 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),
Expand All @@ -731,12 +732,13 @@ TEST(Shunts, base) {
TEST(LinesByIds, base) {
auto vl = std::make_shared<dfl::inputs::VoltageLevel>("VL");
auto vl2 = std::make_shared<dfl::inputs::VoltageLevel>("VLb");
std::vector<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1")};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")};
std::vector<dfl::inputs::Shunt> shunts3 = {dfl::inputs::Shunt("3.1"), dfl::inputs::Shunt("3.2"), dfl::inputs::Shunt("3.3")};
std::vector<dfl::inputs::Shunt> shunts4 = {dfl::inputs::Shunt("4.1"), dfl::inputs::Shunt("4.2"), dfl::inputs::Shunt("4.3"), dfl::inputs::Shunt("4.4")};
std::vector<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1", false)};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)};
std::vector<dfl::inputs::Shunt> shunts3 = {dfl::inputs::Shunt("3.1", false), dfl::inputs::Shunt("3.2", false), dfl::inputs::Shunt("3.3", false)};
std::vector<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> 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<std::shared_ptr<dfl::inputs::Node>> 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),
Expand Down
13 changes: 7 additions & 6 deletions tests/algo/TestAlgoDynModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ TEST(TestAlgoDynModel, base) {

auto vl = std::make_shared<dfl::inputs::VoltageLevel>("VL");
auto vl2 = std::make_shared<dfl::inputs::VoltageLevel>("VLb");
std::vector<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1")};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")};
std::vector<dfl::inputs::Shunt> shunts3 = {dfl::inputs::Shunt("3.1"), dfl::inputs::Shunt("3.2"), dfl::inputs::Shunt("3.3")};
std::vector<dfl::inputs::Shunt> shunts4 = {dfl::inputs::Shunt("4.1"), dfl::inputs::Shunt("4.2"), dfl::inputs::Shunt("4.3"), dfl::inputs::Shunt("4.4")};
std::vector<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1", false)};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1", false), dfl::inputs::Shunt("2.2", false)};
std::vector<dfl::inputs::Shunt> shunts3 = {dfl::inputs::Shunt("3.1", false), dfl::inputs::Shunt("3.2", false), dfl::inputs::Shunt("3.3", false)};
std::vector<dfl::inputs::Shunt> 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<dfl::inputs::Shunt> 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<std::shared_ptr<dfl::inputs::Node>> 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),
Expand Down
6 changes: 2 additions & 4 deletions tests/inputs/TestNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ TEST(TestNode, base) {

TEST(TestNode, line) {
auto vl = std::make_shared<dfl::inputs::VoltageLevel>("VL");
std::vector<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1")};
std::vector<dfl::inputs::Shunt> shunts2 = {dfl::inputs::Shunt("2.1"), dfl::inputs::Shunt("2.2")};
std::vector<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1", false)};
std::vector<dfl::inputs::Shunt> 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);
Expand All @@ -49,8 +49,6 @@ TEST(TestNode, line) {

TEST(TestNode, Tfo) {
auto vl = std::make_shared<dfl::inputs::VoltageLevel>("VL");
std::vector<dfl::inputs::Shunt> shunts1 = {dfl::inputs::Shunt("1.1")};
std::vector<dfl::inputs::Shunt> 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., {});

Expand Down
6 changes: 3 additions & 3 deletions tests/outputs/TestPar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 07cd493

Please sign in to comment.