/[ascend]/trunk/models/johnpye/lotka.a4c
ViewVC logotype

Contents of /trunk/models/johnpye/lotka.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 961 - (show annotations) (download) (as text)
Mon Dec 11 14:04:13 2006 UTC (12 years, 10 months ago) by johnpye
File MIME type: text/x-ascend
File size: 1447 byte(s)
Fixed a silly bug with Integrator::setEngine.
Added test case for lotka.a4c to test.py
1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3
4 (*
5 A simple population model using the Lotka-Volterra model.
6
7 http://www.stolaf.edu/people/mckelvey/envision.dir/lotka-volt.html
8 http://www.ento.vt.edu/~sharov/PopEcol/lec10/lotka.html
9 *)
10 MODEL lotka;
11
12 R IS_A factor; (* rabbits *)
13 F IS_A factor; (* foxes *)
14
15 dR_dt IS_A rate;
16 dF_dt IS_A rate;
17
18 r IS_A rate; (* growth rate of rabbits in absence of foxes *)
19 a IS_A rate; (* efficiency of turning hunted rabbits into new foxes*)
20 b IS_A rate; (* production rate of predators per prey eaten *)
21 m IS_A rate; (* natural fox mortality rate *)
22
23 dR_dt = r*R - a*R*F;
24 dF_dt = b*R*F - m*F;
25
26 t IS_A time;
27 METHODS
28
29 METHOD on_load;
30 RUN default_self;
31 RUN reset; RUN values;
32 RUN set_obs;
33 RUN set_ode;
34 END on_load;
35
36 METHOD default_self;
37 R := 1000;
38 F := 9;
39 dR_dt := 0 {Hz};
40 dF_dt := 0 {Hz};
41 END default_self;
42
43 METHOD specify;
44 FIX r,a,b,m;
45 FIX F,R;
46 END specify;
47
48 METHOD values;
49 r := 0.04 {1/s};
50 a := 0.0005 {1/s};
51 b := 0.1*0.0005 {1/s};
52 m := 0.2 {1/s};
53 t := 0{s};
54 END values;
55
56 METHOD set_obs;
57 t.obs_id :=1;
58 R.obs_id :=2;
59 F.obs_id :=3;
60 END set_obs;
61
62 METHOD set_ode; (* this is where the current implementation sux *)
63 R.ode_id := 1; R.ode_type := 1;
64 dR_dt.ode_id := 1; dR_dt.ode_type := 2;
65
66 F.ode_id := 2; F.ode_type := 1;
67 dF_dt.ode_id := 2; dF_dt.ode_type := 2;
68
69 t.ode_type :=-1;
70 END set_ode;
71
72
73 END lotka;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22