Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dpsim-models/include/dpsim-models/Components.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
#include <dpsim-models/EMT/EMT_Ph1_CurrentSource.h>
#include <dpsim-models/EMT/EMT_Ph1_Inductor.h>
#include <dpsim-models/EMT/EMT_Ph1_Resistor.h>
#include <dpsim-models/EMT/EMT_Ph1_SSNTypeI2T.h>
#include <dpsim-models/EMT/EMT_Ph1_SSNTypeV2T.h>
#include <dpsim-models/EMT/EMT_Ph1_SSN_Full_Serial_RLC.h>
#include <dpsim-models/EMT/EMT_Ph1_Switch.h>
#include <dpsim-models/EMT/EMT_Ph1_VoltageSource.h>
#include <dpsim-models/EMT/EMT_Ph1_VoltageSourceNorton.h>
Expand Down
93 changes: 93 additions & 0 deletions dpsim-models/include/dpsim-models/EMT/EMT_Ph1_SSNTypeI2T.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// SPDX-FileCopyrightText: 2025 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
// SPDX-License-Identifier: MPL-2.0

#pragma once

#include <dpsim-models/MNASimPowerComp.h>
#include <dpsim-models/Solver/MNAInterface.h>

namespace CPS {
namespace EMT {
namespace Ph1 {
/// \brief SSNTypeI2T
/// Model for a one phase, two terminal I-type SSN component which can be represented using
/// a state space equation system
/// x' = A * x + B * u
/// y = C * x + D * u
/// with x: state vector, y: output vector, u: input vector,
/// where u represents external current (mIntfCurrent),
/// y represents external voltage (mIntfVoltage),
/// x represents any component states.
class SSNTypeI2T : public MNASimPowerComp<Real>,
public SharedFactory<SSNTypeI2T> {
private:
void ssnUpdateState();
void setSSNMatricesToZero();

protected:
Matrix mX;
Matrix mU;
Matrix mUOld;
Matrix mW;
Matrix mYHist;

public:
Comment thread
MarvinTollnitschRWTH marked this conversation as resolved.
const CPS::Attribute<Matrix>::Ptr mA;
Comment thread
georgii-tishenin marked this conversation as resolved.
const CPS::Attribute<Matrix>::Ptr mB;
const CPS::Attribute<Matrix>::Ptr mC;
const CPS::Attribute<Matrix>::Ptr mD;

const CPS::Attribute<Matrix>::Ptr mdA;
const CPS::Attribute<Matrix>::Ptr mdB;
const CPS::Attribute<Matrix>::Ptr mdC;

/// Defines UID, name, component parameters and logging level
SSNTypeI2T(String uid, String name,
Logger::Level logLevel = Logger::Level::off);
/// Defines name and logging level
SSNTypeI2T(String name, Logger::Level logLevel = Logger::Level::off)
: SSNTypeI2T(name, name, logLevel) {}

SimPowerComp<Real>::Ptr clone(String name) override;

void manualInit(Matrix initialState, Matrix initialInput,
Matrix initialOldInput, Real initCurrent, Real initVoltage);
// #### General ####
void setParameters(const Matrix A, const Matrix B, const Matrix C,
const Matrix D);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// Initializes internal variables of the component
void mnaCompInitialize(Real omega, Real timeStep,
Attribute<Matrix>::Ptr leftVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
/// Update interface voltage from MNA system result
void mnaCompUpdateVoltage(const Matrix &leftVector) override;
/// Update interface current from MNA system result
void mnaCompUpdateCurrent(const Matrix &leftVector) override;

void mnaCompPreStep(Real time, Int timeStepCount) override;
void mnaCompPostStep(Real time, Int timeStepCount,
Attribute<Matrix>::Ptr &leftVector) override;

/// Add MNA pre step dependencies
void mnaCompAddPreStepDependencies(
AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies,
AttributeBase::List &modifiedAttributes) override;
Comment thread
MarvinTollnitschRWTH marked this conversation as resolved.

/// Add MNA post step dependencies
void
mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies,
AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) override;
};
} // namespace Ph1
} // namespace EMT
} // namespace CPS
94 changes: 94 additions & 0 deletions dpsim-models/include/dpsim-models/EMT/EMT_Ph1_SSNTypeV2T.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// SPDX-FileCopyrightText: 2025 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
// SPDX-License-Identifier: MPL-2.0

#pragma once

#include <dpsim-models/MNASimPowerComp.h>
#include <dpsim-models/Solver/MNAInterface.h>

namespace CPS {
namespace EMT {
namespace Ph1 {
/// \brief SSNTypeV2T
/// Model for a one phase, two terminal V-type SSN component which can be represented using
/// a state space equation system
/// x' = A * x + B * u
/// y = C * x + D * u
/// with x: state vector, y: output vector, u: input vector,
/// where u represents external voltage (mIntfVoltage),
/// y represents external current (mIntfCurrent),
/// x represents any component states.
class SSNTypeV2T : public MNASimPowerComp<Real>,
public SharedFactory<SSNTypeV2T> {
private:
void ssnUpdateState();
void setSSNMatricesToZero();

protected:
Matrix mX;
Matrix mU;
Matrix mUOld;
Matrix mW;
Matrix mYHist;

public:
const CPS::Attribute<Matrix>::Ptr mA;
const CPS::Attribute<Matrix>::Ptr mB;
const CPS::Attribute<Matrix>::Ptr mC;
const CPS::Attribute<Matrix>::Ptr mD;

const CPS::Attribute<Matrix>::Ptr mdA;
const CPS::Attribute<Matrix>::Ptr mdB;
const CPS::Attribute<Matrix>::Ptr mdC;

/// Defines UID, name, component parameters and logging level
SSNTypeV2T(String uid, String name,
Logger::Level logLevel = Logger::Level::off);
/// Defines name and logging level
SSNTypeV2T(String name, Logger::Level logLevel = Logger::Level::off)
: SSNTypeV2T(name, name, logLevel) {}

SimPowerComp<Real>::Ptr clone(String name) override;

void manualInit(Matrix initialState, Matrix initialInput,
Matrix initialOldInput, Real initCurrent, Real initVoltage);

// #### General ####
void setParameters(const Matrix A, const Matrix B, const Matrix C,
const Matrix D);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// Initializes internal variables of the component
void mnaCompInitialize(Real omega, Real timeStep,
Attribute<Matrix>::Ptr leftVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
/// Update interface voltage from MNA system result
void mnaCompUpdateVoltage(const Matrix &leftVector) override;
/// Update interface current from MNA system result
void mnaCompUpdateCurrent(const Matrix &leftVector) override;

void mnaCompPreStep(Real time, Int timeStepCount) override;
void mnaCompPostStep(Real time, Int timeStepCount,
Attribute<Matrix>::Ptr &leftVector) override;

/// Add MNA pre step dependencies
void mnaCompAddPreStepDependencies(
AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies,
AttributeBase::List &modifiedAttributes) override;

/// Add MNA post step dependencies
void
mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies,
AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) override;
};
} // namespace Ph1
} // namespace EMT
} // namespace CPS
100 changes: 100 additions & 0 deletions dpsim-models/include/dpsim-models/EMT/EMT_Ph1_SSN_Full_Serial_RLC.h
Comment thread
georgii-tishenin marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// SPDX-FileCopyrightText: 2025 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
// SPDX-License-Identifier: MPL-2.0

#pragma once

#include <dpsim-models/Base/Base_Ph1_Capacitor.h>
#include <dpsim-models/Base/Base_Ph1_Inductor.h>
#include <dpsim-models/Base/Base_Ph1_Resistor.h>
#include <dpsim-models/MNASimPowerComp.h>
#include <dpsim-models/Solver/MNAInterface.h>

namespace CPS {
namespace EMT {
namespace Ph1 {
namespace SSN {
/// \brief Full_Serial_RLC
///
/// This element represents an one port circuit consisting of a resistor,
/// an inductor and a capacitor connected in series. The terminals are at
/// the beginning and the end of the component chain.
/// The states are the capacitor voltage and the inductor current, the output
/// is the latter of those states (inductor current). The input is the voltage
/// across the whole circuit. States and past inputs are updated after each
/// time step and are used to calculate the current (input) voltage,
/// represented as MNA node voltages.
/// SSN theory and variable naming based on
/// C. Dufour, J. Mahseredjian and J. Belanger,
/// "A combined state-space nodal method for the simulation of power system
/// transients," 2011 IEEE Power and Energy Society General Meeting, Detroit,
/// MI, USA, 2011, pp. 1-1, doi: 10.1109/PES.2011.6038887. keywords:
/// {Mathematical model;Analytical models;Equations;Power system transients;
/// Couplings;Switching circuits}

class Full_Serial_RLC final : public MNASimPowerComp<Real>,
public SharedFactory<Full_Serial_RLC>,
public Base::Ph1::Resistor,
public Base::Ph1::Inductor,
public Base::Ph1::Capacitor {
public:
/// Defines UID, name, component parameters and logging level
Full_Serial_RLC(String uid, String name,
Logger::Level logLevel = Logger::Level::off);
/// Defines name and logging level
Full_Serial_RLC(String name, Logger::Level logLevel = Logger::Level::off)
: Full_Serial_RLC(name, name, logLevel) {}

SimPowerComp<Real>::Ptr clone(String name) override;
void setParameters(Real resistance, Real inductance, Real capacitance);

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// Initializes internal variables of the component
void mnaCompInitialize(Real omega, Real timeStep,
Attribute<Matrix>::Ptr leftVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
/// Update interface voltage from MNA system result
void mnaCompUpdateVoltage(const Matrix &leftVector) override;
/// Update interface current from MNA system result
void mnaCompUpdateCurrent(const Matrix &leftVector) override;
/// MNA pre step operations
void mnaCompPreStep(Real time, Int timeStepCount) override;
/// MNA post step operations
void mnaCompPostStep(Real time, Int timeStepCount,
Attribute<Matrix>::Ptr &leftVector) override;
/// Add MNA pre step dependencies
void mnaCompAddPreStepDependencies(
AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies,
AttributeBase::List &modifiedAttributes) override;
/// Add MNA post step dependencies
void
mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies,
AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) override;

private:
Matrix mState = Matrix::Zero(2, 1);
Real mYHistory = 0;

Real mDufourUNT = 0;

Matrix mDufourAKHat = Matrix::Zero(2, 2);
Matrix mDufourBKHat = Matrix::Zero(2, 1);
Comment thread
georgii-tishenin marked this conversation as resolved.
Matrix mDufourBKNHat = Matrix::Zero(2, 1);
Real mDufourWKN = 0;
Matrix mDufourCKN = Matrix::Zero(1, 2);

void ssnUpdateState();
};
} // namespace SSN
} // namespace Ph1
} // namespace EMT
} // namespace CPS
4 changes: 4 additions & 0 deletions dpsim-models/include/dpsim-models/MathUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class Math {
const Matrix &C,
const Real &dt, Matrix &Ad,
Matrix &Bd, Matrix &Cd);
static void calculateStateSpaceTrapezoidalMatrices(const Matrix &A,
const Matrix &B,
const Real &dt, Matrix &Ad,
Matrix &Bd);
/// Apply the trapezoidal based state space matrices Ad, Bd, Cd to get the states at the current time step
static Matrix applyStateSpaceTrapezoidalMatrices(const Matrix &Ad,
const Matrix &Bd,
Expand Down
3 changes: 3 additions & 0 deletions dpsim-models/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ list(APPEND MODELS_SOURCES
EMT/EMT_Ph1_VoltageSourceRamp.cpp
EMT/EMT_Ph1_VoltageSourceNorton.cpp
EMT/EMT_Ph1_Switch.cpp
EMT/EMT_Ph1_SSN_Full_Serial_RLC.cpp
EMT/EMT_Ph1_SSNTypeI2T.cpp
EMT/EMT_Ph1_SSNTypeV2T.cpp

EMT/EMT_Ph3_CurrentSource.cpp
EMT/EMT_Ph3_VoltageSource.cpp
Expand Down
Loading
Loading