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

Contents of /trunk/models/johnpye/zill.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: 1031 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 An example problem used in the text by Zill, 4th Ed, p 472.
6
7 Dennis G Zill, A First Course in Differential Equations with Applications,
8 PWS-KENTm Boston, 1989.
9
10 Actually this is a single-variable integration and can be solved using the
11 Runge-Kutta method (as illustrated by Zill).
12 *)
13 MODEL zill;
14 x IS_A solver_var;
15 y IS_A solver_var;
16 dy_dx IS_A solver_var;
17
18 xderiv: dy_dx = 2 * x * y;
19
20 METHODS
21
22 METHOD values;
23 y := 1; x := 1; (* initial conditions *)
24 dy_dx := 0;
25 END values;
26
27 METHOD specify;
28 FIX x, y;
29 END specify;
30
31 METHOD ode_init;
32 FREE x, y, dy_dx;
33
34 x.ode_type := -1;
35 dy_dx.ode_id := 1; y.ode_id := 1;
36 dy_dx.ode_type := 2; y.ode_type := 1;
37
38 x.obs_id := 1;
39 y.obs_id := 2;
40 END ode_init;
41
42 METHOD on_load;
43 RUN reset; RUN values;
44 RUN ode_init;
45 END on_load;
46
47 METHOD self_test;
48 (* assumes integration up to x = 1.5 *)
49 ASSERT abs(x - 1.5) < 1e-7;
50 ASSERT abs(y - 3.4904) < 0.001; (* this would be true if we used RK4, with h = 0.1 *)
51 END self_test;
52
53 END zill;

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