Template Class SystemModel

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

Class Documentation

template<typename scalar_type, typename index_type>
class SystemModel : public GridKit::EMT::Component<scalar_type, index_type>

EMT system of buses, devices and their submodels.

Each component owns a contiguous block of the system vectors, with parents before their submodels.

Todo:

Synchronize the residual scatters and the Jacobian refill, which add to entries shared by the devices at a bus.

Public Functions

explicit SystemModel(const SystemModelData<RealT, IdxT> &data)
Throws:

std::invalid_argument – for an unknown class, bus or port, or a duplicate id

virtual int allocate() override

The system binds each component to its blocks.

virtual int initialize() override

The initial values come from the state.

virtual int tagDifferentiable() override

Fill the tag() vector with proper indicators.

Note

For some models, this may be a no-op, and the vector returned by tag() will still be empty.

Pre:

allocate() must have been called.

virtual int setAbsoluteTolerance(RealT rel_tol) override

Buses first and parents before submodels, so each model reads the tolerances at its ports.

virtual int evaluateResidual() override

Evaluate the model’s residual function.

For models which can be appropriately modeled in semi-explicit form, this will evaluate

\[F(t, y, \dot{y}) = f(t,y) - M \dot{y},\]
where
\[M\]
is the mass matrix. For models which can be modeled in Hessenberg form,
\[M\]
should be a simple indicator function for if the variable is differential (if
\[\dot{y}\]
appears in its equation). This indicator should be given by tag().

virtual int evaluateJacobian() override

dF/dy + alpha dF/dy’ from the partials of the last tagging

virtual IdxT size() override

How many variables exist in the model.

virtual IdxT nnz() override

How many non-zero elements are in this model’s Jacobian.

This knowledge may be needed to allocate the buffers for the model’s Jacobian, so it it should not depend on allocate() having been called.

See also

getCsrJacobian()

virtual CsrMatrixT *getCsrJacobian() const override

Return a pointer to the CSR Jacobian.

Pre:

allocate() must have been called.

virtual bool monitoring() const override

Is there something to monitor? Defaults to false.

virtual void printMonitoredVariables() const override

Print variables at current state.

virtual void startMonitor() override

Get monitor ready for output.

virtual void stopMonitor() override

Tell monitor to wrap up.

template<typename ModelT>
inline ModelT &device(const std::string &id) const
Throws:

std::invalid_argument – if device id is not a ModelT