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:
72 std::array<UInt, 3> indices;
73
78 String name;
79 };
80
82 UInt getStateCount() const;
83
91 virtual std::vector<String> getLocalStateNames() const;
92
97 virtual std::vector<LocalAbcStateBlock> getLocalAbcStateBlocks() const;
98
100 const Matrix &getDiscreteA() const;
101
103 const Matrix &getDiscreteB() const;
104
106 const Matrix &getC() const;
107
108 void setParameters(const Matrix &A, const Matrix &B, const Matrix &C,
109 const Matrix &D);
110
111 void mnaCompInitialize(Real omega, Real timeStep,
112 Attribute<Matrix>::Ptr leftVector) override final;
113
114 void mnaCompAddPreStepDependencies(
115 AttributeBase::List &prevStepDependencies,
116 AttributeBase::List &attributeDependencies,
117 AttributeBase::List &modifiedAttributes) override final;
118
119 void mnaCompPreStep(Real time, Int timeStepCount) override final;
120
121 void mnaCompAddPostStepDependencies(
122 AttributeBase::List &prevStepDependencies,
123 AttributeBase::List &attributeDependencies,
124 AttributeBase::List &modifiedAttributes,
125 Attribute<Matrix>::Ptr &leftVector) override final;
126};
127
128} // namespace EMT
129} // namespace CPS
virtual std::vector< String > getLocalStateNames() const
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.
const Matrix & getC() const
Get continuous-time output matrix of the SSN model.
virtual void updateStateSpaceModel()
Hook for variable/time-varying SSN components.
virtual std::vector< LocalAbcStateBlock > getLocalAbcStateBlocks() const
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)
std::array< UInt, 3 > indices
Local SSN state indices representing one native abc-frame state block.
Definition EMT_SSNComp.h:72