DPsim
SP_Ph1_PiLine.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_PiLine.h>
12 #include <dpsim-models/CompositePowerComp.h>
13 #include <dpsim-models/SP/SP_Ph1_Capacitor.h>
14 #include <dpsim-models/SP/SP_Ph1_Inductor.h>
15 #include <dpsim-models/SP/SP_Ph1_Resistor.h>
16 #include <dpsim-models/Solver/MNATearInterface.h>
17 #include <dpsim-models/Solver/PFSolverInterfaceBranch.h>
18 
19 namespace CPS {
20 namespace SP {
21 namespace Ph1 {
26 class PiLine : public CompositePowerComp<Complex>,
27  public Base::Ph1::PiLine,
28  public MNATearInterface,
29  public SharedFactory<PiLine>,
31 public:
34 
35  // #### Power flow results ####
38 
41 
44 
45 protected:
52  Real mBaseOmega;
61 
70 
71  // #### Admittance matrix stamp ####
72  MatrixComp mY_element;
74  std::shared_ptr<Inductor> mSubSeriesInductor;
76  std::shared_ptr<Resistor> mSubSeriesResistor;
78  std::shared_ptr<Resistor> mSubParallelResistor0;
79  // Parallel Capacitor submodel at Terminal 0
80  std::shared_ptr<Capacitor> mSubParallelCapacitor0;
82  std::shared_ptr<Resistor> mSubParallelResistor1;
84  std::shared_ptr<Capacitor> mSubParallelCapacitor1;
86  std::vector<const Matrix *> mRightVectorStamps;
87 
88 public:
93 
94  // #### General ####
96  PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
98  PiLine(String name, Logger::Level logLevel = Logger::Level::off)
99  : PiLine(name, name, logLevel) {}
101  SimPowerComp<Complex>::Ptr clone(String copySuffix) override;
103  void setParameters(Real resistance, Real inductance, Real capacitance = -1,
104  Real conductance = -1);
106  void initializeFromNodesAndTerminals(Real frequency) override;
107 
108  // #### Powerflow section ####
110  void setBaseVoltage(Real baseVoltage);
112  void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
114  void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
116  void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
118  void storeNodalInjection(Complex powerInjection);
119 
120  // #### Getter ####
122  MatrixComp Y_element();
123 
124  // #### MNA section ####
126  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
128  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
130  void mnaParentPostStep(Real time, Int timeStepCount,
131  Attribute<Matrix>::Ptr &leftVector) override;
133  void
134  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
135  AttributeBase::List &attributeDependencies,
136  AttributeBase::List &modifiedAttributes,
137  Attribute<Matrix>::Ptr &leftVector) override;
138 
139  MNAInterface::List mnaTearGroundComponents() override;
140  void mnaTearInitialize(Real omega, Real timeStep) override;
141  void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override;
142  void mnaTearApplyVoltageStamp(Matrix &voltageVector) override;
143  void mnaTearPostStep(Complex voltage, Complex current) override;
144 };
145 } // namespace Ph1
146 } // namespace SP
147 } // namespace CPS
Base class for composite power components.
String uid()
Returns unique id.
Common base class of all Component templates.
PI-line static phasor model.
Definition: SP_Ph1_PiLine.h:30
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Real mBaseCapacitance
base capacitance [F]
Definition: SP_Ph1_PiLine.h:60
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Calculates component's parameters in specified per-unit system.
std::shared_ptr< Resistor > mSubSeriesResistor
Series Resistor submodel.
Definition: SP_Ph1_PiLine.h:76
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
Definition: SP_Ph1_PiLine.h:40
Real mSeriesIndPerUnit
Inductance of the line in [pu].
Definition: SP_Ph1_PiLine.h:67
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
Definition: SP_Ph1_PiLine.h:92
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
Definition: SP_Ph1_PiLine.h:37
Real mBaseAdmittance
base admittance [S]
Definition: SP_Ph1_PiLine.h:56
Real mBaseInductance
base inductance [H]
Definition: SP_Ph1_PiLine.h:58
Real mParallelCapPerUnit
Capacitance of the line in [pu].
Definition: SP_Ph1_PiLine.h:65
std::shared_ptr< Resistor > mSubParallelResistor1
Parallel resistor submodel at Terminal 1.
Definition: SP_Ph1_PiLine.h:82
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
Definition: SP_Ph1_PiLine.h:43
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
add MNA post-step dependencies
void updateBranchFlow(VectorComp &current, VectorComp &powerflow)
updates branch current and power flow, input pu value, update with real value
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post-step operations.
MatrixComp Y_element()
get admittance matrix
Real mSeriesResPerUnit
resistance in [pu]
Definition: SP_Ph1_PiLine.h:63
std::shared_ptr< Resistor > mSubParallelResistor0
Parallel Resistor submodel at Terminal 0.
Definition: SP_Ph1_PiLine.h:78
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
std::shared_ptr< Capacitor > mSubParallelCapacitor1
Parallel capacitor submodel at Terminal 1.
Definition: SP_Ph1_PiLine.h:84
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
PiLine(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
Definition: SP_Ph1_PiLine.h:98
SimPowerComp< Complex >::Ptr clone(String copySuffix) override
DEPRECATED: Delete method.
std::shared_ptr< Inductor > mSubSeriesInductor
Series Inductance submodel.
Definition: SP_Ph1_PiLine.h:74
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
Definition: SP_Ph1_PiLine.h:90
Real mParallelCondPerUnit
Conductance of the line in [pu].
Definition: SP_Ph1_PiLine.h:69
Real mBaseApparentPower
base apparent power [VA]
Definition: SP_Ph1_PiLine.h:50
Real mBaseImpedance
base impedance [Ohm]
Definition: SP_Ph1_PiLine.h:54
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
Real mBaseOmega
base omega [1/s]
Definition: SP_Ph1_PiLine.h:52
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
const Attribute< Real >::Ptr mBaseVoltage
base voltage [V]
Definition: SP_Ph1_PiLine.h:33
std::vector< const Matrix * > mRightVectorStamps
Right side vectors of subcomponents.
Definition: SP_Ph1_PiLine.h:86
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17