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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 979 - (show annotations) (download) (as text)
Wed Dec 20 14:34:16 2006 UTC (18 years, 1 month ago) by johnpye
File MIME type: text/x-ascend
File size: 1472 byte(s)
Added simplified ASC_PANIC call that uses var-args, added throughout relation_util.c.
Fixed var_filter_t stuff in djex and fvex.
More assertions in integrator.c
Added output of initial state from lsode.c (hoping that's a good idea?)
Fixed output code from relman_diff2.
Added asc_panic_nofunc for non var-arg CPPs.
Disabled -O3 flag in building C++ API
Added __getitem__ and __getattr__ methods in Simuluation for simplified python syntax (eg M.x instead M.sim.x)
Integrator::analyse throws exceptions on error now.

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 FREE F,R,dR_dt,dF_dt;
64
65 R.ode_id := 1; R.ode_type := 1;
66 dR_dt.ode_id := 1; dR_dt.ode_type := 2;
67
68 F.ode_id := 2; F.ode_type := 1;
69 dF_dt.ode_id := 2; dF_dt.ode_type := 2;
70
71 t.ode_type :=-1;
72 END set_ode;
73
74
75 END lotka;

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