Docsity

Solving Predator-Prey Problem with Runge-Kutta in CFD - Prof. Charles Pruett, Assignments of Mathematics

Toggle sidebar
bg1
Math/Physics 365 Computational Fluid Dynamics
Programming Assignment 0 (Homework Problem 2)
(Spring 2001–Pruett/Sochacki)
DATE ASSIGNED: Tuesday, 16 Jan., 2001
DATE DUE: TBD
BACKGROUND: A classic system of nonlinear ODEs is the predator-prey problem given below:
y0
1=ay1−by1y2
y0
2=−cy1+dby1y2
where a,b,c,and dare positive constants. The system describes population fluctuations over time t
[years] in a biological system comprised of y1(t)prey (e.g., hares, in thousands) and y2predators (e.g.,
foxes, in hundreds). The system is at an equilibrium point if the population vector ~y(t) = [y1(t),y2(t)]
doesn’t change over time. For other initial values [y1(0),y2(0)], the population fluctuates wildly. What is
perhaps most interesting is that this nonlinear problem gives a periodic solution known as a limit cycle.
Why study the predator-prey problem in a CFD class? Well, although the problem is not of direct interest
to us, the numerical solution technique can be readily adapted to the solution of the Blasius boundary-layer
equations, which will become Project 1.
ASSIGNMENT: A second-order Runge-Kutta method (also known has Heun’s method) has been written
for you in Fortran 90. It can be used to solve the predator-prey problem numerically and is located as
rk2.f90 on the Ldrive in directory math365.
1. Identify where the code must be changed to accommodate some other system of equations.
2. Run the program for the predator-prey problem. You will be prompted for all relevant input data,
including the initial conditions. For your choice of initial conditions (each variable somewhere
between 0 and 1), experiment with the time limit (the upper limit of integration) so as to obtain at
least 5 full periods of the limit cycle. Use the Maple plotting routine prpr.mws in the same directory
as the program to help you visualize the solution. Note this routine plots the phase portrait of the
solution, y2vs. y1, so that time is not apparent. You may also want to plot each variable vs. time.
Experiment with drastic variations in the step size. Determine an adequately sized time-step ∆tso
that the solution repeats itself to a high degree of accuracy.
3. Read up on the 4th-order Runge-Kutta method in Numerical Recipes. Modify program rk2.f90 to
fourth-order and call it rk4.f90. Exercise care, otherwise an error could produce a working code of
first-order rather than 4th-order!
4. Repeat step 3 above using rk4.f90. How do the time-step sizes ∆tcompare for the two methods for
the same level of accuracy?

Partial preview of the text

Download Solving Predator-Prey Problem with Runge-Kutta in CFD - Prof. Charles Pruett and more Assignments Mathematics in PDF only on Docsity!

Math/Physics 365 Computational Fluid Dynamics

Programming Assignment 0 (Homework Problem 2)

(Spring 2001–Pruett/Sochacki)

DATE ASSIGNED: Tuesday, 16 Jan., 2001

DATE DUE: TBD

BACKGROUND: A classic system of nonlinear ODEs is the predator-prey problem given below:

y ′ 1 = ay 1 − by 1 y 2 y ′ 2 = − cy 1 + dby 1 y 2

where a , b , c , and d are positive constants. The system describes population fluctuations over time t [years] in a biological system comprised of y 1 ( t ) prey (e.g., hares, in thousands) and y 2 predators (e.g., foxes, in hundreds). The system is at an equilibrium point if the population vector ~ y ( t ) = [ y 1 ( t ), y 2 ( t )] doesn’t change over time. For other initial values [ y 1 ( 0 ), y 2 ( 0 )], the population fluctuates wildly. What is perhaps most interesting is that this nonlinear problem gives a periodic solution known as a limit cycle. Why study the predator-prey problem in a CFD class? Well, although the problem is not of direct interest to us, the numerical solution technique can be readily adapted to the solution of the Blasius boundary-layer equations, which will become Project 1.

ASSIGNMENT : A second-order Runge-Kutta method (also known has Heun’s method) has been written for you in Fortran 90. It can be used to solve the predator-prey problem numerically and is located as rk2.f90 on the L drive in directory math.

  1. Identify where the code must be changed to accommodate some other system of equations.
  2. Run the program for the predator-prey problem. You will be prompted for all relevant input data, including the initial conditions. For your choice of initial conditions (each variable somewhere between 0 and 1), experiment with the time limit (the upper limit of integration) so as to obtain at least 5 full periods of the limit cycle. Use the Maple plotting routine prpr.mws in the same directory as the program to help you visualize the solution. Note this routine plots the phase portrait of the solution, y 2 vs. y 1 , so that time is not apparent. You may also want to plot each variable vs. time. Experiment with drastic variations in the step size. Determine an adequately sized time-step ∆ t so that the solution repeats itself to a high degree of accuracy.
  3. Read up on the 4th-order Runge-Kutta method in Numerical Recipes. Modify program rk2.f90 to fourth-order and call it rk4.f90. Exercise care, otherwise an error could produce a working code of first-order rather than 4th-order!
  4. Repeat step 3 above using rk4.f90. How do the time-step sizes ∆ t compare for the two methods for the same level of accuracy?