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:
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:
100 const Attribute<Real>::Ptr mBaseVoltage;
101
102 // #### Power flow results ####
104 const Attribute<MatrixComp>::Ptr mCurrent;
105
107 const Attribute<Matrix>::Ptr mActivePowerBranch;
108
110 const Attribute<Matrix>::Ptr mReactivePowerBranch;
112 const Attribute<Real>::Ptr mActivePowerInjection;
114 const Attribute<Real>::Ptr mReactivePowerInjection;
115
117 Transformer(String uid, String name,
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
124 SimPowerComp<Complex>::Ptr clone(String name) override;
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 ####
141 Real getNominalVoltageEnd1() const;
143 Real getNominalVoltageEnd2() const;
144 void setBaseVoltage(Real baseVoltage);
146 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
148 void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
150 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
152 void storeNodalInjection(Complex powerInjection);
153
154 // #### Getter ####
156 MatrixComp Y_element();
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
180 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
181 AttributeBase::List &attributeDependencies,
182 AttributeBase::List &modifiedAttributes,
183 Attribute<Matrix>::Ptr &leftVector) override;
184};
185} // namespace Ph1
186} // namespace SP
187} // 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.
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