9#include <dpsim-models/SP/SP_Ph1_varResSwitch.h>
14 Logger::Level logLevel)
23 auto copy = varResSwitch::make(name,
mLogLevel);
35 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
36 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) / impedance;
41 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
48 SparseMatrixRow &systemMatrix) {
52 MNAStampUtils::stampAdmittance(conductance, systemMatrix, matrixNodeIndex(0),
53 matrixNodeIndex(1), terminalNotGrounded(0),
54 terminalNotGrounded(1),
mSLog);
58 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
62 MNAStampUtils::stampAdmittance(conductance, systemMatrix, matrixNodeIndex(0),
63 matrixNodeIndex(1), terminalNotGrounded(0),
64 terminalNotGrounded(1),
mSLog);
68 Matrix &rightVector) {}
71 AttributeBase::List &prevStepDependencies,
72 AttributeBase::List &attributeDependencies,
73 AttributeBase::List &modifiedAttributes,
74 Attribute<Matrix>::Ptr &leftVector) {
76 attributeDependencies.push_back(leftVector);
82 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
89 (**mIntfVoltage)(0, 0) = 0;
90 if (terminalNotGrounded(1))
91 (**mIntfVoltage)(0, 0) =
92 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1));
93 if (terminalNotGrounded(0))
94 (**mIntfVoltage)(0, 0) =
96 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0));
110 if (!(mPrevState == presentState)) {
140void SP::Ph1::varResSwitch::setInitParameters(Real timestep) {
144 mDeltaResOpen = 0.5 * timestep / 0.001 + 1;
145 mPrevState = **mIsClosed;
146 mPrevRes = (**mIsClosed) ? **mClosedResistance : **mOpenResistance;
147 mInitClosedRes = **mClosedResistance;
148 mInitOpenRes = **mOpenResistance;
const Attribute< Real >::Ptr mClosedResistance
Resistance if switch is closed [ohm].
Bool isClosed()
Check if switch is closed.
const Attribute< Real >::Ptr mOpenResistance
Resistance if switch is open [ohm].
const Attribute< Bool >::Ptr mIsClosed
Defines if Switch is open or closed.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
Bool mnaIsClosed()
Check if switch is closed.
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx)
Stamps system matrix considering the defined switch position.
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
Bool hasParameterChanged()
Returns true if one of the element paramters has changed.
void initializeFromNodesAndTerminals(Real frequency)
Initializes states from power flow data.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system results.
varResSwitch(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and log level.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Initializes MNA specific variables.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre step operations.
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system results.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector)
Stamps right side (source) vector.
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
void updateMatrixNodeIndices()
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.