11 mW(
Matrix::Zero(outputSize, inputSize)),
12 mYHist(
Matrix::Zero(outputSize, 1)), mInputSize(inputSize),
18 return static_cast<UInt>(
mA.rows());
23std::vector<EMT::SSNComp::LocalAbcStateBlock>
40 if (
A.rows() !=
A.cols())
41 throw std::invalid_argument(
"A must be square.");
43 if (
B.rows() !=
A.rows() ||
B.cols() != mInputSize)
44 throw std::invalid_argument(
"B has invalid dimensions.");
46 if (
C.rows() != mOutputSize ||
C.cols() !=
A.rows())
47 throw std::invalid_argument(
"C has invalid dimensions.");
49 if (D.rows() != mOutputSize || D.cols() != mInputSize)
50 throw std::invalid_argument(
"D has invalid dimensions.");
57 **
mX = Matrix::Zero(
mA.rows(), 1);
59 mdA = Matrix::Zero(
mA.rows(),
mA.cols());
60 mdB = Matrix::Zero(
mB.rows(),
mB.cols());
62 mW = Matrix::Zero(mOutputSize, mInputSize);
63 mYHist = Matrix::Zero(mOutputSize, 1);
74 Real frequency)
const {
75 const Real omega = 2.0 *
PI * frequency;
77 Complex(0.0, omega) * MatrixComp::Identity(
mA.rows(),
mA.cols()) -
80 return h.inverse() *
mB.cast<
Complex>() * u;
90 **
mX =
mdA * (**mX) +
mdB * (uNew + uOld);
109 throw std::logic_error(
110 "setParameters() must be called before initialization.");
124 prevStepDependencies.push_back(
mX);
139 attributeDependencies.push_back(leftVector);
142 modifiedAttributes.push_back(
mX);
AttributePointer< Attribute< T > > Ptr
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D)
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.
void mnaCompPreStep(Real time, Int timeStepCount) override final
const Attribute< Matrix >::Ptr mX
virtual void recomputeDiscreteModel()
virtual Attribute< Matrix >::Ptr inputAttribute() const =0
const Matrix & getC() const
Get continuous-time output matrix of the SSN model.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override final
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override final
virtual void updateState(const Matrix &uOld, const Matrix &uNew)
virtual Matrix calculateHistoryVector() const
virtual void updateStateSpaceModel()
Hook for variable/time-varying SSN components.
SSNComp(String uid, String name, Int inputSize, Int outputSize, Logger::Level logLevel=Logger::Level::off)
virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u, Real frequency) const
virtual Attribute< Matrix >::Ptr outputAttribute() const =0
virtual std::vector< LocalAbcStateBlock > getLocalAbcStateBlocks() const
UInt getStateCount() const
Get number of internal state variables of the SSN model.
virtual MatrixComp calculateSteadyStateOutputFromInput(const MatrixComp &x, const MatrixComp &u) const
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override final
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Attribute< Matrix >::Ptr mRightVector
virtual void mnaCompApplyRightSideVectorStamp(Matrix &rightVector)
static void calculateStateSpaceTrapezoidalMatrices(const Matrix &A, const Matrix &B, const Matrix &C, const Real &dt, Matrix &Ad, Matrix &Bd, Matrix &Cd)
Calculate the discretized state space matrices Ad, Bd, Cd using trapezoidal rule.
void updateMatrixNodeIndices()
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
std::complex< Real > Complex
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.