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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 669 - (show annotations) (download) (as text)
Wed Jun 21 07:00:45 2006 UTC (18 years, 7 months ago) by johnpye
File MIME type: text/x-ascend
File size: 1029 byte(s)
Merged changes from DAE branch (revisions 702 to 819) back into trunk.
This adds the Integration API to the ASCEND solver (in base/generic).
Also provides pre-alpha support for 'IDA' from the SUNDIALS suite, a DAE solver.
Many other minor code clean-ups, including adoption of new 'ASC_NEW' and friends (to replace 'ascmalloc')
Added some very sketchy stuff providing 'DIFF(...)' syntax, although it is anticipated that this will be removed.
1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3
4 (* spring oscillation model. Intended to demonstrate second-order ODE *)
5 MODEL spring;
6 x IS_A distance;
7 v_x IS_A speed;
8 a_x IS_A acceleration;
9
10 t IS_A time;
11
12 (* equations of motion *)
13 F IS_A force;
14 k IS_A stiffness;
15 m IS_A mass;
16 F = -k*x;
17 F = m*a_x;
18 DIFF(v_x) = a_x;
19 METHODS
20 METHOD specify;
21 FIX m, k;
22 END specify;
23
24 METHOD default_self; (* dynamic vals *)
25 x := 1 {m};
26 v_x := 0 {m/s};
27 a_x := -1 {m/s^2};
28 END default_self;
29
30 METHOD values; (* fixed vals *)
31 m := 1 {kg};
32 k := 5 {N/kg};
33 t := 0 {s};
34 x := 1 {m};
35 v := 0 {m/s};
36 END values;
37
38 METHOD set_ode; (* this is where the current implementation sux *)
39 x.ode_id := 1; x.ode_type := 1;
40 v_x.ode_id := 1; v_x.ode_type := 2;
41 a_x.ode_id := 1; a_x.ode_type := 3;
42
43 t.ode_type :=-1;
44 END set_ode;
45
46 METHOD set_obs; (* this sux also *)
47 x.obs_id := 1;
48 v_x.obs_id := 2;
49 a_x.obs_id := 3;
50 END set_obs;
51
52 METHOD on_load;
53 RUN default_self;
54 RUN reset;
55 RUN specify;
56 RUN set_obs;
57 RUN set_ode;
58 END on_load;
59
60 END spring;

Properties

Name Value
svn:executable *

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