6#include <dpsim-models/DP/DP_Ph3_PiLine.h>
13 mPhaseType = PhaseType::ABC;
14 setVirtualNodeNumber(1);
17 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
24 auto copy = PiLine::make(name,
mLogLevel);
37 Matrix defaultParallelCond = Matrix::Zero(3, 3);
38 defaultParallelCond << 1e-6, 0, 0, 0, 1e-6, 0, 0, 0, 1e-6;
40 ((**mParallelCond)(0, 0) > 0) ? **
mParallelCond : defaultParallelCond;
48 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
49 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
56 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
57 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
64 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
66 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
67 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
73 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
75 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
76 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
79 mSubParallelCapacitor0 =
80 std::make_shared<DP::Ph3::Capacitor>(**
mName +
"_cap0",
mLogLevel);
81 mSubParallelCapacitor0->setParameters(**
mParallelCap / 2.);
82 mSubParallelCapacitor0->connect(
83 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
85 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
86 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
89 std::make_shared<DP::Ph3::Capacitor>(**
mName +
"_cap1",
mLogLevel);
92 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
94 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
95 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
101 Real omega = 2. * PI * frequency;
102 MatrixComp impedance = MatrixComp::Zero(3, 3);
112 MatrixComp vInitABC = MatrixComp::Zero(3, 1);
113 vInitABC(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(1) -
114 RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
115 vInitABC(1, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_B;
116 vInitABC(2, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_C;
117 MatrixComp iInit = impedance.inverse() * vInitABC;
123 MatrixComp vInitTerm0 = MatrixComp::Zero(3, 1);
124 vInitTerm0(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
125 vInitTerm0(1, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_B;
126 vInitTerm0(2, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_C;
133 "\n--- Initialization from powerflow ---"
134 "\nVoltage across: {:s}"
136 "\nTerminal 0 voltage: {:s}"
137 "\nTerminal 1 voltage: {:s}"
138 "\nVirtual Node 1 voltage: {:s}"
139 "\n--- Initialization from powerflow finished ---",
142 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
143 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)),
144 Logger::phasorToString(
mVirtualNodes[0]->initialSingleVoltage()));
148 AttributeBase::List &prevStepDependencies,
149 AttributeBase::List &attributeDependencies,
150 AttributeBase::List &modifiedAttributes) {
162void DP::Ph3::PiLine::mnaParentAddPostStepDependencies(
163 AttributeBase::List &prevStepDependencies,
164 AttributeBase::List &attributeDependencies,
165 AttributeBase::List &modifiedAttributes,
166 Attribute<Matrix>::Ptr &leftVector) {
168 attributeDependencies.push_back(leftVector);
169 modifiedAttributes.push_back(mIntfVoltage);
170 modifiedAttributes.push_back(mIntfCurrent);
173void DP::Ph3::PiLine::mnaParentPostStep(Real time, Int timeStepCount,
174 Attribute<Matrix>::Ptr &leftVector) {
176 this->mnaUpdateVoltage(**leftVector);
177 this->mnaUpdateCurrent(**leftVector);
183 if (terminalNotGrounded(1)) {
184 (**mIntfVoltage)(0, 0) =
185 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
186 (**mIntfVoltage)(1, 0) =
187 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
188 (**mIntfVoltage)(2, 0) =
189 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
191 if (terminalNotGrounded(0)) {
192 (**mIntfVoltage)(0, 0) =
194 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
195 (**mIntfVoltage)(1, 0) =
197 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
198 (**mIntfVoltage)(2, 0) =
200 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
209MNAInterface::List DP::Ph3::PiLine::mnaTearGroundComponents() {
210 MNAInterface::List gndComponents;
212 gndComponents.push_back(mSubParallelResistor0);
213 gndComponents.push_back(mSubParallelResistor1);
215 if ((**mParallelCap)(0, 0) > 0) {
216 gndComponents.push_back(mSubParallelCapacitor0);
217 gndComponents.push_back(mSubParallelCapacitor1);
220 return gndComponents;
223void DP::Ph3::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
224 mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
225 mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
226 mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
227 mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
230void DP::Ph3::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
231 mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
232 mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
235void DP::Ph3::PiLine::mnaTearApplyVoltageStamp(Matrix &voltageVector) {
236 mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
239void DP::Ph3::PiLine::mnaTearPostStep(MatrixComp voltage, MatrixComp current) {
240 mSubSeriesInductor->mnaTearPostStep(voltage - (**mSeriesRes * current),
242 (**mIntfCurrent) = mSubSeriesInductor->intfCurrent();
const Attribute< Matrix >::Ptr mParallelCond
Conductance in parallel to the line [S].
const Attribute< Matrix >::Ptr mSeriesRes
Resistance along the line [ohms].
const Attribute< Matrix >::Ptr mSeriesInd
Inductance along the line [H].
const Attribute< Matrix >::Ptr mParallelCap
Capacitance in parallel to the line [F].
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre and post step operations.
std::shared_ptr< Resistor > mSubSeriesResistor
Series Resistor submodel.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
std::shared_ptr< Capacitor > mSubParallelCapacitor1
Parallel capacitor submodel at Terminal 1.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
SimPowerComp< Complex >::Ptr clone(String copySuffix) override
DEPRECATED: Remove method.
std::shared_ptr< Inductor > mSubSeriesInductor
std::shared_ptr< Resistor > mSubParallelResistor0
Parallel Resistor submodel at Terminal 0.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
add MNA pre and post step dependencies
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
std::shared_ptr< Resistor > mSubParallelResistor1
Parallel resistor submodel at Terminal 1.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
Attribute< Matrix >::Ptr mRightVector
void mnaApplyRightSideVectorStamp(Matrix &rightVector) final
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
SimNode< Complex >::List mVirtualNodes
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.