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 mCf = 0.0;
65 Real mRf = 0.0;
66 Real mRc = 0.0;
67
68 Real mOmegaN = 0.0;
69 Real mKpPLL = 0.0;
70 Real mKiPLL = 0.0;
71
72 Real mOmegaCutoff = 0.0;
73 Real mPRef = 0.0;
74 Real mQRef = 0.0;
75 Real mKpPowerCtrl = 0.0;
76 Real mKiPowerCtrl = 0.0;
77 Real mKpCurrCtrl = 0.0;
78 Real mKiCurrCtrl = 0.0;
79
81 Real mIRefNd = 0.0;
83 Real mIRefNq = 0.0;
84
85 const Attribute<Real>::Ptr mVcD;
86 const Attribute<Real>::Ptr mVcQ;
87 const Attribute<Real>::Ptr mIrcD;
88 const Attribute<Real>::Ptr mIrcQ;
89 const Attribute<Real>::Ptr mPInst;
90 const Attribute<Real>::Ptr mQInst;
91 const Attribute<Real>::Ptr mOmegaPLL;
92 const Attribute<Real>::Ptr mIrcNd;
93 const Attribute<Real>::Ptr mIrcNq;
94
96 struct NegSeqTerms {
97 Complex ircNDQ{0.0, 0.0};
98 Complex vRefNDQ{0.0, 0.0};
99 Complex vRefNEnv0{0.0, 0.0};
100 Complex3 hIrcN{};
101 };
102
104 struct RefSensitivities {
106 std::array<Complex, 7> posOwn{};
107 Complex3 posVcRe{};
108 Complex3 posVcIm{};
109 Complex3 posURe{};
110 Complex3 posUIm{};
111 Complex negPsi{0.0, 0.0};
112 Complex negGammaND{0.0, 0.0};
113 Complex negGammaNQ{0.0, 0.0};
114 Complex3 negVcRe{};
115 Complex3 negVcIm{};
116 Complex3 negURe{};
117 Complex3 negUIm{};
118 };
119
121 void buildStateSpaceModel(const Matrix &x, const Matrix &u, Matrix &A,
122 Matrix &B, Matrix &C, Matrix &D, Matrix &E,
123 Matrix &F) const;
124
126 NegSeqTerms computeNegSeqTerms(const Matrix &x, const Complex3 &vc,
127 const Complex3 &uEnv,
128 const Complex3 &redistFactor,
129 const Complex3 &projCoeff,
130 const Complex &expJPsi) const;
131
133 void buildInductorRows(const Complex3 &redistFactor,
134 const Complex3 &projCoeff,
135 const RefSensitivities &sens, Matrix &A,
136 Matrix &B) const;
137
138protected:
139 Bool updateComponentParameters() override final;
140 void updateLogAttributes(const Matrix &u) const override final;
141
142public:
144
147 Logger::Level logLevel = Logger::Level::off,
148 Bool enableNegSeqControl = false);
150 Logger::Level logLevel = Logger::Level::off,
151 Bool enableNegSeqControl = false)
153 enableNegSeqControl) {}
154
155 void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN,
156 Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef,
157 Real qRef, Real kpPowerCtrl, Real kiPowerCtrl,
158 Real kpCurrCtrl, Real kiCurrCtrl, Real iRefNd = 0.0,
159 Real iRefNq = 0.0);
160
161 void initializeFromNodesAndTerminals(Real frequency) override;
162};
163
164} // namespace Ph3
165} // namespace DP
166} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
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:81
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61
std::complex< Real > Complex
Definition Definitions.h:63
bool Bool
Definition Definitions.h:64