9 #include <dpsim-models/SP/SP_Ph3_Capacitor.h>
16 mPhaseType = PhaseType::ABC;
23 auto copy = Capacitor::make(name, mLogLevel);
24 copy->setParameters(**mCapacitance);
30 Real omega = 2 * PI * frequency;
31 mSusceptance = Matrix::Zero(3, 3);
32 mSusceptance << Complex(0, omega * (**mCapacitance)(0, 0)),
33 Complex(0, omega * (**mCapacitance)(0, 1)),
34 Complex(0, omega * (**mCapacitance)(0, 2)),
35 Complex(0, omega * (**mCapacitance)(1, 0)),
36 Complex(0, omega * (**mCapacitance)(1, 1)),
37 Complex(0, omega * (**mCapacitance)(1, 2)),
38 Complex(0, omega * (**mCapacitance)(2, 0)),
39 Complex(0, omega * (**mCapacitance)(2, 1)),
40 Complex(0, omega * (**mCapacitance)(2, 2));
43 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
44 (**mIntfVoltage)(1, 0) = (**mIntfVoltage)(0, 0) *
45 Complex(cos(-2. / 3. * M_PI), sin(-2. / 3. * M_PI));
46 (**mIntfVoltage)(2, 0) = (**mIntfVoltage)(0, 0) *
47 Complex(cos(2. / 3. * M_PI), sin(2. / 3. * M_PI));
49 **mIntfCurrent = mSusceptance * **mIntfVoltage;
67 updateMatrixNodeIndices();
78 SparseMatrixRow &systemMatrix) {
79 MNAStampUtils::stampAdmittanceMatrix(
80 mSusceptance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
81 terminalNotGrounded(0), terminalNotGrounded(1), mSLog);
85 AttributeBase::List &prevStepDependencies,
86 AttributeBase::List &attributeDependencies,
87 AttributeBase::List &modifiedAttributes,
89 attributeDependencies.push_back(leftVector);
90 modifiedAttributes.push_back(mIntfVoltage);
91 modifiedAttributes.push_back(mIntfCurrent);
94 void SP::Ph3::Capacitor::mnaCompPostStep(Real time, Int timeStepCount,
96 mnaCompUpdateVoltage(**leftVector);
97 mnaCompUpdateCurrent(**leftVector);
102 **mIntfVoltage = Matrix::Zero(3, 1);
103 if (terminalNotGrounded(1)) {
104 (**mIntfVoltage)(0, 0) =
105 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
106 (**mIntfVoltage)(1, 0) =
107 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
108 (**mIntfVoltage)(2, 0) =
109 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
111 if (terminalNotGrounded(0)) {
112 (**mIntfVoltage)(0, 0) =
113 (**mIntfVoltage)(0, 0) -
114 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
115 (**mIntfVoltage)(1, 0) =
116 (**mIntfVoltage)(1, 0) -
117 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
118 (**mIntfVoltage)(2, 0) =
119 (**mIntfVoltage)(2, 0) -
120 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
125 **mIntfCurrent = mSusceptance * **mIntfVoltage;
Base class for all MNA components that are transmitting power.
Capacitor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
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.