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:
63
72
73 // #### Admittance matrix stamp ####
74 MatrixComp mY_element;
76 std::shared_ptr<Inductor> mSubSeriesInductor;
78 std::shared_ptr<Resistor> mSubSeriesResistor;
80 std::shared_ptr<Resistor> mSubParallelResistor0;
81 // Parallel Capacitor submodel at Terminal 0
82 std::shared_ptr<Capacitor> mSubParallelCapacitor0;
84 std::shared_ptr<Resistor> mSubParallelResistor1;
86 std::shared_ptr<Capacitor> mSubParallelCapacitor1;
88 std::vector<const Matrix *> mRightVectorStamps;
89
90public:
92 const Attribute<Real>::Ptr mActivePowerInjection;
94 const Attribute<Real>::Ptr mReactivePowerInjection;
95
96 // #### General ####
98 PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
100 PiLine(String name, Logger::Level logLevel = Logger::Level::off)
101 : PiLine(name, name, logLevel) {}
102
103 SimPowerComp<Complex>::Ptr clone(String copySuffix) override;
105 void setParameters(Real resistance, Real inductance, Real capacitance = -1,
106 Real conductance = -1);
108 void createSubComponents() override;
110 void initializeParentFromNodesAndTerminals(Real frequency) override;
111
112 // #### Powerflow section ####
114 Real getBaseVoltage() const;
116 void setBaseVoltage(Real baseVoltage);
118 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
120 void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
122 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
124 void storeNodalInjection(Complex powerInjection);
125
126 // #### Getter ####
128 MatrixComp Y_element();
129
130 // #### MNA section ####
132 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
134 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
136 void mnaParentPostStep(Real time, Int timeStepCount,
137 Attribute<Matrix>::Ptr &leftVector) override;
139 void
140 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
141 AttributeBase::List &attributeDependencies,
142 AttributeBase::List &modifiedAttributes,
143 Attribute<Matrix>::Ptr &leftVector) override;
144
145 MNAInterface::List mnaTearGroundComponents() override;
146 void mnaTearInitialize(Real omega, Real timeStep) override;
147 void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override;
148 void mnaTearApplyVoltageStamp(Matrix &voltageVector) override;
149 void mnaTearPostStep(Complex voltage, Complex current) override;
150};
151} // namespace Ph1
152} // namespace SP
153} // 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 createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
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 initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
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 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.