Jeffrey
Jeffrey

Reputation: 1804

Implement Fitzhugh-Nagumo model via Crank-Nicolson

For a problem, I need to implement the Fitzhugh-Nagumo model with spatial diffusion via Crank-Nicolson's scheme. Now the problem lays withing the spatial diffusion.

(V_{t}) (DV_{xx} + V(V-a)(1-V) - W + I)
(W_{t}) (epsilon(V - b*W )

whereas DV_{xx} is the spatial diffusion.

Using Matlab, the following function can be given to i.e. an ODE45 solver. However it does not yet implement the spatial diffusion...

function dy = FHN( t, Y, D, a, b, eps, I )
    V  = Y(1);
    W  = Y(2);

    dY = zeros(2,1);

    % FHN-model w/o spatial diffusion
    Vxx = 0;
    dY(0) = D .* Vxx + V .* (V-a) .* (1-V) - W + I;
    dY(1) = eps .* (V-b .* W);

The question: How to implement V_{xx} ?

Besides, what matrix shape does V need to be? Normally V is depending only on t, and is thus a [1 by t] vector. Now V is depending on both x as t, thus i would expect it to be a [x by y] vector, correct?

Thank you

Upvotes: 0

Views: 1832

Answers (1)

Jeffrey
Jeffrey

Reputation: 1804

It took long, but hey its not a normal everyday problem.

function f = FN( t, Y, dx, xend, D, a, b, eps, I )
% Fitzhug-Nagumo model with spatial diffusion.
%       t  = Tijd
%       X  = [V; W]
%       dx = stepsize
%       xend = Size van x

% Get the column vectors dV and dW from Y
    V = Y( 1:xend/dx );
    W = Y( xend/dx+1:end );

% Function
    Vxx = (V([2:end 1])+V([end 1:end-1])-2*V)/dx^2;
    dVdt = D*Vxx + V .* (V-a) .* (1-V) - W + I ;
    dWdt = epsilon .* (V-b*W);

    f = [dVdt ; dWdt];

Both V as W are column vectors with a size of 1:(xend/dx)

Method of calling:

V = zeros(xend/dx,1);
W = zeros(xend/dx,1);

% Start Boundaries
% V(x, 0) = 0.8 for 4 < x < 5
% V(x, 0) = 0.1 for 3 < x < 4
V( (4/dx+1):(5/dx-1) ) = 0.8;
V( (3/dx+1):(4/dx-1) ) = 0.1;

Y0 = [V; W];
t = 0:0.1:400;
options = '';
[T, Y] = ode45( @FN, t, Y0, options, dx, xend, D, a, b, eps, I );

Upvotes: 1

Related Questions