Template Class Rosenbrock

Nested Relationships

Nested Types

Class Documentation

template<class ScalarT, typename IdxT>
class Rosenbrock

A Rosenbrock integrator designed to simulate a GridKit::Model::Evaluator model. Rosenbrock integrators are best for quick medium-accuracy simulation and boast a large amount of customization to simulating a given model.

For the list of available Rosenbrock methods, see Rosenbrock::Tableau.

Public Members

std::unique_ptr<State> asum_

Sum of A-weighted states used for function evaluation in a stage.

std::unique_ptr<State> csum_

Sum of C-weighted states used in linearization in a stage.

std::unique_ptr<State> RHS_

Right-hand side of linear solve used in a stage.

std::unique_ptr<State> RHS_first_stage_

Right-hand side of linear solve used in the first stage. Stored separately from RHS_ since it can be re-used by future steps if the current step is rejected.

See also

skip_f_

std::unique_ptr<State> dFdt_

Time Jacobian for non-autonomous models. Currently unused, since models are assumed to be autonomous.

std::unique_ptr<State> mass_

Vector representation of a diagonal mass matrix.

std::unique_ptr<State> err_est_

Estimated error produced by a step in a method with an empbedded error estimator.

See also

Tableau::e

bool jacobian_analyzed_ = false

Whether or not the Jacobian has been factorized. Initial factorization is required, but pivots can be re-used for a refactorization later. Re-factorization can introduce errors when the Jacobian differs significantly, so this flag should be reset when a significant event can happen, such as re-initializing the simulation.

See also

initializeSimulation()

std::unique_ptr<std::unique_ptr<State>[]> stages_

Integration stages - each a low-order approximation of the state at the abscissae given by the tableau.

struct Parameters

Parameters of the integrator.

Public Members

RealT starting_step_ = 1e-5

What step size the first step should take.

Todo:

Consider adding a starting step size selector to select this automatically.

size_t max_steps_ = 2000

The maximum number of steps the integrator should take. If the integrator has not reached the final time before taking this many steps, then integration is stopped. For more details, see integrate().

bool skip_lu_ = false

Whether or not the integrator should attempt to skip Jacobian decompositions.

Note

This feature is only available if the underlying method is a Rosenbrock-W method and can speed up the time taken to compute each step. However, the overall number of steps taken will increase.

struct Stats

Keeps track of running statistics of the integrator since the last initializeSimulation() call.

Public Members

std::vector<StepInfo> rejections_

Information of each step which has been rejected.

std::vector<StepInfo> skip_lu_steps_

Information of each step which the integrator decided to skip re-factoring the Jacobian.

size_t num_steps_ = 0

How many steps the integrator has taken.

size_t f_evals_ = 0

Number of model residual function evaluations.

size_t f_skipped_ = 0

Number of model residual function evaluations which have been skipped by the integrator.

size_t jac_evals_ = 0

Number of model Jacobian evaluations.

size_t decomp_solves_ = 0

Number of linear solves against the model Jacobian.

RealT min_step_ = INFINITY

Minimum step size.

RealT max_step_ = 0

Maximum step size.

struct StepInfo

Keeps track of a variety of notable properties of a single step.

Public Members

RealT sim_time_

The simulation time at the beginning of the step.

RealT step_size_

The size of the step.

RealT next_step_size_

The size of the next step, as governed by the current StepController in use.

RealT err_est_

The estimated error made by the step, as calculated by the current ErrorNorm in use.

size_t step_no_

The step number, starting at 1.

bool skip_lu_

Whether or not the integrator decided to skip computing the decomposition of the Jacobian on this step.

bool skip_f_

Whether or not the integrator decided to skip evaluating the residual on the first stage on this step.

bool accepted_

Whether or not this step was accepted by the StepController in use.

struct Tableau

A list of the coefficients needed to complete Rosenbrock integration in an accurate way. Each tableau can be considered a different method or scheme, and will have different properties, advantages, and disadvantages.

Public Functions

inline constexpr bool hasEmbedded() const

Whether or not this tableau contains an embedded error estimator method.

inline constexpr bool hasDenseOutput() const

Whether or not this tableau contains coefficients which can be used to construct dense output.

inline constexpr RealT getA(size_t row, size_t col) const

Helper function for accessing elements of A

Public Members

size_t num_stages_

The number of stages used by the method. Each stage requires one model residual evaluation.

RealT gamma_

The coefficient along the diagonal of the Gamma matrix.

std::unique_ptr<RealT[]> alpha_sum_

A vector of sums of rows of the alpha matrix. These are the classic Runge-Kutta ‘c’ coefficients, or abscissae. The size of this vector should be equal to num_stages.

std::unique_ptr<RealT[]> gamma_sum_

A vector of sums of rows of the Gamma matrix. The size of this vector should be equal to num_stages.

std::unique_ptr<RealT[]> m_

A vector of weights for constructing the final solution from the stages. The size of this vector should be equal to num_stages.

std::unique_ptr<RealT[]> e_

OPTIONAL vector of coefficients for the embedded error method. If it exists, the size of this vector should be equal to num_stages.

std::unique_ptr<RealT[]> A_

The transformed A coefficient matrix. Strictly lower triangular and stored in dense row-major form. Upper triangular terms are not accessed. Should be num_stages by num_stages large.

std::unique_ptr<RealT[]> C_

The transformed C coefficient matrix. Strictly lower triangular and stored in dense row-major form. Upper triangular terms are not accessed. Should be num_stages by num_stages large.

std::unique_ptr<RealT[]> H_

OPTIONAL matrix of dense coefficients. Defines how the stages should be transformed into interpolant nodes for computing dense output. The interpolating polynomial has an order one less than the order of the method, and two interpolant nodes are already pre-computed, so if this matrix exists it should be order - 2 by num_stages large.

uint8_t order_

What ODE order these coefficients satisfy. If is_dae is true, then the coefficients must additionally satisfy DAE conditions up to this order. If is_w is true, then the coefficients must additionally satisfy ROW conditions up to this order. If is_krylov is true, then the coefficients must additionally satisfy ROK condition up to this order.

bool is_krylov_

Whether or not these coefficients are appropriate to use in a Rosenbrock-Krylov (ROK) solver.

bool is_w_

Whether or not these coefficients satisfy Rosenbrock-W (ROW) order conditions up to order. The integrator may take advantage of this fact by e.g. using time-delay Jacobians to speed up computation.

bool is_dae_

Whether or not these coefficients satisfy DAE order conditions up to order. If this is not true, these coefficients should not be used to solve models with algebraic conditions (indicated by a Model::Evaluator::tag_ value of 0).