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;
49 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
50 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
58 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
59 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
66 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
69 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
70 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
76 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
79 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
80 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
83 mSubParallelCapacitor0 =
84 std::make_shared<DP::Ph3::Capacitor>(**
mName +
"_cap0",
mLogLevel);
85 mSubParallelCapacitor0->setParameters(**
mParallelCap / 2.);
86 mSubParallelCapacitor0->connect(
87 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
90 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
91 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
94 std::make_shared<DP::Ph3::Capacitor>(**
mName +
"_cap1",
mLogLevel);
97 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
100 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
101 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
107 Real omega = 2. * PI * frequency;
108 MatrixComp impedance = MatrixComp::Zero(3, 3);
118 MatrixComp vInitABC = MatrixComp::Zero(3, 1);
119 vInitABC(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(1) -
120 RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
121 vInitABC(1, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_B;
122 vInitABC(2, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_C;
123 MatrixComp iInit = impedance.inverse() * vInitABC;
129 MatrixComp vInitTerm0 = MatrixComp::Zero(3, 1);
130 vInitTerm0(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
131 vInitTerm0(1, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_B;
132 vInitTerm0(2, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_C;
139 "\n--- Initialization from powerflow ---"
140 "\nVoltage across: {:s}"
142 "\nTerminal 0 voltage: {:s}"
143 "\nTerminal 1 voltage: {:s}"
144 "\nVirtual Node 1 voltage: {:s}"
145 "\n--- Initialization from powerflow finished ---",
148 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
149 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)),
150 Logger::phasorToString(
mVirtualNodes[0]->initialSingleVoltage()));
154 AttributeBase::List &prevStepDependencies,
155 AttributeBase::List &attributeDependencies,
156 AttributeBase::List &modifiedAttributes) {
168void DP::Ph3::PiLine::mnaParentAddPostStepDependencies(
169 AttributeBase::List &prevStepDependencies,
170 AttributeBase::List &attributeDependencies,
171 AttributeBase::List &modifiedAttributes,
172 Attribute<Matrix>::Ptr &leftVector) {
174 attributeDependencies.push_back(leftVector);
175 modifiedAttributes.push_back(mIntfVoltage);
176 modifiedAttributes.push_back(mIntfCurrent);
179void DP::Ph3::PiLine::mnaParentPostStep(Real time, Int timeStepCount,
180 Attribute<Matrix>::Ptr &leftVector) {
182 this->mnaUpdateVoltage(**leftVector);
183 this->mnaUpdateCurrent(**leftVector);
189 if (terminalNotGrounded(1)) {
190 (**mIntfVoltage)(0, 0) =
191 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
192 (**mIntfVoltage)(1, 0) =
193 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
194 (**mIntfVoltage)(2, 0) =
195 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
197 if (terminalNotGrounded(0)) {
198 (**mIntfVoltage)(0, 0) =
200 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
201 (**mIntfVoltage)(1, 0) =
203 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
204 (**mIntfVoltage)(2, 0) =
206 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
215MNAInterface::List DP::Ph3::PiLine::mnaTearGroundComponents() {
216 MNAInterface::List gndComponents;
218 gndComponents.push_back(mSubParallelResistor0);
219 gndComponents.push_back(mSubParallelResistor1);
221 if ((**mParallelCap)(0, 0) > 0) {
222 gndComponents.push_back(mSubParallelCapacitor0);
223 gndComponents.push_back(mSubParallelCapacitor1);
226 return gndComponents;
229void DP::Ph3::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
230 mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
231 mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
232 mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
233 mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
236void DP::Ph3::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
237 mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
238 mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
241void DP::Ph3::PiLine::mnaTearApplyVoltageStamp(Matrix &voltageVector) {
242 mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
245void DP::Ph3::PiLine::mnaTearPostStep(MatrixComp voltage, MatrixComp current) {
246 mSubSeriesInductor->mnaTearPostStep(voltage - (**mSeriesRes * current),
248 (**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.