9#include <dpsim-models/DP/DP_Ph3_SeriesSwitch.h>
14 Logger::Level logLevel)
31 SPDLOG_LOGGER_INFO(
mSLog,
32 "\n--- Initialization from powerflow ---"
33 "\nVoltage across phasor: \n{}"
34 "\nCurrent phasor: \n{}"
35 "\nTerminal 0 voltage phasor: \n{}"
36 "\nTerminal 1 voltage phasor: \n{}",
37 Logger::phasorToString(initialVoltage(0)(0, 0)),
38 Logger::phasorToString(initialVoltage(1)(0, 0)),
45void DP::Ph3::SeriesSwitch::mnaCompInitialize(
46 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
47 updateMatrixNodeIndices();
48 **mRightVector = Matrix::Zero(0, 0);
52 SparseMatrixRow &systemMatrix) {
57 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
58 terminalNotGrounded(0), terminalNotGrounded(1),
mSLog);
62 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
67 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
68 terminalNotGrounded(0), terminalNotGrounded(1),
mSLog);
72 AttributeBase::List &prevStepDependencies,
73 AttributeBase::List &attributeDependencies,
74 AttributeBase::List &modifiedAttributes,
75 Attribute<Matrix>::Ptr &leftVector) {
76 attributeDependencies.push_back(leftVector);
81void DP::Ph3::SeriesSwitch::mnaCompPostStep(
82 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
83 mnaCompUpdateVoltage(**leftVector);
84 mnaCompUpdateCurrent(**leftVector);
90 if (terminalNotGrounded(1)) {
91 (**mIntfVoltage)(0, 0) =
92 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
93 (**mIntfVoltage)(1, 0) =
94 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
95 (**mIntfVoltage)(2, 0) =
96 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
98 if (terminalNotGrounded(0)) {
99 (**mIntfVoltage)(0, 0) =
101 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
102 (**mIntfVoltage)(1, 0) =
104 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
105 (**mIntfVoltage)(2, 0) =
107 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
110 SPDLOG_LOGGER_DEBUG(
mSLog,
"Voltage A: {} < {}",
119 SPDLOG_LOGGER_DEBUG(
mSLog,
"Current A: {} < {}",
const Attribute< Real >::Ptr mClosedResistance
Resistance if switch is closed [ohm].
const Attribute< Real >::Ptr mOpenResistance
Resistance if switch is open [ohm].
const Attribute< Bool >::Ptr mIsClosed
Defines if Switch is open or closed.
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.
Bool hasParameterChanged() override
Returns true if one of the element paramters has changed.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
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
SimTerminal< Complex >::List mTerminals
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Logger::Log mSLog
Component logger.