9#include <dpsim-models/EMT/EMT_Ph3_PiLine.h>
16 mPhaseType = PhaseType::ABC;
17 setVirtualNodeNumber(1);
20 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
29 auto copy = PiLine::make(name,
mLogLevel);
42 Matrix defaultParallelCond = Matrix::Zero(3, 3);
43 defaultParallelCond << 1e-6, 0, 0, 0, 1e-6, 0, 0, 0, 1e-6;
45 ((**mParallelCond)(0, 0) > 0) ? **
mParallelCond : defaultParallelCond;
53 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
54 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
61 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
62 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
66 std::make_shared<EMT::Ph3::Resistor>(**
mName +
"_con0",
mLogLevel);
69 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
71 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
72 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
75 std::make_shared<EMT::Ph3::Resistor>(**
mName +
"_con1",
mLogLevel);
78 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
80 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
81 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
84 mSubParallelCapacitor0 =
85 std::make_shared<EMT::Ph3::Capacitor>(**
mName +
"_cap0",
mLogLevel);
86 mSubParallelCapacitor0->setParameters(**
mParallelCap / 2.);
87 mSubParallelCapacitor0->connect(
88 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
90 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
91 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
93 mSubParallelCapacitor1 =
94 std::make_shared<EMT::Ph3::Capacitor>(**
mName +
"_cap1",
mLogLevel);
95 mSubParallelCapacitor1->setParameters(**
mParallelCap / 2.);
96 mSubParallelCapacitor1->connect(
97 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
99 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
100 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
106 Real omega = 2. * PI * frequency;
107 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;
137 SPDLOG_LOGGER_DEBUG(
mSLog,
146 Logger::matrixCompToString(impedance),
147 Logger::matrixCompToString(vInitABC),
148 Logger::matrixCompToString(iInit));
152 "\n--- Initialization from powerflow ---"
153 "\nVoltage across: {:s}"
155 "\nTerminal 0 voltage: {:s}"
156 "\nTerminal 1 voltage: {:s}"
157 "\nVirtual Node 1 voltage: {:s}"
158 "\n--- Initialization from powerflow finished ---",
161 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
162 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)),
163 Logger::phasorToString(
mVirtualNodes[0]->initialSingleVoltage()));
168 AttributeBase::List &prevStepDependencies,
169 AttributeBase::List &attributeDependencies,
170 AttributeBase::List &modifiedAttributes) {
181 AttributeBase::List &prevStepDependencies,
182 AttributeBase::List &attributeDependencies,
183 AttributeBase::List &modifiedAttributes,
184 Attribute<Matrix>::Ptr &leftVector) {
185 attributeDependencies.push_back(leftVector);
191 Attribute<Matrix>::Ptr &leftVector) {
199 if (terminalNotGrounded(1)) {
200 (**mIntfVoltage)(0, 0) =
201 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 0));
202 (**mIntfVoltage)(1, 0) =
203 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 1));
204 (**mIntfVoltage)(2, 0) =
205 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 2));
207 if (terminalNotGrounded(0)) {
208 (**mIntfVoltage)(0, 0) =
210 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
211 (**mIntfVoltage)(1, 0) =
213 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
214 (**mIntfVoltage)(2, 0) =
216 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
225MNAInterface::List EMT::Ph3::PiLine::mnaTearGroundComponents() {
226 MNAInterface::List gndComponents;
228 gndComponents.push_back(mSubParallelResistor0);
229 gndComponents.push_back(mSubParallelResistor1);
231 if ((**mParallelCap)(0, 0) > 0) {
232 gndComponents.push_back(mSubParallelCapacitor0);
233 gndComponents.push_back(mSubParallelCapacitor1);
236 return gndComponents;
239void EMT::Ph3::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
240 mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
241 mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
242 mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
243 mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
246void EMT::Ph3::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
247 mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
248 mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
251void EMT::Ph3::PiLine::mnaTearApplyVoltageStamp(Matrix &voltageVector) {
252 mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
255void EMT::Ph3::PiLine::mnaTearPostStep(MatrixComp voltage, MatrixComp current) {
256 mSubSeriesInductor->mnaTearPostStep(voltage - (**mSeriesRes * current),
258 (**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< Real >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
SimPowerComp< Real >::Ptr clone(String copySuffix) override
DEPRECATED: Delete method.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
std::shared_ptr< Resistor > mSubParallelResistor0
Parallel Resistor submodel at Terminal 0.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
std::shared_ptr< Inductor > mSubSeriesInductor
std::shared_ptr< Resistor > mSubSeriesResistor
Series Resistor submodel.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
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
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
SimTerminal< Real >::List mTerminals
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
SimNode< Real >::List mVirtualNodes
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.