# FD2D_PREDATOR_PREY Predator Prey Simulation by Marcus Garvie

FD2D_PREDATOR_PREY is a FORTRAN90 program which solves a predator-prey system in a two dimensional region. The program requires both some interactive input from the user, and two simple FORTRAN90 routines that define the initial values.

The nondimensional problem has the form

```        du/dt =         del u + ( 1 - u ) * u        - v * h(u/alpha)

dv/dt = delta * del v     - gamma * v + beta * v * h(u/alpha)
```
in a square [A,B]x[A,B], with initial conditions:
```        u(x,y,0) = u0(x,y)
v(x,y,0) = v0(x,y)
```
and Neumann boundary conditions along the boundary of the square:
```        du/dn = 0
dv/dn = 0
```
The Type II functional response employed here is
```        h(eta) = eta / ( 1 + eta )
```
The parameters ALPHA, BETA, GAMMA and DELTA are strictly positive.

The user must input a value H specifying the desired space step to be used in discretizing the space dimension.

A finite difference scheme is employed to integrate the problem from time 0 to a maximum time T. The user must input the value T, as well as an appropriate time step DELT.

A typical input for this problem is:

```        ALPHA =   0.4
BETA  =   2.0
GAMMA =   0.6
DELTA =  10.0
A     =   0.0
B     = 500.0
H     =   1.0
T     = 150.0
DELT  =   0.041666666666666
SOLVE =   0
```
with the following initial values of U and V supplied in auxiliary subroutines:
```        ustar = gamma * alpha / ( beta - gamma )

u0(i,j) = ustar - 2.0E-07 * ( x(i,j) - 0.1 * y(i,j) - 225.0 )
* ( x(i,j) - 0.1 * y(i,j) - 675.0 )

vstar = ( 1.0 - ustar ) * ( alpha + ustar )

v0(i,j) = vstar - 3.0E-05 * ( x(i,j) - 450.0 )
- 1.2E-04 * ( y(i,j) - 150.0 )
```

### Languages:

FD2D_PREDATOR_PREY is available in a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

FD1D_PREDATOR_PREY, a MATLAB program which uses finite differences to solve a 1D predator prey problem.

### Reference:

1. Marcus Garvie,
Finite-Difference Schemes for Reaction-Diffusion Equations Modeling Predator-Prey Interactions in MATLAB,
Bulletin of Mathematical Biology,
Volume 69, Number 3, 2007, pages 931-956.

### List of Routines:

• MAIN is the main program for FD2D_PREDATOR_PREY.
• DS3_DIAGONAL2 reorders two square DS3 matrices so diagonal entries are first.
• DS3_JAC_SL solves a DS3 system using Jacobi iteration.
• I4_SWAP swaps two I4's.
• I4VEC2_SORT_A_PLUS2 ascending sorts integer pairs, and adjusts real vectors.
• MATVEC_TRIAD computes A*X for a matrix A stored in SLAP Triad form.
• MSOLVE_IDENTITY applies the identity matrix preconditioner.
• R8_SWAP swaps two R8's.
• SPARSE manages the storage of sparse matrix information.
• SORT_HEAP_EXTERNAL externally sorts a list of items into ascending order.

You can go up one level to the FORTRAN90 source codes.

Last revised on 23 March 2005.