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
9
10namespace CPS {
11namespace EMT {
12namespace Ph3 {
13
42 public SharedFactory<SSN_GFL> {
43private:
44 static constexpr Int mStateSize = 14;
45 static constexpr Int mInputSize = 3;
46 static constexpr Int mOutputSize = 3;
47
48 enum StateIndex : Int {
49 ThetaPLL = 0,
50 PhiPLL = 1,
51 PFiltered = 2,
52 QFiltered = 3,
53 PhiD = 4,
54 PhiQ = 5,
55 GammaD = 6,
56 GammaQ = 7,
57 VcA = 8,
58 VcB = 9,
59 VcC = 10,
60 IfA = 11,
61 IfB = 12,
62 IfC = 13
63 };
64
65 // Electrical parameters
66 Real mLf;
67 Real mCf;
68 Real mRf;
69 Real mRc;
70
71 // PLL parameters
72 Real mOmegaN;
73 Real mKpPLL;
74 Real mKiPLL;
75
76 // Power measurement and controller parameters
77 Real mOmegaCutoff;
78 Real mPRef;
79 Real mQRef;
80 Real mKpPowerCtrl;
81 Real mKiPowerCtrl;
82 Real mKpCurrCtrl;
83 Real mKiCurrCtrl;
84
85 // Logging attributes
86 const Attribute<Real>::Ptr mVcD;
87 const Attribute<Real>::Ptr mVcQ;
88 const Attribute<Real>::Ptr mIrcD;
89 const Attribute<Real>::Ptr mIrcQ;
90 const Attribute<Real>::Ptr mPInst;
91 const Attribute<Real>::Ptr mQInst;
92 const Attribute<Real>::Ptr mOmegaPLL;
93
94 Matrix getParkTransformMatrix(Real theta) const;
95 Matrix getInverseParkTransformMatrix(Real theta) const;
96
98 void evaluateStateDerivative(const Matrix &x, const Matrix &u,
99 Matrix &stateDerivative) const;
100
102 void evaluateOutput(const Matrix &x, const Matrix &u, Matrix &output) const;
103
105 void calculateAnalyticalJacobians(const Matrix &x, const Matrix &u, Matrix &A,
106 Matrix &B, Matrix &C, Matrix &D) const;
107
109 void buildStateSpaceModel(const Matrix &x, const Matrix &u, Matrix &A,
110 Matrix &B, Matrix &C, Matrix &D, Matrix &E,
111 Matrix &F) const;
112
113protected:
114 Bool updateComponentParameters() override final;
115 void updateLogAttributes(const Matrix &u) const override final;
116
117public:
119
120 SSN_GFL(String uid, String name, Logger::Level logLevel = Logger::Level::off);
121
122 SSN_GFL(String name, Logger::Level logLevel = Logger::Level::off)
123 : SSN_GFL(name, name, logLevel) {}
124
125 std::vector<String> getLocalStateNames() const override final;
126
127 std::vector<SSNComp::LocalAbcStateBlock>
128 getLocalAbcStateBlocks() const override final;
129
135 void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN,
136 Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef,
137 Real qRef, Real kpPowerCtrl, Real kiPowerCtrl,
138 Real kpCurrCtrl, Real kiCurrCtrl);
139
140 void initializeFromNodesAndTerminals(Real frequency) override final;
141
142 Matrix getState() const;
146};
147
148} // namespace Ph3
149} // namespace EMT
150} // 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:81
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61
bool Bool
Definition Definitions.h:64