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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 854 - (hide annotations) (download) (as text)
Wed Sep 20 13:36:40 2006 UTC (13 years, 4 months ago) by johnpye
File MIME type: text/x-ascend
File size: 1305 byte(s)
First tentative version in 'integration reporting':
Values of observed variables from the simulation are added to an Observer table after simulation completes.
This is not very efficiently coded at this stage but is a start.
Also some minor changes to text and comments in some base/generic files.
1 johnpye 846 REQUIRE "ivpsystem.a4l";
2     REQUIRE "atoms.a4l";
3    
4     (*
5     A simple population model using the Lotka-Volterra model.
6    
7     http://www.ento.vt.edu/~sharov/PopEcol/lec10/lotka.html
8     *)
9     MODEL lotka;
10    
11     H IS_A factor; (* prey *)
12     P IS_A factor; (* predators *)
13    
14     dH_dt IS_A rate;
15     dP_dt IS_A rate;
16    
17     dH_dt = r*H - a*H*P;
18     dP_dt = b*H*P - m*P;
19    
20     r IS_A factor; (* intrinsic rate of prey population increase *)
21     a IS_A factor; (* predation rate coefficient *)
22     b IS_A factor; (* production rate of predators per prey eaten *)
23     m IS_A factor; (* predator mortality rate *)
24    
25     t IS_A time;
26     METHODS
27    
28     METHOD on_load;
29     RUN default_self;
30     RUN reset; RUN values;
31     RUN set_obs;
32     RUN set_ode;
33     END on_load;
34    
35     METHOD default_self;
36     H := 1000;
37     P := 9;
38     dH_dt := 0 {Hz};
39     dP_dt := 0 {Hz};
40     END default_self;
41    
42     METHOD specify;
43     FIX r,a,b,m;
44     FIX P,H;
45     END specify;
46    
47     METHOD values;
48 johnpye 854 r := 0.2;
49 johnpye 846 a := 0.01;
50     b := 0.0005;
51     m := 0.04;
52     END values;
53    
54     METHOD set_obs;
55     H.obs_id :=1;
56     P.obs_id :=2;
57     END set_obs;
58    
59     METHOD set_ode; (* this is where the current implementation sux *)
60     H.ode_id := 1; H.ode_type := 1;
61     dH_dt.ode_id := 1; dH_dt.ode_type := 2;
62    
63     P.ode_id := 2; P.ode_type := 1;
64     dP_dt.ode_id := 2; dP_dt.ode_type := 2;
65    
66     t.ode_type :=-1;
67     END set_ode;
68    
69    
70     END lotka;

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