[SciPy-user] Problems with scipy.integrate.ode
David Linke
davidlinke at tiscali.de
Sat Apr 19 07:37:05 EDT 2003
Hi!
I am having problems with the set_f_params() method in ode.py.
An example showing the use of set_f_params() to supply additional
arguments (two or more) to f would be very heplful.
I tried a while to get it going but without success. I observed strange
behaviour when using a modified function test1 in ode.py to receive
additional arguments:
def test1():
#def f(t,y):
def f(t,y,b):
print type(b), b
a = Numeric.sin(6*t)
return y*y-a+y
ode_runner = ode(f)
ode_runner.set_integrator('vode')
ode_runner.set_initial_value([0.1,0.11,.1]*10)
par_b = 0.1,
ode_runner.set_f_params(par_b)
while ode_runner.successful() and ode_runner.t < 20:
y1 = ode_runner.integrate(ode_runner.t+2)
print ode_runner.t,y1[:3]
Is this the right way to use set_f_params? When I run this example the
arguments are passed to f only in the first two calls, as shown here:
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
>>> Integrators available: vode
Found integrator vode
<type 'tuple'> (0.10000000000000001,) ! 1st call
...
2.0 [-0.1446766 -0.10226142 -0.1446766 ]
<type 'tuple'> (0.10000000000000001,) ! 2nd call
...
4.0 [-0.6351882 -0.5874518 -0.6351882]
<type 'tuple'> (<NULL>,) ! 3rd call
...
6.0 [-0.93274299 -0.92029838 -0.93274299]
<type 'tuple'> (<NULL>,)
8.0 [-1.06178405 -1.05979417 -1.06178405]
...
Thank you for any help.
David
More information about the SciPy-User
mailing list