Python : Speeding up my Runge-Kutta integration code challenge
I am using the attached code to integrate a version of Fitzhugh-Nagumo model : from scipy.integrate import odeint import numpy as np import time P = {'epsilon':0.1, 'a1':1.0, 'a2':1.0, 'b':2.0, 'c':0.2} def fhn_rhs(V,t,P): u,v = V[0],V[1] u_t = u - u**3 - v v_t = P['epsilon']*(u - P['b']*v - P['c']) return np.stack((u_t,v_t)) def integrate(func,V0,t,args,step='RK4'): start = time.clock() P = args[0] result=[V0] for i,tmp in enumerate(t[1:]): result.append(RK4step(func,result[i],tmp,P,(t[i+1]-t[i]))) print "Integration took ",time.clock() - start, " s" return np.array(result) def RK4step(rhs,V