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> mSubResistor2;
38 std::shared_ptr<SP::Ph1::Inductor> mSubInductor2;
40 std::shared_ptr<SP::Ph1::Resistor> mSubMagnetizingResistor;
42 std::shared_ptr<SP::Ph1::Inductor> mSubMagnetizingInductor;
43
45 Real mRatioAbs = 1;
47 Real mRatioPhase = 0;
49 Real mNominalOmega;
51 Real mReactance;
52
54 Complex mLeakage;
55
57 Real mBaseApparentPower;
59 Real mBaseImpedance;
61 Real mBaseInductance;
63 Real mBaseAdmittance;
65 Real mBaseOmega;
66
68 Real mBaseCurrent;
69
71 Real mResistancePerUnit;
73 Real mReactancePerUnit;
75 Real mInductancePerUnit;
77 Complex mLeakagePerUnit;
79 Complex mMagnetizingPerUnit;
81 Real mRatioAbsPerUnit;
83 Complex mRatioPerUnit;
84
85 // #### Admittance matrix stamp ####
86 MatrixComp mY_element;
87
89 Real mMagnetizingResistance;
91 Real mMagnetizingInductance;
93 Real mNoLoadCurrent = 0.01;
95 Real mNoLoadLoss = 1e-3;
96
98 Bool mWithResistiveLosses;
99
101 UInt mReferenceTerminal = 0;
103 UInt nonReferenceTerminal() const { return 1 - mReferenceTerminal; }
105 Complex mRatioFromReference;
107 Real mOrientationSign = 1.;
109 WindingReference mReferenceWinding = WindingReference::Auto;
111 void resolveWindingRoles();
112
113public:
115 void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss) {
116 mNoLoadCurrent = noLoadCurrent;
117 mNoLoadLoss = noLoadLoss;
118 }
119
120 void setReferenceWinding(WindingReference referenceWinding) {
121 mReferenceWinding = referenceWinding;
122 }
123
125
126 // #### Power flow results ####
129
132
139
142 Logger::Level logLevel = Logger::Level::off,
143 Bool withResistiveLosses = false);
145 Transformer(String name, Logger::Level logLevel = Logger::Level::off)
146 : Transformer(name, name, logLevel) {}
147
149
150 // #### General ####
152 void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary,
153 Real ratioAbs, Real ratioPhase, Real resistance,
154 Real inductance);
156 void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary,
157 Real ratedPower, Real ratioAbs, Real ratioPhase,
158 Real resistance, Real inductance);
160 void createSubComponents() override;
162 void initializeParentFromNodesAndTerminals(Real frequency) override;
163
164 // #### Powerflow section ####
169 void setBaseVoltage(Real baseVoltage);
171 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
175 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
177 void storeNodalInjection(Complex powerInjection);
178
179 // #### Getter ####
182
183 // #### MNA Section ####
185 void mnaParentInitialize(Real omega, Real timeStep,
186 Attribute<Matrix>::Ptr leftVector) override;
188 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
190 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
192 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
194 void mnaParentPreStep(Real time, Int timeStepCount) override;
196 void mnaParentPostStep(Real time, Int timeStepCount,
197 Attribute<Matrix>::Ptr &leftVector) override;
200 AttributeBase::List &prevStepDependencies,
201 AttributeBase::List &attributeDependencies,
202 AttributeBase::List &modifiedAttributes) override;
204 void
206 AttributeBase::List &attributeDependencies,
207 AttributeBase::List &modifiedAttributes,
208 Attribute<Matrix>::Ptr &leftVector) override;
209};
210} // namespace Ph1
211} // namespace SP
212} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
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 mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss)
Sets the magnetizing branch from the no-load test quantities.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
Real getNominalVoltagePrimary() const
Get nominal voltage of the primary winding.
void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Set transformer specific parameters (without rated power)
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
void setReferenceWinding(WindingReference referenceWinding)
Selects the winding the nameplate impedance is referred to.
Real getNominalVoltageSecondary() const
Get nominal voltage of the secondary winding.
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]
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:79
std::string String
Definition Definitions.h:63
Eigen::SparseMatrix< Complex, Eigen::RowMajor > SparseMatrixCompRow
Sparse matrix for complex numbers (row major).
Definition Definitions.h:76
double Real
Definition Definitions.h:60
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > VectorComp
Dense vector for complex numbers.
Definition Definitions.h:66
int Int
Definition Definitions.h:59
std::complex< Real > Complex
Definition Definitions.h:61
WindingReference
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Definition Definitions.h:82
bool Bool
Definition Definitions.h:62
unsigned int UInt
Definition Definitions.h:58
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:72