9#include <dpsim-models/EMT/EMT_Ph3_SeriesSwitch.h>
17 Logger::Level logLevel)
20 mPhaseType = PhaseType::ABC;
25 auto copy = SeriesSwitch::make(name,
mLogLevel);
34 Complex phasorA = initialSingleVoltage(1) - initialSingleVoltage(0);
35 (**mIntfVoltage)(0, 0) = phasorA.real();
36 Complex alpha(cos(2. / 3. * PI), sin(2. / 3. * PI));
37 (**mIntfVoltage)(1, 0) = Complex(phasorA * pow(alpha, 2)).real();
38 (**mIntfVoltage)(2, 0) = Complex(phasorA * alpha).real();
42 SPDLOG_LOGGER_INFO(
mSLog,
43 "\n--- Initialization from powerflow ---"
44 "\nVoltage across amplitude and phase: \n{}"
45 "\nCurrent amplitude and phase: \n{}"
46 "\nTerminal 0 voltage amplitude and phase: \n{}"
47 "\nTerminal 1 voltage amplitude and phase: \n{}"
48 "\n--- Initialization from powerflow finished ---",
51 Logger::phasorMatrixToString(initialVoltage(0)),
52 Logger::phasorMatrixToString(initialVoltage(1)));
56 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
64 SparseMatrixRow &systemMatrix) {
69 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
70 terminalNotGrounded(0), terminalNotGrounded(1),
mSLog);
74 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
79 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
80 terminalNotGrounded(0), terminalNotGrounded(1),
mSLog);
84 AttributeBase::List &prevStepDependencies,
85 AttributeBase::List &attributeDependencies,
86 AttributeBase::List &modifiedAttributes,
87 Attribute<Matrix>::Ptr &leftVector) {
88 attributeDependencies.push_back(leftVector);
93void EMT::Ph3::SeriesSwitch::mnaCompPostStep(
94 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
95 mnaCompUpdateVoltage(**leftVector);
96 mnaCompUpdateCurrent(**leftVector);
102 if (terminalNotGrounded(1)) {
103 (**mIntfVoltage)(0, 0) =
104 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 0));
105 (**mIntfVoltage)(1, 0) =
106 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 1));
107 (**mIntfVoltage)(2, 0) =
108 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 2));
110 if (terminalNotGrounded(0)) {
111 (**mIntfVoltage)(0, 0) =
113 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
114 (**mIntfVoltage)(1, 0) =
116 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
117 (**mIntfVoltage)(2, 0) =
119 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
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.
Bool mnaIsClosed() override
Check if switch is closed.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface voltage from MNA system results.
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 log level.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes states from power flow data.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system results.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
SimPowerComp< Real >::Ptr clone(String name) override
Return new instance with the same parameters.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes MNA specific variables.
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) override
Stamps system matrix considering the defined switch position.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Attribute< Matrix >::Ptr mRightVector
static void stampConductanceAs3x3ScalarMatrix(Real conductance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog)
Stamps conductance as a 3x3 scalar matrix (a diagonal matrix, where all diagonal elements are equal t...
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
void updateMatrixNodeIndices()
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.