9 #include <dpsim-models/EMT/EMT_Ph3_RxLine.h>
17 : Base::Ph3::
PiLine(mAttributes),
19 mPhaseType = PhaseType::ABC;
20 setVirtualNodeNumber(1);
23 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
32 auto copy = RxLine::make(name, mLogLevel);
33 copy->setParameters(**mSeriesRes, **mSeriesInd);
40 Real omega = 2. * PI * frequency;
41 MatrixComp impedance = MatrixComp::Zero(3, 3);
42 impedance << Complex((**mSeriesRes)(0, 0), omega * (**mSeriesInd)(0, 0)),
43 Complex((**mSeriesRes)(0, 1), omega * (**mSeriesInd)(0, 1)),
44 Complex((**mSeriesRes)(0, 2), omega * (**mSeriesInd)(0, 2)),
45 Complex((**mSeriesRes)(1, 0), omega * (**mSeriesInd)(1, 0)),
46 Complex((**mSeriesRes)(1, 1), omega * (**mSeriesInd)(1, 1)),
47 Complex((**mSeriesRes)(1, 2), omega * (**mSeriesInd)(1, 2)),
48 Complex((**mSeriesRes)(2, 0), omega * (**mSeriesInd)(2, 0)),
49 Complex((**mSeriesRes)(2, 1), omega * (**mSeriesInd)(2, 1)),
50 Complex((**mSeriesRes)(2, 2), omega * (**mSeriesInd)(2, 2));
52 MatrixComp vInitABC = MatrixComp::Zero(3, 1);
54 mVirtualNodes[0]->initialSingleVoltage() - initialSingleVoltage(0);
55 vInitABC(1, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_B;
56 vInitABC(2, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_C;
58 **mIntfCurrent = (impedance.inverse() * vInitABC).real();
59 **mIntfVoltage = vInitABC.real();
62 MatrixComp vInitTerm0 = MatrixComp::Zero(3, 1);
63 vInitTerm0(0, 0) = initialSingleVoltage(0);
64 vInitTerm0(1, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_B;
65 vInitTerm0(2, 0) = vInitTerm0(0, 0) * SHIFT_TO_PHASE_C;
67 mVirtualNodes[0]->setInitialVoltage(vInitTerm0 +
68 **mSeriesRes * **mIntfCurrent);
72 std::make_shared<EMT::Ph3::Resistor>(**mName +
"_res", mLogLevel);
73 mSubResistor->setParameters(**mSeriesRes);
74 mSubResistor->connect({mTerminals[0]->node(), mVirtualNodes[0]});
75 mSubResistor->initializeFromNodesAndTerminals(frequency);
76 addMNASubComponent(mSubResistor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
77 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
80 std::make_shared<EMT::Ph3::Inductor>(**mName +
"_ind", mLogLevel);
81 mSubInductor->setParameters(**mSeriesInd);
82 mSubInductor->connect({mVirtualNodes[0], mTerminals[1]->node()});
83 mSubInductor->initializeFromNodesAndTerminals(frequency);
84 addMNASubComponent(mSubInductor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
85 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
88 std::make_shared<EMT::Ph3::Resistor>(**mName +
"_snubber_res", mLogLevel);
89 Matrix defaultSnubRes = Matrix::Zero(3, 1);
90 defaultSnubRes << 1e6, 0, 0, 0, 1e6, 0, 0, 0, 1e6;
91 mInitialResistor->setParameters(defaultSnubRes);
92 mInitialResistor->connect({SimNode::GND, mTerminals[1]->node()});
93 mInitialResistor->initializeFromNodesAndTerminals(frequency);
94 addMNASubComponent(mInitialResistor,
95 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
96 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
98 SPDLOG_LOGGER_INFO(mSLog,
99 "\n--- Initialization from powerflow ---"
100 "\nVoltage across: {:s}"
102 "\nTerminal 0 voltage: {:s}"
103 "\nTerminal 1 voltage: {:s}"
104 "\n--- Initialization from powerflow finished ---",
105 Logger::matrixToString(**mIntfVoltage),
106 Logger::matrixToString(**mIntfCurrent),
107 Logger::phasorToString(initialSingleVoltage(0)),
108 Logger::phasorToString(initialSingleVoltage(1)));
111 void EMT::Ph3::RxLine::mnaParentAddPreStepDependencies(
112 AttributeBase::List &prevStepDependencies,
113 AttributeBase::List &attributeDependencies,
114 AttributeBase::List &modifiedAttributes) {
115 modifiedAttributes.push_back(mRightVector);
118 void EMT::Ph3::RxLine::mnaParentAddPostStepDependencies(
119 AttributeBase::List &prevStepDependencies,
120 AttributeBase::List &attributeDependencies,
121 AttributeBase::List &modifiedAttributes,
123 attributeDependencies.push_back(leftVector);
124 modifiedAttributes.push_back(mIntfCurrent);
125 modifiedAttributes.push_back(mIntfVoltage);
129 mnaCompApplyRightSideVectorStamp(**mRightVector);
132 void EMT::Ph3::RxLine::mnaParentPostStep(Real time, Int timeStepCount,
134 mnaCompUpdateVoltage(**leftVector);
135 mnaCompUpdateCurrent(**leftVector);
138 void EMT::Ph3::RxLine::mnaCompUpdateVoltage(
const Matrix &leftVector) {
140 **mIntfVoltage = Matrix::Zero(3, 1);
141 if (terminalNotGrounded(1)) {
142 (**mIntfVoltage)(0, 0) =
143 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 0));
144 (**mIntfVoltage)(1, 0) =
145 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 1));
146 (**mIntfVoltage)(2, 0) =
147 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 2));
149 if (terminalNotGrounded(0)) {
150 (**mIntfVoltage)(0, 0) =
151 (**mIntfVoltage)(0, 0) -
152 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
153 (**mIntfVoltage)(1, 0) =
154 (**mIntfVoltage)(1, 0) -
155 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
156 (**mIntfVoltage)(2, 0) =
157 (**mIntfVoltage)(2, 0) -
158 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
162 void EMT::Ph3::RxLine::mnaCompUpdateCurrent(
const Matrix &leftVector) {
163 **mIntfCurrent = mSubInductor->intfCurrent();
Base class for composite power components.
PI-line dynamic phasor model.
RxLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, logging level.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre and post step operations.
SimPowerComp< Real >::Ptr clone(String name) override
DEPRECATED: Delete method.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
String type()
Get component type (cross-platform)
Base class for all components that are transmitting power.
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
Voltage between terminals.
Logger::Log mSLog
Component logger.