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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 877 - (show annotations) (download) (as text)
Sat Oct 7 09:31:51 2006 UTC (18 years, 3 months ago) by johnpye
File MIME type: text/x-ascend
File size: 1412 byte(s)
Added example of external scripting to the model 'fourbarplot.py'.
Allows plotting of the status of the four bar linkage.
TODO: test in the Tcl/Tk environment
1 REQUIRE "atoms.a4l";
2
3 IMPORT "johnpye/extpy/extpy";
4 IMPORT "johnpye/fourbarplot";
5
6 (*
7 Model of a four-bar linkage
8
9 The pivots are at A, B, C, D. Sides are named after the
10 end points. The 'default' configuration being modelled is
11 of a quadrilater with A and D fixed and B and C free.
12 The angle at A, alpha (to the positive x axis) will also be fixed
13
14 *)
15
16 MODEL fourbar;
17 x_A,y_A IS_A delta_distance;
18 x_B,y_B IS_A delta_distance;
19 x_C,y_C IS_A delta_distance;
20 x_D,y_D IS_A delta_distance;
21
22 AB,BC,CD,DA IS_A distance;
23 alpha, beta, gamma, delta IS_A angle;
24
25 x_B = x_A + AB*cos(alpha);
26 y_B = y_A + AB*sin(alpha);
27
28 (x_C-x_B)^2 + (y_C-y_B)^2 = BC^2;
29 beta = arctan((y_C-y_B)/(x_C-x_B));
30
31 x_D = x_C + CD*cos(gamma);
32 y_D = y_C + CD*sin(gamma);
33
34 x_A = x_D + DA*cos(delta);
35 y_A = y_D + DA*sin(delta);
36
37 METHODS
38 METHOD default_self;
39 y_B := 0.5 {m}; x_B := 0.8 {m};
40 y_C := -0.5{m}; x_C := 1.2 {m};
41 x_D := 2 {m}; y_D := 0 {m};
42 END default_self;
43
44 METHOD specify;
45 FIX x_A, y_A;
46 FIX AB, BC, CD, DA;
47 FIX alpha, delta;
48 END specify;
49 METHOD values;
50 x_A := 0 {m};
51 y_A := 0 {m};
52 delta := 180 {deg};
53 AB := 1 {m};
54 BC := 1 {m};
55 CD := 1 {m};
56 DA := 2 {m};
57
58 alpha:= 30 {deg};
59 END values;
60 METHOD fancyplot;
61 EXTERNAL fourbarplot(SELF);
62 END fancyplot;
63
64 METHOD on_load;
65 RUN reset;
66 RUN values;
67 RUN default_self;
68 END on_load;
69 END fourbar;
70

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