DPsim
Loading...
Searching...
No Matches
EMT_Ph3_Transformer.h
Go to the documentation of this file.
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
17
18namespace CPS {
19namespace EMT {
20namespace Ph3 {
22class Transformer : public CompositePowerComp<Real>,
23 public SharedFactory<Transformer>,
25private:
28 std::shared_ptr<EMT::Ph3::Resistor> mSubResistor;
30 std::shared_ptr<EMT::Ph3::Inductor> mSubInductor;
31
33 std::shared_ptr<EMT::Ph3::Resistor> mSubResistor2;
35 std::shared_ptr<EMT::Ph3::Inductor> mSubInductor2;
37 std::shared_ptr<EMT::Ph3::Resistor> mSubMagnetizingResistor;
39 std::shared_ptr<EMT::Ph3::Inductor> mSubMagnetizingInductor;
40
42 Matrix mMagnetizingResistance;
44 Matrix mMagnetizingInductance;
46 Real mNoLoadCurrent = 0.01;
48 Real mNoLoadLoss = 1e-3;
49
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();
65
66public:
68 void setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss) {
69 mNoLoadCurrent = noLoadCurrent;
70 mNoLoadLoss = noLoadLoss;
71 }
72
73 void setReferenceWinding(WindingReference referenceWinding) {
74 mReferenceWinding = referenceWinding;
75 }
76
78 Logger::Level logLevel = Logger::Level::off,
79 Bool withResistiveLosses = false);
81 Transformer(String name, Logger::Level logLevel = Logger::Level::off)
82 : Transformer(name, name, logLevel) {}
83
85
86 // #### General ####
88 void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary,
89 Real ratedPower, Real ratioAbs, Real ratioPhase,
90 Matrix resistance, Matrix inductance);
92 void createSubComponents() override;
94 void initializeParentFromNodesAndTerminals(Real frequency) override;
95
96 // #### MNA section ####
98 void mnaParentInitialize(Real omega, Real timeStep,
99 Attribute<Matrix>::Ptr leftVector) override;
101 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
103 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
105 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
107 void mnaParentPreStep(Real time, Int timeStepCount) override;
109 void mnaParentPostStep(Real time, Int timeStepCount,
110 Attribute<Matrix>::Ptr &leftVector) override;
113 AttributeBase::List &prevStepDependencies,
114 AttributeBase::List &attributeDependencies,
115 AttributeBase::List &modifiedAttributes) override;
117 void
119 AttributeBase::List &attributeDependencies,
120 AttributeBase::List &modifiedAttributes,
121 Attribute<Matrix>::Ptr &leftVector) override;
122};
123} // namespace Ph3
124} // namespace EMT
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 setMagnetizingBranch(Real noLoadCurrent, Real noLoadLoss)
Sets the magnetizing branch from the no-load test quantities.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
Transformer(String uid, String name, Logger::Level logLevel=Logger::Level::off, Bool withResistiveLosses=false)
Defines UID, name and logging level.
void setReferenceWinding(WindingReference referenceWinding)
Selects the winding the nameplate impedance is referred to.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
Transformer(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
SimPowerComp< Real >::Ptr clone(String name) override
DEPRECATED: Delete method.
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void setParameters(Real nomVoltagePrimary, Real nomVoltageSecondary, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance)
Defines component parameters.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
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.
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