DPsim
Loading...
Searching...
No Matches
DP_SSNComp.h
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 <dpsim-models/MNASimPowerComp.h>
7#include <dpsim-models/Solver/MNAInterface.h>
8
9namespace CPS {
10namespace DP {
11
18class SSNComp : public MNASimPowerComp<Complex> {
19private:
20 const Int mInputSize;
21 const Int mOutputSize;
22
23protected:
24 Real mTimeStep;
25
27 Matrix mA;
28 Matrix mB;
29 Matrix mC;
30 Matrix mD;
31
33 MatrixComp mDiscreteA;
34 MatrixComp mDiscreteB;
35
37 MatrixComp mW;
39 MatrixComp mYHist;
40
42 const Attribute<MatrixComp>::Ptr mX;
43
44 SSNComp(String uid, String name, Int inputSize, Int outputSize,
45 Logger::Level logLevel = Logger::Level::off);
46
48 Matrix buildAugmentedA(Real omega) const;
50 Matrix buildAugmentedB() const;
51
53 virtual void recomputeDiscreteModel(Real omega);
54
55 virtual MatrixComp calculateHistoryVector() const;
56
58 virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u,
59 Real omega) const;
60 virtual MatrixComp
61 calculateSteadyStateOutputFromInput(const MatrixComp &x,
62 const MatrixComp &u) const;
63
64 virtual void updateState(const MatrixComp &uOld, const MatrixComp &uNew);
65
67 virtual void updateStateSpaceModel();
68
69 virtual Attribute<MatrixComp>::Ptr inputAttribute() const = 0;
70 virtual Attribute<MatrixComp>::Ptr outputAttribute() const = 0;
71
72public:
74 UInt getStateCount() const;
75
77 const MatrixComp &getDiscreteA() const;
79 const MatrixComp &getDiscreteB() const;
81 const Matrix &getC() const;
82
83 void setParameters(const Matrix &A, const Matrix &B, const Matrix &C,
84 const Matrix &D);
85
86 void mnaCompInitialize(Real omega, Real timeStep,
87 Attribute<Matrix>::Ptr leftVector) override final;
88
89 void mnaCompAddPreStepDependencies(
90 AttributeBase::List &prevStepDependencies,
91 AttributeBase::List &attributeDependencies,
92 AttributeBase::List &modifiedAttributes) override final;
93
94 void mnaCompPreStep(Real time, Int timeStepCount) override final;
95
96 void mnaCompAddPostStepDependencies(
97 AttributeBase::List &prevStepDependencies,
98 AttributeBase::List &attributeDependencies,
99 AttributeBase::List &modifiedAttributes,
100 Attribute<Matrix>::Ptr &leftVector) override final;
101};
102
103} // namespace DP
104} // namespace CPS
virtual void updateStateSpaceModel()
Hook for variable/time-varying SSN components.
Matrix mA
Continuous-time real physical model (user-provided).
Definition DP_SSNComp.h:27
const MatrixComp & getDiscreteA() const
Get the complex discrete state-transition operator of the envelope model.
UInt getStateCount() const
Get number of internal state variables of the SSN model.
MatrixComp mYHist
Complex history term.
Definition DP_SSNComp.h:39
Matrix buildAugmentedA(Real omega) const
Build A_aug = [[A, w I], [-w I, A]].
virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u, Real omega) const
Steady-state envelope state X_ss = (j w I - A)^-1 B u.
virtual void recomputeDiscreteModel(Real omega)
Discretize the augmented model and fold it into complex dA, dB, W.
MatrixComp mW
Complex Norton matrix W = C dB + D.
Definition DP_SSNComp.h:37
const Attribute< MatrixComp >::Ptr mX
Complex envelope state X.
Definition DP_SSNComp.h:42
const Matrix & getC() const
Get the continuous-time output matrix of the SSN model.
MatrixComp mDiscreteA
Complex envelope discrete operators (folded from the augmented model).
Definition DP_SSNComp.h:33
Matrix buildAugmentedB() const
Build B_aug = blkdiag(B, B).
const MatrixComp & getDiscreteB() const
Get the complex discrete input operator of the envelope model.
String uid()
Returns unique id.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)