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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 962 - (show annotations) (download) (as text)
Mon Dec 11 14:43:02 2006 UTC (13 years, 1 month ago) by johnpye
File MIME type: text/x-ascend
File size: 1031 byte(s)
Adding more LSODE test cases.
Removing some 'error tree' debug output.
Added RTOLDEF and ATOLDEF parameters to LSODE (and fixed a bug relating to integrator_lsode_params_default).
1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3
4 (*
5 Simple dynamic model of object under gravity (for use in test suite)
6 *)
7 MODEL newton;
8 x IS_A distance;
9 dx_dt IS_A speed;
10 v IS_A speed;
11 dv_dt IS_A acceleration;
12 g IS_A gravity_constant;
13 g :== 1{EARTH_G};
14
15 xderiv: dx_dt = v;
16 vderiv: dv_dt = -g;
17
18 t IS_A time;
19 METHODS
20
21 METHOD values;
22 v := +10 {m/s};
23 x := 0 {m};
24 t := 0 {s};
25 END values;
26
27 METHOD specify;
28 FIX x, v;
29 END specify;
30
31 METHOD ode_init;
32 FREE x,v;
33 t.ode_type := -1; t := 0 {s};
34 dx_dt.ode_id := 1; x.ode_id := 1; dx_dt.ode_type := 2; x.ode_type := 1;
35 dv_dt.ode_id := 2; v.ode_id := 2; dv_dt.ode_type := 2; v.ode_type := 1;
36 x.obs_id := 1;
37 v.obs_id := 2;
38 dv_dt.obs_id := 3;
39 v.ode_atol := 1e-8;
40 x.ode_atol := 1e-8;
41 END ode_init;
42
43 METHOD on_load;
44 RUN reset; RUN values;
45 RUN ode_init;
46 END on_load;
47
48 METHOD self_test;
49 (* assumes integration up to t = (20/9.8){s}; *)
50 ASSERT abs(x - 0 {m}) < 1e-5 {m};
51 ASSERT abs(v +10 {m/s}) < 1e-5 {m/s};
52 ASSERT abs(dv_dt + g) == 0 {m/s^2};
53 END self_test;
54
55 END newton;

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