11 #include <dpsim-models/Task.h>
12 #include <dpsim-models/TopologicalNode.h>
16 template <
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);
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;
124 template <
typename VarType>
125 typename SimNode<VarType>::Ptr SimNode<VarType>::GND = SimNode<VarType>::make();
127 template <>
void SimNode<Real>::mnaUpdateVoltage(
const Matrix &leftVector);
129 template <>
void SimNode<Complex>::mnaUpdateVoltage(
const Matrix &leftVector);
132 void SimNode<Complex>::mnaInitializeHarm(
133 std::vector<Attribute<Matrix>::Ptr> leftVector);
135 template <>
void SimNode<Complex>::setVoltage(Complex newVoltage);
137 template <>
void SimNode<Complex>::setPower(Complex newPower);
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeBase::Ptr attribute(const String &name) const
Return pointer to an attribute.
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.
const Attribute< MatrixVar< VarType > >::Ptr mApparentPower
Power injected at node.
void initialize()
Initialize mVoltage according to mInitialVoltage.
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
Returns matrix index for specified phase.
UInt mNumFreqs
Number of harmonics.
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(UInt matrixNodeIndex, PhaseType phaseType=PhaseType::Single)
Matrix mFrequencies
List of considered network harmonics.
Tasks to be defined by every component.