11#include <dpsim-models/Task.h>
12#include <dpsim-models/TopologicalNode.h>
16template <
typename VarType>
18 public std::enable_shared_from_this<SimNode<VarType>>,
22 std::vector<UInt> mMatrixNodeIndex = {0};
32 typedef std::shared_ptr<SimNode<VarType>> Ptr;
33 typedef std::vector<Ptr> List;
44 PhaseType phaseType,
const std::vector<Complex> &initialVoltage);
46 SimNode(PhaseType phaseType = PhaseType::Single);
49 SimNode(String name, PhaseType phaseType = PhaseType::Single,
50 const std::vector<Complex> &initialVoltage = {0, 0, 0})
51 :
SimNode(name, name, {0, 0, 0}, phaseType, initialVoltage) {}
55 PhaseType phaseType = PhaseType::Single,
56 const std::vector<Complex> &initialVoltage = {0, 0, 0})
59 phaseType, initialVoltage) {}
67 std::shared_ptr<TopologicalNode> clone(String name);
78 VarType singleVoltage(PhaseType phaseType = PhaseType::Single);
80 MatrixVar<VarType> voltage();
84 void setVoltage(VarType newVoltage) {}
86 void setPower(VarType newPower) {}
90 void mnaUpdateVoltage(
const Matrix &leftVector);
92 void mnaInitializeHarm(std::vector<Attribute<Matrix>::Ptr> leftVector);
94 void mnaUpdateVoltageHarm(
const Matrix &leftVector, Int freqIdx);
98 class MnaPostStepHarm :
public Task {
101 const std::vector<Attribute<Matrix>::Ptr> &leftVectors)
102 : Task(**node.
mName +
".MnaPostStepHarm"), mNode(node),
103 mLeftVectors(leftVectors) {
104 for (UInt i = 0; i < mLeftVectors.size(); i++)
105 mAttributeDependencies.push_back(mLeftVectors[i]);
106 mModifiedAttributes.push_back(mNode.attribute(
"v"));
108 void execute(Real time, Int timeStepCount);
112 std::vector<Attribute<Matrix>::Ptr> mLeftVectors;
123typedef CPS::SimNode<Real> SimNode;
126template <
typename VarType>
127typename SimNode<VarType>::Ptr SimNode<VarType>::GND = SimNode<VarType>::make();
129template <>
void SimNode<Real>::mnaUpdateVoltage(
const Matrix &leftVector);
131template <>
void SimNode<Complex>::mnaUpdateVoltage(
const Matrix &leftVector);
134void SimNode<Complex>::mnaInitializeHarm(
135 std::vector<Attribute<Matrix>::Ptr> leftVector);
137template <>
void SimNode<Complex>::setVoltage(Complex newVoltage);
139template <>
void SimNode<Complex>::setPower(Complex newPower);
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
SimNode(String uid, String name, std::vector< UInt > matrixNodeIndex, PhaseType phaseType, const std::vector< Complex > &initialVoltage)
This very general constructor is used by other constructors.
void initialize()
Initialize mVoltage according to mInitialVoltage.
void initialize(Matrix frequencies)
Initialize state matrices with size according to phase type and frequency number.
const Task::List & mnaTasks()
Return list of MNA tasks.
SimNode(String uid, String name, UInt matrixNodeIndex, PhaseType phaseType=PhaseType::Single, const std::vector< Complex > &initialVoltage={0, 0, 0})
UInt matrixNodeIndex(PhaseType phaseType=PhaseType::Single) override
std::vector< UInt > matrixNodeIndices() override
Returns all matrix indices.
SimNode(String name, PhaseType phaseType=PhaseType::Single, const std::vector< Complex > &initialVoltage={0, 0, 0})
SimNode(PhaseType phaseType=PhaseType::Single)
Create ground node if no parameters are given.
SimNode(UInt matrixNodeIndex, PhaseType phaseType=PhaseType::Single)
const Attribute< MatrixVar< Complex > >::Ptr mApparentPower