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);
132 Matrix E_eq_vbr = Matrix::Zero(3, 1);
137
144 Matrix K1b = Matrix::Zero(2, 1);
145 Matrix K1 = Matrix::Zero(2, 1);
147 Matrix K2b = Matrix::Zero(2, 1);
148 Matrix K2 = Matrix::Zero(2, 1);
155
164
177
180
183 // CHECK: E1 and F1 seem to be vectors (Zero(2, 1)) and not matrices
184 Matrix E1 = Matrix::Zero(2, 2);
187 Matrix F1 = Matrix::Zero(2, 2);
193 Matrix F3 = Matrix::Zero(2, 2);
194 Matrix C26 = Matrix::Zero(2, 1);
195
196public:
199 Logger::Level logLevel = Logger::Level::off);
202 Logger::Level logLevel = Logger::Level::off);
203
206 Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
207 Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd,
208 Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2,
209 Real Llkq2, Real inertia);
210
214 Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
215 Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t,
216 Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s,
217 Real Tq0_s, Real inertia);
218
220 void setInitialValues(Real initActivePower, Real initReactivePower,
221 Real initTerminalVolt, Real initVoltAngle,
222 Real initMechPower);
223
225 void initialize(Matrix frequencies) override;
226
228 void initializeFromNodesAndTerminals(Real frequency) override;
229
232 void initialize(Real om, Real dt);
233
235 void mnaCompInitialize(Real omega, Real timeStep,
236 Attribute<Matrix>::Ptr leftVector) override;
237
240 void stepInPerUnit();
241
244
247 Real zero);
248
250 void CalculateL();
253
255 //Matrix& rotorFluxes() { return mRotorFlux; }
257 Real electricalTorque() const { return **mElecTorque * mBase_T; }
258 Real rotationalSpeed() const { return **mOmMech * mBase_OmMech; }
259 Real rotorPosition() const { return mThetaMech; }
261
262 // #### MNA section ####
264 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
266 void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
268 Bool mnaHasCompactRightSideVectorStamp() const override { return true; }
269 void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override;
271 void mnaCompPreStep(Real time, Int timeStepCount) override;
273 void mnaCompPostStep(Real time, Int timeStepCount,
274 Attribute<Matrix>::Ptr &leftVector) override;
277 AttributeBase::List &prevStepDependencies,
278 AttributeBase::List &attributeDependencies,
279 AttributeBase::List &modifiedAttributes) override;
281 void
283 AttributeBase::List &attributeDependencies,
284 AttributeBase::List &modifiedAttributes,
285 Attribute<Matrix>::Ptr &leftVector) override;
287 Bool hasParameterChanged() override { return true; }
288 Bool hasContinuouslyChangingSystemMatrix() const override { return true; }
289};
290} // namespace Ph3
291} // namespace EMT
292} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
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)
MatrixFixedSize< 3, 1 > inverseParkTransform(Real theta, Real q, Real d, Real zero)
Inverse Park transform as described in Krause.
Real mVq
Interface voltage q component.
Real mV0
Interface voltage 0 component.
Matrix mConductanceMat
Equivalent Stator Conductance Matrix.
MatrixFixedSize< 3, 3 > mR_eq_vbr_inv
Inverse of the equivalent VBR stator resistance, reused by pre/post-step.
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.
void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override
Real mIq_hist
Q axis stator current of from last time step.
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.
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.
MatrixFixedSize< 3, 1 > parkTransform(Real theta, Real a, Real b, Real c)
Park transform as described in Krause.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
Bool mnaHasCompactRightSideVectorStamp() const override
Accumulate the three active source entries without a network-sized copy.
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:79
std::string String
Definition Definitions.h:63
Eigen::Matrix< Real, rows, cols, Eigen::ColMajor > MatrixFixedSize
Dense matrix for real numbers with fixed dimension.
Definition Definitions.h:99
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
bool Bool
Definition Definitions.h:62
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:72