DPsim
Loading...
Searching...
No Matches
SystemTopology.cpp
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#include <fstream>
10#include <iomanip>
11#include <iostream>
12#include <unordered_map>
13
20
21using namespace CPS;
22
24 Matrix frequencies(1, 1);
25 frequencies << frequency;
26 return frequencies;
27}
28
30 if (auto nodeComplex = std::dynamic_pointer_cast<SimNode<Complex>>(topNode))
31 nodeComplex->initialize(mFrequencies);
32 if (auto nodeReal = std::dynamic_pointer_cast<SimNode<Real>>(topNode))
33 nodeReal->initialize(mFrequencies);
34
35 mNodes.push_back(topNode);
36}
37
39 if (auto node = std::dynamic_pointer_cast<SimNode<Complex>>(topNode))
40 node->initialize(mFrequencies);
41 if (auto nodeReal = std::dynamic_pointer_cast<SimNode<Real>>(topNode))
42 nodeReal->initialize(mFrequencies);
43
44 if (index > mNodes.capacity())
45 mNodes.resize(index + 1);
46
47 mNodes[index] = topNode;
48}
49
51 for (auto topNode : topNodes)
52 addNode(topNode);
53}
54
56 if (auto powerCompComplex =
57 std::dynamic_pointer_cast<SimPowerComp<Complex>>(component))
58 powerCompComplex->initialize(mFrequencies);
59 if (auto powerCompReal =
60 std::dynamic_pointer_cast<SimPowerComp<Real>>(component))
61 powerCompReal->initialize(mFrequencies);
62
63 mComponents.push_back(component);
64}
65
66template <typename VarType>
69 typename SimNode<VarType>::List simNodes) {
70 component->connect(simNodes);
71 for (auto simNode : simNodes)
72 mComponentsAtNode[simNode].push_back(component);
73}
74
76 // Idempotent: the map is a view derived from mComponents, so rebuild it
77 // from scratch instead of accumulating entries across calls (see #635)
78 mComponentsAtNode.clear();
79 for (auto comp : mComponents) {
80 auto powerComp = std::dynamic_pointer_cast<TopologicalPowerComp>(comp);
81 if (powerComp)
82 for (auto topoNode : powerComp->topologicalNodes())
83 mComponentsAtNode[topoNode].push_back(powerComp);
84 }
85}
86
88 for (auto comp : components)
89 addComponent(comp);
90}
91
93 CPS::Domain domain) {
94
95 for (auto nodePF : systemPF.mNodes) {
96 if (auto node = this->node<TopologicalNode>(nodePF->name())) {
97 //SPDLOG_LOGGER_INFO(mSLog, "Updating initial voltage of {} according to powerflow", node->name());
98 //SPDLOG_LOGGER_INFO(mSLog, "Former initial voltage: {}", node->initialSingleVoltage());
99 node->setInitialVoltage(
100 std::dynamic_pointer_cast<CPS::SimNode<CPS::Complex>>(nodePF)
101 ->singleVoltage());
102 if (domain == CPS::Domain::DP && node->phaseType() == PhaseType::ABC) {
103 if (auto dpNode =
104 std::dynamic_pointer_cast<CPS::SimNode<CPS::Complex>>(node))
105 dpNode->setComplexInitialVoltageScale(RMS3PH_TO_PEAK1PH);
106 }
107 //SPDLOG_LOGGER_INFO(mSLog, "Updated initial voltage: {}", node->initialSingleVoltage());
108 }
109 }
110
111 // set initial power of SG
112 for (auto compPF : systemPF.mComponents) {
113 if (auto genPF = std::dynamic_pointer_cast<CPS::SP::Ph1::SynchronGenerator>(
114 compPF)) {
115 if (domain == CPS::Domain::DP || domain == CPS::Domain::SP) {
116 auto comp = this->component<SimPowerComp<Complex>>(compPF->name());
117 if (!comp)
118 continue;
119 auto terminal = comp->terminals()[0];
120 terminal->setPower(-genPF->getApparentPower());
121 } else if (domain == CPS::Domain::EMT) {
122 auto comp = this->component<SimPowerComp<Real>>(compPF->name());
123 if (!comp)
124 continue;
125 auto terminal = comp->terminals()[0];
126 terminal->setPower(-genPF->getApparentPower());
127 }
128 //SPDLOG_LOGGER_INFO(mSLog, "Updated initial power of gen {}: {}", compPF->name(), genPF->getApparentPower());
129 }
130 }
131
132 // Carry terminal powers into matching dynamic components. Node voltages are
133 // already copied above, but several EMT/DP initializers (for example a
134 // current source) also need the PF terminal P/Q. Without this, their
135 // terminals remain at zero power even though the corresponding PF device
136 // has a non-zero operating point. Keep the dedicated synchronous-generator
137 // sign conversion above authoritative.
138 for (auto compPF : systemPF.mComponents) {
139 if (std::dynamic_pointer_cast<CPS::SP::Ph1::SynchronGenerator>(compPF))
140 continue;
141
142 auto pfPowerComp = std::dynamic_pointer_cast<SimPowerComp<Complex>>(compPF);
143 if (!pfPowerComp)
144 continue;
145
146 SimPowerComp<Complex>::Ptr complexComp;
148 if (domain == CPS::Domain::DP || domain == CPS::Domain::SP)
149 complexComp = this->component<SimPowerComp<Complex>>(compPF->name());
150 else if (domain == CPS::Domain::EMT)
151 realComp = this->component<SimPowerComp<Real>>(compPF->name());
152
153 const auto &pfTerminals = pfPowerComp->terminals();
154 const UInt targetTerminalCount =
155 complexComp ? complexComp->terminals().size()
156 : (realComp ? realComp->terminals().size() : 0);
157 const auto pfLoad =
158 std::dynamic_pointer_cast<CPS::SP::Ph1::Load>(pfPowerComp);
159 const auto pfShunt =
160 std::dynamic_pointer_cast<CPS::SP::Ph1::Shunt>(pfPowerComp);
161 const Bool targetIsEmtShunt =
162 realComp &&
163 static_cast<Bool>(std::dynamic_pointer_cast<EMT::Ph3::Shunt>(realComp));
164 if (domain == CPS::Domain::DP && pfShunt && pfTerminals.size() == 1) {
165 if (auto dpShunt = this->component<CPS::DP::Ph1::Shunt>(compPF->name()))
166 dpShunt->setParameters(**pfShunt->mConductance,
167 **pfShunt->mSusceptance);
168 }
169 UInt targetBusTerminalIdx = 0;
170 Bool targetHasGroundTerminal = false;
171 if (targetTerminalCount == 2) {
172 const auto findGroundTerminal = [](const auto &terminals) {
173 for (UInt terminalIdx = 0; terminalIdx < terminals.size();
174 ++terminalIdx)
175 if (terminals[terminalIdx]->node()->isGround())
176 return terminalIdx;
177 return static_cast<UInt>(terminals.size());
178 };
179 const UInt groundTerminalIdx =
180 complexComp ? findGroundTerminal(complexComp->terminals())
181 : findGroundTerminal(realComp->terminals());
182 targetHasGroundTerminal = groundTerminalIdx < targetTerminalCount;
183 if (targetHasGroundTerminal)
184 targetBusTerminalIdx = 1 - groundTerminalIdx;
185 }
186 const Bool mapsToGroundedTwoTerminalLoad =
187 (pfLoad || pfShunt) && pfTerminals.size() == 1 &&
188 targetTerminalCount == 2 && targetHasGroundTerminal;
189 if (targetTerminalCount != pfTerminals.size() &&
190 !mapsToGroundedTwoTerminalLoad)
191 continue;
192
193 for (UInt terminalIdx = 0; terminalIdx < pfTerminals.size();
194 ++terminalIdx) {
195 const UInt targetTerminalIdx =
196 mapsToGroundedTwoTerminalLoad ? targetBusTerminalIdx : terminalIdx;
197 Complex terminalPower = pfTerminals[terminalIdx]->singlePower();
198 if (pfLoad && pfTerminals.size() == 1) {
199 // A PF load stores consumer-positive P/Q. EMT shunts consume power
200 // through their admittance stamp and therefore need network-injection
201 // sign; load and current-source equivalents use consumer-positive.
202 const Complex loadPower(**pfLoad->mActivePower,
203 **pfLoad->mReactivePower);
204 terminalPower = targetIsEmtShunt ? -loadPower : loadPower;
205 } else if (pfShunt && pfTerminals.size() == 1) {
206 // PF shunts stamp admittance directly and may have no terminal power
207 // recorded. Reconstruct power at the connected bus of a grounded
208 // two-terminal equivalent. Loads use consumer sign;
209 // an EMT shunt expects network-injection sign.
210 const Complex voltage =
211 complexComp ? complexComp->terminals()[targetTerminalIdx]
212 ->initialSingleVoltage()
213 : realComp->terminals()[targetTerminalIdx]
214 ->initialSingleVoltage();
215 const Complex consumerPower =
216 std::norm(voltage) *
217 Complex(**pfShunt->mConductance, -(**pfShunt->mSusceptance));
218 terminalPower = targetIsEmtShunt ? -consumerPower : consumerPower;
219 }
220 if (complexComp)
221 complexComp->terminals()[targetTerminalIdx]->setPower(terminalPower);
222 else
223 realComp->terminals()[targetTerminalIdx]->setPower(terminalPower);
224 }
225 }
226}
227
229 if (auto powerCompComplex =
230 std::dynamic_pointer_cast<SimPowerComp<Complex>>(component))
231 powerCompComplex->initialize(mFrequencies);
232
233 if (auto powerCompReal =
234 std::dynamic_pointer_cast<SimPowerComp<Real>>(component))
235 powerCompReal->initialize(mFrequencies);
236
237 mTearComponents.push_back(component);
238}
239
241 const IdentifiedObject::List &components) {
242 for (auto comp : components)
243 addTearComponent(comp);
244}
245
246template <typename Type>
247typename std::shared_ptr<Type> SystemTopology::node(UInt index) {
248 if (index < mNodes.size()) {
249 auto topoNode = mNodes[index];
250 auto node = std::dynamic_pointer_cast<Type>(topoNode);
251 if (node)
252 return node;
253 }
254
255 return nullptr;
256}
257
258template <typename Type>
259typename std::shared_ptr<Type> SystemTopology::node(std::string_view name) {
260 for (auto topoNode : mNodes) {
261 if (topoNode->name() == name) {
262 auto node = std::dynamic_pointer_cast<Type>(topoNode);
263 if (node)
264 return node;
265 else
266 return nullptr;
267 }
268 }
269 return nullptr;
270}
271
272std::map<String, String, std::less<>> SystemTopology::listIdObjects() const {
273 std::map<String, String, std::less<>> objTypeMap;
274
275 for (auto node : mNodes) {
276 objTypeMap[node->name()] = node->type();
277 }
278 for (auto comp : mComponents) {
279 objTypeMap[comp->name()] = comp->type();
280 }
281 return objTypeMap;
282}
283
284template <typename VarType>
285void SystemTopology::multiplyPowerComps(Int numberCopies) {
286 typename SimNode<VarType>::List newNodes;
287 typename SimPowerComp<VarType>::List newComponents;
288
289 for (int copy = 0; copy < numberCopies; copy++) {
290 std::unordered_map<typename SimNode<VarType>::Ptr,
291 typename SimNode<VarType>::Ptr>
292 nodeMap;
293 String copySuffix = "_" + std::to_string(copy + 2);
294
295 // copy nodes
296 typename SimNode<VarType>::Ptr nodePtr;
297 for (size_t nNode = 0; nNode < mNodes.size(); nNode++) {
298 auto nodePtr = this->node<SimNode<VarType>>(static_cast<UInt>(nNode));
299 if (!nodePtr)
300 continue;
301
302 // GND is not copied
303 if (nodePtr->isGround()) {
304 nodeMap[nodePtr] = nodePtr;
305 } else {
306 auto nodeCpy = SimNode<VarType>::make(nodePtr->name() + copySuffix,
307 nodePtr->phaseType());
308 nodeCpy->setInitialVoltage(nodePtr->initialVoltage());
309 nodeMap[nodePtr] = nodeCpy;
310 newNodes.push_back(nodeCpy);
311 }
312 }
313
314 // copy components
315 for (auto genComp : mComponents) {
316 auto comp = std::dynamic_pointer_cast<SimPowerComp<VarType>>(genComp);
317 if (!comp)
318 continue;
319 auto copy = comp->clone(comp->name() + copySuffix);
320 if (!copy)
321 throw SystemError("copy() not implemented for " + comp->name());
322
323 // map the nodes to their new copies, creating new terminals
324 typename SimNode<VarType>::List nodeCopies;
325 for (UInt nNode = 0; nNode < comp->terminalNumber(); nNode++) {
326 nodeCopies.push_back(nodeMap[comp->node(nNode)]);
327 }
328 copy->connect(nodeCopies);
329
330 // update the terminal powers for powerflow initialization
331 for (UInt nTerminal = 0; nTerminal < comp->terminalNumber();
332 nTerminal++) {
333 copy->terminal(nTerminal)->setPower(comp->terminal(nTerminal)->power());
334 }
335 newComponents.push_back(copy);
336 }
337 }
338 for (auto node : newNodes)
339 addNode(node);
340 for (auto comp : newComponents)
341 addComponent(comp);
342}
343
345 // SimPowerComps should be all EMT or all DP anyway, but this way we don't have to look
346 multiplyPowerComps<Real>(numCopies);
347 multiplyPowerComps<Complex>(numCopies);
348}
349
352 // for (auto c : mComponents) {
353 // c->reset();
354 // }
355}
356
358 for (auto it = mComponents.begin(); it != mComponents.end();) {
359 if ((*it)->name() == name) {
360 // mComponentsAtNode needs no manual cleanup here: it is rebuilt from
361 // mComponents by componentsAtNodeList() wherever it is consumed (#635)
362 it = mComponents.erase(
363 it); // safe: returns next valid iterator when erasing
364 } else {
365 ++it;
366 }
367 }
368}
369
372static bool isConnectedTo(const IdentifiedObject::Ptr &comp,
373 const TopologicalNode::Ptr &node) {
374 auto powerComp = std::dynamic_pointer_cast<TopologicalPowerComp>(comp);
375 if (!powerComp)
376 return false;
377
378 // Terminals may not be connected yet
379 const auto terminals = powerComp->topologicalTerminals();
380 return std::any_of(terminals.begin(), terminals.end(),
381 [&node](const TopologicalTerminal::Ptr &terminal) {
382 return terminal && terminal->topologicalNodes() == node;
383 });
384}
385
386void SystemTopology::removeComponentsConnectedTo(
387 const TopologicalNode::Ptr &node) {
388 IdentifiedObject::List removedComponents;
389
390 for (auto it = mComponents.begin(); it != mComponents.end();) {
391 if (isConnectedTo(*it, node)) {
392 removedComponents.push_back(*it);
393 it = mComponents.erase(it);
394 } else {
395 ++it;
396 }
397 }
398
399 // mComponentsAtNode needs no manual cleanup here: it is rebuilt from
400 // mComponents by componentsAtNodeList() wherever it is consumed (#635)
401 for (const auto &removed : removedComponents) {
402 mTearComponents.erase(
403 std::remove(mTearComponents.begin(), mTearComponents.end(), removed),
404 mTearComponents.end());
405 }
406}
407
409 for (auto it = mNodes.begin(); it != mNodes.end();) {
410 // The ground node is the network reference and must never be removed
411 if ((*it)->name() == name && !(*it)->isGround()) {
412 removeComponentsConnectedTo(*it);
413 it = mNodes.erase(it);
414 } else {
415 ++it;
416 }
417 }
418}
419
420template <typename VarType>
421void SystemTopology::splitSubnets(std::vector<SystemTopology> &splitSystems) {
422 std::unordered_map<typename SimNode<VarType>::Ptr, int> subnet;
423 int numberSubnets = checkTopologySubnets<VarType>(subnet);
424 if (numberSubnets == 1) {
425 splitSystems.push_back(*this);
426 } else {
427 std::vector<IdentifiedObject::List> components(numberSubnets);
428 std::vector<TopologicalNode::List> nodes(numberSubnets);
429
430 // Split nodes into subnet groups
431 for (auto node : mNodes) {
432 auto pnode = std::dynamic_pointer_cast<SimNode<VarType>>(node);
433 if (!pnode || node->isGround())
434 continue;
435
436 nodes[subnet[pnode]].push_back(node);
437 }
438
439 // Split components into subnet groups
440 for (auto comp : mComponents) {
441 auto pcomp = std::dynamic_pointer_cast<SimPowerComp<VarType>>(comp);
442 if (!pcomp) {
443 // TODO this should only be signal components.
444 // Proper solution would be to pass them to a different "solver"
445 // since they are actually independent of which solver we use
446 // for the electric part.
447 // Just adding them to an arbitrary solver for now has the same effect.
448 components[0].push_back(comp);
449 continue;
450 }
451 for (UInt nodeIdx = 0; nodeIdx < pcomp->terminalNumber(); nodeIdx++) {
452 if (!pcomp->node(nodeIdx)->isGround()) {
453 components[subnet[pcomp->node(nodeIdx)]].push_back(comp);
454 break;
455 }
456 }
457 }
458 for (int currentNet = 0; currentNet < numberSubnets; currentNet++) {
459 splitSystems.emplace_back(mSystemFrequency, mFrequencies,
460 nodes[currentNet], components[currentNet]);
461 }
462 }
463}
464
465template <typename VarType>
467 std::unordered_map<typename SimNode<VarType>::Ptr, int> &subnet) {
468 std::unordered_map<typename SimNode<VarType>::Ptr,
469 typename SimNode<VarType>::List>
470 neighbours;
471
472 for (auto comp : mComponents) {
473 auto pcomp = std::dynamic_pointer_cast<SimPowerComp<VarType>>(comp);
474 if (!pcomp)
475 continue;
476
477 for (UInt nodeIdx1 = 0; nodeIdx1 < pcomp->terminalNumberConnected();
478 nodeIdx1++) {
479 for (UInt nodeIdx2 = 0; nodeIdx2 < nodeIdx1; nodeIdx2++) {
480 auto node1 = pcomp->node(nodeIdx1);
481 auto node2 = pcomp->node(nodeIdx2);
482 if (node1->isGround() || node2->isGround())
483 continue;
484
485 neighbours[node1].push_back(node2);
486 neighbours[node2].push_back(node1);
487 }
488 }
489 }
490
491 int currentNet = 0;
492 size_t totalNodes = mNodes.size();
493 for (auto tnode : mNodes) {
494 auto node = std::dynamic_pointer_cast<SimNode<VarType>>(tnode);
495 if (!node || tnode->isGround()) {
496 totalNodes--;
497 }
498 }
499
500 while (subnet.size() != totalNodes) {
501 std::list<typename SimNode<VarType>::Ptr> nextSet;
502
503 for (auto tnode : mNodes) {
504 auto node = std::dynamic_pointer_cast<SimNode<VarType>>(tnode);
505 if (!node || tnode->isGround())
506 continue;
507
508 if (subnet.find(node) == subnet.end()) {
509 nextSet.push_back(node);
510 break;
511 }
512 }
513 while (!nextSet.empty()) {
514 auto node = nextSet.front();
515 nextSet.pop_front();
516
517 subnet[node] = currentNet;
518 for (auto neighbour : neighbours[node]) {
519 if (subnet.find(neighbour) == subnet.end())
520 nextSet.push_back(neighbour);
521 }
522 }
523 currentNet++;
524 }
525 return currentNet;
526}
527
528#ifdef WITH_GRAPHVIZ
529
530Graph::Graph SystemTopology::topologyGraph() {
531 Graph::Node *n, *c;
532
534
535 g.set("splines", "polyline");
536
537 for (auto node : mNodes) {
538 n = g.addNode(node->uid());
539
540 std::stringstream label, tooltip;
541
542 tooltip << node->uid();
543
544 label << "<FONT POINT-SIZE=\"12\"><B>" << node->name()
545 << "</B></FONT><BR/>";
546
547 double phase = 180.0 / M_PI * std::arg(node->initialSingleVoltage());
548 double mag = std::abs(node->initialSingleVoltage());
549
550 const char *suffixes[] = {"", "k", "M", "G"};
551
552 int s;
553 for (s = 0; s < 3 && mag > 1000; s++)
554 mag *= 1e-3;
555
556 if (node->initialSingleVoltage() != Complex(0, 0)) {
557 label << std::setprecision(2) << std::fixed;
558 label << "<FONT POINT-SIZE=\"10\" COLOR=\"gray28\">";
559 label << "(" << mag << " " << suffixes[s] << "V &gt; " << phase << "°)";
560 label << "</FONT>";
561 }
562
563 n->set("xlabel", label.str(), true);
564 n->set("tooltip", tooltip.str(), true);
565 n->set("fillcolor", phase == 0 ? "red" : "black");
566 n->set("fixedsize", "true");
567 n->set("width", "0.15");
568 n->set("height", "0.15");
569 n->set("shape", "point");
570 }
571
572 std::map<String, String> compColorMap;
573
574 for (auto comp : mComponents) {
575 if (!comp) // TODO: this is a bug in the CIM::Reader!
576 continue;
577
579
580 if (!(topoComp = std::dynamic_pointer_cast<TopologicalPowerComp>(comp)))
581 continue;
582
583 c = g.addNode(topoComp->uid());
584
585 auto type = topoComp->type();
586 auto name = topoComp->name();
587
588 std::stringstream label, tooltip;
589
590 label << "<FONT POINT-SIZE=\"12\"><B>" << name << "</B></FONT><BR/>";
591 label << "<FONT POINT-SIZE=\"10\" COLOR=\"gray28\">" << type
592 << "</FONT><BR/>";
593 if (topoComp->description() != "") {
594 label << "<FONT POINT-SIZE=\"10\" COLOR=\"gray28\">"
595 << topoComp->description() << "</FONT>";
596 }
597
598 tooltip << "Attributes:";
599 for (auto it : topoComp->attributes()) {
600 tooltip << std::endl << it.first << ": " << it.second->toString();
601 }
602
603 if (compColorMap.find(type) != compColorMap.end()) {
604 compColorMap[type] =
605 String("/paired9/") + std::to_string(1 + compColorMap.size() % 9);
606 }
607
608 c->set("color", compColorMap[type]);
609 c->set("label", label.str(), true);
610 c->set("tooltip", tooltip.str(), true);
611 c->set("style", "rounded,filled,bold");
612
613 if (type.find("Line") == std::string::npos) {
614 c->set("shape", "rectangle");
615 c->set("fillcolor", "gray93");
616 } else {
617 c->set("shape", "plaintext");
618 c->set("fillcolor", "transparent");
619 }
620
621 for (auto term : topoComp->topologicalTerminals()) {
622 n = g.node(term->topologicalNodes()->uid());
623 if (!n)
624 continue;
625
626 g.addEdge(term->uid(), c, n);
627 }
628 }
629
630 return g;
631}
632
633String SystemTopology::render() {
634 auto graph = this->topologyGraph();
635 std::stringstream ss;
636 graph.render(ss, "neato", "svg");
637
638 return ss.str();
639}
640
641void SystemTopology::renderToFile(String filename) {
642 std::ofstream ofstr(filename);
643 this->topologyGraph().render(ofstr, "neato", "svg");
644}
645#endif
646
647// Explicit instantiation of template functions to be able to keep the definition in the cpp
648template void SystemTopology::multiplyPowerComps<Real>(Int numberCopies);
649template void SystemTopology::multiplyPowerComps<Complex>(Int numberCopies);
650template std::shared_ptr<TopologicalNode>
652template std::shared_ptr<TopologicalNode>
653SystemTopology::node<TopologicalNode>(std::string_view name);
654template std::shared_ptr<SimNode<Real>>
656template std::shared_ptr<SimNode<Complex>>
658template std::shared_ptr<SimNode<Real>>
659SystemTopology::node<SimNode<Real>>(std::string_view name);
660template std::shared_ptr<SimNode<Complex>>
661SystemTopology::node<SimNode<Complex>>(std::string_view name);
663 typename SimPowerComp<Real>::Ptr component,
664 typename SimNode<Real>::List simNodes);
666 typename SimPowerComp<Complex>::Ptr component,
667 typename SimNode<Complex>::List simNodes);
669 std::unordered_map<typename CPS::SimNode<Real>::Ptr, int> &subnet);
671 std::unordered_map<typename CPS::SimNode<Complex>::Ptr, int> &subnet);
673 std::vector<CPS::SystemTopology> &splitSystems);
675 std::vector<CPS::SystemTopology> &splitSystems);
static bool isConnectedTo(const IdentifiedObject::Ptr &comp, const TopologicalNode::Ptr &node)
void set(const String &key, const String &value, bool html=false)
Definition Graph.cpp:82
std::shared_ptr< IdentifiedObject > Ptr
std::vector< Ptr > List
std::shared_ptr< SimNode< VarType > > Ptr
Definition SimNode.h:34
std::vector< Ptr > List
Definition SimNode.h:35
Base class for all components that are transmitting power.
SimTerminal< VarType >::List terminals()
Return list of Terminal pointers.
std::vector< Ptr > List
std::shared_ptr< SimPowerComp< VarType > > Ptr
void removeNode(const String &name)
Remove node and all components connected to it.
void addNodes(const TopologicalNode::List &topNodes)
Add multiple nodes.
Real mSystemFrequency
System frequency.
IdentifiedObject::List mComponents
List of network components.
static Matrix initFrequency(Real frequency)
std::shared_ptr< Type > node(UInt index)
Returns TopologicalNode by index in node list.
void initWithPowerflow(const SystemTopology &systemPF, CPS::Domain domain)
Initialize nodes and SG power from PowerFlow.
void removeComponent(const String &name)
Remove system component.
void addNode(TopologicalNode::Ptr topNode)
Adds node and initializes frequencies.
std::map< String, String, std::less<> > listIdObjects() const
void addTearComponent(IdentifiedObject::Ptr component)
Adds component and initializes frequencies.
std::shared_ptr< Type > component(const String &name)
Returns Component by name.
TopologicalNode::List mNodes
List of network nodes.
void reset()
Reset state of components.
void addNodeAt(TopologicalNode::Ptr topNode, UInt index)
Adds node at specified position and initializes frequencies.
void addComponents(const IdentifiedObject::List &components)
Add multiple components.
Matrix mFrequencies
List of considered network frequencies.
void connectComponentToNodes(typename SimPowerComp< VarType >::Ptr component, typename SimNode< VarType >::List simNodes)
Connect component to simNodes.
void addComponent(IdentifiedObject::Ptr component)
Adds component and initializes frequencies.
void multiply(Int numberCopies)
Copy the whole topology the given number of times and add the resulting components and nodes to the t...
void splitSubnets(std::vector< CPS::SystemTopology > &splitSystems)
IdentifiedObject::List mTearComponents
SystemTopology()
Do not use this constructor.
void addTearComponents(const IdentifiedObject::List &components)
Add multiple components.
int checkTopologySubnets(std::unordered_map< typename CPS::SimNode< VarType >::Ptr, int > &subnet)
std::map< TopologicalNode::Ptr, TopologicalPowerComp::List > mComponentsAtNode
Map of network components connected to network nodes.
std::vector< Ptr > List
PhaseType phaseType() const
std::shared_ptr< TopologicalNode > Ptr
MatrixComp initialVoltage() const
std::shared_ptr< TopologicalPowerComp > Ptr
std::shared_ptr< TopologicalTerminal > Ptr
static std::shared_ptr< SimNode< VarType > > make(Args &&...args)
Definition PtrFactory.h:19
#define RMS3PH_TO_PEAK1PH
Definition Definitions.h:50
#define M_PI
Definition Definitions.h:41
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:79
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
std::complex< Real > Complex
Definition Definitions.h:61
bool Bool
Definition Definitions.h:62
unsigned int UInt
Definition Definitions.h:58