Home Reading Searching Subscribe Sponsors Statistics Posting Contact Spam Lists Links About Hosting Filtering Features Download Marketing Archives FAQ Blog From: Vitor Matos dei.uminho.pt> Subject: multiple ODE problem with scipy.integrate.ode.ode Newsgroups: gmane.comp.python.scientific.user Date: Monday 2nd May 2011 13:08:01 UTC (over 7 years ago) ```Hi, I've been trying to perform the integration of multiple ODEs. The problem is that only the first ODE being integrated produces the correct solution. The subsequent ODE solution come out as gibberish. To demonstrate the problem, I've written a simple code that solves two RC circuit ODEs: ---------------------------------------------------------------------- from scipy.integrate import * def f(t, y, arg1): # dV/dt = -1/RC (V - Vi) return -1/(arg1[0]*arg1[1])*(y - arg1[2]) y0 = 0 t0 = 0 # 0- R parameter # 1- C parameter # 2- Vin step arg = [100, 0.01, 5] arg2 = [200, 0.005, 5] r = ode(f).set_integrator('vode') r.set_initial_value(y0,t0) r.set_f_params(arg) r2 = ode(f).set_integrator('vode') r2.set_initial_value(y0,t0) r2.set_f_params(arg2) t_final = 10 dt = 0.1 t = [t0] v1 = [y0] v2 = [y0] while r.successful and r.t < t_final \ and r2.successful and r2.t < t_final: r.integrate(r.t + dt) r2.integrate(r2.t + dt) #r2.integrate(r2.t + dt) #r.integrate(r.t + dt) print "1: ", r.t, r.y print "2: ", r2.t, r2.y t.append(r.t) v1.append(r.y) v2.append(r2.y) ## plot the simulation from matplotlib import * from pylab import * figure(1) #Using matplotlib plot(t,v1,t,v2) title('RC circuit') xlabel('Time') show() ---------------------------------------------------------------------- What could be the problem? Also, I'm new to Python and I'm still trying to grasp how to best use it. Thanks in advance, Vitor Matos```
CD: 3ms