Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t > Class Template Reference

ODE solver using a generic linear solver to solve finite-difference equations. More...

#include <ode_it_solve.h>

Public Member Functions

int set_solver (o2scl_linalg::linear_solver< solver_vec_t, solver_mat_t > &ls)
 Set the linear solver.
 
int solve (size_t n_grid, size_t n_eq, size_t nb_left, vec_t &x, mat_t &y, func_t &derivs, func_t &left, func_t &right, solver_mat_t &mat, solver_vec_t &rhs, solver_vec_t &dy)
 Solve derivs with boundary conditions left and right. More...
 
template<class dfunc_t >
int solve_derivs (size_t n_grid, size_t n_eq, size_t nb_left, vec_t &x, mat_t &y, func_t &derivs, func_t &left, func_t &right, dfunc_t &d_derivs, dfunc_t &d_left, dfunc_t &d_right, solver_mat_t &mat, solver_vec_t &rhs, solver_vec_t &dy)
 Solve derivs with boundary conditions left and right. More...
 

Public Attributes

bool make_mats
 
int verbose
 Set level of output (default 0)
 
double eps_rel
 Stepsize for finite differencing (default $ 10^{-4} $)
 
double eps_min
 Minimum stepsize for finite differencing (default $ 10^{-15} $)
 
double tol_rel
 Tolerance (default $ 10^{-8} $)
 
size_t niter
 Maximum number of iterations (default 30)
 
double alpha
 Size of correction to apply (default 1.0)
 
o2scl_linalg::linear_solver_HH< solver_vec_t, solver_mat_t > def_solver
 Default linear solver.
 

Protected Member Functions

virtual double fd_left (size_t ieq, size_t ivar, double x, matrix_row_t &y)
 Compute the derivatives of the LHS boundary conditions. More...
 
virtual double fd_right (size_t ieq, size_t ivar, double x, matrix_row_t &y)
 Compute the derivatives of the RHS boundary conditions. More...
 
virtual double fd_derivs (size_t ieq, size_t ivar, double x, matrix_row_t &y)
 Compute the finite-differenced part of the differential equations. More...
 

Protected Attributes

o2scl_linalg::linear_solver< solver_vec_t, solver_mat_t > * solver
 Solver.
 
Storage for functions
func_t * fl
 
func_t * fr
 
func_t * fd
 

Detailed Description

template<class func_t = ode_it_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class matrix_row_t = boost::numeric::ublas::matrix_row <boost::numeric::ublas::matrix<double> >, class solver_vec_t = boost::numeric::ublas::vector<double>, class solver_mat_t = boost::numeric::ublas::matrix<double>>
class o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t >

Idea for Future:

Set up convergence error if it goes beyond max iterations

Create a GSL-like set() and iterate() interface

Implement as a child of ode_bv_solve ?

Max and average tolerance?

Allow the user to ensure that the solver doesn't apply the full correction

Definition at line 68 of file ode_it_solve.h.

Member Function Documentation

◆ fd_derivs()

template<class func_t = ode_it_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class matrix_row_t = boost::numeric::ublas::matrix_row <boost::numeric::ublas::matrix<double> >, class solver_vec_t = boost::numeric::ublas::vector<double>, class solver_mat_t = boost::numeric::ublas::matrix<double>>
virtual double o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t >::fd_derivs ( size_t  ieq,
size_t  ivar,
double  x,
matrix_row_t &  y 
)
inlineprotectedvirtual

This function computes $ \partial f_{\mathrm{ieq}} / \partial y_{\mathrm{ivar}} $

Definition at line 399 of file ode_it_solve.h.

◆ fd_left()

template<class func_t = ode_it_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class matrix_row_t = boost::numeric::ublas::matrix_row <boost::numeric::ublas::matrix<double> >, class solver_vec_t = boost::numeric::ublas::vector<double>, class solver_mat_t = boost::numeric::ublas::matrix<double>>
virtual double o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t >::fd_left ( size_t  ieq,
size_t  ivar,
double  x,
matrix_row_t &  y 
)
inlineprotectedvirtual

This function computes $ \partial f_{left,\mathrm{ieq}} / \partial y_{\mathrm{ivar}} $

Definition at line 352 of file ode_it_solve.h.

◆ fd_right()

template<class func_t = ode_it_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class matrix_row_t = boost::numeric::ublas::matrix_row <boost::numeric::ublas::matrix<double> >, class solver_vec_t = boost::numeric::ublas::vector<double>, class solver_mat_t = boost::numeric::ublas::matrix<double>>
virtual double o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t >::fd_right ( size_t  ieq,
size_t  ivar,
double  x,
matrix_row_t &  y 
)
inlineprotectedvirtual

This function computes $ \partial f_{right,\mathrm{ieq}} / \partial y_{\mathrm{ivar}} $

Definition at line 375 of file ode_it_solve.h.

◆ solve()

template<class func_t = ode_it_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class matrix_row_t = boost::numeric::ublas::matrix_row <boost::numeric::ublas::matrix<double> >, class solver_vec_t = boost::numeric::ublas::vector<double>, class solver_mat_t = boost::numeric::ublas::matrix<double>>
int o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t >::solve ( size_t  n_grid,
size_t  n_eq,
size_t  nb_left,
vec_t &  x,
mat_t &  y,
func_t &  derivs,
func_t &  left,
func_t &  right,
solver_mat_t &  mat,
solver_vec_t &  rhs,
solver_vec_t &  dy 
)
inline

Given a grid of size n_grid and n_eq differential equations, solve them by relaxation. The grid is specified in x, which is a vector of size n_grid. The differential equations are given in derivs, the boundary conditions on the left hand side in left, and the boundary conditions on the right hand side in right. The number of boundary conditions on the left hand side is nb_left, and the number of boundary conditions on the right hand side should be n_eq-nb_left. The initial guess for the solution, a matrix of size [n_grid][n_eq] should be given in y. Upon success, y will contain an approximate solution of the differential equations. The matrix mat is workspace of size [n_grid*n_eq][n_grid*n_eq], and the vectors rhs and y are workspace of size [n_grid*n_eq].

Function derivatives for iterative solving of ODEs

Definition at line 135 of file ode_it_solve.h.

◆ solve_derivs()

template<class func_t = ode_it_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class matrix_row_t = boost::numeric::ublas::matrix_row <boost::numeric::ublas::matrix<double> >, class solver_vec_t = boost::numeric::ublas::vector<double>, class solver_mat_t = boost::numeric::ublas::matrix<double>>
template<class dfunc_t >
int o2scl::ode_it_solve< func_t, vec_t, mat_t, matrix_row_t, solver_vec_t, solver_mat_t >::solve_derivs ( size_t  n_grid,
size_t  n_eq,
size_t  nb_left,
vec_t &  x,
mat_t &  y,
func_t &  derivs,
func_t &  left,
func_t &  right,
dfunc_t &  d_derivs,
dfunc_t &  d_left,
dfunc_t &  d_right,
solver_mat_t &  mat,
solver_vec_t &  rhs,
solver_vec_t &  dy 
)
inline

Given a grid of size n_grid and n_eq differential equations, solve them by relaxation. The grid is specified in x, which is a vector of size n_grid. The differential equations are given in derivs, the boundary conditions on the left hand side in left, and the boundary conditions on the right hand side in right. The number of boundary conditions on the left hand side is nb_left, and the number of boundary conditions on the right hand side should be n_eq-nb_left. The initial guess for the solution, a matrix of size [n_grid][n_eq] should be given in y. Upon success, y will contain an approximate solution of the differential equations. The matrix mat is workspace of size [n_grid*n_eq][n_grid*n_eq], and the vectors rhs and y are workspace of size [n_grid*n_eq].

Definition at line 184 of file ode_it_solve.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).