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);
36 Real defaultParallelCond = 1e-6;
41 Real omega = 2. * PI * frequency;
44 RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));
45 (**mIntfVoltage)(0, 0) = voltage.real();
46 (**mIntfCurrent)(0, 0) = (voltage / impedance).real();
60 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
61 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
70 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
71 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
75 std::make_shared<EMT::Ph1::Resistor>(**
mName +
"_con0",
mLogLevel);
78 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
82 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
83 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
86 std::make_shared<EMT::Ph1::Resistor>(**
mName +
"_con1",
mLogLevel);
89 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
93 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
94 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
97 mSubParallelCapacitor0 =
98 std::make_shared<EMT::Ph1::Capacitor>(**
mName +
"_cap0",
mLogLevel);
99 mSubParallelCapacitor0->setParameters(**
mParallelCap / 2.);
100 mSubParallelCapacitor0->connect(
101 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
103 mSubParallelCapacitor0->initializeFromNodesAndTerminals(frequency);
105 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
106 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
108 mSubParallelCapacitor1 =
109 std::make_shared<EMT::Ph1::Capacitor>(**
mName +
"_cap1",
mLogLevel);
110 mSubParallelCapacitor1->setParameters(**
mParallelCap / 2.);
111 mSubParallelCapacitor1->connect(
112 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
114 mSubParallelCapacitor1->initializeFromNodesAndTerminals(frequency);
116 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
117 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
120 SPDLOG_LOGGER_DEBUG(
mSLog,
124 "\n Impedance: {:s}",
127 Logger::complexToString(impedance));
131 "\n--- Initialization from powerflow ---"
132 "\nVoltage across: {:s}"
134 "\nTerminal 0 voltage: {:s}"
135 "\nTerminal 1 voltage: {:s}"
136 "\nVirtual Node 1 voltage: {:s}"
137 "\n--- Initialization from powerflow finished ---",
140 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
141 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)),
142 Logger::phasorToString(
mVirtualNodes[0]->initialSingleVoltage()));
147 AttributeBase::List &prevStepDependencies,
148 AttributeBase::List &attributeDependencies,
149 AttributeBase::List &modifiedAttributes) {
160 AttributeBase::List &prevStepDependencies,
161 AttributeBase::List &attributeDependencies,
162 AttributeBase::List &modifiedAttributes,
163 Attribute<Matrix>::Ptr &leftVector) {
164 attributeDependencies.push_back(leftVector);
170 Attribute<Matrix>::Ptr &leftVector) {
176 (**mIntfVoltage)(0, 0) = 0;
177 if (terminalNotGrounded(1))
178 (**mIntfVoltage)(0, 0) =
179 Math::realFromVectorElement(leftVector, matrixNodeIndex(1));
180 if (terminalNotGrounded(0))
181 (**mIntfVoltage)(0, 0) =
183 Math::realFromVectorElement(leftVector, matrixNodeIndex(0));
191MNAInterface::List EMT::Ph1::PiLine::mnaTearGroundComponents() {
192 MNAInterface::List gndComponents;
194 gndComponents.push_back(mSubParallelResistor0);
195 gndComponents.push_back(mSubParallelResistor1);
197 if ((**mParallelCap) > 0) {
198 gndComponents.push_back(mSubParallelCapacitor0);
199 gndComponents.push_back(mSubParallelCapacitor1);
202 return gndComponents;
205void EMT::Ph1::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
206 mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
207 mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
208 mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
209 mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
212void EMT::Ph1::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
213 mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
214 mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
217void EMT::Ph1::PiLine::mnaTearApplyVoltageStamp(Matrix &voltageVector) {
218 mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
221void EMT::Ph1::PiLine::mnaTearPostStep(Complex voltage, Complex current) {
222 mSubSeriesInductor->mnaTearPostStep(voltage - current * **mSeriesRes,
224 (**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
Series Inductance submodel.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
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 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 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.