9#include <dpsim-models/EMT/EMT_Ph1_Switch.h>
22 auto copy = Switch::make(name,
mLogLevel);
31 (**mIntfVoltage)(0, 0) =
33 (initialSingleVoltage(1) - initialSingleVoltage(0)).real();
34 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) / resistance;
36 SPDLOG_LOGGER_INFO(
mSLog,
37 "\n--- Initialization from powerflow ---"
38 "\nVoltage across: {:s}"
40 "\nTerminal 0 voltage: {:s}"
41 "\nTerminal 1 voltage: {:s}"
42 "\n--- Initialization from powerflow finished ---",
45 Logger::phasorToString(RMS3PH_TO_PEAK1PH *
46 initialSingleVoltage(0).real()),
47 Logger::phasorToString(RMS3PH_TO_PEAK1PH *
48 initialSingleVoltage(1).real()));
51void EMT::Ph1::Switch::mnaCompInitialize(Real omega, Real timeStep,
52 Attribute<Matrix>::Ptr leftVector) {
53 updateMatrixNodeIndices();
54 mMnaTasks.push_back(std::make_shared<MnaPostStep>(*
this, leftVector));
60 SparseMatrixRow &systemMatrix) {
64 (**mIsClosed) ? 1. / (**mClosedResistance) : 1. / (**mOpenResistance);
66 MNAStampUtils::stampConductance(conductance, systemMatrix, matrixNodeIndex(0),
67 matrixNodeIndex(1), terminalNotGrounded(0),
68 terminalNotGrounded(1),
mSLog);
72 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
78 MNAStampUtils::stampConductance(conductance, systemMatrix, matrixNodeIndex(0),
79 matrixNodeIndex(1), terminalNotGrounded(0),
80 terminalNotGrounded(1),
mSLog);
86 AttributeBase::List &prevStepDependencies,
87 AttributeBase::List &attributeDependencies,
88 AttributeBase::List &modifiedAttributes,
89 Attribute<Matrix>::Ptr &leftVector) {
90 attributeDependencies.push_back(leftVector);
96 Attribute<Matrix>::Ptr &leftVector) {
104 if (terminalNotGrounded(1)) {
105 (**mIntfVoltage)(0, 0) =
106 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 0));
108 if (terminalNotGrounded(0)) {
109 (**mIntfVoltage)(0, 0) =
111 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
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 mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) override
Stamps system matrix considering the defined switch position.
Bool mnaIsClosed() override
Check if switch is closed.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
Switch(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.