DPsim
SP_Ph1_Transformer.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_Ph1_Transformer.h>
12 #include <dpsim-models/CompositePowerComp.h>
13 #include <dpsim-models/SP/SP_Ph1_Capacitor.h>
14 #include <dpsim-models/SP/SP_Ph1_Inductor.h>
15 #include <dpsim-models/SP/SP_Ph1_Resistor.h>
16 #include <dpsim-models/Solver/MNAInterface.h>
17 #include <dpsim-models/Solver/PFSolverInterfaceBranch.h>
18 
19 namespace CPS {
20 namespace SP {
21 namespace Ph1 {
23 class Transformer : public CompositePowerComp<Complex>,
25  public SharedFactory<Transformer>,
27 
28 private:
30  std::shared_ptr<SP::Ph1::Resistor> mSubResistor;
32  std::shared_ptr<SP::Ph1::Inductor> mSubInductor;
33 
35  std::shared_ptr<SP::Ph1::Resistor> mSubSnubResistor1;
37  std::shared_ptr<SP::Ph1::Resistor> mSubSnubResistor2;
39  std::shared_ptr<SP::Ph1::Capacitor> mSubSnubCapacitor1;
41  std::shared_ptr<SP::Ph1::Capacitor> mSubSnubCapacitor2;
42 
44  Real mSnubberResistance1;
46  Real mSnubberResistance2;
48  Real mSnubberCapacitance1;
50  Real mSnubberCapacitance2;
51 
53  Real mRatioAbs = 1;
55  Real mRatioPhase = 0;
57  Real mNominalOmega;
59  Real mReactance;
60 
62  Complex mLeakage;
63 
65  Real mBaseApparentPower;
67  Real mBaseImpedance;
69  Real mBaseInductance;
71  Real mBaseAdmittance;
73  Real mBaseOmega;
74 
76  Real mBaseCurrent;
77 
79  Real mResistancePerUnit;
81  Real mReactancePerUnit;
83  Real mInductancePerUnit;
85  Complex mLeakagePerUnit;
87  Complex mMagnetizingPerUnit;
89  Real mRatioAbsPerUnit;
90 
91  // #### Admittance matrix stamp ####
92  MatrixComp mY_element;
93 
95  Bool mWithResistiveLosses;
96 
97 public:
100 
101  // #### Power flow results ####
104 
107 
114 
116  Transformer(String uid, String name,
117  Logger::Level logLevel = Logger::Level::off,
118  Bool withResistiveLosses = false);
120  Transformer(String name, Logger::Level logLevel = Logger::Level::off)
121  : Transformer(name, name, logLevel) {}
122 
123  SimPowerComp<Complex>::Ptr clone(String name) override;
124 
125  // #### General ####
127  void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs,
128  Real ratioPhase, Real resistance, Real inductance);
130  void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower,
131  Real ratioAbs, Real ratioPhase, Real resistance,
132  Real inductance);
134  void initializeFromNodesAndTerminals(Real frequency) override;
135 
136  // #### Powerflow section ####
138  void setBaseVoltage(Real baseVoltage);
140  void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
142  void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
144  void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
146  void storeNodalInjection(Complex powerInjection);
147 
148  // #### Getter ####
150  MatrixComp Y_element();
151 
152  // #### MNA Section ####
154  void mnaParentInitialize(Real omega, Real timeStep,
155  Attribute<Matrix>::Ptr leftVector) override;
157  void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
159  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
161  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
163  void mnaParentPreStep(Real time, Int timeStepCount) override;
165  void mnaParentPostStep(Real time, Int timeStepCount,
166  Attribute<Matrix>::Ptr &leftVector) override;
169  AttributeBase::List &prevStepDependencies,
170  AttributeBase::List &attributeDependencies,
171  AttributeBase::List &modifiedAttributes) override;
173  void
174  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
175  AttributeBase::List &attributeDependencies,
176  AttributeBase::List &modifiedAttributes,
177  Attribute<Matrix>::Ptr &leftVector) override;
178 };
179 } // namespace Ph1
180 } // namespace SP
181 } // namespace CPS
Base class for composite power components.
String uid()
Returns unique id.
Common base class of all Component templates.
Transformer that includes an inductance and resistance.
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)
Set base voltage.
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.
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.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
const Attribute< Real >::Ptr mBaseVoltage
base voltage [V]
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17