5 #include <dpsim-models/MNAStampUtils.h>
6 #include <dpsim-models/SimPowerComp.h>
7 #include <dpsim-models/Solver/MNAInterface.h>
12 template <
typename VarType>
21 using Ptr = std::shared_ptr<MNASimPowerComp<VarType>>;
22 using List = std::vector<Ptr>;
33 Logger::Level logLevel)
35 mHasPostStep(hasPostStep),
41 Bool hasPostStep =
true,
42 Logger::Level logLevel = Logger::Level::off)
57 void mnaPreStep(Real time, Int timeStepCount)
final;
58 void mnaPostStep(Real time, Int timeStepCount,
61 AttributeBase::List &attributeDependencies,
62 AttributeBase::List &modifiedAttributes)
final;
63 void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
64 AttributeBase::List &attributeDependencies,
65 AttributeBase::List &modifiedAttributes,
67 void mnaInitializeHarm(Real omega, Real timeStep,
76 virtual void mnaCompInitialize(Real omega, Real timeStep,
78 virtual void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
79 virtual void mnaCompApplyRightSideVectorStamp(Matrix &rightVector);
80 virtual void mnaCompUpdateVoltage(
const Matrix &leftVector);
81 virtual void mnaCompUpdateCurrent(
const Matrix &leftVector);
82 virtual void mnaCompPreStep(Real time, Int timeStepCount);
83 virtual void mnaCompPostStep(Real time, Int timeStepCount,
86 mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies,
87 AttributeBase::List &attributeDependencies,
88 AttributeBase::List &modifiedAttributes);
90 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
91 AttributeBase::List &attributeDependencies,
92 AttributeBase::List &modifiedAttributes,
95 mnaCompInitializeHarm(Real omega, Real timeStep,
97 virtual void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix,
99 virtual void mnaCompApplyRightSideVectorStampHarm(Matrix &sourceVector);
100 virtual void mnaCompApplyRightSideVectorStampHarm(Matrix &sourceVector,
103 const Task::List &
mnaTasks() const final;
104 Attribute<Matrix>::Ptr getRightVector() const final;
109 :
Task(**comp.
mName +
".MnaPreStep"), mComp(comp) {
110 mComp.mnaAddPreStepDependencies(
111 mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
113 void execute(Real time, Int timeStepCount)
override {
114 mComp.mnaPreStep(time, timeStepCount);
125 :
Task(**comp.
mName +
".MnaPostStep"), mComp(comp),
126 mLeftVector(leftVector) {
127 mComp.mnaAddPostStepDependencies(mPrevStepDependencies,
128 mAttributeDependencies,
129 mModifiedAttributes, mLeftVector);
131 void execute(Real time, Int timeStepCount)
override {
132 mComp.mnaPostStep(time, timeStepCount, mLeftVector);
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
Interface to be implemented by all models used by the MNA solver.
Base class for all MNA components that are transmitting power.
void mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) final
Add MNA pre step dependencies.
virtual ~MNASimPowerComp()=default
Destructor - does not do anything.
Task::List mMnaTasks
List of tasks that relate to using MNA for this component (usually pre-step and/or post-step)
void mnaApplyRightSideVectorStampHarm(Matrix &sourceVector) final
Stamps right side (source) vector considering the frequency index.
void mnaApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) final
Stamps system matrix.
void mnaUpdateCurrent(const Matrix &leftVector) final
Update interface current from MNA system result.
void mnaUpdateVoltage(const Matrix &leftVector) final
Update interface voltage from MNA system result.
const Task::List & mnaTasks() const final
Return list of MNA tasks.
void mnaInitialize(Real omega, Real timeStep) final
Initializes variables of components.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Basic constructor that takes UID, name and log level.
Attribute< Matrix >::Ptr mRightVector
MNASimPowerComp(String name, Bool hasPreStep=true, Bool hasPostStep=true, Logger::Level logLevel=Logger::Level::off)
Basic constructor that takes name and log level and sets the UID to name as well.
void mnaPreStep(Real time, Int timeStepCount) final
MNA pre step operations.
void mnaApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix, Int freqIdx) final
Stamps system matrix considering the frequency index.
void mnaApplyRightSideVectorStamp(Matrix &rightVector) final
Stamps right side (source) vector.
Base class for all components that are transmitting power.
Tasks to be defined by every component.