DPsim
Loading...
Searching...
No Matches
EMT_SSNComp.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include <array>
7#include <vector>
8
11
12namespace CPS {
13namespace EMT {
14
24class SSNComp : public MNASimPowerComp<Real> {
25private:
26 const Int mInputSize;
27 const Int mOutputSize;
28
29protected:
31
37
44
47
49 const Matrix *mXValue = nullptr;
50 const Matrix *mInputValue = nullptr;
53 std::vector<UInt> mRightVectorAffectedIndices;
54
55 const Matrix &stateValue() const { return *mXValue; }
56 const Matrix &inputValue() const { return *mInputValue; }
57
58 SSNComp(String uid, String name, Int inputSize, Int outputSize,
59 Logger::Level logLevel = Logger::Level::off);
60
61 virtual void calculateHistoryVector(Matrix &history) const;
62
64 Real frequency) const;
65 virtual MatrixComp
67 const MatrixComp &u) const;
68
69 virtual void updateState(const Matrix &uOld, const Matrix &uNew);
70
72 virtual void updateLogAttributes(const Matrix &u) const;
73
74 virtual void recomputeDiscreteModel();
75
77 virtual void updateStateSpaceModel();
78
81
82public:
85 std::array<UInt, 3> indices;
86
92 };
93
95 UInt getStateCount() const;
96
104 virtual std::vector<String> getLocalStateNames() const;
105
110 virtual std::vector<LocalAbcStateBlock> getLocalAbcStateBlocks() const;
111
113 const Matrix &getDiscreteA() const;
114
116 const Matrix &getDiscreteB() const;
117
119 const Matrix &getC() const;
120
121 void setParameters(const Matrix &A, const Matrix &B, const Matrix &C,
122 const Matrix &D, const Matrix &D1 = Matrix());
123
124 void mnaCompInitialize(Real omega, Real timeStep,
125 Attribute<Matrix>::Ptr leftVector) override final;
126
128 AttributeBase::List &prevStepDependencies,
129 AttributeBase::List &attributeDependencies,
130 AttributeBase::List &modifiedAttributes) override final;
131
132 void mnaCompPreStep(Real time, Int timeStepCount) override final;
133
134 Bool mnaHasCompactRightSideVectorStamp() const override final { return true; }
135
136 void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override final;
137
139 AttributeBase::List &prevStepDependencies,
140 AttributeBase::List &attributeDependencies,
141 AttributeBase::List &modifiedAttributes,
142 Attribute<Matrix>::Ptr &leftVector) override final;
143};
144
145} // namespace EMT
146} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
Matrix mD1
Feedthrough from the time derivative of the input, for capacitive ports.
Definition EMT_SSNComp.h:43
virtual std::vector< String > getLocalStateNames() const
virtual void updateLogAttributes(const Matrix &u) const
Update derived attributes used for logging/inspection.
Matrix mHistoryState
Reused workspaces for the per-step linear history evaluation.
Definition EMT_SSNComp.h:35
const Matrix & getDiscreteA() const
Get discrete state transition matrix used by the trapezoidal SSN model.
const Matrix & getDiscreteB() const
Get discrete input matrix used by the trapezoidal SSN model.
void mnaCompPreStep(Real time, Int timeStepCount) override final
const Matrix * mXValue
Definition EMT_SSNComp.h:49
const Attribute< Matrix >::Ptr mX
Definition EMT_SSNComp.h:48
virtual void recomputeDiscreteModel()
virtual Attribute< Matrix >::Ptr inputAttribute() const =0
const Matrix & getC() const
Get continuous-time output matrix of the SSN model.
const Matrix & stateValue() const
Definition EMT_SSNComp.h:55
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override final
const Matrix & inputValue() const
Definition EMT_SSNComp.h:56
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override final
virtual void updateState(const Matrix &uOld, const Matrix &uNew)
const Matrix * mInputValue
Definition EMT_SSNComp.h:50
virtual void updateStateSpaceModel()
Hook for variable/time-varying SSN components.
SSNComp(String uid, String name, Int inputSize, Int outputSize, Logger::Level logLevel=Logger::Level::off)
virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u, Real frequency) const
virtual Attribute< Matrix >::Ptr outputAttribute() const =0
Matrix mPreviousInput
Reused storage for the previous SSN input during post-step updates.
Definition EMT_SSNComp.h:52
virtual std::vector< LocalAbcStateBlock > getLocalAbcStateBlocks() const
void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override final
UInt getStateCount() const
Get number of internal state variables of the SSN model.
std::vector< UInt > mRightVectorAffectedIndices
Definition EMT_SSNComp.h:53
virtual void calculateHistoryVector(Matrix &history) const
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D, const Matrix &D1=Matrix())
virtual MatrixComp calculateSteadyStateOutputFromInput(const MatrixComp &x, const MatrixComp &u) const
Bool mnaHasCompactRightSideVectorStamp() const override final
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override final
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:79
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Definition Definitions.h:82
bool Bool
Definition Definitions.h:62
unsigned int UInt
Definition Definitions.h:58
std::array< UInt, 3 > indices
Local SSN state indices representing one native abc-frame state block.
Definition EMT_SSNComp.h:85