DPsim
SP_Ph1_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/SP/SP_Ph1_Inductor.h>
14 #include <dpsim-models/SP/SP_Ph1_VoltageSource.h>
15 #include <dpsim-models/Solver/MNAInterface.h>
16 
17 namespace CPS {
18 namespace SP {
19 namespace Ph1 {
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;
41  Matrix mStates;
43  Bool mUseOmegaRef = false;
45  Bool mConvertWithOmegaMech = true;
46 
47 public:
48  // #### Model specific variables ####
60  const Attribute<Real>::Ptr mRefOmega;
62  const Attribute<Real>::Ptr mRefDelta;
64  SynchronGeneratorTrStab(String uid, String name,
65  Logger::Level logLevel = Logger::Level::off);
67  SynchronGeneratorTrStab(String name,
68  Logger::Level logLevel = Logger::Level::off)
69  : SynchronGeneratorTrStab(name, name, logLevel) {}
70 
71  SimPowerComp<Complex>::Ptr clone(String name) override;
72 
73  // #### General Functions ####
75  void setModelFlags(Bool convertWithOmegaMech);
77  void setInitialValues(Complex elecPower, Real mechPower);
79  void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq,
80  Real Ll, Real Lmd, Real Llfd, Real inertia,
81  Real D = 0);
83  void setStandardParametersSI(Real nomPower, Real nomVolt, Real nomFreq,
84  Int polePairNumber, Real Rs, Real Lpd,
85  Real inertiaJ, Real Kd = 0);
87  void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq,
88  Real Xpd, Real inertia, Real Rs = 0, Real D = 0);
90  void step(Real time);
92  void initializeFromNodesAndTerminals(Real frequency) override;
93 
94  // #### MNA Functions ####
96  void mnaParentInitialize(Real omega, Real timeStep,
97  Attribute<Matrix>::Ptr leftVector) override;
98 
100  void mnaParentPreStep(Real time, Int timeStepCount) override;
101  void mnaParentPostStep(Real time, Int timeStepCount,
102  Attribute<Matrix>::Ptr &leftVector) override;
104  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
106  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
107 
109  AttributeBase::List &prevStepDependencies,
110  AttributeBase::List &attributeDependencies,
111  AttributeBase::List &modifiedAttributes) override;
112  void
113  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
114  AttributeBase::List &attributeDependencies,
115  AttributeBase::List &modifiedAttributes,
116  Attribute<Matrix>::Ptr &leftVector) override;
117 
118  void setReferenceOmega(Attribute<Real>::Ptr refOmegaPtr,
119  Attribute<Real>::Ptr refDeltaPtr);
120  class AddBStep : public Task {
121  public:
123  : Task(**generator.mName + ".AddBStep"), mGenerator(generator) {
124  mAttributeDependencies.push_back(
125  generator.mSubVoltageSource->attribute("right_vector"));
126  mAttributeDependencies.push_back(
127  generator.mSubInductor->attribute("right_vector"));
128  mModifiedAttributes.push_back(generator.attribute("right_vector"));
129  }
130 
131  void execute(Real time, Int timeStepCount);
132 
133  private:
134  SynchronGeneratorTrStab &mGenerator;
135  };
136 };
137 } // namespace Ph1
138 } // namespace SP
139 } // namespace CPS
Base synchronous generator model.
Base class for composite power components.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeBase::Ptr attribute(const String &name) const
Return pointer to an attribute.
Synchronous generator model for transient stability analysis.
Complex mImpedance
Equivalent impedance for loadflow calculation.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre and post step operations.
Bool mConvertWithOmegaMech
Flag for usage of actual mechanical speed for torque conversion (otherwise mNomOmega is used)
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
void setModelFlags(Bool convertWithOmegaMech)
Flags to modify model behavior.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
std::shared_ptr< VoltageSource > mSubVoltageSource
Inner voltage source that represents the generator.
const Attribute< Complex >::Ptr mEp
emf behind transient reactance
void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Xpd, Real inertia, Real Rs=0, Real D=0)
Initializes the machine parameters.
const Attribute< Real >::Ptr mDelta_p
Angle by which the emf Ep is leading the terminal voltage.
std::shared_ptr< Inductor > mSubInductor
Inner inductor that represents the generator impedance.
Real mLpd
Absolute d-axis transient inductance.
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.
Bool mUseOmegaRef
Flag for usage of attribute of w_ref (otherwise mNomOmega is used)
Real mXpd
Absolute d-axis transient reactance X'd.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Ll, Real Lmd, Real Llfd, Real inertia, Real D=0)
Initializes the machine parameters.
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17
Tasks to be defined by every component.
Definition: Task.h:25