DPsim
Loading...
Searching...
No Matches
DP_Ph1_AvVoltSourceInverterStateSpace.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/DP/DP_Ph1_MixedVTypeVariableSSNComp.h>
7
8namespace CPS {
9namespace DP {
10namespace Ph1 {
11
13class AvVoltSourceInverterStateSpace final
14 : public MixedVTypeVariableSSNComp,
15 public SharedFactory<AvVoltSourceInverterStateSpace> {
16private:
17 enum StateIndex : Int {
18 Psi = 0,
19 PhiPLL = 1,
20 PFiltered = 2,
21 QFiltered = 3,
22 PhiD = 4,
23 PhiQ = 5,
24 GammaD = 6,
25 GammaQ = 7,
26 VcRe = 8,
27 VcIm = 9,
28 IfRe = 10,
29 IfIm = 11
30 };
31
32 Real mLf;
33 Real mCf;
34 Real mRf;
35 Real mRc;
36
37 Real mOmegaN;
38 Real mKpPLL;
39 Real mKiPLL;
40
41 Real mOmegaCutoff;
42 Real mPRef;
43 Real mQRef;
44 Real mKpPowerCtrl;
45 Real mKiPowerCtrl;
46 Real mKpCurrCtrl;
47 Real mKiCurrCtrl;
48
49 const Attribute<Real>::Ptr mVcD;
50 const Attribute<Real>::Ptr mVcQ;
51 const Attribute<Real>::Ptr mIrcD;
52 const Attribute<Real>::Ptr mIrcQ;
53 const Attribute<Real>::Ptr mPInst;
54 const Attribute<Real>::Ptr mQInst;
55 const Attribute<Real>::Ptr mOmegaPLL;
56
58 void buildStateSpaceModel(const Matrix &x, const Matrix &u, Matrix &A,
59 Matrix &B, Matrix &C, Matrix &D, Matrix &E,
60 Matrix &F) const;
61
62protected:
63 Bool updateComponentParameters() override final;
64 void updateLogAttributes(const Matrix &u) const override final;
65
66public:
67 using SharedFactory<AvVoltSourceInverterStateSpace>::make;
68
69 AvVoltSourceInverterStateSpace(String uid, String name,
70 Logger::Level logLevel = Logger::Level::off);
71 AvVoltSourceInverterStateSpace(String name,
72 Logger::Level logLevel = Logger::Level::off)
73 : AvVoltSourceInverterStateSpace(name, name, logLevel) {}
74
75 void setParameters(Real lf, Real cf, Real rf, Real rc, Real omegaN,
76 Real kpPLL, Real kiPLL, Real omegaCutoff, Real pRef,
77 Real qRef, Real kpPowerCtrl, Real kiPowerCtrl,
78 Real kpCurrCtrl, Real kiCurrCtrl);
79
80 void initializeFromNodesAndTerminals(Real frequency) override;
81};
82
83} // namespace Ph1
84} // namespace DP
85} // namespace CPS
Bool updateComponentParameters() override final
Rebuild A/B/C/D/E/F from the current state/input; returns true if the stamp changed.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
String uid()
Returns unique id.