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;
35 Bool mSubCompCreated = false;
37 Bool mWithResistiveLosses;
38
40 UInt mReferenceTerminal = 0;
42 UInt nonReferenceTerminal() const { return 1 - mReferenceTerminal; }
44 Complex mRatioFromReference;
46 Real mOrientationSign = 1.;
48 WindingReference mReferenceWinding = WindingReference::Auto;
50 void resolveWindingRoles();
52 void createSubComponents() override;
53
54public:
56 void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss) {
57 mNoLoadCurrent = noLoadCurrent;
58 mNoLoadLoss = noLoadLoss;
59 }
60
61 void setReferenceWinding(WindingReference referenceWinding) {
62 mReferenceWinding = referenceWinding;
63 }
64
66 Logger::Level logLevel = Logger::Level::off,
67 Bool withResistiveLosses = false);
69 Transformer(String name, Logger::Level logLevel = Logger::Level::off)
70 : Transformer(name, name, logLevel) {}
71
73
75 void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary,
76 Real ratedPower, Real ratioAbs, Real ratioPhase,
77 Matrix resistance, Matrix inductance);
78
79 void initializeParentFromNodesAndTerminals(Real frequency) override;
80
81 void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
82 void mnaParentPreStep(Real time, Int timeStepCount) override;
84 AttributeBase::List &prevStepDependencies,
85 AttributeBase::List &attributeDependencies,
86 AttributeBase::List &modifiedAttributes) override;
87 void
89 AttributeBase::List &attributeDependencies,
90 AttributeBase::List &modifiedAttributes,
91 Attribute<Matrix>::Ptr &leftVector) override;
92 void mnaParentPostStep(Real time, Int timeStepCount,
93 Attribute<Matrix>::Ptr &leftVector) override;
94 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
95 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
96};
97} // namespace Ph3
98} // namespace DP
99} // 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 mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
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 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
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