9 #include <dpsim-models/DP/DP_Ph3_SeriesSwitch.h>
14 Logger::Level logLevel)
16 Base::Ph1::Switch(mAttributes) {
24 Real impedance = (**mIsClosed) ? **mClosedResistance : **mOpenResistance;
25 **mIntfVoltage = initialVoltage(1) - initialVoltage(0);
26 **mIntfCurrent = **mIntfVoltage / impedance;
28 SPDLOG_LOGGER_INFO(mSLog,
29 "\n--- Initialization from powerflow ---"
30 "\nVoltage across phasor: \n{}"
31 "\nCurrent phasor: \n{}"
32 "\nTerminal 0 voltage phasor: \n{}"
33 "\nTerminal 1 voltage phasor: \n{}",
34 Logger::phasorToString(initialVoltage(0)(0, 0)),
35 Logger::phasorToString(initialVoltage(1)(0, 0)),
36 Logger::phasorToString((**mIntfVoltage)(0, 0)),
37 Logger::phasorToString((**mIntfCurrent)(0, 0)));
42 void DP::Ph3::SeriesSwitch::mnaCompInitialize(
44 updateMatrixNodeIndices();
45 **mRightVector = Matrix::Zero(0, 0);
49 SparseMatrixRow &systemMatrix) {
50 Complex conductance = (**mIsClosed) ? Complex(1. / **mClosedResistance, 0)
51 : Complex(1. / **mOpenResistance, 0);
54 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
55 terminalNotGrounded(0), terminalNotGrounded(1), mSLog);
59 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
60 Complex conductance = (closed) ? Complex(1. / **mClosedResistance, 0)
61 : Complex(1. / **mOpenResistance, 0);
64 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
65 terminalNotGrounded(0), terminalNotGrounded(1), mSLog);
69 AttributeBase::List &prevStepDependencies,
70 AttributeBase::List &attributeDependencies,
71 AttributeBase::List &modifiedAttributes,
73 attributeDependencies.push_back(leftVector);
74 modifiedAttributes.push_back(mIntfVoltage);
75 modifiedAttributes.push_back(mIntfCurrent);
78 void DP::Ph3::SeriesSwitch::mnaCompPostStep(
80 mnaCompUpdateVoltage(**leftVector);
81 mnaCompUpdateCurrent(**leftVector);
86 **mIntfVoltage = MatrixComp::Zero(3, 1);
87 if (terminalNotGrounded(1)) {
88 (**mIntfVoltage)(0, 0) =
89 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
90 (**mIntfVoltage)(1, 0) =
91 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
92 (**mIntfVoltage)(2, 0) =
93 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
95 if (terminalNotGrounded(0)) {
96 (**mIntfVoltage)(0, 0) =
97 (**mIntfVoltage)(0, 0) -
98 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
99 (**mIntfVoltage)(1, 0) =
100 (**mIntfVoltage)(1, 0) -
101 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
102 (**mIntfVoltage)(2, 0) =
103 (**mIntfVoltage)(2, 0) -
104 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
107 SPDLOG_LOGGER_DEBUG(mSLog,
"Voltage A: {} < {}",
108 std::abs((**mIntfVoltage)(0, 0)),
109 std::arg((**mIntfVoltage)(0, 0)));
113 Real impedance = (**mIsClosed) ? **mClosedResistance : **mOpenResistance;
114 **mIntfCurrent = **mIntfVoltage / impedance;
116 SPDLOG_LOGGER_DEBUG(mSLog,
"Current A: {} < {}",
117 std::abs((**mIntfCurrent)(0, 0)),
118 std::arg((**mIntfCurrent)(0, 0)));
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
Bool mnaIsClosed() override
Check if switch is closed.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) override
Stamps system matrix considering the defined switch position.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
SeriesSwitch(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name and logging level.
Base class for all MNA components that are transmitting power.
static void stampAdmittanceAs3x3ScalarMatrix(Complex admittance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog, Int maxFreq=1, Int freqIdx=0)
Stamps admittance as a 3x3 scalar matrix (a diagonal matrix, where all diagonal elements are equal to...
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Voltage between terminals.