/[ascend]/trunk/doc/howto-plot.lyx
ViewVC logotype

Contents of /trunk/doc/howto-plot.lyx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2785 - (show annotations) (download) (as text)
Mon Jun 23 08:17:49 2014 UTC (10 years, 5 months ago) by jpye
File MIME type: application/x-lyx
File size: 28306 byte(s)
updating RPM spec for Fed20
1 #LyX 2.1 created this file. For more info see http://www.lyx.org/
2 \lyxformat 474
3 \begin_document
4 \begin_header
5 \textclass book
6 \use_default_options false
7 \maintain_unincluded_children false
8 \language english
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_math auto
16 \font_default_family default
17 \use_non_tex_fonts false
18 \font_sc false
19 \font_osf false
20 \font_sf_scale 100
21 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \spacing single
29 \use_hyperref false
30 \papersize a4paper
31 \use_geometry false
32 \use_package amsmath 2
33 \use_package amssymb 2
34 \use_package cancel 1
35 \use_package esint 0
36 \use_package mathdots 0
37 \use_package mathtools 1
38 \use_package mhchem 0
39 \use_package stackrel 1
40 \use_package stmaryrd 1
41 \use_package undertilde 1
42 \cite_engine basic
43 \cite_engine_type default
44 \biblio_style plain
45 \use_bibtopic false
46 \use_indices false
47 \paperorientation portrait
48 \suppress_date false
49 \justification true
50 \use_refstyle 0
51 \index Index
52 \shortcut idx
53 \color #008000
54 \end_index
55 \secnumdepth 3
56 \tocdepth 3
57 \paragraph_separation indent
58 \paragraph_indentation default
59 \quotes_language english
60 \papercolumns 1
61 \papersides 2
62 \paperpagestyle default
63 \tracking_changes false
64 \output_changes false
65 \html_math_output 0
66 \html_css_as_file 0
67 \html_be_strict false
68 \end_header
69
70 \begin_body
71
72 \begin_layout Chapter
73 Plotting
74 \begin_inset Index idx
75 status collapsed
76
77 \begin_layout Plain Layout
78 plotting
79 \end_layout
80
81 \end_inset
82
83 data sampled from complex models
84 \begin_inset CommandInset label
85 LatexCommand label
86 name "cha:plot"
87
88 \end_inset
89
90
91 \end_layout
92
93 \begin_layout Standard
94 Often you need a plot of data sampled from arbitrary locations in a model
95 that are not naturally grouped in a single easily plotted vector.
96 The
97 \family typewriter
98 plot.a4l
99 \family default
100
101 \begin_inset Index idx
102 status collapsed
103
104 \begin_layout Plain Layout
105 plot.a4l
106 \end_layout
107
108 \end_inset
109
110 library provides models (
111 \family typewriter
112 plt_curve
113 \family default
114
115 \begin_inset Index idx
116 status collapsed
117
118 \begin_layout Plain Layout
119 plt
120 \begin_inset ERT
121 status collapsed
122
123 \begin_layout Plain Layout
124
125
126 \backslash
127 _
128 \end_layout
129
130 \end_inset
131
132 curve
133 \end_layout
134
135 \end_inset
136
137 ,
138 \family typewriter
139 plt_plot_symbol
140 \family default
141
142 \begin_inset Index idx
143 status collapsed
144
145 \begin_layout Plain Layout
146 plt
147 \begin_inset ERT
148 status collapsed
149
150 \begin_layout Plain Layout
151
152
153 \backslash
154 _
155 \end_layout
156
157 \end_inset
158
159 plot
160 \begin_inset ERT
161 status collapsed
162
163 \begin_layout Plain Layout
164
165
166 \backslash
167 _
168 \end_layout
169
170 \end_inset
171
172 symbol
173 \end_layout
174
175 \end_inset
176
177 , and
178 \family typewriter
179 plt_plot_integer
180 \family default
181
182 \begin_inset Index idx
183 status collapsed
184
185 \begin_layout Plain Layout
186 plt
187 \begin_inset ERT
188 status collapsed
189
190 \begin_layout Plain Layout
191
192
193 \backslash
194 _
195 \end_layout
196
197 \end_inset
198
199 plot
200 \begin_inset ERT
201 status collapsed
202
203 \begin_layout Plain Layout
204
205
206 \backslash
207 _
208 \end_layout
209
210 \end_inset
211
212 integer
213 \end_layout
214
215 \end_inset
216
217 ) that can be used with the Browser's Display Plot button.
218 In this chapter we see how to create such a plot using the ASCEND statement
219 ALIASES/IS_A to sample data from a mechanical system of stretched springs,
220 masses, anchors, and fingers.
221 Creating plots of time series data output from ASCEND's initial value solver
222 LSODE is discussed in Chapter
223 \begin_inset space ~
224 \end_inset
225
226
227 \begin_inset CommandInset ref
228 LatexCommand vref
229 reference "cha:ivp"
230
231 \end_inset
232
233 .
234 \end_layout
235
236 \begin_layout Standard
237 Chemical engineers who can tolerate distillation models should visit the
238 file
239 \family typewriter
240 plotcol.a4c
241 \family default
242 in the models library for more complicated examples of plotting and visit
243 the model
244 \family typewriter
245 simple_column_profiles
246 \family default
247
248 \begin_inset Index idx
249 status collapsed
250
251 \begin_layout Plain Layout
252 simple
253 \begin_inset ERT
254 status collapsed
255
256 \begin_layout Plain Layout
257
258
259 \backslash
260 _
261 \end_layout
262
263 \end_inset
264
265 column
266 \begin_inset ERT
267 status collapsed
268
269 \begin_layout Plain Layout
270
271
272 \backslash
273 _
274 \end_layout
275
276 \end_inset
277
278 profiles
279 \end_layout
280
281 \end_inset
282
283 in
284 \family typewriter
285 column.a4l
286 \family default
287
288 \begin_inset Index idx
289 status collapsed
290
291 \begin_layout Plain Layout
292 column.a4l
293 \end_layout
294
295 \end_inset
296
297 for more complicated examples of sampling data.
298 Reading this chapter first may be of help in interpreting those models.
299 \end_layout
300
301 \begin_layout Section
302 The graph we want
303 \end_layout
304
305 \begin_layout Standard
306 We want to plot the positions X1 to X3 of the connecting hooks h1, h2, and
307 h3 in a mechanical system as shown in Figure
308 \begin_inset space ~
309 \end_inset
310
311
312 \begin_inset CommandInset ref
313 LatexCommand ref
314 reference "fig:plot.springSystem"
315
316 \end_inset
317
318
319 \noun off
320 .
321 The anchor, hooks, springs, and finger (we could replace either spring
322 with a block mass, also) are all separate objects which we have modeled
323 very simply.
324 These models are given at the end of the chapter and can also be found
325 (with improvements) in
326 \family typewriter
327 \noun default
328 force1d.a4c
329 \begin_inset Index idx
330 status collapsed
331
332 \begin_layout Plain Layout
333 force1d.a4c
334 \end_layout
335
336 \end_inset
337
338
339 \family default
340 \noun off
341 , a model file in the distributed ASCEND libraries.
342
343 \end_layout
344
345 \begin_layout Standard
346 \begin_inset Float figure
347 wide false
348 sideways false
349 status open
350
351 \begin_layout Plain Layout
352
353 \noun off
354 \begin_inset space ~
355 \end_inset
356
357
358 \begin_inset space ~
359 \end_inset
360
361
362 \begin_inset space ~
363 \end_inset
364
365
366 \begin_inset space ~
367 \end_inset
368
369
370 \begin_inset space ~
371 \end_inset
372
373
374 \begin_inset space ~
375 \end_inset
376
377
378 \begin_inset space ~
379 \end_inset
380
381
382 \begin_inset space ~
383 \end_inset
384
385
386 \begin_inset space ~
387 \end_inset
388
389
390 \begin_inset space ~
391 \end_inset
392
393
394 \begin_inset space ~
395 \end_inset
396
397
398 \begin_inset space ~
399 \end_inset
400
401
402 \begin_inset space ~
403 \end_inset
404
405
406 \begin_inset space ~
407 \end_inset
408
409
410 \begin_inset space ~
411 \end_inset
412
413
414 \begin_inset space ~
415 \end_inset
416
417
418 \begin_inset space ~
419 \end_inset
420
421
422 \begin_inset space ~
423 \end_inset
424
425
426 \begin_inset space ~
427 \end_inset
428
429
430 \begin_inset space ~
431 \end_inset
432
433
434 \begin_inset space ~
435 \end_inset
436
437
438 \begin_inset space ~
439 \end_inset
440
441
442 \begin_inset space ~
443 \end_inset
444
445
446 \begin_inset space ~
447 \end_inset
448
449
450 \begin_inset space ~
451 \end_inset
452
453
454 \begin_inset space ~
455 \end_inset
456
457
458 \begin_inset Graphics
459 filename howto-plotFig1.eps
460 scale 80
461 BoundingBox 0bp 0bp 400bp 200bp
462
463 \end_inset
464
465
466 \end_layout
467
468 \begin_layout Plain Layout
469 \begin_inset Caption Standard
470
471 \begin_layout Plain Layout
472 Spring test model
473 \begin_inset Index idx
474 status collapsed
475
476 \begin_layout Plain Layout
477 spring test model
478 \end_layout
479
480 \end_inset
481
482 system,
483 \family typewriter
484 st
485 \family default
486
487 \begin_inset CommandInset label
488 LatexCommand label
489 name "fig:plot.springSystem"
490
491 \end_inset
492
493
494 \end_layout
495
496 \end_inset
497
498
499 \end_layout
500
501 \end_inset
502
503
504 \end_layout
505
506 \begin_layout Standard
507 Plotting is usually a post-solution analysis
508 \begin_inset Index idx
509 status collapsed
510
511 \begin_layout Plain Layout
512 post-solution analysis
513 \end_layout
514
515 \end_inset
516
517 tool, so our plots should not be entangled with the basic models or with
518 the total mechanical system model,
519 \family typewriter
520 st
521 \family default
522 .
523 We might want to explain the system
524 \family typewriter
525 st
526 \family default
527 to someone and this could be hard to do if the code is cluttered up with
528 plot information.
529 \end_layout
530
531 \begin_layout Section
532 Constructing a plot curve
533 \end_layout
534
535 \begin_layout Standard
536 The plot library models follow object-oriented thinking carefully, perhaps
537 a little too carefully.
538 A
539 \family typewriter
540 plt_plot_integer
541 \family default
542 is a plottable model built out of plt_curves which are in turn built out
543 of arrays of data points from the user.
544 Constructing these data arrays is the only significant challenge in using
545 the plot models.
546 Begin by building a new model with the system st as a part:
547 \end_layout
548
549 \begin_layout LyX-Code
550 MODEL plot_spring_test;
551 \end_layout
552
553 \begin_layout LyX-Code
554 st IS_A spring_test;
555 \end_layout
556
557 \begin_layout LyX-Code
558 Plot_X IS_A plt_plot_integer(curve_set,curves);
559 \end_layout
560
561 \begin_layout LyX-Code
562 END plot_spring_test;
563 \end_layout
564
565 \begin_layout Standard
566 We want to create a
567 \family typewriter
568 plt_curve
569 \family default
570 from the array of hook numbers
571 \family typewriter
572 y_data[1..3]
573 \family default
574 plotted against horizontal hook position
575 \family typewriter
576 x_data[1..3]
577 \family default
578 .
579 There are obvious problems with the model above:
580 \family typewriter
581 curves
582 \family default
583 and
584 \family typewriter
585 curve_set
586 \family default
587 are used without being defined, and there is no mention of
588 \family typewriter
589 x_data
590 \family default
591 or
592 \family typewriter
593 y_data
594 \family default
595 .
596
597 \end_layout
598
599 \begin_layout Standard
600 Begin by using an ALIASES
601 \begin_inset Index idx
602 status collapsed
603
604 \begin_layout Plain Layout
605 ALIASES
606 \end_layout
607
608 \end_inset
609
610 /IS_A statement to construct the array of positions
611 \family typewriter
612 x_data
613 \family default
614 from the variables X stored in the hooks of model
615 \family typewriter
616 st
617 \family default
618 .
619 \end_layout
620
621 \begin_layout LyX-Code
622 x_data[Xset] ALIASES (st.h1.X,st.h2.X,st.h3.X)
623 \end_layout
624
625 \begin_layout LyX-Code
626 WHERE Xset IS_A set OF integer_constant;
627 \end_layout
628
629 \begin_layout Standard
630 This statement creates a set,
631 \family typewriter
632 Xset
633 \family default
634 , indexing a new array
635 \family typewriter
636 x_data
637 \family default
638 with elements collected from
639 \family typewriter
640 st
641 \family default
642 .
643 Since the value of
644 \family typewriter
645 Xset
646 \family default
647 is not specified, it becomes by default the set [1,2,3].
648 \end_layout
649
650 \begin_layout Standard
651 Now we need the hook numbers,
652 \family typewriter
653 y_data
654 \family default
655 .
656 These do not exist in
657 \family typewriter
658 st
659 \family default
660 , so we create them.
661 We will set the numeric values of these in the
662 \family typewriter
663 default_self
664 \family default
665 method.
666 We will include method in the final model, but do not show it here.
667 \end_layout
668
669 \begin_layout LyX-Code
670 y_data[Xset] IS_A real;
671 \end_layout
672
673 \begin_layout Standard
674 Having both
675 \family typewriter
676 y_data
677 \family default
678 and
679 \family typewriter
680 x_data
681 \family default
682 , we can construct a curve from them:
683 \end_layout
684
685 \begin_layout LyX-Code
686 X_curve IS_A plt_curve(Xset,y_data,x_data);
687 \end_layout
688
689 \begin_layout Section
690 Constructing the array of curves
691 \end_layout
692
693 \begin_layout Standard
694 We have a curve, but the
695 \family typewriter
696 plt_plot_integer
697 \family default
698 model
699 \family typewriter
700 Plot_x
701 \family default
702 expects an array of curves and the set indexing this array as input.
703 We can make both from
704 \family typewriter
705 X_curve
706 \family default
707 easily using, once again, an ALIASES/IS_A statement.
708 \end_layout
709
710 \begin_layout LyX-Code
711 curves[curve_set] ALIASES (X_curve)
712 \end_layout
713
714 \begin_layout LyX-Code
715 WHERE curve_set IS_A set OF integer_constant;
716 \end_layout
717
718 \begin_layout Standard
719 All the pieces are now in place, so we have the final model:
720 \end_layout
721
722 \begin_layout LyX-Code
723 MODEL plot_spring_test;
724 \end_layout
725
726 \begin_layout LyX-Code
727
728 \end_layout
729
730 \begin_layout LyX-Code
731 (* create our system model and plot.
732 *)
733 \end_layout
734
735 \begin_layout LyX-Code
736 st IS_A spring_test;
737 \end_layout
738
739 \begin_layout LyX-Code
740 Plot_X IS_A plt_plot_integer(curve_set,curves);
741 \end_layout
742
743 \begin_layout LyX-Code
744
745 \end_layout
746
747 \begin_layout LyX-Code
748 (* Gather the sampled data into an array *)
749 \end_layout
750
751 \begin_layout LyX-Code
752 x_data[Xset] ALIASES (st.h1.X,st.h2.X,st.h3.X)
753 \end_layout
754
755 \begin_layout LyX-Code
756 WHERE Xset IS_A set OF integer_constant;
757 \end_layout
758
759 \begin_layout LyX-Code
760 (* Create the Y coordinates *)
761 \end_layout
762
763 \begin_layout LyX-Code
764 y_data[Xset] IS_A real;
765 \end_layout
766
767 \begin_layout LyX-Code
768
769 \end_layout
770
771 \begin_layout LyX-Code
772 (* create the curve *)
773 \end_layout
774
775 \begin_layout LyX-Code
776 X_curve IS_A plt_curve(Xset,y_data,x_data);
777 \end_layout
778
779 \begin_layout LyX-Code
780 (* Make X_curve into the array for plt_plot_integer *)
781 \end_layout
782
783 \begin_layout LyX-Code
784 curves[curve_set] ALIASES (X_curve) WHERE
785 \end_layout
786
787 \begin_layout LyX-Code
788 curve_set IS_A set OF integer_constant;
789 \end_layout
790
791 \begin_layout LyX-Code
792 METHOD default_self;
793 \end_layout
794
795 \begin_layout LyX-Code
796 RUN st.default_self;
797 \end_layout
798
799 \begin_layout LyX-Code
800 st.s1.L0 := 0.2{m}; (* make st more interesting *)
801 \end_layout
802
803 \begin_layout LyX-Code
804 RUN Plot_X.default_self;
805 \end_layout
806
807 \begin_layout LyX-Code
808 RUN X_curve.default_self;
809 \end_layout
810
811 \begin_layout LyX-Code
812 FOR i IN Xset DO
813 \end_layout
814
815 \begin_layout LyX-Code
816 y_data[i] := i;
817 \end_layout
818
819 \begin_layout LyX-Code
820 END FOR;
821 \end_layout
822
823 \begin_layout LyX-Code
824 X_curve.legend := 'meter';
825 \end_layout
826
827 \begin_layout LyX-Code
828 Plot_X.title := 'Hook locations';
829 \end_layout
830
831 \begin_layout LyX-Code
832 Plot_X.XLabel := 'location';
833 \end_layout
834
835 \begin_layout LyX-Code
836 Plot_X.YLabel := 'hook #';
837 \end_layout
838
839 \begin_layout LyX-Code
840 END default_self;
841 \end_layout
842
843 \begin_layout LyX-Code
844 END plot_spring_test;
845 \end_layout
846
847 \begin_layout Section
848 Resulting position plot
849 \end_layout
850
851 \begin_layout Standard
852 We can compile the plot model and obtain the graph in with the following
853 short script.
854 \end_layout
855
856 \begin_layout LyX-Code
857 READ FILE force1d.a4c;
858 \end_layout
859
860 \begin_layout LyX-Code
861 COMPILE pst OF plot_spring_test;
862 \end_layout
863
864 \begin_layout LyX-Code
865 BROWSE {pst};
866 \end_layout
867
868 \begin_layout LyX-Code
869 RUN {pst.st.reset};
870 \end_layout
871
872 \begin_layout LyX-Code
873 SOLVE {pst.st} WITH QRSlv;
874 \end_layout
875
876 \begin_layout LyX-Code
877 PLOT {pst.Plot_X} ;
878 \end_layout
879
880 \begin_layout LyX-Code
881 SHOW LAST;
882 \end_layout
883
884 \begin_layout Standard
885 We can also obtain the plot by moving to
886 \family typewriter
887 pst.Plot_X
888 \family default
889 in the Browser window and then pushing the Display
890 \begin_inset Formula $\rightarrow$
891 \end_inset
892
893 Plot button or then typing "Alt-d p".
894 We see the hooks are positioned near 0, 230, and 370 mm.
895 We also see that xgraph
896 \begin_inset Index idx
897 status collapsed
898
899 \begin_layout Plain Layout
900 xgraph
901 \end_layout
902
903 \end_inset
904
905 sometimes makes less than pretty graphs (Figure
906 \begin_inset CommandInset ref
907 LatexCommand ref
908 reference "fig:plot.plotXforSpring"
909
910 \end_inset
911
912 ).
913 \end_layout
914
915 \begin_layout Standard
916 \begin_inset Float figure
917 wide false
918 sideways false
919 status open
920
921 \begin_layout Plain Layout
922 \begin_inset Graphics
923 filename howto-plotFig2.eps
924 BoundingBox 30bp 0bp 480bp 460bp
925
926 \end_inset
927
928
929 \end_layout
930
931 \begin_layout Plain Layout
932 \begin_inset Caption Standard
933
934 \begin_layout Plain Layout
935 \begin_inset CommandInset label
936 LatexCommand label
937 name "fig:plot.plotXforSpring"
938
939 \end_inset
940
941 Plot_X in plot_spring_test
942 \end_layout
943
944 \end_inset
945
946
947 \end_layout
948
949 \end_inset
950
951
952 \end_layout
953
954 \begin_layout Section
955 1-D mechanical hook, spring, mass, anchor, and finger models
956 \end_layout
957
958 \begin_layout Standard
959 The models used in this chapter are very simple versions of masses and springs
960 horizontally at rest, but possibly under tension, stretched between an
961 anchor and a finger.
962 Only the code absolutely necessary for this example is given here; the
963 full code with methods and additional comments is given in
964 \family typewriter
965 force1d.a4c
966 \family default
967 , an ASCEND modeling example in the library.
968
969 \end_layout
970
971 \begin_layout Standard
972 These models could easily be extended to include mass, momentum, and acceleratio
973 n in two or three dimensions.
974 Most of the methods in the
975 \family typewriter
976 force1d.a4c
977 \family default
978 models are unedited from the code generated by the ASCEND Library button
979 Edit
980 \begin_inset Formula $\rightarrow$
981 \end_inset
982
983 Suggest method
984 \begin_inset Index idx
985 status collapsed
986
987 \begin_layout Plain Layout
988 method, Suggest method
989 \end_layout
990
991 \end_inset
992
993
994 \begin_inset Index idx
995 status collapsed
996
997 \begin_layout Plain Layout
998 Suggest method tool
999 \end_layout
1000
1001 \end_inset
1002
1003 .
1004 If you improve on these models, please share them with us and the rest
1005 of the ASCEND community.
1006 \end_layout
1007
1008 \begin_layout LyX-Code
1009 REQUIRE "atoms.a4l";
1010 \end_layout
1011
1012 \begin_layout LyX-Code
1013 CONSTANT spring_constant REFINES real_constant DIMENSION M/T^2;
1014 \end_layout
1015
1016 \begin_layout LyX-Code
1017 CONSTANT position_constant REFINES real_constant DIMENSION L;
1018 \end_layout
1019
1020 \begin_layout LyX-Code
1021 ATOM position REFINES distance DEFAULT 0{m};
1022 \end_layout
1023
1024 \begin_layout LyX-Code
1025 END position;
1026 \end_layout
1027
1028 \begin_layout LyX-Code
1029
1030 \end_layout
1031
1032 \begin_layout LyX-Code
1033 MODEL hook;
1034 \end_layout
1035
1036 \begin_layout LyX-Code
1037 F_left, F_right IS_A force;
1038 \end_layout
1039
1040 \begin_layout LyX-Code
1041 F_left = F_right;
1042 \end_layout
1043
1044 \begin_layout LyX-Code
1045 X IS_A position;
1046 \end_layout
1047
1048 \begin_layout LyX-Code
1049 METHODS
1050 \end_layout
1051
1052 \begin_layout LyX-Code
1053 METHOD default_self;
1054 \end_layout
1055
1056 \begin_layout LyX-Code
1057 (* ATOM defaults are fine *)
1058 \end_layout
1059
1060 \begin_layout LyX-Code
1061 END default_self;
1062 \end_layout
1063
1064 \begin_layout LyX-Code
1065 METHOD specify;
1066 \end_layout
1067
1068 \begin_layout LyX-Code
1069 F_right.fixed := TRUE;
1070 \end_layout
1071
1072 \begin_layout LyX-Code
1073 END specify;
1074 \end_layout
1075
1076 \begin_layout LyX-Code
1077 METHOD specify_float;
1078 \end_layout
1079
1080 \begin_layout LyX-Code
1081 END specify_float;
1082 \end_layout
1083
1084 \begin_layout LyX-Code
1085 END hook;
1086 \end_layout
1087
1088 \begin_layout LyX-Code
1089
1090 \end_layout
1091
1092 \begin_layout LyX-Code
1093 MODEL massless_spring(
1094 \end_layout
1095
1096 \begin_layout LyX-Code
1097 k IS_A spring_constant;
1098 \end_layout
1099
1100 \begin_layout LyX-Code
1101 h_left WILL_BE hook;
1102 \end_layout
1103
1104 \begin_layout LyX-Code
1105 h_right WILL_BE hook;
1106 \end_layout
1107
1108 \begin_layout LyX-Code
1109 ) WHERE (
1110 \end_layout
1111
1112 \begin_layout LyX-Code
1113 h_left, h_right WILL_NOT_BE_THE_SAME;
1114 \end_layout
1115
1116 \begin_layout LyX-Code
1117 );
1118 \end_layout
1119
1120 \begin_layout LyX-Code
1121 L0, dx IS_A distance;
1122 \end_layout
1123
1124 \begin_layout LyX-Code
1125 h_right.X = h_left.X + L0 + dx;
1126 \end_layout
1127
1128 \begin_layout LyX-Code
1129 F = k * dx;
1130 \end_layout
1131
1132 \begin_layout LyX-Code
1133 h_left.F_right = F;
1134 \end_layout
1135
1136 \begin_layout LyX-Code
1137 h_right.F_left = F;
1138 \end_layout
1139
1140 \begin_layout LyX-Code
1141 F IS_A force;
1142 \end_layout
1143
1144 \begin_layout LyX-Code
1145 METHODS
1146 \end_layout
1147
1148 \begin_layout LyX-Code
1149 METHOD default_self;
1150 \end_layout
1151
1152 \begin_layout LyX-Code
1153 dx := 1{cm};
1154 \end_layout
1155
1156 \begin_layout LyX-Code
1157 L0 := 10{cm};
1158 \end_layout
1159
1160 \begin_layout LyX-Code
1161 END default_self;
1162 \end_layout
1163
1164 \begin_layout LyX-Code
1165 METHOD specify;
1166 \end_layout
1167
1168 \begin_layout LyX-Code
1169 L0.fixed := TRUE;
1170 \end_layout
1171
1172 \begin_layout LyX-Code
1173 RUN h_left.reset;
1174 \end_layout
1175
1176 \begin_layout LyX-Code
1177 RUN h_right.reset;
1178 \end_layout
1179
1180 \begin_layout LyX-Code
1181 h_left.F_right.fixed := FALSE;
1182 \end_layout
1183
1184 \begin_layout LyX-Code
1185 h_left.X.fixed := TRUE;
1186 \end_layout
1187
1188 \begin_layout LyX-Code
1189 END specify;
1190 \end_layout
1191
1192 \begin_layout LyX-Code
1193 METHOD specify_float;
1194 \end_layout
1195
1196 \begin_layout LyX-Code
1197 L0.fixed := TRUE;
1198 \end_layout
1199
1200 \begin_layout LyX-Code
1201 RUN h_left.specify_float;
1202 \end_layout
1203
1204 \begin_layout LyX-Code
1205 RUN h_right.specify_float;
1206 \end_layout
1207
1208 \begin_layout LyX-Code
1209 END specify_float;
1210 \end_layout
1211
1212 \begin_layout LyX-Code
1213 END massless_spring;
1214 \end_layout
1215
1216 \begin_layout LyX-Code
1217
1218 \end_layout
1219
1220 \begin_layout LyX-Code
1221 MODEL massless_block(
1222 \end_layout
1223
1224 \begin_layout LyX-Code
1225 h_left WILL_BE hook;
1226 \end_layout
1227
1228 \begin_layout LyX-Code
1229 h_right WILL_BE hook;
1230 \end_layout
1231
1232 \begin_layout LyX-Code
1233 ) WHERE (
1234 \end_layout
1235
1236 \begin_layout LyX-Code
1237 h_left, h_right WILL_NOT_BE_THE_SAME;
1238 \end_layout
1239
1240 \begin_layout LyX-Code
1241 );
1242 \end_layout
1243
1244 \begin_layout LyX-Code
1245 width IS_A distance;
1246 \end_layout
1247
1248 \begin_layout LyX-Code
1249 h_left.F_right = h_right.F_left;
1250 \end_layout
1251
1252 \begin_layout LyX-Code
1253 h_right.X = h_left.X + width;
1254 \end_layout
1255
1256 \begin_layout LyX-Code
1257 X "center of the block" IS_A position;
1258 \end_layout
1259
1260 \begin_layout LyX-Code
1261 X = width/2 + h_left.X;
1262 \end_layout
1263
1264 \begin_layout LyX-Code
1265 METHODS
1266 \end_layout
1267
1268 \begin_layout LyX-Code
1269 METHOD default_self;
1270 \end_layout
1271
1272 \begin_layout LyX-Code
1273 width := 3{cm};
1274 \end_layout
1275
1276 \begin_layout LyX-Code
1277 END default_self;
1278 \end_layout
1279
1280 \begin_layout LyX-Code
1281 METHOD specify;
1282 \end_layout
1283
1284 \begin_layout LyX-Code
1285 width.fixed := TRUE;
1286 \end_layout
1287
1288 \begin_layout LyX-Code
1289 RUN h_left.reset;
1290 \end_layout
1291
1292 \begin_layout LyX-Code
1293 h_left.F_right.fixed := FALSE;
1294 \end_layout
1295
1296 \begin_layout LyX-Code
1297 h_left.X.fixed := TRUE;
1298 \end_layout
1299
1300 \begin_layout LyX-Code
1301 RUN h_right.reset;
1302 \end_layout
1303
1304 \begin_layout LyX-Code
1305 END specify;
1306 \end_layout
1307
1308 \begin_layout LyX-Code
1309 METHOD specify_float;
1310 \end_layout
1311
1312 \begin_layout LyX-Code
1313 width.fixed := TRUE;
1314 \end_layout
1315
1316 \begin_layout LyX-Code
1317 RUN h_left.specify_float;
1318 \end_layout
1319
1320 \begin_layout LyX-Code
1321 RUN h_right.specify_float;
1322 \end_layout
1323
1324 \begin_layout LyX-Code
1325 END specify_float;
1326 \end_layout
1327
1328 \begin_layout LyX-Code
1329 END massless_block;
1330 \end_layout
1331
1332 \begin_layout LyX-Code
1333
1334 \end_layout
1335
1336 \begin_layout LyX-Code
1337 MODEL anchor(
1338 \end_layout
1339
1340 \begin_layout LyX-Code
1341 x IS_A position_constant;
1342 \end_layout
1343
1344 \begin_layout LyX-Code
1345 h_right WILL_BE hook;
1346 \end_layout
1347
1348 \begin_layout LyX-Code
1349 );
1350 \end_layout
1351
1352 \begin_layout LyX-Code
1353 h_right.X = x;
1354 \end_layout
1355
1356 \begin_layout LyX-Code
1357 F = h_right.F_left;
1358 \end_layout
1359
1360 \begin_layout LyX-Code
1361 F IS_A force;
1362 \end_layout
1363
1364 \begin_layout LyX-Code
1365 METHODS
1366 \end_layout
1367
1368 \begin_layout LyX-Code
1369 METHOD default_self;
1370 \end_layout
1371
1372 \begin_layout LyX-Code
1373 END default_self;
1374 \end_layout
1375
1376 \begin_layout LyX-Code
1377 METHOD specify;
1378 \end_layout
1379
1380 \begin_layout LyX-Code
1381 RUN h_right.reset;
1382 \end_layout
1383
1384 \begin_layout LyX-Code
1385 END specify;
1386 \end_layout
1387
1388 \begin_layout LyX-Code
1389 METHOD specify_float;
1390 \end_layout
1391
1392 \begin_layout LyX-Code
1393 END specify_float;
1394 \end_layout
1395
1396 \begin_layout LyX-Code
1397 END anchor;
1398 \end_layout
1399
1400 \begin_layout LyX-Code
1401
1402 \end_layout
1403
1404 \begin_layout LyX-Code
1405 MODEL finger(
1406 \end_layout
1407
1408 \begin_layout LyX-Code
1409 h1 WILL_BE hook;
1410 \end_layout
1411
1412 \begin_layout LyX-Code
1413 );
1414 \end_layout
1415
1416 \begin_layout LyX-Code
1417 pull IS_A force;
1418 \end_layout
1419
1420 \begin_layout LyX-Code
1421 h1.F_right = pull;
1422 \end_layout
1423
1424 \begin_layout LyX-Code
1425 METHODS
1426 \end_layout
1427
1428 \begin_layout LyX-Code
1429 METHOD default_self;
1430 \end_layout
1431
1432 \begin_layout LyX-Code
1433 pull := 3{N};
1434 \end_layout
1435
1436 \begin_layout LyX-Code
1437 END default_self;
1438 \end_layout
1439
1440 \begin_layout LyX-Code
1441 END finger;
1442 \end_layout
1443
1444 \begin_layout LyX-Code
1445
1446 \end_layout
1447
1448 \begin_layout LyX-Code
1449 MODEL finger_test;
1450 \end_layout
1451
1452 \begin_layout LyX-Code
1453 NOTES 'ascii-picture' SELF {
1454 \end_layout
1455
1456 \begin_layout LyX-Code
1457 ___ __
1458 \end_layout
1459
1460 \begin_layout LyX-Code
1461
1462 \backslash
1463
1464 \backslash
1465 --O--/
1466 \backslash
1467 /
1468 \backslash
1469 /
1470 \backslash
1471 /
1472 \backslash
1473 /
1474 \backslash
1475 /--O--| |--O(_
1476 \backslash
1477
1478 \end_layout
1479
1480 \begin_layout LyX-Code
1481 |___|
1482 \backslash
1483
1484 \backslash
1485
1486 \end_layout
1487
1488 \begin_layout LyX-Code
1489 (reference)-h1-(s1)-h2-(m1)-h3-(pinky)
1490 \end_layout
1491
1492 \begin_layout LyX-Code
1493 }
1494 \end_layout
1495
1496 \begin_layout LyX-Code
1497 END NOTES;
1498 \end_layout
1499
1500 \begin_layout LyX-Code
1501 h1 IS_A hook;
1502 \end_layout
1503
1504 \begin_layout LyX-Code
1505 s1 IS_A massless_spring(100{kg/s^2},h1,h2);
1506 \end_layout
1507
1508 \begin_layout LyX-Code
1509 h2 IS_A hook;
1510 \end_layout
1511
1512 \begin_layout LyX-Code
1513 m1 IS_A massless_block(h2,h3);
1514 \end_layout
1515
1516 \begin_layout LyX-Code
1517 h3 IS_A hook;
1518 \end_layout
1519
1520 \begin_layout LyX-Code
1521 pinky IS_A finger(h3);
1522 \end_layout
1523
1524 \begin_layout LyX-Code
1525 METHODS
1526 \end_layout
1527
1528 \begin_layout LyX-Code
1529 METHOD default_self;
1530 \end_layout
1531
1532 \begin_layout LyX-Code
1533 RUN h1.default_self;
1534 \end_layout
1535
1536 \begin_layout LyX-Code
1537 RUN h2.default_self;
1538 \end_layout
1539
1540 \begin_layout LyX-Code
1541 RUN h3.default_self;
1542 \end_layout
1543
1544 \begin_layout LyX-Code
1545 RUN m1.default_self;
1546 \end_layout
1547
1548 \begin_layout LyX-Code
1549 RUN pinky.default_self;
1550 \end_layout
1551
1552 \begin_layout LyX-Code
1553 RUN reference.default_self;
1554 \end_layout
1555
1556 \begin_layout LyX-Code
1557 RUN s1.default_self;
1558 \end_layout
1559
1560 \begin_layout LyX-Code
1561 END default_self;
1562 \end_layout
1563
1564 \begin_layout LyX-Code
1565 METHOD specify;
1566 \end_layout
1567
1568 \begin_layout LyX-Code
1569 RUN m1.specify_float;
1570 \end_layout
1571
1572 \begin_layout LyX-Code
1573 RUN pinky.reset;
1574 \end_layout
1575
1576 \begin_layout LyX-Code
1577 RUN reference.specify_float;
1578 \end_layout
1579
1580 \begin_layout LyX-Code
1581 RUN s1.specify_float;
1582 \end_layout
1583
1584 \begin_layout LyX-Code
1585 END specify;
1586 \end_layout
1587
1588 \begin_layout LyX-Code
1589 END finger_test;
1590 \end_layout
1591
1592 \begin_layout LyX-Code
1593
1594 \end_layout
1595
1596 \begin_layout LyX-Code
1597 MODEL spring_test;
1598 \end_layout
1599
1600 \begin_layout LyX-Code
1601 NOTES 'ascii-picture' SELF {
1602 \end_layout
1603
1604 \begin_layout LyX-Code
1605
1606 \backslash
1607
1608 \backslash
1609 --O--/
1610 \backslash
1611 /
1612 \backslash
1613 /
1614 \backslash
1615 /
1616 \backslash
1617 /
1618 \backslash
1619 /--O--
1620 \backslash
1621 /
1622 \backslash
1623 /
1624 \backslash
1625 --O(
1626 \backslash
1627
1628 \end_layout
1629
1630 \begin_layout LyX-Code
1631 (reference)-h1-(s1)-h2-(s2)-h3-(pinky)
1632 \end_layout
1633
1634 \begin_layout LyX-Code
1635 }
1636 \end_layout
1637
1638 \begin_layout LyX-Code
1639 END NOTES;
1640 \end_layout
1641
1642 \begin_layout LyX-Code
1643 reference IS_A anchor(0.0{m},h1);
1644 \end_layout
1645
1646 \begin_layout LyX-Code
1647 h1 IS_A hook;
1648 \end_layout
1649
1650 \begin_layout LyX-Code
1651 s1 IS_A massless_spring(100{kg/s^2},h1,h2);
1652 \end_layout
1653
1654 \begin_layout LyX-Code
1655 h2 IS_A hook;
1656 \end_layout
1657
1658 \begin_layout LyX-Code
1659 s2 IS_A massless_spring(75{kg/s^2},h2,h3);
1660 \end_layout
1661
1662 \begin_layout LyX-Code
1663 h3 IS_A hook;
1664 \end_layout
1665
1666 \begin_layout LyX-Code
1667 pinky IS_A finger(h3);
1668 \end_layout
1669
1670 \begin_layout LyX-Code
1671 METHODS
1672 \end_layout
1673
1674 \begin_layout LyX-Code
1675 METHOD default_self;
1676 \end_layout
1677
1678 \begin_layout LyX-Code
1679 RUN h1.default_self;
1680 \end_layout
1681
1682 \begin_layout LyX-Code
1683 RUN h2.default_self;
1684 \end_layout
1685
1686 \begin_layout LyX-Code
1687 RUN h3.default_self;
1688 \end_layout
1689
1690 \begin_layout LyX-Code
1691 RUN s2.default_self;
1692 \end_layout
1693
1694 \begin_layout LyX-Code
1695 RUN pinky.default_self;
1696 \end_layout
1697
1698 \begin_layout LyX-Code
1699 RUN reference.default_self;
1700 \end_layout
1701
1702 \begin_layout LyX-Code
1703 RUN s1.default_self;
1704 \end_layout
1705
1706 \begin_layout LyX-Code
1707 END default_self;
1708 \end_layout
1709
1710 \begin_layout LyX-Code
1711 METHOD specify;
1712 \end_layout
1713
1714 \begin_layout LyX-Code
1715 RUN pinky.reset;
1716 \end_layout
1717
1718 \begin_layout LyX-Code
1719 RUN reference.specify_float;
1720 \end_layout
1721
1722 \begin_layout LyX-Code
1723 RUN s1.specify_float;
1724 \end_layout
1725
1726 \begin_layout LyX-Code
1727 RUN s2.specify_float;
1728 \end_layout
1729
1730 \begin_layout LyX-Code
1731 END specify;
1732 \end_layout
1733
1734 \begin_layout LyX-Code
1735 END spring_test;
1736 \end_layout
1737
1738 \begin_layout LyX-Code
1739
1740 \end_layout
1741
1742 \begin_layout LyX-Code
1743 REQUIRE "plot.a4l";
1744 \end_layout
1745
1746 \begin_layout LyX-Code
1747 MODEL plot_spring_test;
1748 \end_layout
1749
1750 \begin_layout LyX-Code
1751
1752 \end_layout
1753
1754 \begin_layout LyX-Code
1755 (* create our model *)
1756 \end_layout
1757
1758 \begin_layout LyX-Code
1759 st IS_A spring_test;
1760 \end_layout
1761
1762 \begin_layout LyX-Code
1763
1764 \end_layout
1765
1766 \begin_layout LyX-Code
1767 (* Now gather the sampled data into an array for plotting *)
1768 \end_layout
1769
1770 \begin_layout LyX-Code
1771 x_data[Xset] ALIASES (st.h1.X,st.h2.X,st.h3.X)
1772 \end_layout
1773
1774 \begin_layout LyX-Code
1775 WHERE Xset IS_A set OF integer_constant;
1776 \end_layout
1777
1778 \begin_layout LyX-Code
1779
1780 \end_layout
1781
1782 \begin_layout LyX-Code
1783 (* Now create the Y coordinates of the plot since there is no
1784 \end_layout
1785
1786 \begin_layout LyX-Code
1787 * natural Y coordinate in our MODEL.
1788 \end_layout
1789
1790 \begin_layout LyX-Code
1791 *)
1792 \end_layout
1793
1794 \begin_layout LyX-Code
1795 y_data[Xset] IS_A real; (* all will be assigned to 1.0 *)
1796 \end_layout
1797
1798 \begin_layout LyX-Code
1799
1800 \end_layout
1801
1802 \begin_layout LyX-Code
1803 X_curve IS_A plt_curve(Xset,y_data,x_data);
1804 \end_layout
1805
1806 \begin_layout LyX-Code
1807
1808 \end_layout
1809
1810 \begin_layout LyX-Code
1811 (* Make X_curve into the expected array for plt_plot *)
1812 \end_layout
1813
1814 \begin_layout LyX-Code
1815 curves[curve_set] ALIASES (X_curve) WHERE
1816 \end_layout
1817
1818 \begin_layout LyX-Code
1819 curve_set IS_A set OF integer_constant;
1820 \end_layout
1821
1822 \begin_layout LyX-Code
1823
1824 \end_layout
1825
1826 \begin_layout LyX-Code
1827 Plot_X IS_A plt_plot_integer(curve_set,curves);
1828 \end_layout
1829
1830 \begin_layout LyX-Code
1831 METHODS
1832 \end_layout
1833
1834 \begin_layout LyX-Code
1835 METHOD default_self;
1836 \end_layout
1837
1838 \begin_layout LyX-Code
1839 RUN st.default_self;
1840 \end_layout
1841
1842 \begin_layout LyX-Code
1843 st.s1.L0 := 0.2{m};
1844 \end_layout
1845
1846 \begin_layout LyX-Code
1847 RUN X_curve.default_self;
1848 \end_layout
1849
1850 \begin_layout LyX-Code
1851 RUN Plot_X.default_self;
1852 \end_layout
1853
1854 \begin_layout LyX-Code
1855 FOR i IN Xset DO
1856 \end_layout
1857
1858 \begin_layout LyX-Code
1859 y_data[i] := i;
1860 \end_layout
1861
1862 \begin_layout LyX-Code
1863 END FOR;
1864 \end_layout
1865
1866 \begin_layout LyX-Code
1867 X_curve.legend := 'meter';
1868 \end_layout
1869
1870 \begin_layout LyX-Code
1871 Plot_X.title := 'Hook locations';
1872 \end_layout
1873
1874 \begin_layout LyX-Code
1875 Plot_X.XLabel := 'location {m}';
1876 \end_layout
1877
1878 \begin_layout LyX-Code
1879 Plot_X.YLabel := 'hook #';
1880 \end_layout
1881
1882 \begin_layout LyX-Code
1883 END default_self;
1884 \end_layout
1885
1886 \begin_layout LyX-Code
1887 END plot_spring_test;
1888 \end_layout
1889
1890 \begin_layout Standard
1891
1892 \end_layout
1893
1894 \end_body
1895 \end_document

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