DPsim
DP_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/DP/DP_Ph1_Capacitor.h>
14 #include <dpsim-models/DP/DP_Ph1_Inductor.h>
15 #include <dpsim-models/DP/DP_Ph1_Resistor.h>
16 #include <dpsim-models/Solver/MNAInterface.h>
17 
18 namespace CPS {
19 namespace DP {
20 namespace Ph1 {
22 class Transformer : public CompositePowerComp<Complex>,
23  public SharedFactory<Transformer>,
24  public Base::Ph1::Transformer {
25 private:
27  std::shared_ptr<DP::Ph1::Resistor> mSubResistor;
29  std::shared_ptr<DP::Ph1::Inductor> mSubInductor;
30 
32  std::shared_ptr<DP::Ph1::Resistor> mSubSnubResistor1;
34  std::shared_ptr<DP::Ph1::Resistor> mSubSnubResistor2;
36  std::shared_ptr<DP::Ph1::Capacitor> mSubSnubCapacitor1;
38  std::shared_ptr<DP::Ph1::Capacitor> mSubSnubCapacitor2;
39 
41  Real mSnubberResistance1;
43  Real mSnubberResistance2;
45  Real mSnubberCapacitance1;
47  Real mSnubberCapacitance2;
48 
50  Bool mWithResistiveLosses;
51 
52 public:
54  Transformer(String uid, String name,
55  Logger::Level logLevel = Logger::Level::off,
56  Bool withResistiveLosses = false);
58  Transformer(String name, Logger::Level logLevel = Logger::Level::off)
59  : Transformer(name, name, logLevel) {}
60 
61  SimPowerComp<Complex>::Ptr clone(String name) override;
62 
63  // #### General ####
65  void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs,
66  Real ratioPhase, Real resistance, Real inductance);
68  void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower,
69  Real ratioAbs, Real ratioPhase, Real resistance,
70  Real inductance);
72  void initializeFromNodesAndTerminals(Real frequency) override;
73 
74  // #### MNA section ####
76  void mnaParentInitialize(Real omega, Real timeStep,
77  Attribute<Matrix>::Ptr leftVector) override;
79  void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
81  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
83  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
85  void mnaParentPreStep(Real time, Int timeStepCount) override;
87  void mnaParentPostStep(Real time, Int timeStepCount,
88  Attribute<Matrix>::Ptr &leftVector) override;
91  AttributeBase::List &prevStepDependencies,
92  AttributeBase::List &attributeDependencies,
93  AttributeBase::List &modifiedAttributes) override;
95  void
96  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
97  AttributeBase::List &attributeDependencies,
98  AttributeBase::List &modifiedAttributes,
99  Attribute<Matrix>::Ptr &leftVector) override;
100 };
101 } // namespace Ph1
102 } // namespace DP
103 } // namespace CPS
Base class for composite power components.
Transformer that includes an inductance and resistance.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Defines component parameters.
Transformer(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
Transformer(String uid, String name, Logger::Level logLevel=Logger::Level::off, Bool withResistiveLosses=false)
Defines UID, name and logging level.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables 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 mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
String uid()
Returns unique id.
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17