DPsim
Loading...
Searching...
No Matches
EMT_SSNComp.h
1// SPDX-FileCopyrightText: 2026 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 <array>
7#include <vector>
8
9#include <dpsim-models/MNASimPowerComp.h>
10#include <dpsim-models/Solver/MNAInterface.h>
11
12namespace CPS {
13namespace EMT {
14
24class SSNComp : public MNASimPowerComp<Real> {
25private:
26 const Int mInputSize;
27 const Int mOutputSize;
28
29protected:
30 Real mTimeStep;
31
32 Matrix mW;
33 Matrix mYHist;
34
35 Matrix mA;
36 Matrix mB;
37 Matrix mC;
38 Matrix mD;
39
40 Matrix mdA;
41 Matrix mdB;
42
43 const Attribute<Matrix>::Ptr mX;
44
45 SSNComp(String uid, String name, Int inputSize, Int outputSize,
46 Logger::Level logLevel = Logger::Level::off);
47
48 virtual Matrix calculateHistoryVector() const;
49
50 virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u,
51 Real frequency) const;
52 virtual MatrixComp
53 calculateSteadyStateOutputFromInput(const MatrixComp &x,
54 const MatrixComp &u) const;
55
56 virtual void updateState(const Matrix &uOld, const Matrix &uNew);
57
59 virtual void updateLogAttributes(const Matrix &u) const;
60
61 virtual void recomputeDiscreteModel();
62
64 virtual void updateStateSpaceModel();
65
66 virtual Attribute<Matrix>::Ptr inputAttribute() const = 0;
67 virtual Attribute<Matrix>::Ptr outputAttribute() const = 0;
68
69public:
71 UInt getStateCount() const;
72
77 virtual std::vector<std::array<UInt, 3>> getLocalAbcStateIndexTriples() const;
78
80 const Matrix &getDiscreteA() const;
81
83 const Matrix &getDiscreteB() const;
84
86 const Matrix &getC() const;
87
88 void setParameters(const Matrix &A, const Matrix &B, const Matrix &C,
89 const Matrix &D);
90
91 void mnaCompInitialize(Real omega, Real timeStep,
92 Attribute<Matrix>::Ptr leftVector) override final;
93
94 void mnaCompAddPreStepDependencies(
95 AttributeBase::List &prevStepDependencies,
96 AttributeBase::List &attributeDependencies,
97 AttributeBase::List &modifiedAttributes) override final;
98
99 void mnaCompPreStep(Real time, Int timeStepCount) override final;
100
101 void mnaCompAddPostStepDependencies(
102 AttributeBase::List &prevStepDependencies,
103 AttributeBase::List &attributeDependencies,
104 AttributeBase::List &modifiedAttributes,
105 Attribute<Matrix>::Ptr &leftVector) override final;
106};
107
108} // namespace EMT
109} // namespace CPS
virtual void updateLogAttributes(const Matrix &u) const
Update derived attributes used for logging/inspection.
const Matrix & getDiscreteA() const
Get discrete state transition matrix used by the trapezoidal SSN model.
const Matrix & getDiscreteB() const
Get discrete input matrix used by the trapezoidal SSN model.
virtual std::vector< std::array< UInt, 3 > > getLocalAbcStateIndexTriples() const
const Matrix & getC() const
Get continuous-time output matrix of the SSN model.
virtual void updateStateSpaceModel()
Hook for variable/time-varying SSN components.
UInt getStateCount() const
Get number of internal state variables of the SSN model.
String uid()
Returns unique id.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)