[SciPy-user] (no subject)
Travis Oliphant
oliphant.travis at ieee.org
Thu Feb 23 14:37:45 CST 2006
Adrián López wrote:
>Hi people,
>
>I use SciPy since a few months ago. I use it mainly to integrate a
>system of ODEs. Until now this piece of code was running nicely with
>the previous version of SciPy:
>
>
>from Numeric import *
>
>
from numpy import *
>from scipy.integrate import odeint
>
>def func(x, t, *args):
>
>
You don't actually use the *args variable so don't define it. All of
your parameters are being grabbed from the module name-space.
def func(x, t0):
> xdot = [0.0, 5.0, 0.0, 15.0, 0.0, 0.0, 0.0]
>
> xdot[0] = + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0
>
>
I have no idea why you are doing this instead of xdot[0]=0.
> xdot[1] = - (x[1] * beta) + x[4] * beta
>
> xdot[2] = - (x[2] * beta) + x[5] * beta
>
> xdot[3] = + x[6] * beta - (x[3] * beta)
>
>
This line kept giving me errors. I'm not sure why....
> xdot[4] = + alpha0 + (alpha + (x[3])**( n) * alpha1) / ((K)**
>( n) + (x[3])**( n)) - (k1 * x[4])
>
> xdot[5] = + alpha0 + (alpha + (x[1])**( n) * alpha1) / ((K)**
>( n) + (x[1])**( n)) - (k1 * x[5])
>
> xdot[6] = - (k1 * x[6]) + alpha0 + (alpha + (x[2])**( n) *
>alpha1) / ((K)**( n) + (x[2])**( n))
>
> g.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n'%(t, xdot[0], xdot
>[1], xdot[2], xdot[3], xdot[4], xdot[5], xdot[6]))
>
> return xdot
>
>t = arange(0, 100.01, 0.01)
>
>alpha0 = 0.0
>alpha1 = 0.0
>K = 1.0
>beta = 5.0
>n = 2.1
>k1 = 1.0
>alpha = 250.0
>cell = 1.0
>
>parameters = [alpha0, alpha1, K, beta, n, k1, alpha, cell]
>
>x_0 = [0.0, 5.0, 0.0, 15.0, 0.0, 0.0, 0.0]
>
>g = open('repressilator.veloc.out', 'w')
>
>args = (parameters, g)
>
>x = odeint(func, x_0, t, args)
>
>
>
You don't actually use the arguments in the function call but instead
the use global variables inside the function, so you don't need the args
(or parameters) variables and can just write
x = odeint(func, x_0, t)
>[alopez at thymus tmp]$ python file.py
>Segmentation fault
>
>on a linux machine and
>
>Macintosh-3:~/work/tmp adrianlopez$ python test.py
>Bus error
>
>
Can you tell when the error is occurring. Put print statements in
file.py to see when the segfault is actually happening. If it's on
import of scipy (which I suspect), then it's a problem with your
installation (the wrong NumPy C-API is being used for some reason).
-Travis
More information about the SciPy-user
mailing list