Go to the documentation of this file.
23 #ifndef O2SCL_ODE_BV_MSHOOT_H
24 #define O2SCL_ODE_BV_MSHOOT_H
30 #include <o2scl/ode_bv_solve.h>
32 #ifndef DOXYGEN_NO_O2NS
71 vec_t &x_bound, mat_t &y_bound,
72 vec_int_t &index, func_t &derivs) {
83 int lhs_unks=0, rhs_conts=0;
87 for (
size_t i=0;i<n;i++) {
88 if (index[i]<2) lhs_unks++;
89 if (index[i]%2==1) rhs_conts++;
93 if (lhs_unks!=rhs_conts) {
94 O2SCL_ERR2(
"Incorrect boundary conditions in ",
95 "ode_bv_mshoot::solve()",gsl_einval);
99 int n_solve=lhs_unks+n*(n_bound-2);
106 for (
size_t i=0;i<n;i++) {
112 for(
size_t k=1;k<n_bound-1;k++) {
113 for(
size_t i=0;i<n;i++) {
130 mm_funct_mfptr<ode_bv_mshoot<func_t,mat_t,vec_t,vec_int_t> >
136 O2SCL_ERR(
"Solver failed in ode_bv_mshoot::solve().",ret);
145 template<
class mat_row_t>
146 int solve_store(
double h,
size_t n,
size_t n_bound, vec_t &x_bound,
147 mat_t &y_bound, vec_int_t &index,
size_t &n_sol,
148 vec_t &x_sol, mat_t &y_sol, mat_t &dydx_sol,
149 mat_t &yerr_sol, func_t &derivs) {
152 O2SCL_ERR2(
"Not enough boundaries (must be at least two) in ",
153 "ode_bv_mshoot::solve_store().",gsl_einval);
156 O2SCL_ERR2(
"Not enough room to store boundaries in ",
157 "ode_bv_mshoot::solve_store().",gsl_einval);
164 ubvector_int inxs(n_bound);
165 for(
size_t k=0;k<n_bound;k++) {
166 inxs[k]=((size_t)(((
double)k)/((double)n_bound)*
167 (((double)(n_sol))-1.0+1.0e-12)));
168 std::cout << k <<
" " << inxs[k] <<
" " << n_sol << std::endl;
171 for(
size_t k=1;k<n_bound-1;k++) {
172 if (inxs[k]==inxs[k-1] || inxs[k]==inxs[k+1]) {
173 O2SCL_ERR2(
"Not enough room to store boundaries in ",
174 "ode_bv_mshoot::solve_store().",gsl_einval);
179 for(
size_t k=0;k<n_bound-1;k++) {
180 size_t n_sol_tmp=inxs[k+1];
181 mat_row_t ystart(y_bound,k);
183 std::cout <<
"Old boundaries: " << inxs << std::endl;
185 oisp->template solve_store<mat_t,mat_row_t>
186 (x_bound[k],x_bound[k+1],h,n,ystart,
187 n_sol_tmp,x_sol,y_sol,dydx_sol,yerr_sol,derivs,inxs[k]);
189 std::cout <<
"New boundaries: " << n_sol_tmp << std::endl;
193 if (((
int)n_sol_tmp)<inxs[k+1]) {
194 for(
size_t k2=k+1;k2<n_bound;k2++) {
195 inxs[k2]=((size_t)(((
double)k2-k-1)/((double)(n_bound-k-1))*
196 (((
double)(n_sol-n_sol_tmp)))))+n_sol_tmp-1;
200 std::cout <<
"New boundaries: " << inxs << std::endl;
203 n_sol=inxs[n_bound-1];
227 #ifndef DOXYGEN_INTERNAL
263 vec_t sy, sy2, syerr, sdydx, sdydx2;
282 for(
size_t i=0;i<this->
l_n;i++) {
283 if ((*this->l_index)[i]<2) {
289 for(
size_t i=0;i<this->
l_n;i++) {
306 for(
size_t i=0;i<this->
l_n;i++) {
313 oisp->solve_final_value(x0,
x1,this->l_h,this->l_n,sy,
314 sy2,*this->l_derivs);
318 for(
size_t i=0;i<this->
l_n;i++) {
319 ty[j_y]=sy2[i]-yb[k+1][i];
324 for(
size_t i=0;i<this->
l_n;i++) {
325 if ((*this->l_index)[i]%2==1) {
326 double yright=yb[k+1][i];
330 ty[j_y]=(sy2[i]-yright)/yright;
347 #ifndef DOXYGEN_NO_O2NS
Solve an initial-value ODE problems given an adaptive ODE stepper.
mat_t * l_ybound
Storage for the ending vector.
size_t l_n
The number of functions.
int set_iv(ode_iv_solve< func_t, vec_t > &ois)
Set initial value solver.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
int solve_final_value(double h, size_t n, size_t n_bound, vec_t &x_bound, mat_t &y_bound, vec_int_t &index, func_t &derivs)
Solve the boundary-value problem and store the solution.
ode_iv_solve< func_t, vec_t > def_ois
The default initial value solver.
vec_int_t * l_index
The index defining the boundary conditions.
One-dimensional solver [abstract base].
double l_h
Storage for the stepsize.
int solve_store(double h, size_t n, size_t n_bound, vec_t &x_bound, mat_t &y_bound, vec_int_t &index, size_t &n_sol, vec_t &x_sol, mat_t &y_sol, mat_t &dydx_sol, mat_t &yerr_sol, func_t &derivs)
Solve the boundary-value problem and store the solution.
gsl_mroot_hybrids< mm_funct<> > def_mroot
The default equation solver.
static const double x1[5]
size_t l_nbound
The number of boundaries.
func_t * l_derivs
The functions to integrate.
vec_t * l_xbound
Storage for the starting vector.
std::function< int(double, size_t, const boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &)> ode_funct
Ordinary differential equation function in src/ode/ode_funct.h.
int set_mroot(mroot< mm_funct<> > &root)
Set the equation solver.
virtual int msolve(size_t n, vec_t &x, func_t &func)=0
Solve func using x as an initial guess, returning x.
Multidimensional root-finding [abstract base].
int solve_fun(size_t nv, const vec_t &tx, vec_t &ty)
The shooting function to be solved by the multidimensional solver.
ode_iv_solve< func_t, vec_t > * oisp
The solver for the initial value problem.
std::function< int(size_t, const boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &) > mm_funct
Array of multi-dimensional functions typedef in src/base/mm_funct.h.
size_t l_lhs_unks
The number of unknowns on the LHS.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
Solve boundary-value ODE problems by multishooting with a generic nonlinear solver.
Base class for boundary-value ODE solvers.
size_t mem_size
Size of recent allocation.
mroot< mm_funct<> > * mrootp
The equation solver.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).