Template Class SystemModel
Defined in File SystemModel.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public GridKit::EMT::Component< scalar_type, index_type >(Template Class Component)
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. An input that the case leaves out reads a held signal, and an input that names an output reads a signal that follows it. The system adds one block of each.
- 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)
Construct the buses, then the devices, and the monitor sinks of
data.- Throws:
std::invalid_argument – for an unknown class, bus, device or name, or a duplicate id.
- Post:
Every device terminal is connected to its bus and every device input to what it reads, and
blocks_lists each component before its submodels.
-
virtual Model::ConfigurationChecks verify() const override
Check every component and its connections within this system.
A terminal and an input are connected, and an output may be. A connection to an external variable of another component requires that component earlier in
blocks_.- Returns:
The failed checks, each naming its component.
-
virtual int allocate() override
Verify the system, compose the system vectors, allocate the Jacobian and start the monitor.
- Returns:
0 on success, 1 if a check fails or an allocation fails.
- Post:
Each component views its block of the system vectors and has resolved its indices.
-
virtual int initialize() override
Mark the values and derivatives that the state has set.
The initial values come from the state, so no component initializes itself.
- Returns:
0.
- Pre:
allocatehas succeeded.
-
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
Set the absolute tolerance of every variable, in block order.
Buses come first and parents before submodels, so each model reads the tolerances of its external values. A signal takes the tolerance that the model of its output sets, which defaults to
rel_tol.- Parameters:
rel_tol – [in] Relative tolerance of the integrator.
- Returns:
0 on success, or the status of the first component that fails.
- Pre:
allocatehas succeeded.
-
virtual int evaluateResidual() override
Zero the system residual, then add the residual of every component.
- Returns:
0 on success, or the status of the first component that fails.
- Pre:
allocatehas succeeded.
-
virtual int evaluateJacobian() override
Set the Jacobian entries to dF/dy + alpha dF/dy’.
- Returns:
0.
- Pre:
tagDifferentiablehas stored the partials of the entries.
-
virtual CsrMatrixT *getCsrJacobian() const override
System Jacobian in CSR format, null before
allocate.
-
virtual bool monitoring() const override
True if the monitor has entries to write.
-
virtual void printMonitoredVariables() const override
Write the monitored variables to the monitor sinks.
-
virtual void startMonitor() override
Start the monitor output.
-
virtual void stopMonitor() override
Stop the monitor output.
-
ComponentT &bus(const std::string &number) const
Bus of case number
number.- Throws:
std::invalid_argument – if the system has no such bus.
-
ComponentT &device(const std::string &id) const
Device of case id
id.- Throws:
std::invalid_argument – if the system has no such device.