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) {}
76 VarType singleVoltage(PhaseType phaseType = PhaseType::Single);
78 MatrixVar<VarType> voltage();
82 void setVoltage(VarType newVoltage) {}
84 void setPower(VarType newPower) {}
88 void mnaUpdateVoltage(
const Matrix &leftVector);
90 void mnaInitializeHarm(std::vector<Attribute<Matrix>::Ptr> leftVector);
92 void mnaUpdateVoltageHarm(
const Matrix &leftVector, Int freqIdx);
96 class MnaPostStepHarm :
public Task {
99 const std::vector<Attribute<Matrix>::Ptr> &leftVectors)
100 : Task(**node.
mName +
".MnaPostStepHarm"), mNode(node),
101 mLeftVectors(leftVectors) {
102 for (UInt i = 0; i < mLeftVectors.size(); i++)
103 mAttributeDependencies.push_back(mLeftVectors[i]);
104 mModifiedAttributes.push_back(mNode.attribute(
"v"));
106 void execute(Real time, Int timeStepCount);
110 std::vector<Attribute<Matrix>::Ptr> mLeftVectors;
121typedef CPS::SimNode<Real> SimNode;
124template <
typename VarType>
125typename SimNode<VarType>::Ptr SimNode<VarType>::GND = SimNode<VarType>::make();
127template <>
void SimNode<Real>::mnaUpdateVoltage(
const Matrix &leftVector);
129template <>
void SimNode<Complex>::mnaUpdateVoltage(
const Matrix &leftVector);
132void SimNode<Complex>::mnaInitializeHarm(
133 std::vector<Attribute<Matrix>::Ptr> leftVector);
135template <>
void SimNode<Complex>::setVoltage(Complex newVoltage);
137template <>
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