ode_iv_solve Class Template Reference

Solve an initial-value ODE problems given an adaptive ODE stepper. More...

#include <ode_iv_solve.h>


Detailed Description

template<class param_t, class func_t = ode_funct<param_t>, class vec_t = ovector_base, class alloc_vec_t = ovector, class alloc_t = ovector_alloc, class mat_row_t = omatrix_row>
class ode_iv_solve< param_t, func_t, vec_t, alloc_vec_t, alloc_t, mat_row_t >

Solve an initial-value ODE problems given an adaptive ODE stepper.

Idea for future:
Add error information

Definition at line 44 of file ode_iv_solve.h.


Public Member Functions

int set_adapt_step (adapt_step< param_t, func_t, vec_t, alloc_vec_t, alloc_t > &as)
 Set the adaptive stepper to use.
template<class mat_t >
int solve_table (double x0, double x1, double h, size_t n, vec_t &ystart, size_t &nsol, vec_t &xsol, mat_t &ysol, param_t &pa, func_t &derivs)
 Solve the initial-value problem and output a table.
template<class mat_t >
int solve_grid (double x0, double x1, double h, size_t n, vec_t &ystart, size_t nsol, vec_t &xsol, mat_t &ysol, param_t &pa, func_t &derivs)
 Solve the initial-value problem from x0 to x1 over a grid.
template<class mat_t >
int solve_grid_derivs (double x0, double x1, double h, size_t n, vec_t &ystart, size_t nsol, vec_t &xsol, mat_t &ysol, mat_t &dydx_sol, param_t &pa, func_t &derivs)
 Solve the initial-value problem from x0 to x1 over a grid storing derivatives.
int solve_final_value (double x0, double x1, double h, size_t n, vec_t &ystart, vec_t &yend, param_t &pa, func_t &derivs)
 Solve the initial-value problem to get the final value.
int solve_final_value_derivs (double x0, double x1, double h, size_t n, vec_t &ystart, vec_t &yend, vec_t &dydx_start, vec_t &dydx_end, param_t &pa, func_t &derivs)
 Solve the initial-value problem to get the final value and derivative.
virtual const char * type ()
 Return the type, "ode_iv_solve".

Data Fields

int verbose
 Set output level.
size_t nsteps_out
 Number of output points if verbose is greater than zero (default 10).
int ntrial
 Maximum number of steps for solve_final_value() (default 1000).
bool exit_on_fail
 If true, stop the solution if the adaptive stepper fails.
gsl_astep< param_t, func_t,
vec_t, alloc_vec_t, alloc_t > 
gsl_astp
 The default adaptive stepper.

Protected Member Functions

virtual int print_iter (double x, size_t nv, vec_t &y)
 Print out iteration information.

Protected Attributes

alloc_vec_t dydx
 Derivative.
alloc_t ao
 Memory allocator.
adapt_step< param_t, func_t,
vec_t, alloc_vec_t, alloc_t > * 
astp
 The adaptive stepper.

Member Function Documentation

int solve_final_value ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
vec_t &  yend,
param_t &  pa,
func_t &  derivs 
) [inline]

Solve the initial-value problem to get the final value.

If verbose is greater than zero, The solution at less than or approximately equal to nsteps_out points will be written to std::cout. If verbose is greater than one, a character will be required after each selected point.

The solution fails if more than ntrial steps are required.

Definition at line 503 of file ode_iv_solve.h.

int solve_final_value_derivs ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
vec_t &  yend,
vec_t &  dydx_start,
vec_t &  dydx_end,
param_t &  pa,
func_t &  derivs 
) [inline]

Solve the initial-value problem to get the final value and derivative.

If verbose is greater than zero, The solution at less than or approximately equal to nsteps_out points will be written to std::cout. If verbose is greater than one, a character will be required after each selected point.

The solution fails if more than ntrial steps are required.

This function will also fail if x1>x0 and h<0 or if x1<x0 but h>0.

Todo:
Add error information
Todo:
At present, dydx_start is computed, but it should probably be assumed that the user will provide this.
Idea for future:
It looks like the x0<x1 code and the x1<x0 code is the same?

Definition at line 534 of file ode_iv_solve.h.

int solve_grid ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
size_t  nsol,
vec_t &  xsol,
mat_t &  ysol,
param_t &  pa,
func_t &  derivs 
) [inline]

Solve the initial-value problem from x0 to x1 over a grid.

Initially, xsol should be an array of size nsol, and ysol should be a matrix of size [nsol][n]. This function never takes a step larger than the grid size, but will take a step smaller than the grid size in order to ensure accuracy.

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

Definition at line 200 of file ode_iv_solve.h.

int solve_grid_derivs ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
size_t  nsol,
vec_t &  xsol,
mat_t &  ysol,
mat_t &  dydx_sol,
param_t &  pa,
func_t &  derivs 
) [inline]

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

Initially, xsol should be an array of size nsol, and ysol should be a omatrix 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.

Todo:
Add error information

Definition at line 294 of file ode_iv_solve.h.

int solve_table ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
size_t &  nsol,
vec_t &  xsol,
mat_t &  ysol,
param_t &  pa,
func_t &  derivs 
) [inline]

Solve the initial-value problem and output a table.

Initially, xsol should be a vector of size nsol, and ysol should be a two-dimensional array (e.g. omatrix) of size [nsol][n]. On exit, nsol will will be the size of the solution table, less than or equal to the original value of nsol.

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

If the given value of h is small enough, the solution may generate more points than the space initially allocated and the full solution will not be generated.

Idea for future:
Should we give the option not to call the error handler in case running out of space in the table?
Idea for future:
Consider modifying so that this can handle tables which are too small by removing half the rows and doubling the stepsize. Alternatively, make a function which accepts allocation objects and can re-allocate the vector and matrix space if required? (This latter option might be hard for arrays since they are really of fixed size.) A final alternative is to offer an ovector/omatrix interface which does the reallocation automatically if necessary.
Idea for future:
Some copying is done here and it would be nice if that could be avoided.

Definition at line 125 of file ode_iv_solve.h.


Field Documentation

If true, stop the solution if the adaptive stepper fails.

If this is false, then failures in the adaptive stepper are ignored.

Definition at line 684 of file ode_iv_solve.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page