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 <dpsim-models/MNASimPowerComp.h>
7#include <dpsim-models/Solver/MNAInterface.h>
8
9namespace CPS {
10namespace EMT {
11
21class SSNComp : public MNASimPowerComp<Real> {
22private:
23 const Int mInputSize;
24 const Int mOutputSize;
25
26protected:
27 Real mTimeStep;
28
29 Matrix mW;
30 Matrix mYHist;
31
32 Matrix mA;
33 Matrix mB;
34 Matrix mC;
35 Matrix mD;
36
37 Matrix mdA;
38 Matrix mdB;
39
40 const Attribute<Matrix>::Ptr mX;
41
42 SSNComp(String uid, String name, Int inputSize, Int outputSize,
43 Logger::Level logLevel = Logger::Level::off);
44
45 virtual Matrix calculateHistoryVector() const;
46
47 virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u,
48 Real frequency) const;
49 virtual MatrixComp
50 calculateSteadyStateOutputFromInput(const MatrixComp &x,
51 const MatrixComp &u) const;
52
53 virtual void updateState(const Matrix &uOld, const Matrix &uNew);
54
56 virtual void updateLogAttributes(const Matrix &u) const;
57
58 virtual void recomputeDiscreteModel();
59
61 virtual void updateStateSpaceModel();
62
63 virtual Attribute<Matrix>::Ptr inputAttribute() const = 0;
64 virtual Attribute<Matrix>::Ptr outputAttribute() const = 0;
65
66public:
68 UInt getStateCount() const;
69
71 const Matrix &getDiscreteA() const;
72
74 const Matrix &getDiscreteB() const;
75
77 const Matrix &getC() const;
78
79 void setParameters(const Matrix &A, const Matrix &B, const Matrix &C,
80 const Matrix &D);
81
82 void mnaCompInitialize(Real omega, Real timeStep,
83 Attribute<Matrix>::Ptr leftVector) override final;
84
85 void mnaCompAddPreStepDependencies(
86 AttributeBase::List &prevStepDependencies,
87 AttributeBase::List &attributeDependencies,
88 AttributeBase::List &modifiedAttributes) override final;
89
90 void mnaCompPreStep(Real time, Int timeStepCount) override final;
91
92 void mnaCompAddPostStepDependencies(
93 AttributeBase::List &prevStepDependencies,
94 AttributeBase::List &attributeDependencies,
95 AttributeBase::List &modifiedAttributes,
96 Attribute<Matrix>::Ptr &leftVector) override final;
97};
98
99} // namespace EMT
100} // 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.
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)