[SciPy-User] problem using optimize.root
Slavin, Jonathan
jslavin at cfa.harvard.edu
Mon Jun 8 12:16:18 EDT 2015
Hi,
I'm trying to solve a two-point boundary value problem using odeint in
conjunction with root. I've written a function (the objective function)
that takes as an argument the eigenvalue for the problem and returns the
difference between the endpoint value for one of the variables and the
desired value. So the function calls odeint with extra arguments that give
the initial conditions at the left boundary as well as the eigenvalue. I
can call this function perfectly well from the prompt and it behaves as
expected but when I run it within the call to scipy.optimize.root I get the
following error:
...
/export/slavin/python/anaconda/lib/python2.7/site-packages/scipy/integrate/odepack.pyc
in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol,
atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords,
printmessg)
146 output = _odepack.odeint(func, y0, t, args, Dfun, col_deriv,
ml, mu,
147 full_output, rtol, atol, tcrit, h0,
hmax, hmin,
--> 148 ixpr, mxstep, mxhnil, mxordn, mxords)
149 if output[-1] < 0:
150 print(_msgs[output[-1]])
TypeError: Cannot cast array data from dtype('O') to dtype('float64')
according to the rule 'safe'
>
/export/slavin/python/anaconda/lib/python2.7/site-packages/scipy/integrate/odepack.py(148)odeint()
147 full_output, rtol, atol, tcrit, h0,
hmax, hmin,
--> 148 ixpr, mxstep, mxhnil, mxordn, mxords)
149 if output[-1] < 0:
So when root calls the function, which in turn calls odeint, something that
was previously of float type somehow gets the dtype of object. I've used
pdb within ipython to try to find what is happening, but it seems that all
the inputs to odeint are of the correct dtype. Any help would be
appreciated.
Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
fax: (617) 496-7577 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150608/3f70bc05/attachment.html>
More information about the SciPy-User
mailing list