DPsim
Loading...
Searching...
No Matches
DP_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
16
20
22 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
24 mTimeStep = timeStep;
25
26 // The MNA solver invokes initializeFromNodesAndTerminals() before this
27 // point. Build the machine's electrical states only now so they use the
28 // PF-derived terminal power and voltage rather than zero-valued defaults.
30
31 SPDLOG_LOGGER_INFO(mSLog,
32 "\nFluxStateSpaceMat: \n{}"
33 "\nOmegaFluxMat: \n{}"
34 "\nResistances: {} {} {}",
36 mVdq0(0, 0) / mIdq0(0, 0), mVdq0(1, 0) / mIdq0(1, 0),
37 mVdq0(2, 0) / mIdq0(2, 0));
38}
39
41 AttributeBase::List &prevStepDependencies,
42 AttributeBase::List &attributeDependencies,
43 AttributeBase::List &modifiedAttributes) {
44 modifiedAttributes.push_back(mRightVector);
45 prevStepDependencies.push_back(mIntfVoltage);
46}
47
49 Int timeStepCount) {
50 stepInPerUnit(time); //former system solve (trapezoidal)
52}
53
57
59 // Receives the voltage of time step k and has to
60 // calculate the current output for time step k+1
61 for (Int i = 0; i < mMultisamplingRate; i++) {
62 // Calculate per unit values and
63 // transform per unit voltages from abc to dq0
66 mVsr(0, 0) = mVdq0(0, 0);
67 mVsr(3, 0) = mVdq0(1, 0);
68 mVsr(6, 0) = mVdq0(2, 0);
69 // Current is already available in pu dq0 from previous step
70
71 // Update of fd winding voltage from exciter
72 if (mHasExciter) {
73 //mVsr(1,0) = mExciter.step(mVsr(0,0), mVsr(3,0), 1, mTimeStep);
74 }
75
76 // Update of mechanical torque from turbine governor
77 if (mHasTurbineGovernor == true) {
78 //mMechTorque = mTurbineGovernor.step(mOmMech, 1, 300e6 / 555e6, mTimeStep);
79 }
80
81 // Calculation of electrical torque
82 **mElecTorque = (mPsisr(3, 0) * mIsr(0, 0) - mPsisr(0, 0) * mIsr(3, 0));
83
84 // Update mechanical rotor angle with respect to electrical angle
85 // using Euler and previous states
87
88 // Update of omega using Euler
89 **mOmMech = **mOmMech + mTimeStep * (1. / (2. * **mInertia) *
90 (**mMechTorque - **mElecTorque));
91
92 // Update of fluxes
95 mPsisr,
98 } else {
100 mPsisr,
103 }
104
105 // Calculate new currents from fluxes
107 }
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:249
Matrix mIsr
Vector of stator and rotor currents.
Real mTimeStep
Simulation time step.
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.
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.
Matrix mOmegaFluxMat
Omega-flux matrix for state space system.
Matrix mIdq0
dq0 current calculated from terminal current
Real mBase_OmElec
base electrical angular frequency
Matrix mVdq0
dq0 voltage calculated from terminal voltage
Real mBase_OmMech
base mechanical angular frequency
Real mBase_V
base stator voltage (phase-to-ground peak)
const Attribute< Real >::Ptr mOmMech
rotor speed omega_r
Bool mHasTurbineGovernor
Determines if legacy TurbineGovernor is activated.
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
MatrixFixedSizeComp< 3, 1 > dq0ToAbcTransform(Real theta, const Eigen::Ref< const Matrix > &dq0)
Inverse Park transform as described in Krause.
void initializeMatrixAndStates()
Build the per-unit steady-state machine state after PF values are loaded.
SynchronGeneratorDQ(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
MatrixFixedSize< 3, 1 > abcToDq0Transform(Real theta, MatrixComp &abc)
Park transform as described in Krause.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaCompPreStep(Real time, Int timeStepCount) override
SynchronGeneratorDQTrapez(String uid, String name, Logger::Level loglevel=Logger::Level::off)
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes variables of component.
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
Attribute< Matrix >::Ptr mRightVector
static Matrix StateSpaceTrapezoidalNoCopy(const Matrix &states, const Matrix &A, const Matrix &B, Real dt, const Matrix &u_new, const Matrix &u_old)
static Matrix StateSpaceEulerNoCopy(const Matrix &states, const Matrix &A, const Matrix &B, Real dt, const Matrix &u)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Logger::Log mSLog
Component logger.
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59