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;
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;
103 void mnaParentPreStep(Real time, Int timeStepCount) override;
105 void mnaParentPostStep(Real time, Int timeStepCount,
106 Attribute<Matrix>::Ptr &leftVector) override;
108 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
110 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
111
113 AttributeBase::List &prevStepDependencies,
114 AttributeBase::List &attributeDependencies,
115 AttributeBase::List &modifiedAttributes) override;
116 void
117 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
118 AttributeBase::List &attributeDependencies,
119 AttributeBase::List &modifiedAttributes,
120 Attribute<Matrix>::Ptr &leftVector) override;
121
122 void setReferenceOmega(Attribute<Real>::Ptr refOmegaPtr,
123 Attribute<Real>::Ptr refDeltaPtr);
124
125 class AddBStep : public Task {
126 public:
127 AddBStep(SynchronGeneratorTrStab &generator)
128 : Task(**generator.mName + ".AddBStep"), mGenerator(generator) {
129 mAttributeDependencies.push_back(
130 generator.mSubVoltageSource->mRightVector);
131 mAttributeDependencies.push_back(generator.mSubInductor->mRightVector);
132 mModifiedAttributes.push_back(generator.mRightVector);
133 }
134
135 void execute(Real time, Int timeStepCount);
136
137 private:
138 SynchronGeneratorTrStab &mGenerator;
139 };
140};
141} // namespace Ph1
142} // namespace DP
143} // 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.
Complex mImpedance
Equivalent impedance for loadflow calculation.
const Attribute< Complex >::Ptr mEp
True after createSubComponents() runs; prevents double-construction.
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.
void createSubComponents() override
Constructs and registers MNA subcomponents without emf value; idempotent.
void initializeParentFromNodesAndTerminals(Real frequency) override
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