Template Class PowerElectronicsModel

Inheritance Relationships

Base Type

Class Documentation

template<class ScalarT, typename IdxT>
class PowerElectronicsModel : public GridKit::CircuitComponent<ScalarT, IdxT>

Public Functions

inline PowerElectronicsModel()

Default constructor for the system model.

Post:

System model parameters set as default

inline PowerElectronicsModel(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 ~PowerElectronicsModel()

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 avalible. 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 CircuitComponent::y_int_, CircuitComponent::yp_int_, and CircuitComponent::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 intial y and y’ of each component.

Returns:

int 0 if successful, positive if there’s a recoverable error, negative if unrecoverable

inline int distributeVectors()

Distribute y and y’ to each component based of node connection graph.

Post:

Each component has y and y’ set

Returns:

int 0 if successful, positive if there’s a recoverable error, negative if unrecoverable

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 evaluateExternalResidual() final

Todo:

implement this for nested systems

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.

Todo:

Remove this and use CsrMatrix for jac_