DPsim
Loading...
Searching...
No Matches
DP_Ph3_Transformer.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
10
11namespace CPS {
12namespace DP {
13namespace Ph3 {
14
15class Transformer : public CompositePowerComp<Complex>,
16 public SharedFactory<Transformer>,
18private:
19 std::shared_ptr<DP::Ph3::Resistor> mSubResistor;
20 std::shared_ptr<DP::Ph3::Resistor> mSubResistor2;
21 std::shared_ptr<DP::Ph3::Inductor> mSubInductor;
22 std::shared_ptr<DP::Ph3::Inductor> mSubInductor2;
23 std::shared_ptr<DP::Ph3::Resistor> mSubMagnetizingResistor;
24 std::shared_ptr<DP::Ph3::Inductor> mSubMagnetizingInductor;
25
27 Matrix mMagnetizingResistance;
29 Matrix mMagnetizingInductance;
31 Real mNoLoadCurrent = 0.01;
33 Real mNoLoadLoss = 1e-3;
34 Bool mUseSubcomponents = true;
35 MatrixComp mDirectInductorAdmittance = MatrixComp::Zero(3, 3);
36 Complex mDirectInductorPrevCurrentFactor = Complex(0., 0.);
37 MatrixComp mDirectInductorCurrent0 = MatrixComp::Zero(3, 1);
38 MatrixComp mDirectInductorCurrent1 = MatrixComp::Zero(3, 1);
39 MatrixComp mDirectInductorVoltage0 = MatrixComp::Zero(3, 1);
40 MatrixComp mDirectInductorVoltage1 = MatrixComp::Zero(3, 1);
41 MatrixComp mDirectInductorHistory0 = MatrixComp::Zero(3, 1);
42 MatrixComp mDirectInductorHistory1 = MatrixComp::Zero(3, 1);
43 MatrixComp mDirectMagnetizingAdmittance = MatrixComp::Zero(3, 3);
44 Complex mDirectMagnetizingPrevCurrentFactor = Complex(0., 0.);
45 MatrixComp mDirectMagnetizingCurrent = MatrixComp::Zero(3, 1);
46 MatrixComp mDirectMagnetizingVoltage = MatrixComp::Zero(3, 1);
47 MatrixComp mDirectMagnetizingHistory = MatrixComp::Zero(3, 1);
49 Bool mSubCompCreated = false;
51 Bool mWithResistiveLosses;
52
54 UInt mReferenceTerminal = 0;
56 UInt nonReferenceTerminal() const { return 1 - mReferenceTerminal; }
58 Complex mRatioFromReference;
60 Real mOrientationSign = 1.;
62 WindingReference mReferenceWinding = WindingReference::Auto;
64 void resolveWindingRoles();
66 void createSubComponents() override;
67
68public:
70 void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss) {
71 mNoLoadCurrent = noLoadCurrent;
72 mNoLoadLoss = noLoadLoss;
73 }
74
75 void setReferenceWinding(WindingReference referenceWinding) {
76 mReferenceWinding = referenceWinding;
77 }
78
80 Logger::Level logLevel = Logger::Level::off,
81 Bool withResistiveLosses = false);
82 Transformer(String uid, String name, Bool useSubcomponents,
83 Logger::Level logLevel = Logger::Level::off,
84 Bool withResistiveLosses = false);
85 Transformer(String name, Bool useSubcomponents,
86 Logger::Level logLevel = Logger::Level::off,
87 Bool withResistiveLosses = false)
88 : Transformer(name, name, useSubcomponents, logLevel,
89 withResistiveLosses) {}
90
91 Transformer(String name, Logger::Level logLevel = Logger::Level::off)
92 : Transformer(name, name, logLevel) {}
93
95
97 void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary,
98 Real ratedPower, Real ratioAbs, Real ratioPhase,
99 Matrix resistance, Matrix inductance);
100
101 void initializeParentFromNodesAndTerminals(Real frequency) override;
102
103 void mnaParentInitialize(Real omega, Real timeStep,
104 Attribute<Matrix>::Ptr leftVector) override;
105
106 void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
107 void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override;
108 void mnaParentPreStep(Real time, Int timeStepCount) override;
110 AttributeBase::List &prevStepDependencies,
111 AttributeBase::List &attributeDependencies,
112 AttributeBase::List &modifiedAttributes) override;
113 void
115 AttributeBase::List &attributeDependencies,
116 AttributeBase::List &modifiedAttributes,
117 Attribute<Matrix>::Ptr &leftVector) override;
118 void mnaParentPostStep(Real time, Int timeStepCount,
119 Attribute<Matrix>::Ptr &leftVector) override;
120 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
121 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
122};
123} // namespace Ph3
124} // namespace DP
125} // 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)
void initializeParentFromNodesAndTerminals(Real frequency) override
Transformer(String uid, String name, Logger::Level logLevel=Logger::Level::off, Bool withResistiveLosses=false)
Defines UID, name and logging level.
void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance)
Defines component parameters.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
Transformer(String name, Bool useSubcomponents, Logger::Level logLevel=Logger::Level::off, Bool withResistiveLosses=false)
void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss)
Sets the magnetizing branch from the no-load test quantities.
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void setReferenceWinding(WindingReference referenceWinding)
Selects the winding the nameplate impedance is referred to.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
void mnaCompUpdateVoltage(const Matrix &leftVector) override
void mnaParentPreStep(Real time, Int timeStepCount) override
Transformer(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
void mnaCompUpdateCurrent(const Matrix &leftVector) override
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
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
double Real
Definition Definitions.h:60
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