DPsim
Loading...
Searching...
No Matches
DP_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/DP/DP_Ph1_Inductor.h>
14#include <dpsim-models/DP/DP_Ph1_VoltageSource.h>
15#include <dpsim-models/Solver/MNAInterface.h>
16
17namespace CPS {
18namespace DP {
19namespace Ph1 {
23class SynchronGeneratorTrStab : public CompositePowerComp<Complex>,
25 public SharedFactory<SynchronGeneratorTrStab> {
26protected:
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;
46
47public:
48 // #### Model specific variables ####
50 const Attribute<Complex>::Ptr mEp;
53 const Attribute<Real>::Ptr mEp_abs;
56 const Attribute<Real>::Ptr mEp_phase;
58 const Attribute<Real>::Ptr mDelta_p;
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;
100 void mnaParentPreStep(Real time, Int timeStepCount) override;
102 void mnaParentPostStep(Real time, Int timeStepCount,
103 Attribute<Matrix>::Ptr &leftVector) override;
105 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
107 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
108
110 AttributeBase::List &prevStepDependencies,
111 AttributeBase::List &attributeDependencies,
112 AttributeBase::List &modifiedAttributes) override;
113 void
114 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
115 AttributeBase::List &attributeDependencies,
116 AttributeBase::List &modifiedAttributes,
117 Attribute<Matrix>::Ptr &leftVector) override;
118
119 void setReferenceOmega(Attribute<Real>::Ptr refOmegaPtr,
120 Attribute<Real>::Ptr refDeltaPtr);
121
122 class AddBStep : public Task {
123 public:
124 AddBStep(SynchronGeneratorTrStab &generator)
125 : Task(**generator.mName + ".AddBStep"), mGenerator(generator) {
126 mAttributeDependencies.push_back(
127 generator.mSubVoltageSource->mRightVector);
128 mAttributeDependencies.push_back(generator.mSubInductor->mRightVector);
129 mModifiedAttributes.push_back(generator.mRightVector);
130 }
131
132 void execute(Real time, Int timeStepCount);
133
134 private:
135 SynchronGeneratorTrStab &mGenerator;
136 };
137};
138} // namespace Ph1
139} // namespace DP
140} // namespace CPS
Base synchronous generator model.
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
Retrieves calculated voltage from simulation for next step.
std::shared_ptr< Inductor > mSubInductor
Inner inductor that represents the generator impedance.
void setStandardParametersSI(Real nomPower, Real nomVolt, Real nomFreq, Int polePairNumber, Real Rs, Real Lpd, Real inertiaJ, Real Kd=0)
Initializes the machine parameters.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
Complex mImpedance
Equivalent impedance for loadflow calculation.
const Attribute< Complex >::Ptr mEp
emf behind transient reactance
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
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.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes variables of component.
void setModelFlags(Bool convertWithOmegaMech)
Flags to modify model behavior.
Real mXpd
Absolute d-axis transient reactance X'd.
Bool mConvertWithOmegaMech
Flag for usage of actual mechanical speed for torque conversion (otherwise mNomOmega is used)
Bool mUseOmegaRef
Flag for usage of attribute of w_ref (otherwise mNomOmega is used)
void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Ll, Real Lmd, Real Llfd, Real inertia, Real D=0)
Initializes the machine parameters.
std::shared_ptr< VoltageSource > mSubVoltageSource
Inner voltage source that represents the generator.
void mnaParentPreStep(Real time, Int timeStepCount) override
Real mLpd
Absolute d-axis transient inductance.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
Attribute< Matrix >::Ptr mRightVector