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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1193 - (show annotations) (download) (as text)
Sun Jan 21 12:51:19 2007 UTC (15 years, 5 months ago) by johnpye
File MIME type: text/x-ascend
File size: 1594 byte(s)
Fixed idadenx for test.py
1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3
4 (*
5 ASCEND model based on the 'idadenx.c' example problem that accompanies IDA.
6 The root-finding part isn't yet implemented though.
7 ----------------------------------------------------------------------------
8 This simple example problem for IDA, due to Robertson,
9 is from chemical kinetics, and consists of the following three
10 equations:
11
12 dy1/dt = -.04*y1 + 1.e4*y2*y3
13 dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
14 0 = y1 + y2 + y3 - 1
15
16 on the interval from t = 0.0 to t = 4.e10, with initial
17 conditions: y1 = 1, y2 = y3 = 0.
18
19 This model is tested (using the same parameters as used by idadenx.c) by the
20 script pygtk/test.py.
21 *)
22 MODEL idadenx;
23 y1, y2, y3 IS_A factor;
24 dy1_dt IS_A factor;
25 dy2_dt IS_A factor;
26
27 eq1: dy1_dt = -0.04 * y1 + 1e4 * y2*y3;
28 eq2: dy2_dt = +0.04 * y1 - 1e4 * y2*y3 - 3e7*y2^2;
29 eq3: 0 = y1 + y2 + y3 - 1;
30
31 t IS_A time;
32 METHODS
33
34 METHOD values; (* initial values *)
35 y1 := 1;
36 y2 := 0;
37 y3 := 0;
38 t := 0 {s};
39 END values;
40
41 METHOD specify;
42 FIX y1, y2;
43 END specify;
44
45 METHOD ode_init;
46 FREE y1, y2;
47 t.ode_type := -1; t := 0 {s};
48 dy1_dt.ode_id := 1; dy1_dt.ode_type := 2;
49 y1.ode_id := 1; y1.ode_type := 1;
50
51 dy2_dt.ode_id := 2; dy2_dt.ode_type := 2;
52 y2.ode_id := 2; y2.ode_type := 1;
53
54 (* y3.ode_id := 3; *)
55
56 t.obs_id := 1;
57 y1.obs_id := 2;
58 y2.obs_id := 3;
59 y3.obs_id := 4;
60 dy1_dt.obs_id := 5;
61 dy2_dt.obs_id := 6;
62
63 y1.ode_atol := 1e-8;
64 y2.ode_atol := 1e-14;
65 y3.ode_atol := 1e-6;
66 END ode_init;
67
68 METHOD on_load;
69 RUN reset;
70 RUN values;
71 RUN ode_init;
72 END on_load;
73
74 END idadenx;

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