DPsim
Loading...
Searching...
No Matches
EMT_Ph3_SynchronGeneratorTrStab.h
Go to the documentation of this file.
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
16
17namespace CPS {
18namespace EMT {
19namespace Ph3 {
25 public SharedFactory<SynchronGeneratorTrStab> {
26protected:
27 // #### Model specific variables ####
37 std::shared_ptr<VoltageSource> mSubVoltageSource;
39 std::shared_ptr<Inductor> mSubInductor;
40 // Logging
45
46public:
47 // #### Model specific variables ####
64 Logger::Level logLevel = Logger::Level::off);
67 Logger::Level logLevel = Logger::Level::off)
68 : SynchronGeneratorTrStab(name, name, logLevel) {}
69
71
76
77 // #### General Functions ####
79 void setInitialValues(Complex elecPower, Real mechPower);
81 void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq,
82 Real Ll, Real Lmd, Real Llfd, Real inertia,
83 Real D = 0);
85 void setStandardParametersSI(Real nomPower, Real nomVolt, Real nomFreq,
86 Int polePairNumber, Real Rs, Real Lpd,
87 Real inertiaJ, Real Kd = 0);
89 void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq,
90 Real Xpd, Real inertia, Real Rs = 0, Real D = 0);
92 void step(Real time);
94 void createSubComponents() override;
96 void initializeParentFromNodesAndTerminals(Real frequency) override;
97
98 // #### MNA Functions ####
100 void mnaParentInitialize(Real omega, Real timeStep,
101 Attribute<Matrix>::Ptr leftVector) override;
104 void mnaParentPreStep(Real time, Int timeStepCount) override;
106 void mnaParentPostStep(Real time, Int timeStepCount,
107 Attribute<Matrix>::Ptr &leftVector) override;
109 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
111 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
112
114 AttributeBase::List &prevStepDependencies,
115 AttributeBase::List &attributeDependencies,
116 AttributeBase::List &modifiedAttributes) override;
117 void
119 AttributeBase::List &attributeDependencies,
120 AttributeBase::List &modifiedAttributes,
121 Attribute<Matrix>::Ptr &leftVector) override;
122
123 class AddBStep : public Task {
124 public:
126 : Task(**generator.mName + ".AddBStep"), mGenerator(generator) {
127 mAttributeDependencies.push_back(
128 generator.mSubVoltageSource->mRightVector);
129 mAttributeDependencies.push_back(generator.mSubInductor->mRightVector);
130 mModifiedAttributes.push_back(generator.mRightVector);
131 }
132
133 void execute(Real time, Int timeStepCount);
134
135 private:
136 SynchronGeneratorTrStab &mGenerator;
137 };
138};
139} // namespace Ph3
140} // namespace EMT
141} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
Base synchronous generator model.
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Xpd, Real inertia, Real Rs=0, Real D=0)
Initializes the machine parameters.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
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.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
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.
SynchronGeneratorTrStab(String uid, String name, Logger::Level logLevel=Logger::Level::off)
const Attribute< Complex >::Ptr mEp
True after createSubComponents() runs; prevents double-construction.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Matrix parkTransformPowerInvariant(Real theta, const Matrix &fabc)
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 initializeParentFromNodesAndTerminals(Real frequency) override
const Attribute< Real >::Ptr mDelta_p
Angle by which the emf Ep is leading the terminal voltage.
void setInitialValues(Complex elecPower, Real mechPower)
void createSubComponents() override
Constructs and registers MNA subcomponents without emf value; idempotent.
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.
SynchronGeneratorTrStab(String name, Logger::Level logLevel=Logger::Level::off)
Real mXpd
Absolute d-axis transient reactance X'd.
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
Attribute< Matrix >::Ptr mRightVector
std::shared_ptr< SimPowerComp< VarType > > Ptr
std::vector< AttributeBase::Ptr > mModifiedAttributes
Definition Task.h:53
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:52
Task()
Definition Task.h:30
std::string mName
Definition Task.h:51
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:81
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61
std::complex< Real > Complex
Definition Definitions.h:63