DPsim
Loading...
Searching...
No Matches
DP_Ph3_AvVoltSourceInverterStateSpace.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
9
10namespace CPS {
11namespace DP {
12namespace Ph3 {
13
17 public SharedFactory<AvVoltSourceInverterStateSpace> {
18private:
21 enum StateIndex : Int {
22 VcARe = 0,
23 VcAIm = 1,
24 VcBRe = 2,
25 VcBIm = 3,
26 VcCRe = 4,
27 VcCIm = 5,
28 IfARe = 6,
29 IfAIm = 7,
30 IfBRe = 8,
31 IfBIm = 9,
32 IfCRe = 10,
33 IfCIm = 11,
34 Psi = 12,
35 PhiPLL = 13,
36 PFiltered = 14,
37 QFiltered = 15,
38 PhiD = 16,
39 PhiQ = 17,
40 GammaD = 18,
41 GammaQ = 19,
42 GammaND = 20,
43 GammaNQ = 21
44 };
45
47 using Complex3 = std::array<Complex, 3>;
48
50 const Bool mEnableNegSeqControl;
51
52 static constexpr std::array<Int, 3> mVcReCol = {VcARe, VcBRe, VcCRe};
53 static constexpr std::array<Int, 3> mVcImCol = {VcAIm, VcBIm, VcCIm};
54 static constexpr std::array<Int, 3> mIfReCol = {IfARe, IfBRe, IfCRe};
55 static constexpr std::array<Int, 3> mIfImCol = {IfAIm, IfBIm, IfCIm};
56 static constexpr std::array<Int, 3> mUReCol = {0, 2, 4};
57 static constexpr std::array<Int, 3> mUImCol = {1, 3, 5};
58
60 static constexpr std::array<Int, 7> mOwnCol = {
61 Psi, PFiltered, QFiltered, PhiD, PhiQ, GammaD, GammaQ};
62
63 Real mLf = 0.0;
64 Real mInvLf = 0.0;
65 Real mCf = 0.0;
66 Real mRf = 0.0;
67 Real mRc = 0.0;
68
69 Real mOmegaN = 0.0;
70 Real mKpPLL = 0.0;
71 Real mKiPLL = 0.0;
72
73 Real mOmegaCutoff = 0.0;
74 Real mPRef = 0.0;
75 Real mQRef = 0.0;
76 Real mKpPowerCtrl = 0.0;
77 Real mKiPowerCtrl = 0.0;
78 Real mKpCurrCtrl = 0.0;
79 Real mKiCurrCtrl = 0.0;
80
82 Real mIRefNd = 0.0;
84 Real mIRefNq = 0.0;
85
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 const Attribute<Real>::Ptr mIrcNd;
94 const Attribute<Real>::Ptr mIrcNq;
95
97 Matrix mParameterStateOffset;
98 Matrix mParameterOutputOffset;
99
101 struct NegSeqTerms {
102 Complex ircNDQ{0.0, 0.0};
103 Complex vRefNDQ{0.0, 0.0};
104 Complex vRefNEnv0{0.0, 0.0};
105 Complex3 hIrcN{};
106 };
107
109 struct RefSensitivities {
111 std::array<Complex, 7> posOwn{};
112 Complex3 posVcRe{};
113 Complex3 posVcIm{};
114 Complex3 posURe{};
115 Complex3 posUIm{};
116 Complex negPsi{0.0, 0.0};
117 Complex negGammaND{0.0, 0.0};
118 Complex negGammaNQ{0.0, 0.0};
119 Complex3 negVcRe{};
120 Complex3 negVcIm{};
121 Complex3 negURe{};
122 Complex3 negUIm{};
123 };
124
126 void buildStateSpaceModel(const Matrix &x, const Matrix &u, Matrix &A,
127 Matrix &B, Matrix &C, Matrix &D, Matrix &E,
128 Matrix &F) const;
129
131 NegSeqTerms computeNegSeqTerms(const Matrix &x, const Complex3 &vc,
132 const Complex3 &uEnv,
133 const Complex3 &redistFactor,
134 const Complex3 &projCoeff,
135 const Complex &expJPsi) const;
136
138 void buildInductorRows(const Complex3 &redistFactor,
139 const Complex3 &projCoeff,
140 const RefSensitivities &sens, Matrix &A,
141 Matrix &B) const;
142
143protected:
144 Bool updateComponentParameters() override final;
145 void updateLogAttributes(const Matrix &u) const override final;
146
147public:
149
152 Logger::Level logLevel = Logger::Level::off,
153 Bool enableNegSeqControl = false);
155 Logger::Level logLevel = Logger::Level::off,
156 Bool enableNegSeqControl = false)
158 enableNegSeqControl) {}
159
160 void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN,
161 Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef,
162 Real qRef, Real kpPowerCtrl, Real kiPowerCtrl,
163 Real kpCurrCtrl, Real kiCurrCtrl, Real iRefNd = 0.0,
164 Real iRefNq = 0.0);
165
166 void initializeFromNodesAndTerminals(Real frequency) override;
167};
168
169} // namespace Ph3
170} // namespace DP
171} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
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, Real iRefNd=0.0, Real iRefNq=0.0)
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
AvVoltSourceInverterStateSpace(String uid, String name, Logger::Level logLevel=Logger::Level::off, Bool enableNegSeqControl=false)
AvVoltSourceInverterStateSpace(String name, Logger::Level logLevel=Logger::Level::off, Bool enableNegSeqControl=false)
Bool updateComponentParameters() override final
Rebuild A/B/C/D/E/F from the current state/input; returns true if the stamp changed.
MixedVTypeVariableSSNComp(String uid, String name, Int realStateCount, Int complexStateCount, Logger::Level logLevel=Logger::Level::off)
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
static std::shared_ptr< AvVoltSourceInverterStateSpace > 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
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
std::complex< Real > Complex
Definition Definitions.h:61
bool Bool
Definition Definitions.h:62