DPsim
Loading...
Searching...
No Matches
EMT_Ph3_SSN_GFL.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 <vector>
7
10
11namespace CPS {
12namespace EMT {
13namespace Ph3 {
14
43 public SharedFactory<SSN_GFL> {
44private:
45 static constexpr Int mStateSize = 14;
46 static constexpr Int mInputSize = 3;
47 static constexpr Int mOutputSize = 3;
48
49 enum StateIndex : Int {
50 ThetaPLL = 0,
51 PhiPLL = 1,
52 PFiltered = 2,
53 QFiltered = 3,
54 PhiD = 4,
55 PhiQ = 5,
56 GammaD = 6,
57 GammaQ = 7,
58 VcA = 8,
59 VcB = 9,
60 VcC = 10,
61 IfA = 11,
62 IfB = 12,
63 IfC = 13
64 };
65
66 // Electrical parameters
67 Real mLf;
68 Real mCf;
69 Real mRf;
70 Real mRc;
71
72 // PLL parameters
73 Real mOmegaN;
74 Real mKpPLL;
75 Real mKiPLL;
76
77 // Power measurement and controller parameters
78 Real mOmegaCutoff;
79 Real mPRef;
80 Real mQRef;
81 Real mKpPowerCtrl;
82 Real mKiPowerCtrl;
83 Real mKpCurrCtrl;
84 Real mKiCurrCtrl;
85
86 Matrix mStateDerivativeScratch = Matrix::Zero(mStateSize, 1);
87 Matrix mOutputScratch = Matrix::Zero(mOutputSize, 1);
88 Matrix mStateOffsetScratch = Matrix::Zero(mStateSize, 1);
89 Matrix mOutputOffsetScratch = Matrix::Zero(mOutputSize, 1);
90
91 // Logging attributes
92 const Attribute<Real>::Ptr mVcD;
93 const Attribute<Real>::Ptr mVcQ;
94 const Attribute<Real>::Ptr mIrcD;
95 const Attribute<Real>::Ptr mIrcQ;
96 const Attribute<Real>::Ptr mPInst;
97 const Attribute<Real>::Ptr mQInst;
98 const Attribute<Real>::Ptr mOmegaPLL;
99
100 MatrixFixedSize<2, 3> getParkTransformMatrix(Real theta) const;
101 MatrixFixedSize<3, 2> getInverseParkTransformMatrix(Real theta) const;
102
104 void evaluateStateDerivative(const Matrix &x, const Matrix &u,
105 Matrix &stateDerivative) const;
106
108 void evaluateOutput(const Matrix &x, const Matrix &u, Matrix &output) const;
109
111 void calculateAnalyticalJacobians(const Matrix &x, const Matrix &u, Matrix &A,
112 Matrix &B, Matrix &C, Matrix &D) const;
113
115 void buildStateSpaceModel(const Matrix &x, const Matrix &u, Matrix &A,
116 Matrix &B, Matrix &C, Matrix &D, Matrix &E,
117 Matrix &F);
118
119protected:
120 Bool updateComponentParameters() override final;
121 void updateLogAttributes(const Matrix &u) const override final;
122
123public:
125
126 SSN_GFL(String uid, String name, Logger::Level logLevel = Logger::Level::off);
127
128 SSN_GFL(String name, Logger::Level logLevel = Logger::Level::off)
129 : SSN_GFL(name, name, logLevel) {}
130
131 std::vector<String> getLocalStateNames() const override final;
132
133 std::vector<SSNComp::LocalAbcStateBlock>
134 getLocalAbcStateBlocks() const override final;
135
141 void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN,
142 Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef,
143 Real qRef, Real kpPowerCtrl, Real kiPowerCtrl,
144 Real kpCurrCtrl, Real kiCurrCtrl);
145
146 void initializeFromNodesAndTerminals(Real frequency) override final;
147
148 Matrix getState() const;
152};
153
154} // namespace Ph3
155} // namespace EMT
156} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
Matrix getInterfaceVoltage() const
std::vector< String > getLocalStateNames() const override final
Bool updateComponentParameters() override final
Matrix getInterfaceCurrent() const
std::vector< SSNComp::LocalAbcStateBlock > getLocalAbcStateBlocks() const override final
SSN_GFL(String name, Logger::Level logLevel=Logger::Level::off)
void updateLogAttributes(const Matrix &u) const override final
Update derived attributes used for logging/inspection.
void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN, Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef, Real qRef, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl)
Configure the GFL filter, PLL, power loop and current loop.
SSN_GFL(String uid, String name, Logger::Level logLevel=Logger::Level::off)
void initializeFromNodesAndTerminals(Real frequency) override final
Initializes Component variables according to power flow data stored in Nodes.
Matrix getStateDerivative() const
TwoTerminalVTypeVariableSSNComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Abstract base class for EMT state-space nodal (SSN) components.
Definition EMT_SSNComp.h:24
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
static std::shared_ptr< SSN_GFL > make(Args &&...args)
Definition PtrFactory.h:19
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
Eigen::Matrix< Real, rows, cols, Eigen::ColMajor > MatrixFixedSize
Dense matrix for real numbers with fixed dimension.
Definition Definitions.h:99
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
bool Bool
Definition Definitions.h:62