|
| 1 | +// SPDX-FileCopyrightText: 2025 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +#pragma once |
| 5 | + |
| 6 | +#include <dpsim-models/Base/Base_Ph1_Capacitor.h> |
| 7 | +#include <dpsim-models/Base/Base_Ph1_Inductor.h> |
| 8 | +#include <dpsim-models/Base/Base_Ph1_Resistor.h> |
| 9 | +#include <dpsim-models/MNASimPowerComp.h> |
| 10 | +#include <dpsim-models/Solver/MNAInterface.h> |
| 11 | + |
| 12 | +namespace CPS { |
| 13 | +namespace EMT { |
| 14 | +namespace Ph1 { |
| 15 | +namespace SSN { |
| 16 | +/// \brief Full_Serial_RLC |
| 17 | +/// |
| 18 | +/// This element represents an one port circuit consisting of a resistor, |
| 19 | +/// an inductor and a capacitor connected in series. The terminals are at |
| 20 | +/// the beginning and the end of the component chain. |
| 21 | +/// The states are the capacitor voltage and the inductor current, the output |
| 22 | +/// is the latter of those states (inductor current). The input is the voltage |
| 23 | +/// across the whole circuit. States and past inputs are updated after each |
| 24 | +/// time step and are used to calculate the current (input) voltage, |
| 25 | +/// represented as MNA node voltages. |
| 26 | +/// SSN theory and variable naming based on |
| 27 | +/// C. Dufour, J. Mahseredjian and J. Belanger, |
| 28 | +/// "A combined state-space nodal method for the simulation of power system |
| 29 | +/// transients," 2011 IEEE Power and Energy Society General Meeting, Detroit, |
| 30 | +/// MI, USA, 2011, pp. 1-1, doi: 10.1109/PES.2011.6038887. keywords: |
| 31 | +/// {Mathematical model;Analytical models;Equations;Power system transients; |
| 32 | +/// Couplings;Switching circuits} |
| 33 | + |
| 34 | +class Full_Serial_RLC final : public MNASimPowerComp<Real>, |
| 35 | + public SharedFactory<Full_Serial_RLC>, |
| 36 | + public Base::Ph1::Resistor, |
| 37 | + public Base::Ph1::Inductor, |
| 38 | + public Base::Ph1::Capacitor { |
| 39 | +public: |
| 40 | + /// Defines UID, name, component parameters and logging level |
| 41 | + Full_Serial_RLC(String uid, String name, |
| 42 | + Logger::Level logLevel = Logger::Level::off); |
| 43 | + /// Defines name and logging level |
| 44 | + Full_Serial_RLC(String name, Logger::Level logLevel = Logger::Level::off) |
| 45 | + : Full_Serial_RLC(name, name, logLevel) {} |
| 46 | + |
| 47 | + SimPowerComp<Real>::Ptr clone(String name) override; |
| 48 | + void setParameters(Real resistance, Real inductance, Real capacitance); |
| 49 | + |
| 50 | + // #### General #### |
| 51 | + /// Initializes component from power flow data |
| 52 | + void initializeFromNodesAndTerminals(Real frequency) override; |
| 53 | + |
| 54 | + // #### MNA section #### |
| 55 | + /// Initializes internal variables of the component |
| 56 | + void mnaCompInitialize(Real omega, Real timeStep, |
| 57 | + Attribute<Matrix>::Ptr leftVector) override; |
| 58 | + /// Stamps system matrix |
| 59 | + void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override; |
| 60 | + /// Stamps right side (source) vector |
| 61 | + void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override; |
| 62 | + /// Update interface voltage from MNA system result |
| 63 | + void mnaCompUpdateVoltage(const Matrix &leftVector) override; |
| 64 | + /// Update interface current from MNA system result |
| 65 | + void mnaCompUpdateCurrent(const Matrix &leftVector) override; |
| 66 | + /// MNA pre step operations |
| 67 | + void mnaCompPreStep(Real time, Int timeStepCount) override; |
| 68 | + /// MNA post step operations |
| 69 | + void mnaCompPostStep(Real time, Int timeStepCount, |
| 70 | + Attribute<Matrix>::Ptr &leftVector) override; |
| 71 | + /// Add MNA pre step dependencies |
| 72 | + void mnaCompAddPreStepDependencies( |
| 73 | + AttributeBase::List &prevStepDependencies, |
| 74 | + AttributeBase::List &attributeDependencies, |
| 75 | + AttributeBase::List &modifiedAttributes) override; |
| 76 | + /// Add MNA post step dependencies |
| 77 | + void |
| 78 | + mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, |
| 79 | + AttributeBase::List &attributeDependencies, |
| 80 | + AttributeBase::List &modifiedAttributes, |
| 81 | + Attribute<Matrix>::Ptr &leftVector) override; |
| 82 | + |
| 83 | +private: |
| 84 | + Matrix mState = Matrix::Zero(2, 1); |
| 85 | + Real mYHistory = 0; |
| 86 | + |
| 87 | + Real mDufourUNT = 0; |
| 88 | + |
| 89 | + Matrix mDufourAKHat = Matrix::Zero(2, 2); |
| 90 | + Matrix mDufourBKHat = Matrix::Zero(2, 1); |
| 91 | + Matrix mDufourBKNHat = Matrix::Zero(2, 1); |
| 92 | + Real mDufourWKN = 0; |
| 93 | + Matrix mDufourCKN = Matrix::Zero(1, 2); |
| 94 | + |
| 95 | + void ssnUpdateState(); |
| 96 | +}; |
| 97 | +} // namespace SSN |
| 98 | +} // namespace Ph1 |
| 99 | +} // namespace EMT |
| 100 | +} // namespace CPS |
0 commit comments