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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2630 - (show annotations) (download) (as text)
Mon Aug 6 13:42:14 2012 UTC (9 years, 10 months ago) by jpye
File MIME type: text/x-ascend
File size: 1453 byte(s)
Trying to split up instantiate.c. A big job actually.
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 t IS_A time;
12 R "rabbit population" IS_A factor;
13 F "fox population" IS_A factor;
14
15 dR_dt IS_A rate;
16 dF_dt IS_A rate;
17
18 r "growth rate of rabbits in absence of foxes" IS_A rate;
19 a "fraction of rabbits killed per fox per time" IS_A rate;
20 b "production rate of predators per prey eaten" IS_A rate;
21 m "natural fox mortality rate" IS_A rate;
22
23 dR_dt = r*R - a*R*F;
24 dF_dt = -m*F + b*R*F ;
25 METHODS
26
27 METHOD on_load;
28 RUN default_self;
29 RUN reset; RUN values;
30 RUN set_obs;
31 RUN set_ode;
32 END on_load;
33
34 METHOD default_self;
35 R := 1000;
36 F := 9;
37 dR_dt := 0 {Hz};
38 dF_dt := 0 {Hz};
39 END default_self;
40
41 METHOD specify;
42 FIX r,a,b,m;
43 FIX F,R;
44 END specify;
45
46 METHOD values;
47 r := 0.1 {1/s};
48 a := 0.01 {1/s};
49 b := 0.1 * a;
50 m := 0.05 {1/s};
51 t := 0{s};
52 END values;
53
54 METHOD set_obs;
55 t.obs_id :=1;
56 R.obs_id :=3;
57 F.obs_id :=4;
58 END set_obs;
59
60 METHOD set_ode; (* this is where the current implementation sux *)
61 FREE F,R,dR_dt,dF_dt;
62
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