DPsim
Loading...
Searching...
No Matches
SP_Ph1_Transformer.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
18
19namespace CPS {
20namespace SP {
21namespace Ph1 {
23class Transformer : public CompositePowerComp<Complex>,
25 public SharedFactory<Transformer>,
27
28private:
31 std::shared_ptr<SP::Ph1::Resistor> mSubResistor;
33 std::shared_ptr<SP::Ph1::Inductor> mSubInductor;
34
36 std::shared_ptr<SP::Ph1::Resistor> mSubSnubResistor1;
38 std::shared_ptr<SP::Ph1::Resistor> mSubSnubResistor2;
40 std::shared_ptr<SP::Ph1::Capacitor> mSubSnubCapacitor1;
42 std::shared_ptr<SP::Ph1::Capacitor> mSubSnubCapacitor2;
43
45 Real mSnubberResistance1;
47 Real mSnubberResistance2;
49 Real mSnubberCapacitance1;
51 Real mSnubberCapacitance2;
52
54 Real mRatioAbs = 1;
56 Real mRatioPhase = 0;
58 Real mNominalOmega;
60 Real mReactance;
61
63 Complex mLeakage;
64
66 Real mBaseApparentPower;
68 Real mBaseImpedance;
70 Real mBaseInductance;
72 Real mBaseAdmittance;
74 Real mBaseOmega;
75
77 Real mBaseCurrent;
78
80 Real mResistancePerUnit;
82 Real mReactancePerUnit;
84 Real mInductancePerUnit;
86 Complex mLeakagePerUnit;
88 Complex mMagnetizingPerUnit;
90 Real mRatioAbsPerUnit;
91
92 // #### Admittance matrix stamp ####
93 MatrixComp mY_element;
94
96 Bool mWithResistiveLosses;
97
98public:
101
102 // #### Power flow results ####
105
108
115
118 Logger::Level logLevel = Logger::Level::off,
119 Bool withResistiveLosses = false);
121 Transformer(String name, Logger::Level logLevel = Logger::Level::off)
122 : Transformer(name, name, logLevel) {}
123
125
126 // #### General ####
128 void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs,
129 Real ratioPhase, Real resistance, Real inductance);
131 void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower,
132 Real ratioAbs, Real ratioPhase, Real resistance,
133 Real inductance);
135 void createSubComponents() override;
137 void initializeParentFromNodesAndTerminals(Real frequency) override;
138
139 // #### Powerflow section ####
144 void setBaseVoltage(Real baseVoltage);
146 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
150 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
152 void storeNodalInjection(Complex powerInjection);
153
154 // #### Getter ####
157
158 // #### MNA Section ####
160 void mnaParentInitialize(Real omega, Real timeStep,
161 Attribute<Matrix>::Ptr leftVector) override;
163 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
165 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
167 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
169 void mnaParentPreStep(Real time, Int timeStepCount) override;
171 void mnaParentPostStep(Real time, Int timeStepCount,
172 Attribute<Matrix>::Ptr &leftVector) override;
175 AttributeBase::List &prevStepDependencies,
176 AttributeBase::List &attributeDependencies,
177 AttributeBase::List &modifiedAttributes) override;
179 void
181 AttributeBase::List &attributeDependencies,
182 AttributeBase::List &modifiedAttributes,
183 Attribute<Matrix>::Ptr &leftVector) override;
184};
185} // namespace Ph1
186} // namespace SP
187} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
Common base class of all Component templates.
Transformer(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
Transformer(String uid, String name, Logger::Level logLevel=Logger::Level::off, Bool withResistiveLosses=false)
Defines UID, name and logging level.
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Initializes component from power flow data.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
void updateBranchFlow(VectorComp &current, VectorComp &powerflow)
updates branch current and power flow, input pu value, update with real value
void setBaseVoltage(Real baseVoltage)
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Set transformer specific parameters (without rated power)
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
Real getNominalVoltageEnd1() const
Get nominal voltage at end 1.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
MatrixComp Y_element()
get admittance matrix
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
const Attribute< Real >::Ptr mBaseVoltage
base voltage [V]
Real getNominalVoltageEnd2() const
Get nominal voltage at end 2.
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
std::shared_ptr< SimPowerComp< VarType > > Ptr
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
Eigen::SparseMatrix< Complex, Eigen::RowMajor > SparseMatrixCompRow
Sparse matrix for complex numbers (row major).
Definition Definitions.h:78
double Real
Definition Definitions.h:62
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > VectorComp
Dense vector for complex numbers.
Definition Definitions.h:68
int Int
Definition Definitions.h:61
std::complex< Real > Complex
Definition Definitions.h:63
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Definition Definitions.h:84
bool Bool
Definition Definitions.h:64
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:74