up

MAE 185, UCI third project. Solution of Lotka-Volterra two species model

Nasser M. Abbasi

May 27, 2003

Contents

1 User Guide For Running the program "Solution of Lotka-Volterra two species model"
2 Technical notes
 2.1 Problem
 2.2 Analysis and Solution
 2.3 Algorithm
 2.4 Example outputs and results
 2.5 Source code listing

1 User Guide For Running the program "Solution of Lotka-Volterra two species model"

To run the program, please copy the content of the floppy disk (which contains the required 2 matlab files, one is called nma_185_proj3.m, and the other is a utility support file called nma_inputNumeric.m) to your MATLAB work folder on your C: drive.

The MATLAB work folder will be located under the main MATLAB folder. The name of the MATLAB main folder depends on the version of MATLAB you have installed. For example, for MATLAB 6.5, it is called

C:\MATLAB6p5

Once the files are copied to the work folder below the above MATLAB main folder, then start matlab itself, and from the matlab console, type the command:

nma_185_proj3

The program now will start and asks for input. This is an example of the required input from one test run:

>> nma_185_proj3  
Initial rabbits population ? >10  
Initial fox population ? >5000  
Number of steps ? >1000  
Step size ? >1  
>>

The program will then solve the problem and will display 3 different figure windows to show the results. It will display the state-space solution, the time-domain solution for each independent variable, both on the same plot and on separate plots. Please see test cases below for more examples.

2 Technical notes

2.1 Problem

Let prey by rabbits (R), and predators be foxes (F). Model is

ddRt = a R (t)- b R (t) F (t)

dF = e b R (t) F (t)- c F (t)
dt

Where

a  is natural growth of R in absence of F.

c  is natural death rate of F in absence of its food R.

b  is the death rate per encounter of R due to predation.

e  is the efficiency of turning predated R into F.

Solve the couple ODE using Runge-Kutta 4th order classical method.

Use the following values for the above parameters:

a = 0.04

c = 0.0005

b = 0.2

e = 0.1

Try different initial conditions for R and F population.

2.2 Analysis and Solution

let ddRt = f (t,R,F )

let dF = g(t,F,R )
dt

Since the rate of population is not explicitly given in terms of the independent variable t,  I could write the above as

ddRt = f (R, F)

dF = g(F,R )
dt

But for generality, I will keep the first form.

To solve using R-K 4th order method, then we write

           Δt
Ri+1 = Ri +-6 (K1,R + 2K2,R + 2K3,R + K4,R)

Fi+1 = Fi + Δt6 (K1,F + 2K2,F + 2K3,F + K4,F )

Let h = Δt  , the step size.

The only trick in these coupled ODE is the order in which we evaluate the K coefficients. This can be seen when we write the K down. When writing the K coefficients down, use this notation Ki,R  to mean the   i th  K for rabbits. And Ki,F  to mean the i th  K for Foxes. This means the second subscript represents the independent variable. This will reduce confusion and mistakes.

K1,R = f (Ri,Fi)

K   =  g(F ,R )
 1,F      i  i

        (    1          1              1      )
K2,R = f t+  2h ,  Ri + 2h K1,R,   Fi + 2h K1,F

        (                                     )
K2,F = g t+ 12h,   Fi + 12h K1,F , Ri + 12h K1,R

        (                                     )
K3,1 = f t+ 12h,   Ri + 12h K2,R ,  Fi + 12h K2,F

K3,2 = g (t + 1h, Fi + 1h K2,F,   Ri + 1h K2,R)
            2         2               2

K4,1 = f (t+ h,    Ri + h K3,R,     Fi + h K3,F)

K4,2 = g (t + h,   Fi + h K3,F,     Ri + h K3,R)

Hence, looking at the dependency of the K  above, we see some possible sequential ordering in which to evaluate those K  for each step. See diagram 1


PIC

Figure 1: two possible ordering for K evaluation


I will pick the first ordering sequence above for the implementation.

The above gives all the setup I need to implement the algorithm. This is implemented in MATLAB function called nma_185_proj2.m. The function asks the user for the initial population of the F and R, and the number of time steps, and for the size of the time step and will display the solution obtained.

2.3 Algorithm

  Read initial R and F and time step size and number of steps.  
 
  i=0  
  Loop  
     i=i+1  
     IF i greater than user supplied maximum number of steps THEN  
        exit LOOP  
     END IF  
 
     Find the K’s in the order shown above.  
     Find R(i+1), F(i+1), use user supplied initial values for R,F for i=1  
     Save these solutions in global solution matrix  
 
  End Loop  
  Plot the solution from the solution matrix.

2.4 Example outputs and results


PIC

Figure 2: test1



PIC

Figure 3: test2



PIC

Figure 4: test3



PIC

Figure 5: test4



PIC

Figure 6: test5



PIC

Figure 7: test6



PIC

Figure 8: test7



PIC

Figure 9: test8


2.5 Source code listing

The file nma_185_proj3.m is moved to my main matlab functions page here