Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Numerical Integration Causes Errors

I have a 4 ODE model of a chemical oscillator. desolve_system_rk4 and desolve_odeint give different, equally strange errors. My source and the errors are pasted below. Any ideas what could be causing this?

------Cell 1-------

var('x y z u t')

m=.4

a=.3

h=.16

k1=(2e6)*h

k2=2(h^2)a

k3=3000

k4=42ha

k7=29*m

if m>=.1: k9=.1*m

else: k9=.07*m

k10=0.05*m

kr=2e8

kred=5e6

d=1e-5

c0=3e-3

cmin=sqrt((2kr(k9+k10)*c0)/(kred^2))

rhs=[]

rhs.append(-k1xy+k2y-2k3(x^2)+k4x*((c0-z)/(c0-z+cmin)))

rhs.append(-3k1xy-2k2y-k3(x^2)+k7u+k9*z)

rhs.append(2k4x((c0-z)/(c0-z+cmin))-k9z-k10*z)

rhs.append(2k1xy+k2y+k3(x^2)-k7u)

-------Cell 2-------

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

print P

---------Cell 2 Error-----

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

[[ 0.00000000e+000 1.00000000e-001 5.00000000e-001 0.00000000e+000

0.00000000e+000]

[ 1.91816300e-273 1.00000000e-001 5.00000000e-001 -3.33812103e-313

0.00000000e+000]

[ 4.77937088e-268 1.00000000e-001 5.00000000e-001 5.69304317e-311

0.00000000e+000]

[ 2.00438470e-267 1.00000000e-001 5.00000000e-001 2.35773229e-310

0.00000000e+000]

[ 2.36867914e-267 1.00000000e-001 5.00000000e-001 2.78367228e-310

0.00000000e+000]

[ 2.38572583e-267 1.00000000e-001 5.00000000e-001 2.80306160e-310

0.00000000e+000]

[ 2.39510579e-267 1.00000000e-001 5.00000000e-001 2.81360368e-310

0.00000000e+000]

[ 2.39681901e-267 1.00000000e-001 5.00000000e-001 2.81529855e-310

0.00000000e+000]

[ 2.39086550e-267 1.00000000e-001 5.00000000e-001 2.80814619e-310

0.00000000e+000]

[ 2.37724526e-267 1.00000000e-001 5.00000000e-001 2.79214662e-310

0.00000000e+000]

[ 2.35595828e-267 1.00000000e-001 5.00000000e-001 2.76729981e-310

0.00000000e+000]

[ 2.32700457e-267 1.00000000e-001 5.00000000e-001 2.73360579e-310

0.00000000e+000]

[ 2.29038413e-267 1.00000000e-001 5.00000000e-001 2.69106454e-310

0.00000000e+000]

[ 2.24609696e-267 1.00000000e-001 5.00000000e-001 2.63967607e-310

0.00000000e+000]

[ 2.19414306e-267 1.00000000e-001 5.00000000e-001 2.57944037e-310

0.00000000e+000]

[ 2.13452242e-267 1.00000000e-001 5.00000000e-001 2.51035746e-310

0.00000000e+000]

[ 2.06896087e-267 1.00000000e-001 5.00000000e-001 2.43444676e-310

0.00000000e+000]

[ 2.12162851e-267 1.00000000e-001 5.00000000e-001 2.49700403e-310

0.00000000e+000]

[ 2.36901260e-267 1.00000000e-001 5.00000000e-001 2.78752969e-310

0.00000000e+000]

[ 2.81111315e-267 1.00000000e-001 5.00000000e-001 3.30602374e-310

0.00000000e+000]

[ 3.44793016e-267 1.00000000e-001 5.00000000e-001 4.05248617e-310

0.00000000e+000]

[ 4.27946362e-267 1.00000000e-001 5.00000000e-001 5.02691698e-310

0.00000000e+000]

[ 5.30571354e-267 1.00000000e-001 5.00000000e-001 6.22931619e-310

0.00000000e+000]

[ 6.52667991e-267 1.00000000e-001 5.00000000e-001 7.65968378e-310

0.00000000e+000]

[ 7.94236274e-267 1.00000000e-001 5.00000000e-001 9.31801975e-310

0.00000000e+000]

[ 9.55276203e-267 1.00000000e-001 5.00000000e-001 1.12043241e-309

0.00000000e+000]

[ 1.13578778e-266 1.00000000e-001 5.00000000e-001 1.33185969e-309

0.00000000e+000]

[ 1.33577100e-266 1.00000000e-001 5.00000000e-001 1.56608380e-309

0.00000000e+000]]

------Cell 3------

P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28)

print P

------Cell 3 Error-----

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "_sage_input_31.py", line 10, in <module>

exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" +

_support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL

Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\n");

execfile(os.path.abspath("___code___.py"))

File "", line 1, in <module>

File "/tmp/tmpBY363j/___code___.py", line 3, in <module>

P=desolve_system_rk4(rhs,[x,y,z,u],[_sage_const_0 ,_sage_const_p1

,_sage_const_p5 ,_sage_const_0 ,_sage_const_0 ],t,_sage_const_p28 )

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1342, in desolve_system_rk4

sol_2=maxima(cmd).sage()

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/interface.py", line 868, in sage

return self._sage_()

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima_abstract.py", line 1224, in _sage_

maxima=self.parent())

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/calculus.py", line 1634, in symbolic_expression_from_maxima_string

s = maxima._eval_line('_tmp_;')

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 787, in _eval_line

self._error_check(line, out)

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 924, in _error_check

self._error_msg(cmd, out)

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 941, in _error_msg

raise TypeError, "Error executing code in Maxima\nCODE:\n\t%s\nMaxima ERROR:\n

\t%s"%(cmd, out.replace('-- an error. To debug this try debugmode(true);',''))

TypeError: Error executing code in Maxima

CODE:

_tmp_;

Maxima ERROR:

(%o52)

Maxima encountered a Lisp error:

#

Automatically continuing.

To enable the Lisp debugger set debugger-hook to nil.

click to hide/show revision 2
formatted code snippets

Numerical Integration Causes Errors

I have a 4 ODE model of a chemical oscillator. desolve_system_rk4 and desolve_odeint give different, equally strange errors. My source and the errors are pasted below. Any ideas what could be causing this?

------Cell 1-------

var('x y z u t')

m=.4

a=.3

h=.16

k1=(2e6)*h

k2=2(h^2)a

k3=3000

k4=42ha

k7=29*m

t') m=.4 a=.3 h=.16 k1=(2e6)*h k2=2*(h^2)*a k3=3000 k4=42*h*a k7=29*m if m>=.1: k9=.1*m

k9=.1*m else: k9=.07*m

k10=0.05*m

kr=2e8

kred=5e6

d=1e-5

c0=3e-3

cmin=sqrt((2kr(k9+k10)*c0)/(kred^2))

rhs=[]

rhs.append(-k1xy+k2y-2k3(x^2)+k4x*((c0-z)/(c0-z+cmin)))

rhs.append(-3k1xy-2k2y-k3(x^2)+k7u+k9*z)

rhs.append(2k4x((c0-z)/(c0-z+cmin))-k9z-k10*z)

rhs.append(2k1xy+k2y+k3(x^2)-k7u)

k9=.07*m k10=0.05*m kr=2e8 kred=5e6 d=1e-5 c0=3e-3 cmin=sqrt((2*kr*(k9+k10)*c0)/(kred^2)) rhs=[] rhs.append(-k1*x*y+k2*y-2*k3*(x^2)+k4*x*((c0-z)/(c0-z+cmin))) rhs.append(-3*k1*x*y-2*k2*y*-k3*(x^2)+k7*u+k9*z) rhs.append(2*k4*x*((c0-z)/(c0-z+cmin))-k9*z-k10*z) rhs.append(2*k1*x*y+k2*y+k3*(x^2)-k7*u)

-------Cell 2-------

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

print P

P

---------Cell 2 Error-----

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289)

ValueError

/wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func

func

    return [dec(*v) for dec in desc]

File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

(sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func

func [[ 0.00000000e+000 1.00000000e-001 5.00000000e-001 0.00000000e+000

0.00000000e+000]

0.00000000e+000 0.00000000e+000] [ 1.91816300e-273 1.00000000e-001 5.00000000e-001 -3.33812103e-313

0.00000000e+000]

-3.33812103e-313 0.00000000e+000] [ 4.77937088e-268 1.00000000e-001 5.00000000e-001 5.69304317e-311

0.00000000e+000]

5.69304317e-311 0.00000000e+000] [ 2.00438470e-267 1.00000000e-001 5.00000000e-001 2.35773229e-310

0.00000000e+000]

2.35773229e-310 0.00000000e+000] [ 2.36867914e-267 1.00000000e-001 5.00000000e-001 2.78367228e-310

0.00000000e+000]

2.78367228e-310 0.00000000e+000] [ 2.38572583e-267 1.00000000e-001 5.00000000e-001 2.80306160e-310

0.00000000e+000]

2.80306160e-310 0.00000000e+000] [ 2.39510579e-267 1.00000000e-001 5.00000000e-001 2.81360368e-310

0.00000000e+000]

2.81360368e-310 0.00000000e+000] [ 2.39681901e-267 1.00000000e-001 5.00000000e-001 2.81529855e-310

0.00000000e+000]

2.81529855e-310 0.00000000e+000] [ 2.39086550e-267 1.00000000e-001 5.00000000e-001 2.80814619e-310

0.00000000e+000]

2.80814619e-310 0.00000000e+000] [ 2.37724526e-267 1.00000000e-001 5.00000000e-001 2.79214662e-310

0.00000000e+000]

2.79214662e-310 0.00000000e+000] [ 2.35595828e-267 1.00000000e-001 5.00000000e-001 2.76729981e-310

0.00000000e+000]

2.76729981e-310 0.00000000e+000] [ 2.32700457e-267 1.00000000e-001 5.00000000e-001 2.73360579e-310

0.00000000e+000]

2.73360579e-310 0.00000000e+000] [ 2.29038413e-267 1.00000000e-001 5.00000000e-001 2.69106454e-310

0.00000000e+000]

2.69106454e-310 0.00000000e+000] [ 2.24609696e-267 1.00000000e-001 5.00000000e-001 2.63967607e-310

0.00000000e+000]

2.63967607e-310 0.00000000e+000] [ 2.19414306e-267 1.00000000e-001 5.00000000e-001 2.57944037e-310

0.00000000e+000]

2.57944037e-310 0.00000000e+000] [ 2.13452242e-267 1.00000000e-001 5.00000000e-001 2.51035746e-310

0.00000000e+000]

2.51035746e-310 0.00000000e+000] [ 2.06896087e-267 1.00000000e-001 5.00000000e-001 2.43444676e-310

0.00000000e+000]

2.43444676e-310 0.00000000e+000] [ 2.12162851e-267 1.00000000e-001 5.00000000e-001 2.49700403e-310

0.00000000e+000]

2.49700403e-310 0.00000000e+000] [ 2.36901260e-267 1.00000000e-001 5.00000000e-001 2.78752969e-310

0.00000000e+000]

2.78752969e-310 0.00000000e+000] [ 2.81111315e-267 1.00000000e-001 5.00000000e-001 3.30602374e-310

0.00000000e+000]

3.30602374e-310 0.00000000e+000] [ 3.44793016e-267 1.00000000e-001 5.00000000e-001 4.05248617e-310

0.00000000e+000]

4.05248617e-310 0.00000000e+000] [ 4.27946362e-267 1.00000000e-001 5.00000000e-001 5.02691698e-310

0.00000000e+000]

5.02691698e-310 0.00000000e+000] [ 5.30571354e-267 1.00000000e-001 5.00000000e-001 6.22931619e-310

0.00000000e+000]

6.22931619e-310 0.00000000e+000] [ 6.52667991e-267 1.00000000e-001 5.00000000e-001 7.65968378e-310

0.00000000e+000]

7.65968378e-310 0.00000000e+000] [ 7.94236274e-267 1.00000000e-001 5.00000000e-001 9.31801975e-310

0.00000000e+000]

9.31801975e-310 0.00000000e+000] [ 9.55276203e-267 1.00000000e-001 5.00000000e-001 1.12043241e-309

0.00000000e+000]

1.12043241e-309 0.00000000e+000] [ 1.13578778e-266 1.00000000e-001 5.00000000e-001 1.33185969e-309

0.00000000e+000]

1.33185969e-309 0.00000000e+000] [ 1.33577100e-266 1.00000000e-001 5.00000000e-001 1.56608380e-309

1.56608380e-309

    0.00000000e+000]]

------Cell 3------

P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28)

P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28)

print P

P

------Cell 3 Error-----

Traceback (most recent call last):

last): File "<stdin>", line 1, in <module>

<module> File "_sage_input_31.py", line 10, in <module>

<module>

    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" +

_support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL

Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\n");

execfile(os.path.abspath("___code___.py"))

+ _support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

<module> File "/tmp/tmpBY363j/___code___.py", line 3, in <module>

<module>

    P=desolve_system_rk4(rhs,[x,y,z,u],[_sage_const_0 ,_sage_const_p1

,_sage_const_p1 ,_sage_const_p5 ,_sage_const_0 ,_sage_const_0 ],t,_sage_const_p28 )

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

) File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1342, in desolve_system_rk4

desolve_system_rk4

    sol_2=maxima(cmd).sage()

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /interface.py", line 868, in sage

sage

    return self._sage_()

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima_abstract.py", line 1224, in _sage_

_sage_

    maxima=self.parent())

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /calculus.py", line 1634, in symbolic_expression_from_maxima_string

symbolic_expression_from_maxima_string


    s = maxima._eval_line('_tmp_;')

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima.py", line 787, in _eval_line

_eval_line


    self._error_check(line, out)

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima.py", line 924, in _error_check

_error_check


    self._error_msg(cmd, out)

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima.py", line 941, in _error_msg

_error_msg



    raise TypeError, "Error executing code in Maxima\nCODE:\n\t%s\nMaxima ERROR:\n

\t%s"%(cmd, out.replace('-- an error. To debug this try debugmode(true);',''))

debugmode(true);','')) TypeError: Error executing code in Maxima

CODE:

Maxima


CODE:

    _tmp_;

Maxima ERROR:

ERROR: (%o52)

Maxima encountered a Lisp error:

#

error: #<a ARITHMETIC-ERROR> Automatically continuing.

continuing. To enable the Lisp debugger set debugger-hook *debugger-hook* to nil.

nil.

Numerical Integration Causes Errors

I have a 4 ODE model of a chemical oscillator. desolve_system_rk4 and desolve_odeint give different, equally strange errors. My source and the errors are pasted below. Any ideas what could be causing this?

------Cell 1-------

var('x y z u t')

m=.4

a=.3

h=.16

k1=(2e6)*h


k2=2*(h^2)*a

k3=3000


k4=42*h*a

k7=29*m



m = .4; a = .3; h = .16
k1 = (2e6)*h
k2 = 2*(h^2)*a
k3 = 3000
k4 = 42*h*a
k7 = 29*m
k9 = .1*m if m>=.1: k9=.1*m

else:    k9=.07*m


k10=0.05*m


kr=2e8

kred=5e6


d=1e-5

c0=3e-3


cmin=sqrt((2*kr*(k9+k10)*c0)/(kred^2))




rhs=[]

m>=.1 else .07*m
k10 = 0.05*m
kr = 2e8
kred = 5e6
d = 1e-5
c0 = 3e-3
cmin = sqrt((2*kr*(k9+k10)*c0)/(kred^2))
rhs = []
rhs.append(-k1*x*y+k2*y-2*k3*(x^2)+k4*x*((c0-z)/(c0-z+cmin)))
 rhs.append(-3*k1*x*y-2*k2*y*-k3*(x^2)+k7*u+k9*z)
 rhs.append(2*k4*x*((c0-z)/(c0-z+cmin))-k9*z-k10*z)
 rhs.append(2*k1*x*y+k2*y+k3*(x^2)-k7*u)

-------Cell 2-------

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

print P
desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

---------Cell 2 Error-----

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]

  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters
/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):


  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]


  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)


ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]

  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]

  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]

  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]

  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]

  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

    return [dec(*v) for dec in desc]


  File "wrapper_rdf.pyx", line 73, in 

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)


ValueError



odepack.error: Error occured while calling the Python function named func


[[  0.00000000e+000   1.00000000e-001   5.00000000e-001   0.00000000e+000

    0.00000000e+000]

 [  1.91816300e-273   1.00000000e-001   5.00000000e-001  -3.33812103e-313

    0.00000000e+000]

 [  4.77937088e-268   1.00000000e-001   5.00000000e-001   5.69304317e-311


    0.00000000e+000]

 [  2.00438470e-267   1.00000000e-001   5.00000000e-001   2.35773229e-310

    0.00000000e+000]

 [  2.36867914e-267   1.00000000e-001   5.00000000e-001   2.78367228e-310

    0.00000000e+000]


 [  2.38572583e-267   1.00000000e-001   5.00000000e-001   2.80306160e-310


    0.00000000e+000]

 [  2.39510579e-267   1.00000000e-001   5.00000000e-001   2.81360368e-310

    0.00000000e+000]

 [  2.39681901e-267   1.00000000e-001   5.00000000e-001   2.81529855e-310

    0.00000000e+000]

 [  2.39086550e-267   1.00000000e-001   5.00000000e-001   2.80814619e-310

    0.00000000e+000]

 [  2.37724526e-267   1.00000000e-001   5.00000000e-001   2.79214662e-310

    0.00000000e+000]

 [  2.35595828e-267   1.00000000e-001   5.00000000e-001   2.76729981e-310

    0.00000000e+000]

 [  2.32700457e-267   1.00000000e-001   5.00000000e-001   2.73360579e-310

    0.00000000e+000]

 [  2.29038413e-267   1.00000000e-001   5.00000000e-001   2.69106454e-310

    0.00000000e+000]

 [  2.24609696e-267   1.00000000e-001   5.00000000e-001   2.63967607e-310

    0.00000000e+000]

 [  2.19414306e-267   1.00000000e-001   5.00000000e-001   2.57944037e-310

    0.00000000e+000]

 [  2.13452242e-267   1.00000000e-001   5.00000000e-001   2.51035746e-310

    0.00000000e+000]

 [  2.06896087e-267   1.00000000e-001   5.00000000e-001   2.43444676e-310

    0.00000000e+000]

 [  2.12162851e-267   1.00000000e-001   5.00000000e-001   2.49700403e-310

    0.00000000e+000]

 [  2.36901260e-267   1.00000000e-001   5.00000000e-001   2.78752969e-310

    0.00000000e+000]

 [  2.81111315e-267   1.00000000e-001   5.00000000e-001   3.30602374e-310

    0.00000000e+000]

 [  3.44793016e-267   1.00000000e-001   5.00000000e-001   4.05248617e-310

    0.00000000e+000]

 [  4.27946362e-267   1.00000000e-001   5.00000000e-001   5.02691698e-310

    0.00000000e+000]

 [  5.30571354e-267   1.00000000e-001   5.00000000e-001   6.22931619e-310

    0.00000000e+000]

 [  6.52667991e-267   1.00000000e-001   5.00000000e-001   7.65968378e-310

    0.00000000e+000]

 [  7.94236274e-267   1.00000000e-001   5.00000000e-001   9.31801975e-310

    0.00000000e+000]

 [  9.55276203e-267   1.00000000e-001   5.00000000e-001   1.12043241e-309

    0.00000000e+000]

 [  1.13578778e-266   1.00000000e-001   5.00000000e-001   1.33185969e-309

    0.00000000e+000]

 [  1.33577100e-266   1.00000000e-001   5.00000000e-001   1.56608380e-309

    0.00000000e+000]]

------Cell 3------

P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28)

print P

------Cell 3 Error-----

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "_sage_input_31.py", line 10, in <module>

    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + 

_support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL


Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\\n"); 


execfile(os.path.abspath("___code___.py"))


  File "", line 1, in <module>

  File "/tmp/tmpBY363j/___code___.py", line 3, in <module>

    P=desolve_system_rk4(rhs,[x,y,z,u],[_sage_const_0 ,_sage_const_p1 

,_sage_const_p5 ,_sage_const_0 ,_sage_const_0 ],t,_sage_const_p28 )


  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1342, in desolve_system_rk4

    sol_2=maxima(cmd).sage()

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/interface.py", line 868, in sage

    return self._sage_()

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima_abstract.py", line 1224, in _sage_

    maxima=self.parent())

  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/calculus.py", line 1634, in symbolic_expression_from_maxima_string


    s = maxima._eval_line('_tmp_;')


  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 787, in _eval_line


    self._error_check(line, out)


  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 924, in _error_check


    self._error_msg(cmd, out)


  File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces


/maxima.py", line 941, in _error_msg



    raise TypeError, "Error executing code in Maxima\nCODE:\n\t%s\nMaxima ERROR:\n


\t%s"%(cmd, out.replace('-- an error.  To debug this try debugmode(true);',''))


TypeError: Error executing code in Maxima


CODE:

    _tmp_;


Maxima ERROR:



(%o52) 


Maxima encountered a Lisp error:


 #<a ARITHMETIC-ERROR>

Automatically continuing.


To enable the Lisp debugger set *debugger-hook* to nil.