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 |
|
49 |
dy1_dt.ode_id := 1; dy1_dt.ode_type := 2; |
50 |
y1.ode_id := 1; y1.ode_type := 1; |
51 |
|
52 |
dy2_dt.ode_id := 2; dy2_dt.ode_type := 2; |
53 |
y2.ode_id := 2; y2.ode_type := 1; |
54 |
|
55 |
(* y3.ode_id := 3; *) |
56 |
|
57 |
t.obs_id := 1; |
58 |
y1.obs_id := 2; |
59 |
y2.obs_id := 3; |
60 |
y3.obs_id := 4; |
61 |
dy1_dt.obs_id := 5; |
62 |
dy2_dt.obs_id := 6; |
63 |
|
64 |
y1.ode_atol := 1e-8; |
65 |
y2.ode_atol := 1e-14; |
66 |
y3.ode_atol := 1e-6; |
67 |
END ode_init; |
68 |
|
69 |
METHOD on_load; |
70 |
RUN reset; |
71 |
RUN values; |
72 |
RUN ode_init; |
73 |
END on_load; |
74 |
|
75 |
END idadenx; |