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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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