DPsim
Loading...
Searching...
No Matches
EMT_Ph3_SynchronGeneratorDQTrapez.cpp
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
10
11using namespace CPS;
12
13// !!! TODO: Adaptions to use in EMT_Ph3 models phase-to-ground peak variables
14// !!! with initialization from phase-to-phase RMS variables
15
22
26
34
36 AttributeBase::List &prevStepDependencies,
37 AttributeBase::List &attributeDependencies,
38 AttributeBase::List &modifiedAttributes) {
39 modifiedAttributes.push_back(mRightVector);
40 prevStepDependencies.push_back(mIntfVoltage);
41}
42
44 Int timeStepCount) {
45 stepInPerUnit(time); //former system solve (trapezoidal)
47}
48
50 // Receives the voltage of time step k and has to
51 // calculate the current output for time step k+1
52
53 // Calculate per unit values and
54 // transform per unit voltages from abc to dq0
56 mVsr(0, 0) = mVdq0(0, 0);
57 mVsr(3, 0) = mVdq0(1, 0);
58 mVsr(6, 0) = mVdq0(2, 0);
59 // Current is already available in pu dq0 from previous step
60
61 // Update of fd winding voltage from exciter
62 if (mHasExciter) {
63 Real Vpss = mHasPSS ? mPSS->step(**mOmMech, **mElecTorque, mVsr(0, 0),
64 mVsr(3, 0), mTimeStep)
65 : 0.0;
66 // Note: scaled by Rfd/Lmd to transform from exciter pu system
67 // to the synchronous generator pu system
68 mVsr(1, 0) =
69 (mRfd / mLmd) * mExciter->step(mVsr(0, 0), mVsr(3, 0), mTimeStep, Vpss);
70 }
71
72 // Update of mechanical torque from turbine governor
74 Real Pgv = mGovernor->step(**mOmMech, mTimeStep);
75 **mMechTorque = mTurbine->step(Pgv, mTimeStep);
76 } else if (mHasTurbineGovernorType1)
78 else if (mHasTurbineGovernor)
81
82 // Calculation of electrical torque
83 **mElecTorque = (mPsisr(3, 0) * mIsr(0, 0) - mPsisr(0, 0) * mIsr(3, 0));
84
85 // Update mechanical rotor angle with respect to electrical angle
86 // using Euler and previous states
88
89 // Update of omega using Euler
90 **mOmMech = **mOmMech + mTimeStep * (1. / (2. * **mInertia) *
91 (**mMechTorque - **mElecTorque));
92
93 // Update using euler
94 **mDelta = **mDelta + mTimeStep * (**mOmMech - 1);
95
96 // Update of fluxes
101 else
105
106 // Calculate new currents from fluxes
108
109 mIdq0(0, 0) = mIsr(0, 0);
110 mIdq0(1, 0) = mIsr(3, 0);
111 mIdq0(2, 0) = mIsr(6, 0);
113}
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
Matrix mIsr
Vector of stator and rotor currents.
Bool mHasTurbineGovernorType1
Determines if TurbineGovernorType1 is activated.
Real mTimeStep
Simulation time step.
Real mLmd
d-axis mutual inductance Lmd [H]
Real mBase_I
base stator current peak
Bool mHasExciter
Determines if Exciter is activated.
const Attribute< Real >::Ptr mMechTorque
mechanical torque
Matrix mFluxToCurrentMat
Calculates currents from fluxes.
std::shared_ptr< Base::Exciter > mExciter
Signal component modelling voltage regulator and exciter.
std::shared_ptr< Base::Turbine > mTurbine
Modular turbine (SteamTurbine / HydroTurbine)
Matrix mFluxStateSpaceMat
Flux state space matrix excluding omega term.
Matrix mVsr
Vector of stator and rotor voltages.
Matrix mPsisr
Vector of stator and rotor fluxes.
Bool mHasGovernorAndTurbine
Determines if modular Governor + Turbine pair is activated.
std::shared_ptr< Base::PSS > mPSS
Power system stabilizer.
std::shared_ptr< Signal::TurbineGovernor > mTurbineGovernor
Signal component modelling governor control and steam turbine (legacy)
Matrix mOmegaFluxMat
Omega-flux matrix for state space system.
Matrix mIdq0
dq0 current calculated from terminal current
std::shared_ptr< Base::Governor > mGovernor
Modular governor (SteamTurbineGovernor / HydroTurbineGovernor)
Real mRfd
field resistance Rfd [Ohm]
Real mBase_OmElec
base electrical angular frequency
Matrix mVdq0
dq0 voltage calculated from terminal voltage
Real mBase_OmMech
base mechanical angular frequency
const Attribute< Real >::Ptr mDelta
rotor angle delta
Bool mHasPSS
Determines if PSS is activated.
Real mBase_V
base stator voltage (phase-to-ground peak)
Real mNomPower
nominal power Pn [VA]
const Attribute< Real >::Ptr mOmMech
rotor speed omega_r
Bool mHasTurbineGovernor
Determines if legacy TurbineGovernor is activated.
std::shared_ptr< Signal::TurbineGovernorType1 > mTurbineGovernorType1
Signal component modelling governor control and steam turbine (TurbineGovernorType1)
const Attribute< Real >::Ptr mInertia
inertia constant H [s] for per unit or moment of inertia J [kg*m^2]
const Attribute< Real >::Ptr mElecTorque
electrical torque
Matrix dq0ToAbcTransform(Real theta, Matrix &dq0)
Inverse Park transform as described in Krause.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
void initializeMatrixAndStates()
Initializes internal states and matrix.
Matrix abcToDq0Transform(Real theta, Matrix &abc)
Park transform as described in Krause.
SynchronGeneratorDQ(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaCompPreStep(Real time, Int timeStepCount) override
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
SynchronGeneratorDQTrapez(String uid, String name, Logger::Level loglevel=Logger::Level::off)
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
Attribute< Matrix >::Ptr mRightVector
static Matrix StateSpaceEuler(Matrix states, Matrix A, Matrix B, Real dt, Matrix u)
static Matrix StateSpaceTrapezoidal(Matrix states, Matrix A, Matrix B, Real dt, Matrix u_new, Matrix u_old)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61