DPsim
Loading...
Searching...
No Matches
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
19namespace CPS {
20namespace SP {
21namespace Ph1 {
23class Transformer : public CompositePowerComp<Complex>,
25 public SharedFactory<Transformer>,
27
28private:
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
97public:
99 const Attribute<Real>::Ptr mBaseVoltage;
100
101 // #### Power flow results ####
103 const Attribute<MatrixComp>::Ptr mCurrent;
104
106 const Attribute<Matrix>::Ptr mActivePowerBranch;
107
109 const Attribute<Matrix>::Ptr mReactivePowerBranch;
111 const Attribute<Real>::Ptr mActivePowerInjection;
113 const Attribute<Real>::Ptr mReactivePowerInjection;
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 Real getNominalVoltageEnd1() const;
140 Real getNominalVoltageEnd2() const;
141 void setBaseVoltage(Real baseVoltage);
143 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
145 void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
147 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
149 void storeNodalInjection(Complex powerInjection);
150
151 // #### Getter ####
153 MatrixComp Y_element();
154
155 // #### MNA Section ####
157 void mnaParentInitialize(Real omega, Real timeStep,
158 Attribute<Matrix>::Ptr leftVector) override;
160 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
162 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
164 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
166 void mnaParentPreStep(Real time, Int timeStepCount) override;
168 void mnaParentPostStep(Real time, Int timeStepCount,
169 Attribute<Matrix>::Ptr &leftVector) override;
172 AttributeBase::List &prevStepDependencies,
173 AttributeBase::List &attributeDependencies,
174 AttributeBase::List &modifiedAttributes) override;
176 void
177 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
178 AttributeBase::List &attributeDependencies,
179 AttributeBase::List &modifiedAttributes,
180 Attribute<Matrix>::Ptr &leftVector) override;
181};
182} // namespace Ph1
183} // namespace SP
184} // namespace CPS
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
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 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.
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]
Real getNominalVoltageEnd2() const
Get nominal voltage at end 2.
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection