% IDE Integrodifference Equation Simulator % % This program numerically solves a scalar % integrodifference equation and plots the % result. % % Author: Michael Neubert % 2/8/2000 % r = growth parameter % alpha = dispersal parameter % iterations = number of iterations to perform % lowval = truncation threshold % diameter = length of the domain % nodes = number of nodes in domain (should be 2^m + 1) % x = vector of node locations % x2 = vector of node locations for extended domain % dx = internode distance % n = matrix of population densities % k = dispersal kernel % f = growth function % xmin, xmax, ymin, ymax: graphics scales % irad = radius of initial condition % idens = initial density iterations = 50; r = 1; alpha = 7; lowval = 1e-14; diameter = 250; nodes = (2^13)+1; irad = 0.1; idens = 1; xmin = -60; xmax = 60; ymin = 0; ymax = 1.2; radius = diameter/2; x = linspace(-radius,radius,nodes); x2 = linspace(-diameter,diameter,2*nodes-1); dx = diameter/(nodes-1); n = zeros(1,length(x)); k = (alpha/2)*exp(-alpha*abs(x2)); %SET THE INITIAL CONDITIONS n = zeros(size(n)); temp = find(abs(x) <= irad); n(temp) = idens*ones(size(n(temp))); %PLOT INITIAL CONDITIONS AND WAIT FOR KEYSTRIKE plot(x,n); xlabel('location (x)'); ylabel('population density [ n_{t} (x) ]'); title('t = 0'); axis([xmin xmax ymin ymax]); drawnow; disp('Strike any key when ready...'); pause; %DO THE SIMULATION ITERATIONS n1 = zeros(1,length(x2)+length(x)-1); for j = 1:iterations n1 = zeros(size(n1)); % Ricker Growth f = n.*exp(r*(1-n)); % Convolution n1 = fft_conv(k,f); n = dx*n1(nodes:length(x2)); n(1) = n(1)/2; n(nodes) = n(nodes)/2; temp = find(n < lowval); n(temp) = zeros(size(n(temp))); % Graphics plot(x,n); xlabel('location (x)'); ylabel('population density [ n_{t} (x) ]'); title(['t = ',num2str(j)]); axis([xmin xmax ymin ymax]); drawnow; end