Automatic Differentiation
 
Loading...
Searching...
No Matches
stan::math::cvodes_integrator< Lmm, F, T_y0, T_t0, T_ts, T_Args > Class Template Reference

Detailed Description

template<int Lmm, typename F, typename T_y0, typename T_t0, typename T_ts, typename... T_Args>
class stan::math::cvodes_integrator< Lmm, F, T_y0, T_t0, T_ts, T_Args >

Integrator interface for CVODES' ODE solvers (Adams & BDF methods).

Template Parameters
LmmID of ODE solver (1: ADAMS, 2: BDF)
FType of ODE right hand side
T_y0Type of initial state
T_paramType of scalars for parameters
T_t0Type of scalar of initial time point
T_tsType of time-points where ODE solution is returned

Definition at line 35 of file cvodes_integrator.hpp.

#include <cvodes_integrator.hpp>

Public Member Functions

template<require_eigen_col_vector_t< T_y0 > * = nullptr>
 cvodes_integrator (const char *function_name, const F &f, const T_y0 &y0, const T_t0 &t0, const std::vector< T_ts > &ts, double relative_tolerance, double absolute_tolerance, long int max_num_steps, std::ostream *msgs, const T_Args &... args)
 Construct cvodes_integrator object.
 
 ~cvodes_integrator ()
 
std::vector< Eigen::Matrix< T_Return, Eigen::Dynamic, 1 > > operator() ()
 Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1, t2, t3, ... } using the stiff backward differentiation formula (BDF) solver in CVODES.
 

Private Types

using T_Return = return_type_t< T_y0, T_t0, T_ts, T_Args... >
 
using T_y0_t0 = return_type_t< T_y0, T_t0 >
 

Private Member Functions

void rhs (double t, const double y[], double dy_dt[]) const
 Calculates the ODE RHS, dy_dt, using the user-supplied functor at the given time t and state y.
 
void jacobian_states (double t, const double y[], SUNMatrix J) const
 Calculates the jacobian of the ODE RHS wrt to its states y at the given time-point t and state y.
 
void rhs_sens (double t, const double y[], N_Vector *yS, N_Vector *ySdot)
 Calculates the RHS of the sensitivity ODE system which corresponds to the coupled ode system from which the first N states are omitted, since the first N states are the ODE RHS which CVODES separates from the main ODE RHS.
 

Static Private Member Functions

static int cv_rhs (realtype t, N_Vector y, N_Vector ydot, void *user_data)
 Implements the function of type CVRhsFn which is the user-defined ODE RHS passed to CVODES.
 
static int cv_rhs_sens (int Ns, realtype t, N_Vector y, N_Vector ydot, N_Vector *yS, N_Vector *ySdot, void *user_data, N_Vector tmp1, N_Vector tmp2)
 Implements the function of type CVSensRhsFn which is the RHS of the sensitivity ODE system.
 
static int cv_jacobian_states (realtype t, N_Vector y, N_Vector fy, SUNMatrix J, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
 Implements the function of type CVDlsJacFn which is the user-defined callback for CVODES to calculate the jacobian of the ode_rhs wrt to the states y.
 

Private Attributes

const char * function_name_
 
sundials::Context sundials_context_
 
const F & f_
 
const Eigen::Matrix< T_y0_t0, Eigen::Dynamic, 1 > y0_
 
const T_t0 t0_
 
const std::vector< T_ts > & ts_
 
std::tuple< const T_Args &... > args_tuple_
 
std::tuple< plain_type_t< decltype(value_of(std::declval< const T_Args & >()))> value_of_args_tuple_
 
const size_t N_
 
std::ostream * msgs_
 
double relative_tolerance_
 
double absolute_tolerance_
 
long int max_num_steps_
 
const size_t num_y0_vars_
 
const size_t num_args_vars_
 
coupled_ode_system< F, T_y0_t0, T_Args... > coupled_ode_
 
std::vector< double > coupled_state_
 
N_Vector nv_state_
 
N_Vector * nv_state_sens_
 
SUNMatrix A_
 
SUNLinearSolver LS_
 

The documentation for this class was generated from the following file: