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);
33 Real omega = 2. * PI * frequency;
34 MatrixComp impedance = MatrixComp::Zero(3, 3);
44 MatrixComp vInitABC = MatrixComp::Zero(3, 1);
45 vInitABC(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(1) -
46 RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
47 vInitABC(1, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_B;
48 vInitABC(2, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_C;
49 MatrixComp iInit = impedance.inverse() * vInitABC;
55 MatrixComp vInitTerm0 = MatrixComp::Zero(3, 1);
56 vInitTerm0(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
57 vInitTerm0(1, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_B;
58 vInitTerm0(2, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_C;
71 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
72 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
81 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
82 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
86 Matrix defaultParallelCond = Matrix::Zero(3, 3);
87 defaultParallelCond << 1e-6, 0, 0, 0, 1e-6, 0, 0, 0, 1e-6;
89 ((**mParallelCond)(0, 0) > 0) ? **
mParallelCond : defaultParallelCond;
96 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
100 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
101 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
104 std::make_shared<DP::Ph3::Resistor>(**
mName +
"_con1",
mLogLevel);
107 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
111 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
112 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
115 mSubParallelCapacitor0 =
116 std::make_shared<DP::Ph3::Capacitor>(**
mName +
"_cap0",
mLogLevel);
117 mSubParallelCapacitor0->setParameters(**
mParallelCap / 2.);
118 mSubParallelCapacitor0->connect(
119 SimNode::List{SimNode::GND,
mTerminals[0]->node()});
121 mSubParallelCapacitor0->initializeFromNodesAndTerminals(frequency);
123 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
124 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
127 std::make_shared<DP::Ph3::Capacitor>(**
mName +
"_cap1",
mLogLevel);
130 SimNode::List{SimNode::GND,
mTerminals[1]->node()});
134 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
135 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
140 "\n--- Initialization from powerflow ---"
141 "\nVoltage across: {:s}"
143 "\nTerminal 0 voltage: {:s}"
144 "\nTerminal 1 voltage: {:s}"
145 "\nVirtual Node 1 voltage: {:s}"
146 "\n--- Initialization from powerflow finished ---",
149 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
150 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)),
151 Logger::phasorToString(
mVirtualNodes[0]->initialSingleVoltage()));
155 AttributeBase::List &prevStepDependencies,
156 AttributeBase::List &attributeDependencies,
157 AttributeBase::List &modifiedAttributes) {
169void DP::Ph3::PiLine::mnaParentAddPostStepDependencies(
170 AttributeBase::List &prevStepDependencies,
171 AttributeBase::List &attributeDependencies,
172 AttributeBase::List &modifiedAttributes,
173 Attribute<Matrix>::Ptr &leftVector) {
175 attributeDependencies.push_back(leftVector);
176 modifiedAttributes.push_back(mIntfVoltage);
177 modifiedAttributes.push_back(mIntfCurrent);
180void DP::Ph3::PiLine::mnaParentPostStep(Real time, Int timeStepCount,
181 Attribute<Matrix>::Ptr &leftVector) {
183 this->mnaUpdateVoltage(**leftVector);
184 this->mnaUpdateCurrent(**leftVector);
190 if (terminalNotGrounded(1)) {
191 (**mIntfVoltage)(0, 0) =
192 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
193 (**mIntfVoltage)(1, 0) =
194 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
195 (**mIntfVoltage)(2, 0) =
196 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
198 if (terminalNotGrounded(0)) {
199 (**mIntfVoltage)(0, 0) =
201 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
202 (**mIntfVoltage)(1, 0) =
204 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
205 (**mIntfVoltage)(2, 0) =
207 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
216MNAInterface::List DP::Ph3::PiLine::mnaTearGroundComponents() {
217 MNAInterface::List gndComponents;
219 gndComponents.push_back(mSubParallelResistor0);
220 gndComponents.push_back(mSubParallelResistor1);
222 if ((**mParallelCap)(0, 0) > 0) {
223 gndComponents.push_back(mSubParallelCapacitor0);
224 gndComponents.push_back(mSubParallelCapacitor1);
227 return gndComponents;
230void DP::Ph3::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
231 mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
232 mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
233 mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
234 mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
237void DP::Ph3::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
238 mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
239 mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
242void DP::Ph3::PiLine::mnaTearApplyVoltageStamp(Matrix &voltageVector) {
243 mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
246void DP::Ph3::PiLine::mnaTearPostStep(MatrixComp voltage, MatrixComp current) {
247 mSubSeriesInductor->mnaTearPostStep(voltage - (**mSeriesRes * current),
249 (**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
Series Inductance submodel.
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 initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
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.