13template <
typename VarType>
33template <
typename VarType>
35 :
SimNode(
"gnd",
"gnd", {0, 0, 0}, phaseType, {0, 0, 0}) {
37 **mInitialVoltage = MatrixComp::Zero(3, 1);
49 (**mVoltage)(0, 0) = (**mInitialVoltage)(0, 0);
51 (**mVoltage)(1, 0) = (**mInitialVoltage)(1, 0);
52 (**mVoltage)(2, 0) = (**mInitialVoltage)(2, 0);
56template <
typename VarType>
64template <
typename VarType>
71template <
typename VarType>
81template <
typename VarType>
97template <
typename VarType>
113template <
typename VarType>
123 (**mVoltage)(0, 0) = newVoltage;
127 (**mApparentPower)(0, 0) = newPower;
131 if (mMatrixNodeIndex[0] >= 0)
135 if (mMatrixNodeIndex[1] >= 0)
138 if (mMatrixNodeIndex[2] >= 0)
145 for (
UInt freq = 0; freq < mNumFreqs; freq++) {
146 if (mMatrixNodeIndex[0] >= 0)
148 leftVector, mMatrixNodeIndex[0], mNumFreqs, freq);
150 if (mMatrixNodeIndex[1] >= 0)
152 leftVector, mMatrixNodeIndex[1], mNumFreqs, freq);
153 if (mMatrixNodeIndex[2] >= 0)
155 leftVector, mMatrixNodeIndex[2], mNumFreqs, freq);
167 if (mMatrixNodeIndex[0] >= 0)
168 (**mVoltage)(0, freqIdx) =
171 if (mMatrixNodeIndex[1] >= 0)
172 (**mVoltage)(1, freqIdx) =
174 if (mMatrixNodeIndex[2] >= 0)
175 (**mVoltage)(2, freqIdx) =
187 mMnaTasks = {std::make_shared<MnaPostStepHarm>(*
this, leftVectors)};
192 for (
UInt freq = 0; freq < mNode.mNumFreqs; freq++)
193 mNode.mnaUpdateVoltageHarm(**mLeftVectors[freq], freq);
199template class CPS::SimNode<Real>;
200template class CPS::SimNode<Complex>;
AttributePointer< Attribute< T > > Ptr
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
void execute(Real time, Int timeStepCount)
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 mnaUpdateVoltage(const Matrix &leftVector)
void setVoltage(VarType newVoltage)
void initialize()
Initialize mVoltage according to mInitialVoltage.
void setPower(VarType newPower)
std::shared_ptr< TopologicalNode > clone(String name)
const Task::List & mnaTasks()
Return list of MNA tasks.
UInt matrixNodeIndex(PhaseType phaseType=PhaseType::Single) override
Returns matrix index for specified phase.
MatrixVar< VarType > voltage()
void setMatrixNodeIndex(UInt phase, UInt matrixNodeIndex) override
const Attribute< MatrixVar< VarType > >::Ptr mVoltage
UInt mNumFreqs
Number of harmonics.
VarType singleVoltage(PhaseType phaseType=PhaseType::Single)
std::vector< UInt > matrixNodeIndices() override
Returns all matrix indices.
void mnaUpdateVoltageHarm(const Matrix &leftVector, Int freqIdx)
void mnaInitializeHarm(std::vector< Attribute< Matrix >::Ptr > leftVector)
const Attribute< MatrixVar< VarType > >::Ptr mApparentPower
Power injected at node.
Matrix mFrequencies
List of considered network harmonics.
std::vector< UInt > mMatrixNodeIndex
const Attribute< MatrixComp >::Ptr mInitialVoltage
PhaseType phaseType() const
MatrixComp initialVoltage() const
static std::shared_ptr< SimNode< VarType > > make(Args &&...args)
#define RMS3PH_TO_PEAK1PH
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Eigen::Matrix< VarType, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixVar
std::complex< Real > Complex