6#include <dpsim-models/EMT/EMT_Ph1_PiLine.h>
13 setVirtualNodeNumber(1);
16 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
25 auto copy = PiLine::make(name,
mLogLevel);
38 Real defaultParallelCond = 1e-6;
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);
61 std::make_shared<EMT::Ph1::Resistor>(**
mName +
"_con0",
mLogLevel);
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);
70 std::make_shared<EMT::Ph1::Resistor>(**
mName +
"_con1",
mLogLevel);
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<EMT::Ph1::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);
88 mSubParallelCapacitor1 =
89 std::make_shared<EMT::Ph1::Capacitor>(**
mName +
"_cap1",
mLogLevel);
90 mSubParallelCapacitor1->setParameters(**
mParallelCap / 2.);
91 mSubParallelCapacitor1->connect(
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;
104 RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));
105 (**mIntfVoltage)(0, 0) = voltage.real();
106 (**mIntfCurrent)(0, 0) = (voltage / impedance).real();
109 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(0) +
112 SPDLOG_LOGGER_DEBUG(
mSLog,
116 "\n Impedance: {:s}",
119 Logger::complexToString(impedance));
123 "\n--- Initialization from powerflow ---"
124 "\nVoltage across: {:s}"
126 "\nTerminal 0 voltage: {:s}"
127 "\nTerminal 1 voltage: {:s}"
128 "\nVirtual Node 1 voltage: {:s}"
129 "\n--- Initialization from powerflow finished ---",
132 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
133 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)),
134 Logger::phasorToString(
mVirtualNodes[0]->initialSingleVoltage()));
139 AttributeBase::List &prevStepDependencies,
140 AttributeBase::List &attributeDependencies,
141 AttributeBase::List &modifiedAttributes) {
152 AttributeBase::List &prevStepDependencies,
153 AttributeBase::List &attributeDependencies,
154 AttributeBase::List &modifiedAttributes,
155 Attribute<Matrix>::Ptr &leftVector) {
156 attributeDependencies.push_back(leftVector);
162 Attribute<Matrix>::Ptr &leftVector) {
168 (**mIntfVoltage)(0, 0) = 0;
169 if (terminalNotGrounded(1))
170 (**mIntfVoltage)(0, 0) =
171 Math::realFromVectorElement(leftVector, matrixNodeIndex(1));
172 if (terminalNotGrounded(0))
173 (**mIntfVoltage)(0, 0) =
175 Math::realFromVectorElement(leftVector, matrixNodeIndex(0));
183MNAInterface::List EMT::Ph1::PiLine::mnaTearGroundComponents() {
184 MNAInterface::List gndComponents;
186 gndComponents.push_back(mSubParallelResistor0);
187 gndComponents.push_back(mSubParallelResistor1);
189 if ((**mParallelCap) > 0) {
190 gndComponents.push_back(mSubParallelCapacitor0);
191 gndComponents.push_back(mSubParallelCapacitor1);
194 return gndComponents;
197void EMT::Ph1::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
198 mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
199 mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
200 mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
201 mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
204void EMT::Ph1::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
205 mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
206 mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
209void EMT::Ph1::PiLine::mnaTearApplyVoltageStamp(Matrix &voltageVector) {
210 mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
213void EMT::Ph1::PiLine::mnaTearPostStep(Complex voltage, Complex current) {
214 mSubSeriesInductor->mnaTearPostStep(voltage - current * **mSeriesRes,
216 (**mIntfCurrent) = mSubSeriesInductor->intfCurrent();
const Attribute< Real >::Ptr mParallelCap
Capacitance in parallel to the line [F].
const Attribute< Real >::Ptr mParallelCond
Conductance in parallel to the line [S].
const Attribute< Real >::Ptr mSeriesInd
Inductance along the line [H].
const Attribute< Real >::Ptr mSeriesRes
Resistance along the line [ohms].
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)
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
std::shared_ptr< Inductor > mSubSeriesInductor
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
std::shared_ptr< Resistor > mSubParallelResistor1
Parallel resistor submodel at Terminal 1.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
std::shared_ptr< Resistor > mSubSeriesResistor
Series Resistor submodel.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
SimPowerComp< Real >::Ptr clone(String copySuffix) override
DEPRECATED: Delete method.
std::shared_ptr< Resistor > mSubParallelResistor0
Parallel Resistor submodel at Terminal 0.
PiLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
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.