DPsim
Loading...
Searching...
No Matches
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
19namespace CPS {
20namespace SP {
21namespace Ph1 {
26class PiLine : public CompositePowerComp<Complex>,
27 public Base::Ph1::PiLine,
28 public MNATearInterface,
29 public SharedFactory<PiLine>,
31private:
33 Real mBaseVoltage;
34
35public:
36 // #### Power flow results ####
38 const Attribute<MatrixComp>::Ptr mCurrent;
39
41 const Attribute<Matrix>::Ptr mActivePowerBranch;
42
44 const Attribute<Matrix>::Ptr mReactivePowerBranch;
45
46protected:
62
71
72 // #### Admittance matrix stamp ####
73 MatrixComp mY_element;
75 std::shared_ptr<Inductor> mSubSeriesInductor;
77 std::shared_ptr<Resistor> mSubSeriesResistor;
79 std::shared_ptr<Resistor> mSubParallelResistor0;
80 // Parallel Capacitor submodel at Terminal 0
81 std::shared_ptr<Capacitor> mSubParallelCapacitor0;
83 std::shared_ptr<Resistor> mSubParallelResistor1;
85 std::shared_ptr<Capacitor> mSubParallelCapacitor1;
87 std::vector<const Matrix *> mRightVectorStamps;
88
89public:
91 const Attribute<Real>::Ptr mActivePowerInjection;
93 const Attribute<Real>::Ptr mReactivePowerInjection;
94
95 // #### General ####
97 PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
99 PiLine(String name, Logger::Level logLevel = Logger::Level::off)
100 : PiLine(name, name, logLevel) {}
101
102 SimPowerComp<Complex>::Ptr clone(String copySuffix) override;
104 void setParameters(Real resistance, Real inductance, Real capacitance = -1,
105 Real conductance = -1);
107 void initializeFromNodesAndTerminals(Real frequency) override;
108
109 // #### Powerflow section ####
111 Real getBaseVoltage() const;
113 void setBaseVoltage(Real baseVoltage);
115 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
117 void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
119 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
121 void storeNodalInjection(Complex powerInjection);
122
123 // #### Getter ####
125 MatrixComp Y_element();
126
127 // #### MNA section ####
129 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
131 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
133 void mnaParentPostStep(Real time, Int timeStepCount,
134 Attribute<Matrix>::Ptr &leftVector) override;
136 void
137 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
138 AttributeBase::List &attributeDependencies,
139 AttributeBase::List &modifiedAttributes,
140 Attribute<Matrix>::Ptr &leftVector) override;
141
142 MNAInterface::List mnaTearGroundComponents() override;
143 void mnaTearInitialize(Real omega, Real timeStep) override;
144 void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override;
145 void mnaTearApplyVoltageStamp(Matrix &voltageVector) override;
146 void mnaTearPostStep(Complex voltage, Complex current) override;
147};
148} // namespace Ph1
149} // namespace SP
150} // namespace CPS
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
Common base class of all Component templates.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Real mBaseCapacitance
base capacitance [F]
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Calculates component's parameters in specified per-unit system.
std::shared_ptr< Resistor > mSubSeriesResistor
Series Resistor submodel.
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
Real mSeriesIndPerUnit
Inductance of the line in [pu].
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
Real mBaseAdmittance
base admittance [S]
Real mBaseInductance
base inductance [H]
Real mParallelCapPerUnit
Capacitance of the line in [pu].
std::shared_ptr< Resistor > mSubParallelResistor1
Parallel resistor submodel at Terminal 1.
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
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]
std::shared_ptr< Resistor > mSubParallelResistor0
Parallel Resistor submodel at Terminal 0.
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.
Real getBaseVoltage() const
Get base voltage.
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.
SimPowerComp< Complex >::Ptr clone(String copySuffix) override
DEPRECATED: Delete method.
std::shared_ptr< Inductor > mSubSeriesInductor
Series Inductance submodel.
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
Real mParallelCondPerUnit
Conductance of the line in [pu].
Real mBaseApparentPower
base apparent power [VA]
Real mBaseImpedance
base impedance [Ohm]
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]
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
std::vector< const Matrix * > mRightVectorStamps
Right side vectors of subcomponents.