Class ode_iv_solve_grid (o2scl)

O2scl : Class List

template<class func_t = ode_funct_solve_grid, class mat_row_t = solve_grid_mat_row>
class ode_iv_solve_grid

Solve an initial-value ODE problems on a grid given an adaptive ODE stepper.

This class works as similar to ode_iv_solve::solve_store() except that the solution is stored on a grid of points in the independent variable specified by the user, at the cost of taking extra steps to ensure that function values, derivatives, and errors are computed at each grid point.

There is an example for the usage of this class in examples/ex_ode.cpp< documented in the Ordinary differential equations example.

Main solver function

int verbose

Set output level.

size_t ntrial

Maximum number of applications of the adaptive stepper (default 1000)

size_t nsteps

Number of adaptive steps employed.

template<class vec_t, class mat_t>
inline int solve_grid(double h, size_t n, size_t nsol, vec_t &xsol, mat_t &ysol, mat_t &err_sol, mat_t &dydx_sol, func_t &derivs)

Solve the initial-value problem from x0 to x1 over a grid storing derivatives and errors.

Initially, xsol should be an array of size nsol, and ysol should be a ubmatrix of size [nsol][n]. This function never takes a step larger than the grid size.

If verbose is greater than zero, The solution at each grid point will be written to std::cout. If verbose is greater than one, a character will be required after each point.

\verbatim embed:rst
.. todo::
Future: Consider making a version of grid which gives the same answers as solve_final_value(). After each proposed step, it would go back and fill in the grid points if the proposed step was past the next grid point.

The adaptive stepper

bool exit_on_fail

If true, stop the solution if the adaptive stepper fails (default true)

astep_gsl<mat_row_t, mat_row_t, mat_row_t, func_t> gsl_astp

The default adaptive stepper.

inline int set_astep(astep_base<mat_row_t, mat_row_t, mat_row_t, func_t> &as)

Set the adaptive stepper to use.

inline virtual const char *type()

Return the type, "ode_iv_solve".

Public Functions

inline ode_iv_solve_grid()
inline virtual ~ode_iv_solve_grid()

Public Members

bool err_nonconv

If true, call the error handler if the solution does not converge (default true)

Protected Functions

inline virtual int print_iter(double x, size_t nv, mat_row_t &y)

Print out iteration information.

Protected Attributes

astep_base<mat_row_t, mat_row_t, mat_row_t, func_t, double> *astp

The adaptive stepper.