DPsim
SP_Ph1_RXLine.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/Solver/PFSolverInterfaceBranch.h"
12 #include <dpsim-models/Base/Base_Ph1_PiLine.h>
13 #include <dpsim-models/CompositePowerComp.h>
14 #include <dpsim-models/SP/SP_Ph1_Inductor.h>
15 #include <dpsim-models/SP/SP_Ph1_Resistor.h>
16 
17 namespace CPS {
18 namespace SP {
19 namespace Ph1 {
20 
21 class RXLine : public CompositePowerComp<Complex>,
22  public SharedFactory<RXLine>,
24  public Base::Ph1::PiLine {
25 protected:
34  Real mBaseOmega;
43 
50 
51  // #### Admittance matrix stamp ####
52  MatrixComp mY_element;
53 
55  std::shared_ptr<Inductor> mSubInductor;
57  std::shared_ptr<Resistor> mSubResistor;
59  std::shared_ptr<Resistor> mInitialResistor;
60 
61 public:
67 
72 
73  // #### Power flow results ####
76 
79 
82 
83  // #### constructors ####
84  // power flow
85 
87  RXLine(String uid, String name, Real baseVoltage, Real resistance,
88  Real inductance, Logger::Level logLevel = Logger::Level::off);
89  // MNA
91  RXLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
93  RXLine(String name, Logger::Level logLevel = Logger::Level::off)
94  : RXLine(name, name, logLevel) {}
95 
96  // #### General ####
98  void setPerUnitSystem(Real baseApparentPower, Real baseOmega);
101 
102  // #### Powerflow section ####
104  void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
105 
107  void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
109  void storeNodalInjection(Complex powerInjection);
110 
111  // #### Getter ####
113  MatrixComp Y_element();
114 
115  // #### MNA Section ####
116 
117  SimPowerComp<Complex>::Ptr clone(String name) override;
118 
119  // #### General ####
121  void initializeFromNodesAndTerminals(Real frequency) override;
122 
123  // #### MNA section ####
124  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
125  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
126 
127  void mnaParentPreStep(Real time, Int timeStepCount) override;
128  void mnaParentPostStep(Real time, Int timeStepCount,
129  Attribute<Matrix>::Ptr &leftVector) override;
130 
131  void mnaParentAddPreStepDependencies(
132  AttributeBase::List &prevStepDependencies,
133  AttributeBase::List &attributeDependencies,
134  AttributeBase::List &modifiedAttributes) override;
135  void
136  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
137  AttributeBase::List &attributeDependencies,
138  AttributeBase::List &modifiedAttributes,
139  Attribute<Matrix>::Ptr &leftVector) override;
140 };
141 } // namespace Ph1
142 } // namespace SP
143 } // namespace CPS
Base class for composite power components.
String uid()
Returns unique id.
Common base class of all Component templates.
std::shared_ptr< Resistor > mInitialResistor
Inductor end to ground resistor to facilitate initialization.
Definition: SP_Ph1_RXLine.h:59
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
const Attribute< Real >::Ptr mInductance
Definition: SP_Ph1_RXLine.h:66
RXLine(String name, Logger::Level logLevel=Logger::Level::off)
Defines name, component parameters and logging level.
Definition: SP_Ph1_RXLine.h:93
Real mBaseApparentPower
base apparent power [VA]
Definition: SP_Ph1_RXLine.h:32
void transformParametersToPerUnitSystem()
Transform component parameters to the specified per-unit system.
Real mParallelCapPerUnit
Capacitance of the line in [pu].
Definition: SP_Ph1_RXLine.h:47
std::shared_ptr< Resistor > mSubResistor
Resistor submodel.
Definition: SP_Ph1_RXLine.h:57
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
Definition: SP_Ph1_RXLine.h:69
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
Real mSeriesResPerUnit
resistance in [pu]
Definition: SP_Ph1_RXLine.h:45
Real mBaseAdmittance
base admittance [S]
Definition: SP_Ph1_RXLine.h:38
Real mBaseImpedance
base impedance [Ohm]
Definition: SP_Ph1_RXLine.h:36
void setPerUnitSystem(Real baseApparentPower, Real baseOmega)
Specify per-unit system by base voltage, base apparent power and omega (rms value for voltage expecte...
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
Definition: SP_Ph1_RXLine.h:78
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
void updateBranchFlow(VectorComp &current, VectorComp &powerflow)
updates branch current and power flow, input pu value, update with real value
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
Definition: SP_Ph1_RXLine.h:75
Real mBaseInductance
base inductance [H]
Definition: SP_Ph1_RXLine.h:40
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
Definition: SP_Ph1_RXLine.h:81
RXLine(String uid, String name, Real baseVoltage, Real resistance, Real inductance, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, base voltage, component parameters and logging level.
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
Definition: SP_Ph1_RXLine.h:71
const Attribute< Real >::Ptr mBaseVoltage
base voltage [V]
Definition: SP_Ph1_RXLine.h:63
Real mSeriesIndPerUnit
Inductance of the line in [pu].
Definition: SP_Ph1_RXLine.h:49
std::shared_ptr< Inductor > mSubInductor
Inductance submodel.
Definition: SP_Ph1_RXLine.h:55
Real mBaseCapacitance
base capacitance [F]
Definition: SP_Ph1_RXLine.h:42
Real mBaseCurrent
base current [V]
Definition: SP_Ph1_RXLine.h:30
Real mBaseOmega
base omega [1/s]
Definition: SP_Ph1_RXLine.h:34
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
MatrixComp Y_element()
get admittance matrix
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17