9 #include <dpsim-models/DP/DP_Ph1_Switch.h>
15 Base::Ph1::
Switch(mAttributes) {
22 auto copy = Switch::make(name, mLogLevel);
23 copy->setParameters(**mOpenResistance, **mClosedResistance, **mIsClosed);
29 Real impedance = (**mIsClosed) ? **mClosedResistance : **mOpenResistance;
30 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
31 (**mIntfCurrent)(0, 0) = (**mIntfVoltage)(0, 0) / impedance;
33 SPDLOG_LOGGER_INFO(mSLog,
34 "\n--- Initialization from powerflow ---"
35 "\nVoltage across: {:s}"
37 "\nTerminal 0 voltage: {:s}"
38 "\nTerminal 1 voltage: {:s}"
39 "\n--- Initialization from powerflow finished ---",
40 Logger::phasorToString((**mIntfVoltage)(0, 0)),
41 Logger::phasorToString((**mIntfCurrent)(0, 0)),
42 Logger::phasorToString(initialSingleVoltage(0)),
43 Logger::phasorToString(initialSingleVoltage(1)));
46 void DP::Ph1::Switch::mnaCompInitialize(Real omega, Real timeStep,
48 updateMatrixNodeIndices();
49 **mRightVector = Matrix::Zero(0, 0);
53 SparseMatrixRow &systemMatrix) {
54 Complex conductance = (**mIsClosed) ? Complex(1. / **mClosedResistance, 0)
55 : Complex(1. / **mOpenResistance, 0);
57 MNAStampUtils::stampAdmittance(conductance, systemMatrix, matrixNodeIndex(0),
58 matrixNodeIndex(1), terminalNotGrounded(0),
59 terminalNotGrounded(1), mSLog);
63 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
64 Complex conductance = (closed) ? Complex(1. / **mClosedResistance, 0)
65 : Complex(1. / **mOpenResistance, 0);
67 MNAStampUtils::stampAdmittance(conductance, systemMatrix, matrixNodeIndex(0),
68 matrixNodeIndex(1), terminalNotGrounded(0),
69 terminalNotGrounded(1), mSLog);
78 (**mIntfVoltage)(0, 0) = 0;
79 if (terminalNotGrounded(1))
80 (**mIntfVoltage)(0, 0) =
81 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
82 if (terminalNotGrounded(0))
83 (**mIntfVoltage)(0, 0) =
84 (**mIntfVoltage)(0, 0) -
85 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0));
89 (**mIntfCurrent)(0, 0) = (**mIsClosed)
90 ? (**mIntfVoltage)(0, 0) / **mClosedResistance
91 : (**mIntfVoltage)(0, 0) / **mOpenResistance;
95 AttributeBase::List &prevStepDependencies,
96 AttributeBase::List &attributeDependencies,
97 AttributeBase::List &modifiedAttributes,
100 attributeDependencies.push_back(leftVector);
101 modifiedAttributes.push_back(mIntfVoltage);
102 modifiedAttributes.push_back(mIntfCurrent);
107 mnaCompUpdateVoltage(**leftVector);
108 mnaCompUpdateCurrent(**leftVector);
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system result.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
Add MNA post step dependencies.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system result.
Bool mnaIsClosed()
Check if switch is closed.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA post step operations.
Switch(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx)
Stamps system matrix considering the defined switch position.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector)
Stamps right side (source) vector.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
Base class for all MNA components that are transmitting power.
Base class for all components that are transmitting power.
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Voltage between terminals.