DPsim
Loading...
Searching...
No Matches
EMT_DC_PiLine.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
10
11#include <array>
12
13namespace CPS {
14namespace EMT {
15namespace DC {
16
22class PiLine final : public CompositePowerComp<Real>,
23 public SharedFactory<PiLine> {
24public:
26
37
38 PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
40 PiLine(String uid, String name, Bool useSubcomponents,
41 Logger::Level logLevel = Logger::Level::off);
42 PiLine(String name, Bool useSubcomponents,
43 Logger::Level logLevel = Logger::Level::off)
44 : PiLine(name, name, useSubcomponents, logLevel) {}
45 PiLine(String name, Logger::Level logLevel = Logger::Level::off)
46 : PiLine(name, name, logLevel) {}
47
49 void setParameters(Real seriesResistance, Real seriesInductance,
50 Real parallelCapacitance = 0.0,
51 Real parallelConductance = 0.0, Real initialCurrent = 0.0);
52
53 void createSubComponents() override final;
54 void initializeParentFromNodesAndTerminals(Real frequency) override final;
55 void mnaParentInitialize(Real omega, Real timeStep,
56 Attribute<Matrix>::Ptr leftVector) override final;
57 void
58 mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override final;
59 void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override final;
60 Bool mnaHasCompactRightSideVectorStamp() const override final;
61 void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override final;
62
63 void mnaCompUpdateVoltage(const Matrix &leftVector) override final;
64 void mnaCompUpdateCurrent(const Matrix &leftVector) override final;
65 void mnaParentPreStep(Real time, Int timeStepCount) override final;
66 void mnaParentPostStep(Real time, Int timeStepCount,
67 Attribute<Matrix>::Ptr &leftVector) override final;
69 AttributeBase::List &prevStepDependencies,
70 AttributeBase::List &attributeDependencies,
71 AttributeBase::List &modifiedAttributes) override final;
73 AttributeBase::List &prevStepDependencies,
74 AttributeBase::List &attributeDependencies,
75 AttributeBase::List &modifiedAttributes,
76 Attribute<Matrix>::Ptr &leftVector) override final;
77
78private:
79 Bool mUseSubcomponents = true;
80 Attribute<Matrix>::Ptr mDirectState;
81 Real mDirectInductorAdmittance = 0.;
82 Real mDirectSeriesAdmittance = 0.;
83 Real mDirectCapAdmittance = 0.;
84 Real mDirectSeriesHistory = 0.;
85 Real mDirectCapHistory0 = 0.;
86 Real mDirectCapHistory1 = 0.;
87 std::array<UInt, 2> mDirectTerminalRows{};
88 std::array<Bool, 2> mDirectTerminalNotGrounded{};
89 std::shared_ptr<Resistor> mSeriesResistor;
90 std::shared_ptr<Inductor> mSeriesInductor;
91 std::shared_ptr<Resistor> mShuntResistor0;
92 std::shared_ptr<Resistor> mShuntResistor1;
93 std::shared_ptr<Capacitor> mShuntCapacitor0;
94 std::shared_ptr<Capacitor> mShuntCapacitor1;
95
96 void validateDCTerminals() const;
97};
98
99} // namespace DC
100} // namespace EMT
101} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
std::shared_ptr< CompositePowerComp< Real > > Ptr
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
const Attribute< Real >::Ptr mSeriesResistance
Series resistance [ohm].
Bool mnaHasCompactRightSideVectorStamp() const override final
Composite stamps touch only their cached terminal and virtual-node rows.
void initializeParentFromNodesAndTerminals(Real frequency) override final
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override final
const Attribute< Real >::Ptr mInitialCurrent
Initial series current from terminal 1 to terminal 0 [A].
void mnaCompUpdateVoltage(const Matrix &leftVector) override final
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override final
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override final
void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override final
const Attribute< Real >::Ptr mParallelCapacitance
Total terminal-to-ground shunt capacitance [F].
const Attribute< Real >::Ptr mSeriesInductance
Series inductance [H].
void mnaAddCompactRightSideVectorStamp(Matrix &rightVector) override final
void createSubComponents() override final
Constructs and registers MNA subcomponents; called before collectVirtualNodes so virtual nodes exist ...
void mnaParentPreStep(Real time, Int timeStepCount) override final
void setParameters(Real seriesResistance, Real seriesInductance, Real parallelCapacitance=0.0, Real parallelConductance=0.0, Real initialCurrent=0.0)
void mnaCompUpdateCurrent(const Matrix &leftVector) override final
const Attribute< Real >::Ptr mParallelConductance
Total terminal-to-ground shunt conductance [S].
SimPowerComp< Real >::Ptr clone(String name) override final
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override final
PiLine(String name, Logger::Level logLevel=Logger::Level::off)
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override final
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
PiLine(String name, Bool useSubcomponents, Logger::Level logLevel=Logger::Level::off)
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
std::shared_ptr< SimPowerComp< VarType > > Ptr
static std::shared_ptr< PiLine > make(Args &&...args)
Definition PtrFactory.h:19
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:79
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
bool Bool
Definition Definitions.h:62
unsigned int UInt
Definition Definitions.h:58
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:72