3 #include <dpsim-models/CompositePowerComp.h>
7 template <
typename VarType>
9 typename SimPowerComp<VarType>::Ptr subc,
10 MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder,
11 Bool contributeToRightVector) {
12 this->mSubComponents.push_back(subc);
15 this->mSubcomponentsMNA.push_back(mnasubcomp);
17 if (contributeToRightVector) {
18 this->mRightVectorStamps.push_back(mnasubcomp->mRightVector);
21 switch (preStepOrder) {
22 case MNA_SUBCOMP_TASK_ORDER::NO_TASK:
24 case MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT: {
25 this->mSubcomponentsBeforePreStep.push_back(mnasubcomp);
28 case MNA_SUBCOMP_TASK_ORDER::TASK_AFTER_PARENT: {
29 this->mSubcomponentsAfterPreStep.push_back(mnasubcomp);
33 switch (postStepOrder) {
34 case MNA_SUBCOMP_TASK_ORDER::NO_TASK:
36 case MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT: {
37 this->mSubcomponentsBeforePostStep.push_back(mnasubcomp);
40 case MNA_SUBCOMP_TASK_ORDER::TASK_AFTER_PARENT: {
41 this->mSubcomponentsAfterPostStep.push_back(mnasubcomp);
48 template <
typename VarType>
53 for (
auto subComp : mSubcomponentsMNA) {
54 subComp->mnaInitialize(omega, timeStep, leftVector);
57 **this->mRightVector = Matrix::Zero(leftVector->
get().rows(), 1);
59 mnaParentInitialize(omega, timeStep, leftVector);
62 template <
typename VarType>
64 SparseMatrixRow &systemMatrix) {
65 for (
auto subComp : mSubcomponentsMNA) {
66 subComp->mnaApplySystemMatrixStamp(systemMatrix);
68 mnaParentApplySystemMatrixStamp(systemMatrix);
71 template <
typename VarType>
73 Matrix &rightVector) {
74 rightVector.setZero();
75 for (
auto stamp : mRightVectorStamps) {
76 if ((**stamp).size() != 0) {
77 rightVector += **stamp;
80 mnaParentApplyRightSideVectorStamp(rightVector);
83 template <
typename VarType>
85 for (
auto subComp : mSubcomponentsBeforePreStep) {
86 subComp->mnaPreStep(time, timeStepCount);
88 mnaParentPreStep(time, timeStepCount);
89 for (
auto subComp : mSubcomponentsAfterPreStep) {
90 subComp->mnaPreStep(time, timeStepCount);
94 template <
typename VarType>
97 for (
auto subComp : mSubcomponentsBeforePostStep) {
98 subComp->mnaPostStep(time, timeStepCount, leftVector);
100 mnaParentPostStep(time, timeStepCount, leftVector);
101 for (
auto subComp : mSubcomponentsAfterPostStep) {
102 subComp->mnaPostStep(time, timeStepCount, leftVector);
106 template <
typename VarType>
108 AttributeBase::List &prevStepDependencies,
109 AttributeBase::List &attributeDependencies,
110 AttributeBase::List &modifiedAttributes) {
111 for (
auto subComp : mSubcomponentsMNA) {
112 subComp->mnaAddPreStepDependencies(
113 prevStepDependencies, attributeDependencies, modifiedAttributes);
115 mnaParentAddPreStepDependencies(prevStepDependencies, attributeDependencies,
119 template <
typename VarType>
121 AttributeBase::List &prevStepDependencies,
122 AttributeBase::List &attributeDependencies,
123 AttributeBase::List &modifiedAttributes,
125 for (
auto subComp : mSubcomponentsMNA) {
126 subComp->mnaAddPostStepDependencies(prevStepDependencies,
127 attributeDependencies,
128 modifiedAttributes, leftVector);
130 mnaParentAddPostStepDependencies(prevStepDependencies, attributeDependencies,
131 modifiedAttributes, leftVector);
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes variables of components.
void addMNASubComponent(typename SimPowerComp< VarType >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
Add a new subcomponent implementing MNA methods.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
Base class for all MNA components that are transmitting power.
void updateMatrixNodeIndices()
Update the "cached" mMatrixNodeIndices and mMatrixNodeIndexIsGround members.