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;
35 bool mParallelCapIsFallback = false;
37 bool mParallelCondIsFallback = false;
38
39public:
40 // #### Power flow results ####
42 const Attribute<MatrixComp>::Ptr mCurrent;
43
45 const Attribute<Matrix>::Ptr mActivePowerBranch;
46
48 const Attribute<Matrix>::Ptr mReactivePowerBranch;
49
50protected:
67
76
77 // #### Admittance matrix stamp ####
78 MatrixComp mY_element;
80 std::shared_ptr<Inductor> mSubSeriesInductor;
82 std::shared_ptr<Resistor> mSubSeriesResistor;
84 std::shared_ptr<Resistor> mSubParallelResistor0;
85 // Parallel Capacitor submodel at Terminal 0
86 std::shared_ptr<Capacitor> mSubParallelCapacitor0;
88 std::shared_ptr<Resistor> mSubParallelResistor1;
90 std::shared_ptr<Capacitor> mSubParallelCapacitor1;
92 std::vector<const Matrix *> mRightVectorStamps;
93
94public:
96 const Attribute<Real>::Ptr mActivePowerInjection;
98 const Attribute<Real>::Ptr mReactivePowerInjection;
99
100 // #### General ####
102 PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
104 PiLine(String name, Logger::Level logLevel = Logger::Level::off)
105 : PiLine(name, name, logLevel) {}
106
107 SimPowerComp<Complex>::Ptr clone(String copySuffix) override;
109 void setParameters(Real resistance, Real inductance, Real capacitance = -1,
110 Real conductance = -1);
112 void createSubComponents() override;
114 void initializeParentFromNodesAndTerminals(Real frequency) override;
115
116 // #### Powerflow section ####
118 Real getBaseVoltage() const;
120 void setBaseVoltage(Real baseVoltage);
122 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
124 void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override;
126 void updateBranchFlow(VectorComp &current, VectorComp &powerflow);
128 void storeNodalInjection(Complex powerInjection);
129
130 // #### Getter ####
132 MatrixComp Y_element();
133
134 // #### MNA section ####
136 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
138 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
140 void mnaParentPostStep(Real time, Int timeStepCount,
141 Attribute<Matrix>::Ptr &leftVector) override;
143 void
144 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
145 AttributeBase::List &attributeDependencies,
146 AttributeBase::List &modifiedAttributes,
147 Attribute<Matrix>::Ptr &leftVector) override;
148
149 MNAInterface::List mnaTearGroundComponents() override;
150 void mnaTearInitialize(Real omega, Real timeStep) override;
151 void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override;
152 void mnaTearApplyVoltageStamp(Matrix &voltageVector) override;
153 void mnaTearPostStep(Complex voltage, Complex current) override;
154};
155} // namespace Ph1
156} // namespace SP
157} // 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.