Template Class SystemModel
Defined in File SystemModel.hpp
Inheritance Relationships
Base Type
public GridKit::PowerElectronics::Component< ScalarT, IdxT >(Template Class Component)
Class Documentation
-
template<class ScalarT, typename IdxT>
class SystemModel : public GridKit::PowerElectronics::Component<ScalarT, IdxT> Public Functions
-
inline SystemModel()
Default constructor for the system model.
- Post:
System model parameters set as default
-
inline SystemModel(bool use_jac = false)
Constructor for the system model.
- Parameters:
use_jac – [in] Boolean to choose if to use jacobian
- Post:
System model parameters set as input
-
inline virtual ~SystemModel()
Destructor for the system model.
- Pre:
System components are allocated
- Post:
System components are deallocated
-
inline virtual bool hasJacobian() final
Will check if each component has jacobian available. If one doesn’t have it, return false.
- Returns:
true if all components have jacobian
- Returns:
false otherwise
-
inline virtual int allocate() final
Allocate system vectors and construct the system CSR Jacobian.
- Post:
System model vectors allocated with the computed total number of unknowns
- Post:
CSR Jacobian sparsity pattern is computed
- Post:
COO->CSR mapping is computed
- Post:
Every component’s Component::y_int_, Component::yp_int_, and Component::f_int_ pointers are set to their appropriate offsets in the system vector, allowing them to directly access their internal variables, derivatives, and residuals.
- Returns:
int 0 if successful, positive if there’s a recoverable error, negative if unrecoverable
-
inline virtual int initialize() final
Set initial y and y’ of each component.
- Returns:
int 0 if successful, positive if there’s a recoverable error, negative if unrecoverable
-
inline virtual int tagDifferentiable() final
Tags all system variables as differentiable, based on what the components that own those variables tag them as.
Starts by asking all components to tag their differentiables. This implementation assumes all node variables are algebraic, and will not ask nodes to tag their differentiables. Sets all variables to algebraic (
false) to start, then loops over all component internal variables. Re-creates the same internal variable to system variables mapping as in allocate() - all internal variables from the same component are stored contiguously in a block, and blocks are stored contiguously in the same order as components_, with node variables at the end. Each internal variable’s tag in the system is set to its tag in the component.
-
inline virtual int setAbsoluteTolerance(RealT rel_tol) final
Compute the absolute tolerance for each variable in the model.
This represents a “noise” level close to zero for which pure relative error cannot be used.
- Parameters:
rel_tol – The relative tolerance which can be used to pick the absolute tolerance.
- Template Parameters:
ScalarT – Scalar data type
IdxT – Index data type
- Returns:
int 0 if successful, non-zero otherwise.
-
inline virtual int evaluateInternalResidual() final
Evaluate Residuals at each component then collect them.
- Returns:
int 0 if successful, positive if there’s a recoverable error, negative if unrecoverable
-
inline virtual int evaluateJacobian() final
Creates the system Jacobian representing \(\alpha dF/dy' + dF/dy\).
Updates the CSR Jacobian values using the per-component mappings computed during allocate().
- Returns:
int 0 if successful, positive if there’s a recoverable error, negative if unrecoverable
-
inline virtual int evaluateIntegrand() final
Evaluate integrands for the system quadratures.
-
inline virtual int initializeAdjoint() final
Initialize system adjoint.
Updates variables and optimization parameters, then initializes adjoints locally and copies them to the system adjoint vector.
-
inline virtual int evaluateAdjointResidual() final
Compute adjoint residual for the system model.
-
inline virtual int evaluateAdjointIntegrand() final
Evaluate adjoint integrand for the system model.
-
inline virtual void updateTime(RealT t, RealT a) final
Distribute time and time scaling for each component.
- Parameters:
t –
a –
-
inline virtual CsrMatrixT *getCsrJacobian() const override
Return a pointer to the CSR Jacobian.
- Pre:
allocate() must have been called.
-
inline SystemModel()