DPsim
EMT_Ph3_SynchronGeneratorTrStab.h
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 
11 #include <dpsim-models/Base/Base_SynchronGenerator.h>
12 #include <dpsim-models/CompositePowerComp.h>
13 #include <dpsim-models/EMT/EMT_Ph3_Inductor.h>
14 #include <dpsim-models/EMT/EMT_Ph3_VoltageSource.h>
15 #include <dpsim-models/Solver/MNAInterface.h>
16 
17 namespace CPS {
18 namespace EMT {
19 namespace Ph3 {
25  public SharedFactory<SynchronGeneratorTrStab> {
26 protected:
27  // #### Model specific variables ####
29  Real mXpd;
31  Real mLpd;
33  Real mKd;
35  Complex mImpedance;
37  std::shared_ptr<VoltageSource> mSubVoltageSource;
39  std::shared_ptr<Inductor> mSubInductor;
40  // Logging
41  Matrix mStates;
43  Real mThetaN = 0;
44 
45 public:
46  // #### Model specific variables ####
58  const Attribute<Real>::Ptr mRefOmega;
60  const Attribute<Real>::Ptr mRefDelta;
62  SynchronGeneratorTrStab(String uid, String name,
63  Logger::Level logLevel = Logger::Level::off);
65  SynchronGeneratorTrStab(String name,
66  Logger::Level logLevel = Logger::Level::off)
67  : SynchronGeneratorTrStab(name, name, logLevel) {}
68 
69  SimPowerComp<Real>::Ptr clone(String name) override;
70 
72  Matrix parkTransformPowerInvariant(Real theta, const Matrix &fabc);
74  Matrix getParkTransformMatrixPowerInvariant(Real theta);
75 
76  // #### General Functions ####
78  void setInitialValues(Complex elecPower, Real mechPower);
80  void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq,
81  Real Ll, Real Lmd, Real Llfd, Real inertia,
82  Real D = 0);
84  void setStandardParametersSI(Real nomPower, Real nomVolt, Real nomFreq,
85  Int polePairNumber, Real Rs, Real Lpd,
86  Real inertiaJ, Real Kd = 0);
88  void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq,
89  Real Xpd, Real inertia, Real Rs = 0, Real D = 0);
91  void step(Real time);
93  void initializeFromNodesAndTerminals(Real frequency) override;
94 
95  // #### MNA Functions ####
97  void mnaParentInitialize(Real omega, Real timeStep,
98  Attribute<Matrix>::Ptr leftVector) override;
101  void mnaParentPreStep(Real time, Int timeStepCount) override;
103  void mnaParentPostStep(Real time, Int timeStepCount,
104  Attribute<Matrix>::Ptr &leftVector) override;
106  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
108  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
109 
110  void mnaParentAddPreStepDependencies(
111  AttributeBase::List &prevStepDependencies,
112  AttributeBase::List &attributeDependencies,
113  AttributeBase::List &modifiedAttributes) override;
114  void
115  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
116  AttributeBase::List &attributeDependencies,
117  AttributeBase::List &modifiedAttributes,
118  Attribute<Matrix>::Ptr &leftVector) override;
119 
120  class AddBStep : public Task {
121  public:
123  : Task(**generator.mName + ".AddBStep"), mGenerator(generator) {
124  mAttributeDependencies.push_back(
125  generator.mSubVoltageSource->mRightVector);
126  mAttributeDependencies.push_back(generator.mSubInductor->mRightVector);
127  mModifiedAttributes.push_back(generator.mRightVector);
128  }
129 
130  void execute(Real time, Int timeStepCount);
131 
132  private:
133  SynchronGeneratorTrStab &mGenerator;
134  };
135 };
136 } // namespace Ph3
137 } // namespace EMT
138 } // namespace CPS
Base synchronous generator model.
Base class for composite power components.
Synchronous generator model for transient stability analysis.
void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Xpd, Real inertia, Real Rs=0, Real D=0)
Initializes the machine parameters.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes variables of component.
void setStandardParametersSI(Real nomPower, Real nomVolt, Real nomFreq, Int polePairNumber, Real Rs, Real Lpd, Real inertiaJ, Real Kd=0)
Initializes the machine parameters.
std::shared_ptr< VoltageSource > mSubVoltageSource
Inner voltage source that represents the generator.
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
Retrieves calculated voltage from simulation for next step.
const Attribute< Complex >::Ptr mEp
emf behind transient reactance
void mnaParentPreStep(Real time, Int timeStepCount) override
Complex mImpedance
Equivalent impedance for loadflow calculation.
std::shared_ptr< Inductor > mSubInductor
Inner inductor that represents the generator impedance.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
const Attribute< Real >::Ptr mDelta_p
Angle by which the emf Ep is leading the terminal voltage.
void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Ll, Real Lmd, Real Llfd, Real inertia, Real D=0)
Initializes the machine parameters.
Real mLpd
Absolute d-axis transient inductance.
Real mXpd
Absolute d-axis transient reactance X'd.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
Attribute< Matrix >::Ptr mRightVector
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17
Tasks to be defined by every component.
Definition: Task.h:25