Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using desolve_odeint with external stimulus

I'm trying to numerically solve a two-variable system of differential equations with a periodic external driver (square wave). Right now, the code I have is:

from scipy.signal import square
def sqstim(t, amp=1): 
    return (amp/2)*float(square(t))+amp/2

var("V,w")
trange=srange(0,100,0.1)

def eqns(t):
    return [1/100*(-w+(V^3-V)+sqstim(t)), V-0.2*w]

sol=desolve_odeint(eqns, times=trange, ics=[0.1,0.1], dvars=[V,w])

This gives "TypeError: 'function' object is not iterable". What should I do instead?