I'm trying to come up with a python implementation for the Fitzhugh-Nagumo model.
V_t = V_xx + V(V - a)(1 - V) - W + I
W_t = eps(beta*V - W)
Using the really basic code for eps = 0.05, a = 0.2, beta = 5, I = .1
I can numerically solve the system(with out the V_xx
), but I can't seem to figure out how to implement the spacial diffusion.
def func_v(v, w):
return v * (1 - v) * (v - .2) - w + .1
def func_w(v, w):
return .05 * (5 * v - w)
def get_yn(t0, v, w, h, t):
while t0 < t:
w += h * func_w(v, w)
v += h * func_v(v, w)
t0 += h
return v, w
I know the centered difference formula for second order derivatives is
V_xx(x_i, t) = (V(x_i+1, t) - 2*V(x_i, t) + V(x_i-1, t)) / dx^2
but how would I implement the different values for x_i
(let's say from x=0
to 10
) in order to get the wave to propagate along the x-axis?
The results should give a wave that propagates something like this.