Solution to Lota-Volterra prey-predator model using Fortran
Lotka Volterra prey-predator model, for an autocatalytic reaction.
- lvpp.f - Main Routine
- derivs.f - ODE Sub Routine
- rk4.f - 4th Order Runge-Kutta Method to solve a system of differential equations
For the reaction
Rate change for X and Y can be defined as:
Using the 4th Order Runge-Kutta Method to solve the above system of differential equations:
Using the above algorithm, a Fortran program is created and values of
Initial values as:
Output Result
Output result file lv-res.dat is included here for reference.
gnuplot is used for plotting the result obtained from the simulation. After the result is obtained, gnuplot is set to output in svg/png. Sample plot is shown below. You can also check the svg files in images directory.
Settings for gnuplot to output svg files are as follows:
#!/usr/local/bin/gnuplot -persist
set terminal svg enhanced font 'Arial,11'
set output "rk.svg"
set title "[X]/[Y] vs Time Plot"
set xlabel "Time (t)"
set ylabel "[X]/[Y]"
set yrange [0:450]
plot "lv-res.dat" u (column(0)):2 w l lw 3 title "[X]","lv-res.dat" u (column(0)):3 w l lw 3 title "[Y]"
set terminal svg enhanced font 'Arial,11'
set title "[X] vs [Y] Plot"
set xlabel "[X]"
set ylabel "[Y]"
set output "rk2.svg"
plot "lv-res.dat" using 2:3 w l lw 3 title ""
This setting file is included as a shell script file xy_svg.sh
[X],[Y] vs Time (t) plot
[X] vs [Y] Plot
- The subroutine rk4.f was adapted from Numerical Recipes in Fortran 77, Second Edition (1992)