DPsim
Loading...
Searching...
No Matches
EMT_Ph3_SynchronGeneratorVBR.h
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
19
20namespace CPS {
21namespace EMT {
22namespace Ph3 {
32 public SharedFactory<SynchronGeneratorVBR> {
33protected:
38
43
54
61
68
75
82
95
98
100 Matrix mIabc = Matrix::Zero(3, 1);
102 Matrix mVabc = Matrix::Zero(3, 1);
104 Matrix mDVabc = Matrix::Zero(3, 1);
105
107 Matrix mDqStatorCurrents = Matrix::Zero(2, 1);
112
113 // ### Useful Matrices ###
115 Matrix mDInductanceMat = Matrix::Zero(3, 3);
116
118 Matrix mPsikq1kq2 = Matrix::Zero(2, 1);
120 Matrix mPsifdkd = Matrix::Zero(2, 1);
122 Matrix mConductanceMat = Matrix::Zero(3, 3);
124 Matrix mISourceEq = Matrix::Zero(3, 1);
126 Matrix mDVqd = Matrix::Zero(2, 1);
130 Matrix E_eq_vbr = Matrix::Zero(3, 1);
135
142 Matrix K1b = Matrix::Zero(2, 1);
143 Matrix K1 = Matrix::Zero(2, 1);
145 Matrix K2b = Matrix::Zero(2, 1);
146 Matrix K2 = Matrix::Zero(2, 1);
147 Matrix H_qdr = Matrix::Zero(3, 1);
150 Matrix mEsh_vbr = Matrix::Zero(3, 1);
151 Matrix E_r_vbr = Matrix::Zero(3, 1);
153
162
175
178
180 Matrix E1b = Matrix::Zero(2, 1);
181 // CHECK: E1 and F1 seem to be vectors (Zero(2, 1)) and not matrices
182 Matrix E1 = Matrix::Zero(2, 2);
184 Matrix F1b = Matrix::Zero(2, 1);
185 Matrix F1 = Matrix::Zero(2, 2);
190 Matrix F3b = Matrix::Zero(2, 1);
191 Matrix F3 = Matrix::Zero(2, 2);
192 Matrix C26 = Matrix::Zero(2, 1);
193
194public:
197 Logger::Level logLevel = Logger::Level::off);
200 Logger::Level logLevel = Logger::Level::off);
201
204 Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
205 Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd,
206 Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2,
207 Real Llkq2, Real inertia);
208
212 Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
213 Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t,
214 Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s,
215 Real Tq0_s, Real inertia);
216
218 void setInitialValues(Real initActivePower, Real initReactivePower,
219 Real initTerminalVolt, Real initVoltAngle,
220 Real initMechPower);
221
223 void initialize(Matrix frequencies) override;
224
226 void initializeFromNodesAndTerminals(Real frequency) override;
227
230 void initialize(Real om, Real dt);
231
233 void mnaCompInitialize(Real omega, Real timeStep,
234 Attribute<Matrix>::Ptr leftVector) override;
235
238 void stepInPerUnit();
239
241 Matrix parkTransform(Real theta, Real a, Real b, Real c);
242
244 Matrix inverseParkTransform(Real theta, Real q, Real d, Real zero);
245
247 void CalculateL();
250
252 //Matrix& rotorFluxes() { return mRotorFlux; }
254 Real electricalTorque() const { return **mElecTorque * mBase_T; }
255 Real rotationalSpeed() const { return **mOmMech * mBase_OmMech; }
256 Real rotorPosition() const { return mThetaMech; }
258
259 // #### MNA section ####
261 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
263 void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
265 void mnaCompPreStep(Real time, Int timeStepCount) override;
267 void mnaCompPostStep(Real time, Int timeStepCount,
268 Attribute<Matrix>::Ptr &leftVector) override;
271 AttributeBase::List &prevStepDependencies,
272 AttributeBase::List &attributeDependencies,
273 AttributeBase::List &modifiedAttributes) override;
275 void
277 AttributeBase::List &attributeDependencies,
278 AttributeBase::List &modifiedAttributes,
279 Attribute<Matrix>::Ptr &leftVector) override;
281 Bool hasParameterChanged() override { return true; }
282};
283} // namespace Ph3
284} // namespace EMT
285} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
Base synchronous generator model.
Real mBase_OmMech
base mechanical angular frequency
const Attribute< Real >::Ptr mOmMech
rotor speed omega_r
const Attribute< Real >::Ptr mElecTorque
electrical torque
SynchronGeneratorVBR(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
Real mPsikq1
Magnetizing flux linkage 1st damper winding q axis.
void setBaseAndFundamentalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd, Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2, Real inertia)
Initializes the base and fundamental machine parameters in per unit.
Real mPsimd
Magnetizing flux linkage in d axis.
void initialize(Real om, Real dt)
Real mVq
Interface voltage q component.
Real mV0
Interface voltage 0 component.
Matrix mConductanceMat
Equivalent Stator Conductance Matrix.
void initialize(Matrix frequencies) override
Initialize components with correct network frequencies.
void setBaseAndOperationalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t, Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s, Real Tq0_s, Real inertia)
MatrixFixedSize< 3, 3 > R_eq_vbr
Equivalent VBR Stator Resistance.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
Real mId_hist
D axis stator current of from last time step.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
MatrixFixedSize< 3, 3 > mKrs_teta
Park Transformation Matrix.
Real mPsikd
Magnetizing flux linkage damper winding d axis.
Matrix E_eq_vbr
Equivalent VBR Stator Voltage Source.
Real mPsifd
Magnetizing flux linkage excitation.
void mnaCompPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
Real mIq
Interface current q component.
Real mIq_hist
Q axis stator current of from last time step.
Matrix inverseParkTransform(Real theta, Real q, Real d, Real zero)
Inverse Park transform as described in Krause.
MatrixFixedSize< 3, 3 > mKrs_teta_inv
Inverse Park Transformation Matrix.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
Matrix mDqStatorCurrents
Dq stator current vector.
Real mPsimq
Magnetizing flux linkage in q axis.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
Matrix mISourceEq
Equivalent Stator Current Source.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Matrix parkTransform(Real theta, Real a, Real b, Real c)
Park transform as described in Krause.
Real mPsikq2
Magnetizing flux linkage 2nd damper winding q axis.
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
Initialize states according to desired initial electrical powerflow and mechanical input power.
Real mId
Interface current d component.
Real mI0
Interface current 0 component.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void CalculateL()
Calculate inductance Matrix L and its derivative.
Real mVd
Interface voltage d component.
Bool hasParameterChanged() override
Mark that parameter changes so that system matrix is updated.
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
MNA interface to be used by elements that require recomputing of the system matrix.
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
Eigen::Matrix< Real, rows, cols, Eigen::ColMajor > MatrixFixedSize
Dense matrix for real numbers with fixed dimension.
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61
bool Bool
Definition Definitions.h:64
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:74