/[ascend]/trunk/models/test/link/pendulum_wLINK.a4c
ViewVC logotype

Annotation of /trunk/models/test/link/pendulum_wLINK.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2569 - (hide annotations) (download) (as text)
Tue Feb 7 21:01:01 2012 UTC (10 years, 6 months ago) by jpye
File MIME type: text/x-ascend
File size: 1420 byte(s)
Working on tests for LINK functionality. More to do.
Adding notes on usage of VIM highlighting.
1 jpye 2569 REQUIRE "ivpsystem.a4l";
2     REQUIRE "atoms.a4l";
3     IMPORT "johnpye/extpy/extpy";
4     IMPORT "johnpye/solve";
5    
6     MODEL pendulum;
7     x IS_A delta_distance; y IS_A delta_distance;
8     r IS_A distance;
9     theta IS_A angle;
10     -y = r*cos(theta);
11     x = r*sin(theta);
12    
13     m IS_A mass;
14     v_x IS_A speed; v_y IS_A speed;
15     a_x IS_A acceleration; a_y IS_A acceleration;
16     g IS_A acceleration;
17    
18     t IS_A time;
19    
20     (* equations of motion *)
21     Fc IS_A force;
22     +Fc*cos(theta)-m*g = m*a_y;
23    
24     -Fc*sin(theta) = m*a_x;
25    
26    
27     METHODS
28     METHOD specify;
29     FIX r, m, g, x, t;
30     FIX v_x;
31     END specify;
32    
33     METHOD default_self;
34     y := -sqrt(3)/2*(1{m});
35     x := 0.5 {m};
36     r := 1 {m};
37     v_y := 0 {m/s};
38     v_x := 0 {m/s};
39     END default_self;
40    
41     METHOD values;
42     t := 0 {s};
43     r := 1 {m};
44     m := 1 {kg};
45     g := 9.8 {N/kg};
46     END values;
47    
48     METHOD set_ode; (* LINK syntax to set the ode relationships in the procedural part *)
49     DER(v_x, x );
50     DER(a_x,v_x);
51     DER(v_y, y );
52     DER(a_y,v_y);
53     INDEPENDENT t;
54     (* Note: In this case there is no longer the need to create two more variables v_x1 and v_y1, even though they belong to two derivative chains with different types, because their types are taken from the link structure rather than from the varaible children *)
55    
56     END set_ode;
57    
58     METHOD set_obs;
59     x.obs_id :=1;
60     y.obs_id :=2;
61     END set_obs;
62    
63     METHOD on_load;
64     RUN default_self;
65     RUN reset;
66     RUN specify;
67     EXTERNAL solve(SELF);
68     EXTERNAL solve(SELF);
69     RUN set_obs;
70     RUN set_ode;
71     END on_load;
72    
73     END pendulum;

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