DPsim
Loading...
Searching...
No Matches
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
17namespace CPS {
18namespace SP {
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;
47
48public:
49 // #### Model specific variables ####
51 const Attribute<Complex>::Ptr mEp;
54 const Attribute<Real>::Ptr mEp_abs;
57 const Attribute<Real>::Ptr mEp_phase;
59 const Attribute<Real>::Ptr mDelta_p;
61 const Attribute<Real>::Ptr mRefOmega;
63 const Attribute<Real>::Ptr mRefDelta;
65 SynchronGeneratorTrStab(String uid, String name,
66 Logger::Level logLevel = Logger::Level::off);
68 SynchronGeneratorTrStab(String name,
69 Logger::Level logLevel = Logger::Level::off)
70 : SynchronGeneratorTrStab(name, name, logLevel) {}
71
72 SimPowerComp<Complex>::Ptr clone(String name) override;
73
74 // #### General Functions ####
76 void setModelFlags(Bool convertWithOmegaMech);
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 createSubComponents() override;
95 void initializeParentFromNodesAndTerminals(Real frequency) override;
96
97 // #### MNA Functions ####
99 void mnaParentInitialize(Real omega, Real timeStep,
100 Attribute<Matrix>::Ptr leftVector) override;
101
103 void mnaParentPreStep(Real time, Int timeStepCount) override;
104 void mnaParentPostStep(Real time, Int timeStepCount,
105 Attribute<Matrix>::Ptr &leftVector) override;
107 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
109 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
110
112 AttributeBase::List &prevStepDependencies,
113 AttributeBase::List &attributeDependencies,
114 AttributeBase::List &modifiedAttributes) override;
115 void
116 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
117 AttributeBase::List &attributeDependencies,
118 AttributeBase::List &modifiedAttributes,
119 Attribute<Matrix>::Ptr &leftVector) override;
120
121 void setReferenceOmega(Attribute<Real>::Ptr refOmegaPtr,
122 Attribute<Real>::Ptr refDeltaPtr);
123 class AddBStep : public Task {
124 public:
125 AddBStep(SynchronGeneratorTrStab &generator)
126 : Task(**generator.mName + ".AddBStep"), mGenerator(generator) {
127 mAttributeDependencies.push_back(
128 generator.mSubVoltageSource->attribute("right_vector"));
129 mAttributeDependencies.push_back(
130 generator.mSubInductor->attribute("right_vector"));
131 mModifiedAttributes.push_back(generator.attribute("right_vector"));
132 }
133
134 void execute(Real time, Int timeStepCount);
135
136 private:
137 SynchronGeneratorTrStab &mGenerator;
138 };
139};
140} // namespace Ph1
141} // namespace SP
142} // namespace CPS
Base synchronous generator model.
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
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.
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 initializeParentFromNodesAndTerminals(Real frequency) override
void setModelFlags(Bool convertWithOmegaMech)
Flags to modify model behavior.
void createSubComponents() override
Constructs and registers MNA subcomponents without emf value; idempotent.
std::shared_ptr< VoltageSource > mSubVoltageSource
Inner voltage source that represents the generator.
const Attribute< Complex >::Ptr mEp
True after createSubComponents() runs; prevents double-construction.
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.