Class ode_it_solve (o2scl)¶
-
template<class
func_t
= ode_it_funct, classvec_t
= boost::numeric::ublas::vector<double>, classmat_t
= boost::numeric::ublas::matrix<double>, classmatrix_row_t
= boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<double>>, classsolver_vec_t
= boost::numeric::ublas::vector<double>, classsolver_mat_t
= boost::numeric::ublas::matrix<double>>
classo2scl
::
ode_it_solve
¶ ODE solver using a generic linear solver to solve finite-difference equations.
- Idea for Future:
Set up convergence error if it goes beyond max iterations
- Idea for Future:
Create a GSL-like set() and iterate() interface
- Idea for Future:
Implement as a child of ode_bv_solve ?
- Idea for Future:
Max and average tolerance?
- Idea for Future:
Allow the user to ensure that the solver doesn’t apply the full correction
Storage for functions
-
o2scl_linalg::linear_solver<solver_vec_t, solver_mat_t> *
solver
¶ Solver.
-
double
fd_left
(size_t ieq, size_t ivar, double x, matrix_row_t &y)¶ Compute the derivatives of the LHS boundary conditions.
This function computes \( \partial f_{left,\mathrm{ieq}} / \partial y_{\mathrm{ivar}} \)
-
double
fd_right
(size_t ieq, size_t ivar, double x, matrix_row_t &y)¶ Compute the derivatives of the RHS boundary conditions.
This function computes \( \partial f_{right,\mathrm{ieq}} / \partial y_{\mathrm{ivar}} \)
-
double
fd_derivs
(size_t ieq, size_t ivar, double x, matrix_row_t &y)¶ Compute the finite-differenced part of the differential equations.
This function computes \( \partial f_{\mathrm{ieq}} / \partial y_{\mathrm{ivar}} \)
Public Functions
-
ode_it_solve
()¶
-
~ode_it_solve
()¶
-
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 conditionsleft
andright
.Given a grid of size
n_grid
andn_eq
differential equations, solve them by relaxation. The grid is specified inx
, which is a vector of sizen_grid
. The differential equations are given inderivs
, the boundary conditions on the left hand side inleft
, and the boundary conditions on the right hand side inright
. The number of boundary conditions on the left hand side isnb_left
, and the number of boundary conditions on the right hand side should ben_eq-nb_left
. The initial guess for the solution, a matrix of size[n_grid][n_eq]
should be given iny
. Upon success,y
will contain an approximate solution of the differential equations. The matrixmat
is workspace of size[n_grid*n_eq][n_grid*n_eq]
, and the vectorsrhs
andy
are workspace of size[n_grid*n_eq]
.
-
template<class
dfunc_t
>
intsolve_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 conditionsleft
andright
.Given a grid of size
n_grid
andn_eq
differential equations, solve them by relaxation. The grid is specified inx
, which is a vector of sizen_grid
. The differential equations are given inderivs
, the boundary conditions on the left hand side inleft
, and the boundary conditions on the right hand side inright
. The number of boundary conditions on the left hand side isnb_left
, and the number of boundary conditions on the right hand side should ben_eq-nb_left
. The initial guess for the solution, a matrix of size[n_grid][n_eq]
should be given iny
. Upon success,y
will contain an approximate solution of the differential equations. The matrixmat
is workspace of size[n_grid*n_eq][n_grid*n_eq]
, and the vectorsrhs
andy
are workspace of size[n_grid*n_eq]
.
Public Members
-
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.