DPsim
SimTerminal.h
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 #pragma once
10 
11 #include <dpsim-models/SimNode.h>
12 #include <dpsim-models/TopologicalTerminal.h>
13 
14 namespace CPS {
15 
16 template <typename VarType>
18  public SharedFactory<SimTerminal<VarType>> {
19 protected:
20  MatrixVar<VarType> mCurrent;
21  std::weak_ptr<SimNode<VarType>> mNode;
22 
23 public:
24  typedef std::shared_ptr<SimTerminal<VarType>> Ptr;
25  typedef std::vector<Ptr> List;
27  SimTerminal(String name) : TopologicalTerminal(name, name) {}
29  SimTerminal(String uid, String name) : TopologicalTerminal(uid, name) {}
31  typename SimNode<VarType>::Ptr node() { return mNode.lock(); }
33  void setNode(typename SimNode<VarType>::Ptr node) {
34  mNode = node;
35  setPhaseType(node->phaseType());
36  }
38  TopologicalNode::Ptr topologicalNodes() { return node(); }
40  VarType singleVoltage() {
41  if (node()->isGround())
42  return 0.;
43  else
44  return node()->singleVoltage(mPhaseType);
45  }
47  MatrixVar<VarType> voltage() {
48  if (node()->isGround())
49  return {0., 0., 0.};
50  else
51  return node()->voltage();
52  }
53 };
54 } // namespace CPS
String uid()
Returns unique id.
TopologicalNode::Ptr topologicalNodes()
Returns reference to TopologicalNode.
Definition: SimTerminal.h:38
PhaseType mPhaseType
Determines the connection between Component and Node.