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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1352 - (show annotations) (download) (as text)
Sat Mar 17 23:48:07 2007 UTC (16 years, 6 months ago) by jpye
File MIME type: application/x-lyx
File size: 59235 byte(s)
Added some references to items in the ASCEND bibliography
1 #LyX 1.4.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 245
3 \begin_document
4 \begin_header
5 \textclass book
6 \language english
7 \inputencoding auto
8 \fontscheme default
9 \graphics default
10 \paperfontsize default
11 \spacing single
12 \papersize a4paper
13 \use_geometry false
14 \use_amsmath 2
15 \cite_engine basic
16 \use_bibtopic false
17 \paperorientation portrait
18 \secnumdepth 3
19 \tocdepth 3
20 \paragraph_separation indent
21 \defskip medskip
22 \quotes_language english
23 \papercolumns 1
24 \papersides 2
25 \paperpagestyle default
26 \tracking_changes false
27 \output_changes true
28 \end_header
29
30 \begin_body
31
32 \begin_layout Chapter
33 Preparing a model for reuse
34 \begin_inset LatexCommand \index{reuse}
35
36 \end_inset
37
38
39 \begin_inset LatexCommand \label{cha:model2}
40
41 \end_inset
42
43
44 \end_layout
45
46 \begin_layout Standard
47 There are four major ways to prepare a model for reuse.
48 First, you should add comments to a model.
49 Second, you should add methods to a model definition to pass to a future
50 user your experience in creating an instance of this type which is well-posed.
51 Third, you should parameterize the model type definition to alert a future
52 user as to which parts of this model you deem to be the most likely to
53 be shared.
54 And fourth, you should prepare a script that a future user can run to solve
55 a sample problem involving an instance of the model.
56 We shall consider each of these items in turn in what follows.
57 \begin_inset Foot
58 status open
59
60 \begin_layout Standard
61 More detail on these is available in papers and reports by Allan, Zaher,
62 Chittur et al
63 \begin_inset LatexCommand \cite{Allan1997d}
64
65 \end_inset
66
67 ,
68 \begin_inset LatexCommand \cite{Allan1997b}
69
70 \end_inset
71
72 ,
73 \begin_inset LatexCommand \cite{Allan1997}
74
75 \end_inset
76
77 ,
78 \begin_inset LatexCommand \cite{Krishnan1993}
79
80 \end_inset
81
82 ,
83 \begin_inset LatexCommand \cite{Zaher1991}
84
85 \end_inset
86
87 .
88 \end_layout
89
90 \end_inset
91
92
93 \end_layout
94
95 \begin_layout Section
96 Adding comments
97 \begin_inset LatexCommand \index{comments}
98
99 \end_inset
100
101 and notes
102 \begin_inset LatexCommand \index{notes}
103
104 \end_inset
105
106
107 \end_layout
108
109 \begin_layout Standard
110 In ASCEND we can create traditional comments for a model -- i.e., add text
111 to the code that aids anyone looking at the code to understand what is
112 there.
113 We do this by enclosing text with the delimiters
114 \family typewriter
115 (*
116 \family default
117
118 \begin_inset LatexCommand \index{(*}
119
120 \end_inset
121
122 and
123 \family typewriter
124 *)
125 \family default
126
127 \begin_inset LatexCommand \index{*)}
128
129 \end_inset
130
131 .
132 Thus the line
133 \end_layout
134
135 \begin_layout LyX-Code
136 (* This is a comment *)
137 \end_layout
138
139 \begin_layout Standard
140 is a comment in ASCEND.
141 Traditional comments are only visible when we display the code using the
142 Display code tool
143 \begin_inset LatexCommand \index{Display code tool}
144
145 \end_inset
146
147
148 \begin_inset LatexCommand \index{tool, Display code}
149
150 \end_inset
151
152 in the Library window or when we view the code in the text editor we used
153 to create it.
154
155 \end_layout
156
157 \begin_layout Standard
158 We suggest we can do more for the modeler with the concept of Notes, a form
159 of "active" comments available in ASCEND.
160 ASCEND has tools to extract notes and display them in searchable form.
161 \end_layout
162
163 \begin_layout Standard
164 \begin_inset Marginal
165 status collapsed
166
167 \begin_layout Standard
168 notes are active comments
169 \begin_inset LatexCommand \index{comments, active}
170
171 \end_inset
172
173
174 \end_layout
175
176 \end_inset
177
178 In Figure
179 \begin_inset LatexCommand \ref{fig:model2.vesselWithNotes}
180
181 \end_inset
182
183
184 \noun off
185 we show two types of notes the modeler can add.
186 Longer notes are set off in block style starting with the keyword
187 \family typewriter
188 \noun default
189 NOTES
190 \family default
191 \noun off
192 and ending with
193 \family typewriter
194 \noun default
195 END NOTES
196 \family default
197 \noun off
198 .
199 In this model, we declare two notes in this manner: (1) to indicate who
200 the author is and (2) to indicate the creation date for this model.
201 Note that the notes are director to documenting SELF, which is the model
202 itself -- i.e., the vessel model as a whole object.
203 The object one documents can be any instance in the model -- any variable,
204 equation or part.
205 The tools for handling notes can sort on the terms enclosed in single quotes
206 so one could, for example, isolate the author notes for all the models.
207 \end_layout
208
209 \begin_layout Standard
210 \begin_inset Float figure
211 wide false
212 sideways false
213 status open
214
215 \begin_layout LyX-Code
216 REQUIRE "atoms.a4l";
217 \end_layout
218
219 \begin_layout LyX-Code
220 MODEL vessel;
221 \end_layout
222
223 \begin_layout LyX-Code
224 NOTES
225 \end_layout
226
227 \begin_layout LyX-Code
228 'author'SELF {Arthur W.
229 Westerberg}
230 \end_layout
231
232 \begin_layout LyX-Code
233 'creation date' SELF {May, 1998}
234 \end_layout
235
236 \begin_layout LyX-Code
237 END NOTES;
238 \end_layout
239
240 \begin_layout LyX-Code
241 (* variables *)
242 \end_layout
243
244 \begin_layout LyX-Code
245 side_area "the area of the cylindrical side wall of the vessel",
246 \end_layout
247
248 \begin_layout LyX-Code
249 end_area "the area of the flat ends of the vessel"
250 \end_layout
251
252 \begin_layout LyX-Code
253 IS_A area;
254 \end_layout
255
256 \begin_layout LyX-Code
257 vessel_vol "the volume contained within the cylindrical vessel",
258 \end_layout
259
260 \begin_layout LyX-Code
261 wall_vol "the volume of the walls for the vessel"
262 \end_layout
263
264 \begin_layout LyX-Code
265 IS_A volume;
266 \end_layout
267
268 \begin_layout LyX-Code
269 wall_thickness "the thickness of all of the vessel walls",
270 \end_layout
271
272 \begin_layout LyX-Code
273 H "the vessel height (of the cylindrical side walls)",
274 \end_layout
275
276 \begin_layout LyX-Code
277 D "the vessel diameter"
278 \end_layout
279
280 \begin_layout LyX-Code
281 IS_A distance;
282 \end_layout
283
284 \begin_layout LyX-Code
285 H_to_D_ratio "the ratio of vessel height to diameter"
286 \end_layout
287
288 \begin_layout LyX-Code
289 IS_A factor;
290 \end_layout
291
292 \begin_layout LyX-Code
293 metal_density "density of the metal from which the vessel
294 \end_layout
295
296 \begin_layout LyX-Code
297 is constructed"
298 \end_layout
299
300 \begin_layout LyX-Code
301 IS_A mass_density;
302 \end_layout
303
304 \begin_layout LyX-Code
305 metal_mass "the mass of the metal in the walls of the vessel"
306 \end_layout
307
308 \begin_layout LyX-Code
309 IS_A mass;
310 \end_layout
311
312 \begin_layout LyX-Code
313 (* equations *)
314 \end_layout
315
316 \begin_layout LyX-Code
317 FlatEnds:end_area = 1{PI} * D^2 / 4;
318 \end_layout
319
320 \begin_layout LyX-Code
321 Sides:side_area = 1{PI} * D * H;
322 \end_layout
323
324 \begin_layout LyX-Code
325 Cylinder:vessel_vol = end_area * H;
326 \end_layout
327
328 \begin_layout LyX-Code
329 Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;
330 \end_layout
331
332 \begin_layout LyX-Code
333 HD_definition:D * H_to_D_ratio = H;
334 \end_layout
335
336 \begin_layout LyX-Code
337 VesselMass:metal_mass = metal_density * wall_vol;
338 \end_layout
339
340 \begin_layout LyX-Code
341 END vessel;
342 \end_layout
343
344 \begin_layout LyX-Code
345
346 \end_layout
347
348 \begin_layout LyX-Code
349 ADD NOTES IN vessel;
350 \end_layout
351
352 \begin_layout LyX-Code
353 'description' SELF {This model relates the dimensions of a
354 \end_layout
355
356 \begin_layout LyX-Code
357 cylindrical vessel -- e.g., diameter,
358 \end_layout
359
360 \begin_layout LyX-Code
361 height and wall thicknes to the volume of metal
362 \end_layout
363
364 \begin_layout LyX-Code
365 in the walls.
366 It uses a thin wall assumption
367 \end_layout
368
369 \begin_layout LyX-Code
370 -- i.e., that the volume of metal is the area of
371 \end_layout
372
373 \begin_layout LyX-Code
374 the vessel times the wall thickness.}
375 \end_layout
376
377 \begin_layout LyX-Code
378 'purpose' SELF {to illustrate the insertion of notes into a model}
379 \end_layout
380
381 \begin_layout LyX-Code
382 END NOTES;
383 \end_layout
384
385 \begin_layout Caption
386 Vessel model with Notes added (model vesselNotes.a4c
387 \begin_inset LatexCommand \index{vesselNotes.a4c}
388
389 \end_inset
390
391 )
392 \begin_inset LatexCommand \label{fig:model2.vesselWithNotes}
393
394 \end_inset
395
396
397 \end_layout
398
399 \end_inset
400
401
402 \end_layout
403
404 \begin_layout Standard
405 A user may use any term desired in the single quotes.
406 We have not decided yet what the better set of terms should be so we do
407 not as yet suggest any.
408 With time we expect the terms used to settle down to just a few that are
409 repeated for all the models in a library.
410 \end_layout
411
412 \begin_layout Standard
413 \begin_inset Marginal
414 status collapsed
415
416 \begin_layout Standard
417 there are short notes, long notes and separate notes
418 \end_layout
419
420 \end_inset
421
422 There are also short notes we can attach to every variable in the model.
423 A "one liner
424 \begin_inset LatexCommand \index{notes, one liner}
425
426 \end_inset
427
428
429 \begin_inset LatexCommand \index{one liner}
430
431 \end_inset
432
433 " in double quotes just following the variable name allows the automatic
434 annotation of variables in reports.
435 \end_layout
436
437 \begin_layout Standard
438 The last few lines of Figure
439 \begin_inset LatexCommand \ref{fig:model2.vesselWithNotes}
440
441 \end_inset
442
443
444 \noun off
445 shows adding notes we write in a separate ADD NOTES IN object
446 \begin_inset LatexCommand \index{ADD NOTES IN object}
447
448 \end_inset
449
450 .
451 This object can appear before or after or in a different file from the
452 object it describes.
453 This style of note writing is useful as it allows another person to add
454 notes to a model without changing the code for a model.
455 Thus it allows several different sets of notes to exist for a single model,
456 with the choice of which to use being up to the person maintaining the
457 model library.
458 Finally, it allows one to eliminate the "clutter" the documentation often
459 adds to the code.
460 \end_layout
461
462 \begin_layout Section
463 Adding methods
464 \begin_inset LatexCommand \index{methods, adding}
465
466 \end_inset
467
468
469 \begin_inset LatexCommand \index{adding methods}
470
471 \end_inset
472
473
474 \end_layout
475
476 \begin_layout Standard
477 We would next like to pass along our experiences in getting this model to
478 be well-posed -- i.e., we would like to tell future users which variables
479 we decided to fix and which we decided to calculate.
480 We would also like to provide some typical values for the variables we
481 decided to fix.
482 ASCEND allows us to attach any number of methods to a type definition.
483 Methods are procedural code that we can request be run through the interface
484 while browsing a model instance.
485 We shall include methods as described in Table
486 \begin_inset LatexCommand \ref{tab:model2.reqdMethods}
487
488 \end_inset
489
490
491 \noun off
492 to set just the right fixed flags and variable values for an instance of
493 our vessel model to be well-posed.
494 \end_layout
495
496 \begin_layout Standard
497 The system has defaults definitions for all these methods.
498 You already saw that to be true if you went through the process of setting
499 all the fixed flags to FALSE in the previous chapter.
500 In case you did not, load and compile the vesselPlain.a4c model in ASCEND.
501 Export the compiled instance to the Browser.
502 Then in the Browser, under the Edit button, select Run method.
503 You will see a list containing these and other methods we shall be describing
504 shortly.
505 Select specify and hit the OK button.
506 Then look in the Console window.
507 A message similar to the following will appear, with all but the first
508 line being in red to signify you should pay attention to the message:
509 \end_layout
510
511 \begin_layout LyX-Code
512 Running method specify in v
513 \end_layout
514
515 \begin_layout LyX-Code
516 Found STOP
517 \begin_inset LatexCommand \index{STOP}
518
519 \end_inset
520
521 statement in METHOD
522 \end_layout
523
524 \begin_layout LyX-Code
525 C:
526 \backslash
527 PROGRAM FILES
528 \backslash
529 ASCEND
530 \backslash
531 ASCEND4
532 \backslash
533 models
534 \backslash
535 basemodel.a4l:307
536 \end_layout
537
538 \begin_layout LyX-Code
539 STOP {Error
540 \begin_inset LatexCommand \index{error}
541
542 \end_inset
543
544 ! Standard method "specify" called but not
545 \end_layout
546
547 \begin_layout LyX-Code
548 written in MODEL.};
549 \end_layout
550
551 \begin_layout Standard
552 This message is telling you that you have just run the default specify method
553 \begin_inset LatexCommand \index{specify method, default}
554
555 \end_inset
556
557 .
558 We have to hand-craft every specify method so the default method is not
559 appropriate.
560 This message is alerting us to the fact that we did not yet write a special
561 specify method for this model type.
562 \end_layout
563
564 \begin_layout Standard
565 Try running the ClearAll
566 \begin_inset LatexCommand \index{ClearAll}
567
568 \end_inset
569
570 method.
571 The default ClearAll method is always the one you will want so it does
572 not put out a message to alert you that it is the default.
573
574 \end_layout
575
576 \begin_layout Standard
577 \begin_inset Float table
578 wide false
579 sideways false
580 status open
581
582 \begin_layout Caption
583 \begin_inset LatexCommand \label{tab:model2.reqdMethods}
584
585 \end_inset
586
587 Some of the methods
588 \begin_inset LatexCommand \index{methods, required}
589
590 \end_inset
591
592 we require for putting a model into an ASCEND library
593 \end_layout
594
595 \begin_layout Standard
596 \begin_inset Tabular
597 <lyxtabular version="3" rows="5" columns="2">
598 <features>
599 <column alignment="center" valignment="top" leftline="true" width="1.25in">
600 <column alignment="center" valignment="top" leftline="true" rightline="true" width="3.5in">
601 <row topline="true" bottomline="true">
602 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
603 \begin_inset Text
604
605 \begin_layout Standard
606
607 \end_layout
608
609 \end_inset
610 </cell>
611 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
612 \begin_inset Text
613
614 \begin_layout Standard
615
616 \end_layout
617
618 \end_inset
619 </cell>
620 </row>
621 <row topline="true">
622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
623 \begin_inset Text
624
625 \begin_layout Standard
626
627 \family typewriter
628 ClearAll
629 \family default
630
631 \begin_inset LatexCommand \index{ClearAll}
632
633 \end_inset
634
635
636 \end_layout
637
638 \end_inset
639 </cell>
640 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
641 \begin_inset Text
642
643 \begin_layout Standard
644 a method to set all the .fixed flags for variables in the type to FALSE.
645 This puts these flags into a known standard state -- i.e., all are FALSE.
646 All models inherit this method from the base model and the need to rewrite
647 it is very, very rare.
648 \end_layout
649
650 \end_inset
651 </cell>
652 </row>
653 <row topline="true">
654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
655 \begin_inset Text
656
657 \begin_layout Standard
658
659 \family typewriter
660 specify
661 \family default
662
663 \begin_inset LatexCommand \index{specify}
664
665 \end_inset
666
667
668 \end_layout
669
670 \end_inset
671 </cell>
672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
673 \begin_inset Text
674
675 \begin_layout Standard
676
677 \family roman
678 \series medium
679 \shape up
680 \size normal
681 \emph off
682 \bar no
683 \noun off
684 \color none
685 a method which assumes all the fixed flags are currently FALSE and which
686 then sets a suitable set of fixed flags to TRUE to make an instance of
687 this type of model well-posed.
688 A well-posed model is one that is square (n equations in n unknowns) and
689 solvable.
690 \end_layout
691
692 \end_inset
693 </cell>
694 </row>
695 <row topline="true">
696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
697 \begin_inset Text
698
699 \begin_layout Standard
700
701 \family typewriter
702 reset
703 \family default
704
705 \begin_inset LatexCommand \index{reset}
706
707 \end_inset
708
709
710 \end_layout
711
712 \end_inset
713 </cell>
714 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
715 \begin_inset Text
716
717 \begin_layout Standard
718
719 \family roman
720 \series medium
721 \shape up
722 \size normal
723 \emph off
724 \bar no
725 \noun off
726 \color none
727 a method which first runs the ClearAll method and then the specify method.
728 We include this method because it is very convenient.
729 We only have to run one method to make any simulation well-posed, no matter
730 how its fixed flags are currently set.
731 All models inherit this method from the base model, as with ClearAll .
732 It should only rarely have to be rewritten for a model.
733 \end_layout
734
735 \end_inset
736 </cell>
737 </row>
738 <row topline="true" bottomline="true">
739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
740 \begin_inset Text
741
742 \begin_layout Standard
743
744 \family typewriter
745 values
746 \family default
747
748 \begin_inset LatexCommand \index{values}
749
750 \end_inset
751
752
753 \end_layout
754
755 \end_inset
756 </cell>
757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
758 \begin_inset Text
759
760 \begin_layout Standard
761
762 \family roman
763 \series medium
764 \shape up
765 \size normal
766 \emph off
767 \bar no
768 \noun off
769 \color none
770 a method to establish typical values for the variables we have fixed in
771 an application or test model.
772 We may also supply values for some of the variables we will be computing
773 to aid in solving a model instance of this type.
774 These values reflectiveness that we have tested for a simulation of this
775 type and found to work.
776 \end_layout
777
778 \end_inset
779 </cell>
780 </row>
781 </lyxtabular>
782
783 \end_inset
784
785
786 \end_layout
787
788 \end_inset
789
790
791 \end_layout
792
793 \begin_layout Standard
794 \begin_inset Marginal
795 status collapsed
796
797 \begin_layout Standard
798 writing the specify and values methods
799 \end_layout
800
801 \end_inset
802
803 To write the
804 \family typewriter
805 specify
806 \family default
807 and
808 \family typewriter
809 values
810 \family default
811 methods for our vessel model, we note that we have successfully solved
812 the vessel model in at least two different ways above.
813 Thus both variations are examples of being ‚well-posed.‚ We can choose which
814 variation we shall use when creating the
815 \family typewriter
816 specify
817 \family default
818 method for our vessel type definition.
819 Let us choose the alternative where we fixed
820 \family typewriter
821 vessel_volume
822 \family default
823 ,
824 \family typewriter
825 H_to_D_ratio
826 \family default
827 ,
828 \family typewriter
829 metal_density
830 \family default
831 and
832 \family typewriter
833 wall_thickness
834 \family default
835 and provided them with the values of 250 ft^3, 3, 5000 kg/m^3 and 5 mm
836 respectively to be our ‚standard‚ specification.
837 Default methods
838 \family typewriter
839 ClearAll
840 \family default
841 and
842 \family typewriter
843 reset
844 \family default
845 are appropriate
846 \end_layout
847
848 \begin_layout Standard
849 \begin_inset Marginal
850 status collapsed
851
852 \begin_layout Standard
853 default methods ClearAll and reset are appropriate
854 \end_layout
855
856 \end_inset
857
858 As already noted, the purpose of
859 \family typewriter
860 ClearAll
861 \family default
862 is to set all the fixed flags to FALSE, a well-defined state from which
863 we can start over to set these flags as we wish them set.
864
865 \family typewriter
866 reset
867 \family default
868 simply runs
869 \family typewriter
870 ClearAll
871 \family default
872 and then
873 \family typewriter
874 specify
875 \family default
876 for a model.
877 The default versions for these two methods are generally exactly what one
878 wants so one need not write these.
879 \end_layout
880
881 \begin_layout Standard
882 Figure
883 \begin_inset LatexCommand \ref{fig:model2.vesselWithMethods}
884
885 \end_inset
886
887
888 \noun off
889 illustrates our vessel model with our local versions added for
890 \family typewriter
891 \noun default
892 specify
893 \family default
894 \noun off
895 and
896 \family typewriter
897 \noun default
898 values
899 \family default
900 \noun off
901 .
902 Look only at these for the moment and note that they do what we described
903 above.
904 We show some other methods we shall explain in a moment.
905 \end_layout
906
907 \begin_layout Standard
908 \begin_inset Float figure
909 wide false
910 sideways false
911 status open
912
913 \begin_layout LyX-Code
914 REQUIRE "atoms.a4l";
915 \end_layout
916
917 \begin_layout LyX-Code
918 MODEL vessel;
919 \end_layout
920
921 \begin_layout LyX-Code
922 NOTES
923 \end_layout
924
925 \begin_layout LyX-Code
926 'author' SELF {Arthur W.
927 Westerberg}
928 \end_layout
929
930 \begin_layout LyX-Code
931 'creation date' SELF {May, 1998}
932 \end_layout
933
934 \begin_layout LyX-Code
935 END NOTES;
936 \end_layout
937
938 \begin_layout LyX-Code
939
940 \end_layout
941
942 \begin_layout LyX-Code
943 (* variables *)
944 \end_layout
945
946 \begin_layout LyX-Code
947 side_area "the area of the cylindrical side wall of the vessel",
948 \end_layout
949
950 \begin_layout LyX-Code
951 end_area "the area of the flat ends of the vessel"
952 \end_layout
953
954 \begin_layout LyX-Code
955 IS_A area;
956 \end_layout
957
958 \begin_layout LyX-Code
959 vessel_vol "the volume contained within the cylindrical vessel",
960 \end_layout
961
962 \begin_layout LyX-Code
963 wall_vol "the volume of the walls for the vessel"
964 \end_layout
965
966 \begin_layout LyX-Code
967 IS_A volume;
968 \end_layout
969
970 \begin_layout LyX-Code
971 wall_thickness "the thickness of all of the vessel walls",
972 \end_layout
973
974 \begin_layout LyX-Code
975 H "the vessel height (of the cylindrical side walls)",
976 \end_layout
977
978 \begin_layout LyX-Code
979 D "the vessel diameter"
980 \end_layout
981
982 \begin_layout LyX-Code
983 IS_A distance;
984 \end_layout
985
986 \begin_layout LyX-Code
987 H_to_D_ratio "the ratio of vessel height to diameter"
988 \end_layout
989
990 \begin_layout LyX-Code
991 IS_A factor;
992 \end_layout
993
994 \begin_layout LyX-Code
995 metal_density "density of the metal from which the vessel
996 \end_layout
997
998 \begin_layout LyX-Code
999 is constructed"
1000 \end_layout
1001
1002 \begin_layout LyX-Code
1003 IS_A mass_density;
1004 \end_layout
1005
1006 \begin_layout LyX-Code
1007 metal_mass "the mass of the metal in the walls of the vessel"
1008 \end_layout
1009
1010 \begin_layout LyX-Code
1011 IS_A mass;
1012 \end_layout
1013
1014 \begin_layout LyX-Code
1015 (* equations *)
1016 \end_layout
1017
1018 \begin_layout LyX-Code
1019 FlatEnds:end_area = 1{PI} * D^2 / 4;
1020 \end_layout
1021
1022 \begin_layout LyX-Code
1023 Sides:side_area = 1{PI} * D * H;
1024 \end_layout
1025
1026 \begin_layout LyX-Code
1027 Cylinder:vessel_vol = end_area * H;
1028 \end_layout
1029
1030 \begin_layout LyX-Code
1031 Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;
1032 \end_layout
1033
1034 \begin_layout LyX-Code
1035 HD_definition:D * H_to_D_ratio = H;
1036 \end_layout
1037
1038 \begin_layout LyX-Code
1039 VesselMass:metal_mass = metal_density * wall_vol;
1040 \end_layout
1041
1042 \begin_layout LyX-Code
1043
1044 \end_layout
1045
1046 \begin_layout LyX-Code
1047 METHODS
1048 \end_layout
1049
1050 \begin_layout LyX-Code
1051 METHOD specify;
1052 \end_layout
1053
1054 \begin_layout LyX-Code
1055 NOTES
1056 \end_layout
1057
1058 \begin_layout LyX-Code
1059 'purpose' SELF {to fix four variables and make the problem well-posed}
1060 \end_layout
1061
1062 \begin_layout LyX-Code
1063 END NOTES;
1064 \end_layout
1065
1066 \begin_layout LyX-Code
1067 vessel_vol.fixed:=TRUE;
1068 \end_layout
1069
1070 \begin_layout LyX-Code
1071 H_to_D_ratio.fixed:=TRUE;
1072 \end_layout
1073
1074 \begin_layout LyX-Code
1075 wall_thickness.fixed :=TRUE;
1076 \end_layout
1077
1078 \begin_layout LyX-Code
1079 metal_density.fixed:=TRUE;
1080 \end_layout
1081
1082 \begin_layout LyX-Code
1083 END specify;
1084 \end_layout
1085
1086 \begin_layout LyX-Code
1087 METHOD values;
1088 \end_layout
1089
1090 \begin_layout LyX-Code
1091 NOTES
1092 \end_layout
1093
1094 \begin_layout LyX-Code
1095 'purpose' SELF {to set the values for the fixed variables}
1096 \end_layout
1097
1098 \begin_layout LyX-Code
1099 END NOTES;
1100 \end_layout
1101
1102 \begin_layout LyX-Code
1103 H_to_D_ratio := 2;
1104 \end_layout
1105
1106 \begin_layout LyX-Code
1107 vessel_vol := 250 {ft^3};
1108 \end_layout
1109
1110 \begin_layout LyX-Code
1111 wall_thickness := 5 {mm};
1112 \end_layout
1113
1114 \begin_layout LyX-Code
1115 metal_density := 5000 {kg/m^3};
1116 \end_layout
1117
1118 \begin_layout LyX-Code
1119 END values;
1120 \end_layout
1121
1122 \begin_layout LyX-Code
1123 METHOD bound_self;
1124 \end_layout
1125
1126 \begin_layout LyX-Code
1127 END bound_self;
1128 \end_layout
1129
1130 \begin_layout LyX-Code
1131 METHOD scale_self;
1132 \end_layout
1133
1134 \begin_layout LyX-Code
1135 END scale_self;
1136 \end_layout
1137
1138 \begin_layout LyX-Code
1139 METHOD default_self;
1140 \end_layout
1141
1142 \begin_layout LyX-Code
1143 D:=1 {m};
1144 \end_layout
1145
1146 \begin_layout LyX-Code
1147 H:=1 {m};
1148 \end_layout
1149
1150 \begin_layout LyX-Code
1151 H_to_D_ratio :=1;
1152 \end_layout
1153
1154 \begin_layout LyX-Code
1155 vessel_vol := 1 {m^3};
1156 \end_layout
1157
1158 \begin_layout LyX-Code
1159 wall_thickness :=5 {mm};
1160 \end_layout
1161
1162 \begin_layout LyX-Code
1163 metal_density :=5000 {kg/m^3};
1164 \end_layout
1165
1166 \begin_layout LyX-Code
1167 END default_self;
1168 \end_layout
1169
1170 \begin_layout LyX-Code
1171 END vessel;
1172 \end_layout
1173
1174 \begin_layout LyX-Code
1175
1176 \end_layout
1177
1178 \begin_layout LyX-Code
1179 ADD NOTES IN vessel;
1180 \end_layout
1181
1182 \begin_layout LyX-Code
1183 'description' SELF {This model relates the dimensions of a
1184 \end_layout
1185
1186 \begin_layout LyX-Code
1187 cylindrical vessel -- e.g., diameter, height and wall thickness
1188 \end_layout
1189
1190 \begin_layout LyX-Code
1191 to the volume of metal in the walls.
1192 It uses a thin wall
1193 \end_layout
1194
1195 \begin_layout LyX-Code
1196 assumption -- i.e., that the volume of metal is the area of
1197 \end_layout
1198
1199 \begin_layout LyX-Code
1200 the vessel times the wall thickness.}
1201 \end_layout
1202
1203 \begin_layout LyX-Code
1204 'purpose' SELF {to illustrate the insertion of notes into a model}
1205 \end_layout
1206
1207 \begin_layout LyX-Code
1208 END NOTES;
1209 \end_layout
1210
1211 \begin_layout Caption
1212 Version of vessel with methods added (vesselMethods.a4c
1213 \begin_inset LatexCommand \index{vesselMethods.a4c}
1214
1215 \end_inset
1216
1217 )
1218 \begin_inset LatexCommand \label{fig:model2.vesselWithMethods}
1219
1220 \end_inset
1221
1222
1223 \end_layout
1224
1225 \end_inset
1226
1227
1228 \end_layout
1229
1230 \begin_layout Standard
1231 In Table
1232 \begin_inset LatexCommand \ref{tab:model2.addedReqdMethods}
1233
1234 \end_inset
1235
1236
1237 \noun off
1238 we describe additional methods we require before we will put a model into
1239 one of our libraries.
1240 Each of these had two versions, both of which we require.
1241 The designation _self
1242 \begin_inset LatexCommand \index{\_self}
1243
1244 \end_inset
1245
1246 is for a method to do something for all the variables and/or parts we have
1247 defined locally within the current model with an IS_A statement.
1248 The designation _all
1249 \begin_inset LatexCommand \index{\_all}
1250
1251 \end_inset
1252
1253 is for a method to do something for parts that are defined within an "outer"
1254 model that has an instance of this model as a part.
1255 The "outer" model is at a higher scope
1256 \begin_inset LatexCommand \index{scope}
1257
1258 \end_inset
1259
1260 .
1261 It can share its parts with this model by passing them in as parameters,
1262 a topic we cover shortly in
1263 \noun default
1264 Section
1265 \noun off
1266
1267 \begin_inset LatexCommand \ref{sec:model2.parameterizingVessel}
1268
1269 \end_inset
1270
1271 .
1272
1273 \noun default
1274
1275 \noun off
1276 Only the _self versions of these methods are relevant here and are in
1277 \noun default
1278 Figure
1279 \noun off
1280
1281 \begin_inset LatexCommand \ref{fig:model2.vesselWithMethods}
1282
1283 \end_inset
1284
1285 .
1286 \end_layout
1287
1288 \begin_layout Standard
1289 \begin_inset Float table
1290 wide false
1291 sideways false
1292 status open
1293
1294 \begin_layout Caption
1295 Additional methods
1296 \begin_inset LatexCommand \index{methods. required}
1297
1298 \end_inset
1299
1300 required for model in ASCEND libraries
1301 \begin_inset LatexCommand \label{tab:model2.addedReqdMethods}
1302
1303 \end_inset
1304
1305
1306 \end_layout
1307
1308 \begin_layout Standard
1309 \begin_inset Tabular
1310 <lyxtabular version="3" rows="5" columns="2">
1311 <features>
1312 <column alignment="center" valignment="top" leftline="true" width="1.25in">
1313 <column alignment="center" valignment="top" leftline="true" rightline="true" width="3.5in">
1314 <row topline="true" bottomline="true">
1315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1316 \begin_inset Text
1317
1318 \begin_layout Standard
1319 method
1320 \end_layout
1321
1322 \end_inset
1323 </cell>
1324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1325 \begin_inset Text
1326
1327 \begin_layout Standard
1328 description
1329 \end_layout
1330
1331 \end_inset
1332 </cell>
1333 </row>
1334 <row topline="true">
1335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1336 \begin_inset Text
1337
1338 \begin_layout Standard
1339
1340 \family typewriter
1341 default_self
1342 \begin_inset LatexCommand \index{default\_self}
1343
1344 \end_inset
1345
1346 , default_all
1347 \family default
1348
1349 \begin_inset LatexCommand \index{default\_all}
1350
1351 \end_inset
1352
1353
1354 \end_layout
1355
1356 \end_inset
1357 </cell>
1358 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none" width="3.5in">
1359 \begin_inset Text
1360
1361 \begin_layout Standard
1362
1363 \family roman
1364 \series medium
1365 \shape up
1366 \size normal
1367 \emph off
1368 \bar no
1369 \noun off
1370 \color none
1371 a method called automatically when any simulation is compiled to provide
1372 default values and adjust bounds for any variables which may have unsuitable
1373 defaults in their ATOM definitions.
1374 Usually the variables selected are those for which the model becomes ill-behave
1375 d if given poor initial guesses or bounds (e.g., zero).
1376 \end_layout
1377
1378 \end_inset
1379 </cell>
1380 </row>
1381 <row topline="true">
1382 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1383 \begin_inset Text
1384
1385 \begin_layout Standard
1386
1387 \family typewriter
1388 bound_self
1389 \begin_inset LatexCommand \index{bound\_self}
1390
1391 \end_inset
1392
1393 , bound_all
1394 \family default
1395
1396 \begin_inset LatexCommand \index{bound\_all}
1397
1398 \end_inset
1399
1400
1401 \end_layout
1402
1403 \end_inset
1404 </cell>
1405 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1406 \begin_inset Text
1407
1408 \begin_layout Standard
1409
1410 \family roman
1411 \series medium
1412 \shape up
1413 \size normal
1414 \emph off
1415 \bar no
1416 \noun off
1417 \color none
1418 a method to update the .
1419 upper_bound and .
1420 lower_bound value for each of the variables.
1421 ASCEND solvers use these bound values to help solve the model equations.
1422 \end_layout
1423
1424 \end_inset
1425 </cell>
1426 </row>
1427 <row topline="true">
1428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1429 \begin_inset Text
1430
1431 \begin_layout Standard
1432
1433 \family typewriter
1434 scale_self
1435 \begin_inset LatexCommand \index{scale\_self}
1436
1437 \end_inset
1438
1439 , scale_all
1440 \family default
1441
1442 \begin_inset LatexCommand \index{scale\_all}
1443
1444 \end_inset
1445
1446
1447 \end_layout
1448
1449 \end_inset
1450 </cell>
1451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1452 \begin_inset Text
1453
1454 \begin_layout Standard
1455
1456 \family roman
1457 \series medium
1458 \shape up
1459 \size normal
1460 \emph off
1461 \bar no
1462 \noun off
1463 \color none
1464 a method to update the .
1465 nominal value for each of the variables.
1466 ASCEND solvers will use these nominal values to rescale the variable to
1467 have a value of about one in magnitude to help solve the model equations.
1468 \end_layout
1469
1470 \end_inset
1471 </cell>
1472 </row>
1473 <row topline="true" bottomline="true">
1474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1475 \begin_inset Text
1476
1477 \begin_layout Standard
1478
1479 \family typewriter
1480 check_self
1481 \begin_inset LatexCommand \index{check\_self}
1482
1483 \end_inset
1484
1485 , check_all
1486 \family default
1487
1488 \begin_inset LatexCommand \index{check\_all}
1489
1490 \end_inset
1491
1492
1493 \end_layout
1494
1495 \end_inset
1496 </cell>
1497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1498 \begin_inset Text
1499
1500 \begin_layout Standard
1501
1502 \family roman
1503 \series medium
1504 \shape up
1505 \size normal
1506 \emph off
1507 \bar no
1508 \noun off
1509 \color none
1510 a method to check that the computations make sense.
1511 At first this method may be empty, but, with experience, one can add statements
1512 that detect answers that appear to be wrong.
1513 As ASCEND already does bounds checking, one should not check for going
1514 past bounds here.
1515 However, there could be a rule of thumb available that suggests one computed
1516 variable should be about an order of magnitude larger than another.
1517 This check could be done in this method.
1518 \end_layout
1519
1520 \end_inset
1521 </cell>
1522 </row>
1523 </lyxtabular>
1524
1525 \end_inset
1526
1527
1528 \end_layout
1529
1530 \end_inset
1531
1532
1533 \end_layout
1534
1535 \begin_layout Standard
1536 \begin_inset Marginal
1537 status collapsed
1538
1539 \begin_layout Standard
1540 standard methods to a model definition
1541 \end_layout
1542
1543 \end_inset
1544
1545 The
1546 \family typewriter
1547 bound_self
1548 \family default
1549 and
1550 \family typewriter
1551 scale_self
1552 \family default
1553 , methods we have written are both empty.
1554 We anticipate no difficulties with variable scaling or bounding for this
1555 small model.
1556 Larger models can often give difficult problems in solving if the variables
1557 in them are not properly scaled and bounded; these issues must be taken
1558 very seriously for such models.
1559 \end_layout
1560
1561 \begin_layout Standard
1562 We have included the variables that define the geometry of the vessel in
1563
1564 \family typewriter
1565 defaults_self
1566 \family default
1567 method to avoid such things as negative initial values for vessel_volume.
1568 The compiler for ASCEND runs this method as soon as the model is compiled
1569 into an instance so the variables mentioned here start with their default
1570 values.
1571 \end_layout
1572
1573 \begin_layout Standard
1574 \begin_inset Marginal
1575 status open
1576
1577 \begin_layout Standard
1578 using methods when solving
1579 \end_layout
1580
1581 \end_inset
1582
1583 Exit ASCEND and repeat all the steps above to edit, load and compile this
1584 new vessel type definition.
1585 Then proceed as follows.
1586 \end_layout
1587
1588 \begin_layout Itemize
1589 In the Browser window, examine the values for those variables mentioned
1590 in the default_self method.
1591 Note they already have their default values.
1592 \end_layout
1593
1594 \begin_layout Itemize
1595 To place the new instance v in a solvable state, go to the Browser window.
1596 Pick the command Run method under the Edit button.
1597 Select first the method values and hit OK.
1598 \end_layout
1599
1600 \begin_layout Itemize
1601 Repeat the last step but this time select the method reset.
1602
1603 \end_layout
1604
1605 \begin_layout Standard
1606 In the Browser, examine the values for the variables listed in the method
1607 values in Figure
1608 \begin_inset LatexCommand \ref{fig:model2.vesselWithMethods}
1609
1610 \end_inset
1611
1612
1613 \noun off
1614 .
1615 They should be set to those stated (remember you can alter the units ASCEND
1616 uses to report the values by using the tools in the Units window).Also examine
1617 the fixed flags for these variables; they should all be TRUE (remember
1618 that you can find which variables are fixed all at once by using the By
1619 type command under the Find button).
1620
1621 \end_layout
1622
1623 \begin_layout Itemize
1624 Finally export v to the Solver.
1625 The Eligible window should NOT appear; rather that Solver should report
1626 the model to be square.
1627
1628 \end_layout
1629
1630 \begin_layout Itemize
1631 Solve by selecting Solve under the Execute button.
1632 \end_layout
1633
1634 \begin_layout Standard
1635 The inclusion of methods has made the process of making this model much
1636 easier to get well-posed.
1637 This approach is the one that works for really large, complex models.
1638 \end_layout
1639
1640 \begin_layout Section
1641 Parameterizing the vessel model
1642 \begin_inset LatexCommand \label{sec:model2.parameterizingVessel}
1643
1644 \end_inset
1645
1646
1647 \end_layout
1648
1649 \begin_layout Standard
1650 \begin_inset Marginal
1651 status collapsed
1652
1653 \begin_layout Standard
1654 let's compute metal_mass vs.
1655 H_to_D_ratio
1656 \end_layout
1657
1658 \end_inset
1659
1660 Reuse generally implies creating a model which will have as a part an instance
1661 of a previously defined type.
1662 For example, let us compute metal_mass as a function of the H_to_D_ratio
1663 for a vessel for a fixed vessel_volume.
1664 We would like to see if there is a value for the H_to_D_ratio for which
1665 the metal_mass is minimum for a vessel with a given vessel_volume.
1666 We might wonder if metal_mass goes to infinity as this ratio goes either
1667 to zero or infinity.
1668 \end_layout
1669
1670 \begin_layout Subsection
1671 Creating a parameterized version of vessel
1672 \end_layout
1673
1674 \begin_layout Standard
1675 \begin_inset Marginal
1676 status collapsed
1677
1678 \begin_layout Standard
1679 parameters indicate likely object sharing
1680 \end_layout
1681
1682 \end_inset
1683
1684 To use instances of our model as parts in another model, we can parameterize
1685 it.
1686 We use parameterization to tell a future user that the parameters are objects
1687 he or she is likely to share among many different parts of a model.
1688 We wish to create a table containing different values of H_to_D_ratio vs.
1689 metal_mass.
1690 We can accomplish this by computing simultaneously several different vessels
1691 having the same vessel_volume, wall_thickness and metal_density.
1692 The objects we want to see and/or share for each instance of a vessel should
1693 include, therefore: H_to_D_ratio, metal_mass, metal_density, vessel_volume
1694 and wall_thickness.
1695 \end_layout
1696
1697 \begin_layout Standard
1698 The code in Figure
1699 \begin_inset LatexCommand \ref{fig:model2.parameterizedVessel}
1700
1701 \end_inset
1702
1703
1704 \noun off
1705 indicates the changes we make to the model declaration statement and the
1706 statements defining the variables to parameterize our model.
1707 \end_layout
1708
1709 \begin_layout Standard
1710 \begin_inset Float figure
1711 wide false
1712 sideways false
1713 status open
1714
1715 \begin_layout LyX-Code
1716 REQUIRE "atoms.a4l";
1717 \end_layout
1718
1719 \begin_layout LyX-Code
1720 MODEL vessel(
1721 \end_layout
1722
1723 \begin_layout LyX-Code
1724 vessel_vol "the volume contained within the cylindrical vessel"
1725 \end_layout
1726
1727 \begin_layout LyX-Code
1728 WILL_BE volume;
1729 \end_layout
1730
1731 \begin_layout LyX-Code
1732 wall_thickness "the thickness of all of the vessel walls"
1733 \end_layout
1734
1735 \begin_layout LyX-Code
1736 WILL_BE distance;
1737 \end_layout
1738
1739 \begin_layout LyX-Code
1740 metal_density "density of the metal from which the vessel
1741 \end_layout
1742
1743 \begin_layout LyX-Code
1744 is constructed"
1745 \end_layout
1746
1747 \begin_layout LyX-Code
1748 WILL_BE mass_density;
1749 \end_layout
1750
1751 \begin_layout LyX-Code
1752 H_to_D_ratio "the ratio of vessel height to diameter"
1753 \end_layout
1754
1755 \begin_layout LyX-Code
1756 WILL_BE factor;
1757 \end_layout
1758
1759 \begin_layout LyX-Code
1760 metal_mass "the mass of the metal in the walls of the vessel"
1761 \end_layout
1762
1763 \begin_layout LyX-Code
1764 WILL_BE mass;
1765 \end_layout
1766
1767 \begin_layout LyX-Code
1768 );
1769 \end_layout
1770
1771 \begin_layout LyX-Code
1772 NOTES
1773 \end_layout
1774
1775 \begin_layout LyX-Code
1776 'author' SELF {Arthur W.
1777 Westerberg}
1778 \end_layout
1779
1780 \begin_layout LyX-Code
1781 'creation date' SELF {May, 1998}
1782 \end_layout
1783
1784 \begin_layout LyX-Code
1785 END NOTES;
1786 \end_layout
1787
1788 \begin_layout LyX-Code
1789
1790 \end_layout
1791
1792 \begin_layout LyX-Code
1793 (* variables *)
1794 \end_layout
1795
1796 \begin_layout LyX-Code
1797 side_area "the area of the cylindrical side wall of the vessel",
1798 \end_layout
1799
1800 \begin_layout LyX-Code
1801 end_area "the area of the flat ends of the vessel"
1802 \end_layout
1803
1804 \begin_layout LyX-Code
1805 IS_A area;
1806 \end_layout
1807
1808 \begin_layout LyX-Code
1809 wall_vol "the volume of the walls for the vessel"
1810 \end_layout
1811
1812 \begin_layout LyX-Code
1813 IS_A volume;
1814 \end_layout
1815
1816 \begin_layout LyX-Code
1817 H "the vessel height (of the cylindrical side walls)",
1818 \end_layout
1819
1820 \begin_layout LyX-Code
1821 D "the vessel diameter"
1822 \end_layout
1823
1824 \begin_layout LyX-Code
1825 IS_A distance;
1826 \end_layout
1827
1828 \begin_layout LyX-Code
1829 (* equations *)
1830 \end_layout
1831
1832 \begin_layout LyX-Code
1833 FlatEnds:end_area = 1{PI} * D^2 / 4;
1834 \end_layout
1835
1836 \begin_layout LyX-Code
1837 Sides:side_area = 1{PI} * D * H;
1838 \end_layout
1839
1840 \begin_layout LyX-Code
1841 Cylinder:vessel_vol = end_area * H;
1842 \end_layout
1843
1844 \begin_layout LyX-Code
1845 Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;
1846 \end_layout
1847
1848 \begin_layout LyX-Code
1849 HD_definition:D * H_to_D_ratio = H;
1850 \end_layout
1851
1852 \begin_layout LyX-Code
1853 VesselMass:metal_mass = metal_density * wall_vol;
1854 \end_layout
1855
1856 \begin_layout LyX-Code
1857
1858 \end_layout
1859
1860 \begin_layout LyX-Code
1861 METHODS
1862 \end_layout
1863
1864 \begin_layout LyX-Code
1865 METHOD specify;
1866 \end_layout
1867
1868 \begin_layout LyX-Code
1869 NOTES
1870 \end_layout
1871
1872 \begin_layout LyX-Code
1873 'purpose' SELF {to fix four variables and make the problem well-posed}
1874 \end_layout
1875
1876 \begin_layout LyX-Code
1877 END NOTES;
1878 \end_layout
1879
1880 \begin_layout LyX-Code
1881 vessel_vol.fixed:=TRUE;
1882 \end_layout
1883
1884 \begin_layout LyX-Code
1885 H_to_D_ratio.fixed:=TRUE;
1886 \end_layout
1887
1888 \begin_layout LyX-Code
1889 wall_thickness.fixed :=TRUE;
1890 \end_layout
1891
1892 \begin_layout LyX-Code
1893 metal_density.fixed:=TRUE;
1894 \end_layout
1895
1896 \begin_layout LyX-Code
1897 END specify;
1898 \end_layout
1899
1900 \begin_layout LyX-Code
1901 METHOD values;
1902 \end_layout
1903
1904 \begin_layout LyX-Code
1905 NOTES
1906 \end_layout
1907
1908 \begin_layout LyX-Code
1909 'purpose' SELF {to set the values for the fixed variables}
1910 \end_layout
1911
1912 \begin_layout LyX-Code
1913 END NOTES;
1914 \end_layout
1915
1916 \begin_layout LyX-Code
1917 H_to_D_ratio:=2;
1918 \end_layout
1919
1920 \begin_layout LyX-Code
1921 vessel_vol:=250 {ft^3};
1922 \end_layout
1923
1924 \begin_layout LyX-Code
1925 wall_thickness:=5 {mm};
1926 \end_layout
1927
1928 \begin_layout LyX-Code
1929 metal_density:=5000 {kg/m^3};
1930 \end_layout
1931
1932 \begin_layout LyX-Code
1933 END values;
1934 \end_layout
1935
1936 \begin_layout LyX-Code
1937 METHOD bound_self;
1938 \end_layout
1939
1940 \begin_layout LyX-Code
1941 END bound_self;
1942 \end_layout
1943
1944 \begin_layout LyX-Code
1945 METHOD bound_all;
1946 \end_layout
1947
1948 \begin_layout LyX-Code
1949 RUN bound_self;
1950 \end_layout
1951
1952 \begin_layout LyX-Code
1953 END bound_all;
1954 \end_layout
1955
1956 \begin_layout LyX-Code
1957 METHOD scale_self;
1958 \end_layout
1959
1960 \begin_layout LyX-Code
1961 END scale_self;
1962 \end_layout
1963
1964 \begin_layout LyX-Code
1965 METHOD scale_all;
1966 \end_layout
1967
1968 \begin_layout LyX-Code
1969 RUN scale_self;
1970 \end_layout
1971
1972 \begin_layout LyX-Code
1973 END scale_all;
1974 \end_layout
1975
1976 \begin_layout LyX-Code
1977 METHOD default_self;
1978 \end_layout
1979
1980 \begin_layout LyX-Code
1981 D:=1 {m};
1982 \end_layout
1983
1984 \begin_layout LyX-Code
1985 H:=1 {m};
1986 \end_layout
1987
1988 \begin_layout LyX-Code
1989 END default_self;
1990 \end_layout
1991
1992 \begin_layout LyX-Code
1993 METHOD default_all;
1994 \end_layout
1995
1996 \begin_layout LyX-Code
1997 RUN default_self;
1998 \end_layout
1999
2000 \begin_layout LyX-Code
2001 vessel_vol:=1 {m^3};
2002 \end_layout
2003
2004 \begin_layout LyX-Code
2005 wall_thickness:=5 {mm};
2006 \end_layout
2007
2008 \begin_layout LyX-Code
2009 metal_density:=5000 {kg/m^3};
2010 \end_layout
2011
2012 \begin_layout LyX-Code
2013 H_to_D_ratio:=1;
2014 \end_layout
2015
2016 \begin_layout LyX-Code
2017 END default_all;
2018 \end_layout
2019
2020 \begin_layout LyX-Code
2021 END vessel;
2022 \end_layout
2023
2024 \begin_layout LyX-Code
2025 ADD NOTES IN vessel;
2026 \end_layout
2027
2028 \begin_layout LyX-Code
2029 'description' SELF {This model relates the dimensions of a
2030 \end_layout
2031
2032 \begin_layout LyX-Code
2033 cylindrical vessel -- e.g., diameter, height and wall thickness
2034 \end_layout
2035
2036 \begin_layout LyX-Code
2037 to the volume of metal in the walls.
2038 It uses a thin wall
2039 \end_layout
2040
2041 \begin_layout LyX-Code
2042 assumption -- i.e., that the volume of metal is the area of
2043 \end_layout
2044
2045 \begin_layout LyX-Code
2046 the vessel times the wall thickness.}
2047 \end_layout
2048
2049 \begin_layout LyX-Code
2050 'purpose' SELF {to illustrate the insertion of notes into a model}
2051 \end_layout
2052
2053 \begin_layout LyX-Code
2054 END NOTES;
2055 \end_layout
2056
2057 \begin_layout Caption
2058 \begin_inset LatexCommand \label{fig:model2.parameterizedVessel}
2059
2060 \end_inset
2061
2062 The parameterized version of vessel model (
2063 \begin_inset LatexCommand \index{1014608}
2064
2065 \end_inset
2066
2067 vesselParams.a4c)sss
2068 \end_layout
2069
2070 \end_inset
2071
2072
2073 \end_layout
2074
2075 \begin_layout Standard
2076 Substitute the statements in Figure
2077 \begin_inset LatexCommand \ref{fig:model2.parameterizedVessel}
2078
2079 \end_inset
2080
2081
2082 \noun off
2083 for lines 2 through 9 in
2084 \noun default
2085 Figure
2086 \noun off
2087
2088 \begin_inset LatexCommand \ref{fig:model2.vesselWithMethods}
2089
2090 \end_inset
2091
2092 .
2093 Save the result in the file vesselParam.a4c.
2094 \end_layout
2095
2096 \begin_layout Standard
2097 Note the use of the
2098 \begin_inset LatexCommand \index{1014610}
2099
2100 \end_inset
2101
2102
2103 \begin_inset LatexCommand \index{1014609}
2104
2105 \end_inset
2106
2107 WILL_BE statement in the parameter list.
2108 By declaring that the type of a parameter will be compatible with the types
2109 shown, the compiler can tell immediately if a user of this model is passing
2110 the wrong type of object when defining an instance of a vessel.
2111 \end_layout
2112
2113 \begin_layout Subsection
2114 Using the parameterized vessel model
2115 \end_layout
2116
2117 \begin_layout Standard
2118 \begin_inset Marginal
2119 status collapsed
2120
2121 \begin_layout Standard
2122 Creating a
2123 \begin_inset LatexCommand \index{1014611}
2124
2125 \end_inset
2126
2127 table of metal_mass values vs.
2128 H_to_D_ratio
2129 \end_layout
2130
2131 \end_inset
2132
2133 A type definition will set up our table of H_to_D_ratio values vs.
2134 metal_mass so we can observe approximately where it attains a minimum value.
2135 ASCEND allows us to create arrays of instances of any type.
2136 Here we shall create an array of vessels.
2137 The type definition is shown in Figure
2138 \begin_inset LatexCommand \ref{fig:model2.tabulatedVessel}
2139
2140 \end_inset
2141
2142
2143 \noun off
2144 .
2145 Note that the line numbers are not a part of the actual code.
2146 We include them here only so we can reference them as needed later.
2147 \end_layout
2148
2149 \begin_layout Standard
2150 \begin_inset Float figure
2151 wide false
2152 sideways false
2153 status open
2154
2155 \begin_layout LyX-Code
2156 REQUIRE "atoms.a4l";
2157 \end_layout
2158
2159 \begin_layout LyX-Code
2160 MODEL vessel(
2161 \end_layout
2162
2163 \begin_layout LyX-Code
2164 vessel_vol "the volume contained within the cylindrical vessel"
2165 \end_layout
2166
2167 \begin_layout LyX-Code
2168 WILL_BE volume;
2169 \end_layout
2170
2171 \begin_layout LyX-Code
2172 wall_thickness "the thickness of all of the vessel walls"
2173 \end_layout
2174
2175 \begin_layout LyX-Code
2176 WILL_BE distance;
2177 \end_layout
2178
2179 \begin_layout LyX-Code
2180 metal_density "density of the metal from which the vessel
2181 \end_layout
2182
2183 \begin_layout LyX-Code
2184 is constructed"
2185 \end_layout
2186
2187 \begin_layout LyX-Code
2188 WILL_BE mass_density;
2189 \end_layout
2190
2191 \begin_layout LyX-Code
2192 H_to_D_ratio "the ratio of vessel height to diameter"
2193 \end_layout
2194
2195 \begin_layout LyX-Code
2196 WILL_BE factor;
2197 \end_layout
2198
2199 \begin_layout LyX-Code
2200 metal_mass "the mass of the metal in the walls of the vessel"
2201 \end_layout
2202
2203 \begin_layout LyX-Code
2204 WILL_BE mass;
2205 \end_layout
2206
2207 \begin_layout LyX-Code
2208 );
2209 \end_layout
2210
2211 \begin_layout LyX-Code
2212 NOTES
2213 \end_layout
2214
2215 \begin_layout LyX-Code
2216 'author' SELF {Arthur W.
2217 Westerberg}
2218 \end_layout
2219
2220 \begin_layout LyX-Code
2221 'creation date' SELF {May, 1998}
2222 \end_layout
2223
2224 \begin_layout LyX-Code
2225 END NOTES;
2226 \end_layout
2227
2228 \begin_layout LyX-Code
2229
2230 \end_layout
2231
2232 \begin_layout LyX-Code
2233 (* variables *)
2234 \end_layout
2235
2236 \begin_layout LyX-Code
2237 side_area "the area of the cylindrical side wall of the vessel",
2238 \end_layout
2239
2240 \begin_layout LyX-Code
2241 end_area "the area of the flat ends of the vessel"
2242 \end_layout
2243
2244 \begin_layout LyX-Code
2245 IS_A area;
2246 \end_layout
2247
2248 \begin_layout LyX-Code
2249 wall_vol "the volume of the walls for the vessel"
2250 \end_layout
2251
2252 \begin_layout LyX-Code
2253 IS_A volume;
2254 \end_layout
2255
2256 \begin_layout LyX-Code
2257 H "the vessel height (of the cylindrical side walls)",
2258 \end_layout
2259
2260 \begin_layout LyX-Code
2261 D "the vessel diameter"
2262 \end_layout
2263
2264 \begin_layout LyX-Code
2265 IS_A distance;
2266 \end_layout
2267
2268 \begin_layout LyX-Code
2269 (* equations *)
2270 \end_layout
2271
2272 \begin_layout LyX-Code
2273 FlatEnds:end_area = 1{PI} * D^2 / 4;
2274 \end_layout
2275
2276 \begin_layout LyX-Code
2277 Sides:side_area = 1{PI} * D * H;
2278 \end_layout
2279
2280 \begin_layout LyX-Code
2281 Cylinder:vessel_vol = end_area * H;
2282 \end_layout
2283
2284 \begin_layout LyX-Code
2285 Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;
2286 \end_layout
2287
2288 \begin_layout LyX-Code
2289 HD_definition:D * H_to_D_ratio = H;
2290 \end_layout
2291
2292 \begin_layout LyX-Code
2293 VesselMass:metal_mass = metal_density * wall_vol;
2294 \end_layout
2295
2296 \begin_layout LyX-Code
2297 METHODS
2298 \end_layout
2299
2300 \begin_layout LyX-Code
2301 METHOD specify;
2302 \end_layout
2303
2304 \begin_layout LyX-Code
2305 NOTES
2306 \end_layout
2307
2308 \begin_layout LyX-Code
2309 'purpose' SELF {to fix four variables and make the problem well-posed}
2310 \end_layout
2311
2312 \begin_layout LyX-Code
2313 END NOTES;
2314 \end_layout
2315
2316 \begin_layout LyX-Code
2317 vessel_vol.fixed:=TRUE;
2318 \end_layout
2319
2320 \begin_layout LyX-Code
2321 H_to_D_ratio.fixed:=TRUE;
2322 \end_layout
2323
2324 \begin_layout LyX-Code
2325 wall_thickness.fixed:=TRUE;
2326 \end_layout
2327
2328 \begin_layout LyX-Code
2329 metal_density.fixed:=TRUE;
2330 \end_layout
2331
2332 \begin_layout LyX-Code
2333 END specify;
2334 \end_layout
2335
2336 \begin_layout LyX-Code
2337 METHOD values;
2338 \end_layout
2339
2340 \begin_layout LyX-Code
2341 NOTES
2342 \end_layout
2343
2344 \begin_layout LyX-Code
2345 'purpose' SELF {to set the values for the fixed variables}
2346 \end_layout
2347
2348 \begin_layout LyX-Code
2349 END NOTES;
2350 \end_layout
2351
2352 \begin_layout LyX-Code
2353 H_to_D_ratio:=2;
2354 \end_layout
2355
2356 \begin_layout LyX-Code
2357 vessel_vol:=250 {ft^3};
2358 \end_layout
2359
2360 \begin_layout LyX-Code
2361 wall_thickness:=5 {mm};
2362 \end_layout
2363
2364 \begin_layout LyX-Code
2365 metal_density:=5000 {kg/m^3};
2366 \end_layout
2367
2368 \begin_layout LyX-Code
2369 END values;
2370 \end_layout
2371
2372 \begin_layout LyX-Code
2373 METHOD bound_self;
2374 \end_layout
2375
2376 \begin_layout LyX-Code
2377 END bound_self;
2378 \end_layout
2379
2380 \begin_layout LyX-Code
2381 METHOD bound_all;
2382 \end_layout
2383
2384 \begin_layout LyX-Code
2385 RUN bound_self;
2386 \end_layout
2387
2388 \begin_layout LyX-Code
2389 END bound_all;
2390 \end_layout
2391
2392 \begin_layout LyX-Code
2393 METHOD scale_self;
2394 \end_layout
2395
2396 \begin_layout LyX-Code
2397 END scale_self;
2398 \end_layout
2399
2400 \begin_layout LyX-Code
2401 METHOD scale_all;
2402 \end_layout
2403
2404 \begin_layout LyX-Code
2405 RUN scale_self;
2406 \end_layout
2407
2408 \begin_layout LyX-Code
2409 END scale_all;
2410 \end_layout
2411
2412 \begin_layout LyX-Code
2413 METHOD default_self;
2414 \end_layout
2415
2416 \begin_layout LyX-Code
2417 D:= 1 {m};
2418 \end_layout
2419
2420 \begin_layout LyX-Code
2421 H:=1 {m};
2422 \end_layout
2423
2424 \begin_layout LyX-Code
2425 END default_self;
2426 \end_layout
2427
2428 \begin_layout LyX-Code
2429 METHOD default_all;
2430 \end_layout
2431
2432 \begin_layout LyX-Code
2433 RUN default_self;
2434 \end_layout
2435
2436 \begin_layout LyX-Code
2437 vessel_vol:=1 {m^3};
2438 \end_layout
2439
2440 \begin_layout LyX-Code
2441 wall_thickness:=5 {mm};
2442 \end_layout
2443
2444 \begin_layout LyX-Code
2445 metal_density:=5000 {kg/m^3};
2446 \end_layout
2447
2448 \begin_layout LyX-Code
2449 H_to_D_ratio:=1;
2450 \end_layout
2451
2452 \begin_layout LyX-Code
2453 END default_all;
2454 \end_layout
2455
2456 \begin_layout LyX-Code
2457 END vessel;
2458 \end_layout
2459
2460 \begin_layout LyX-Code
2461
2462 \end_layout
2463
2464 \begin_layout LyX-Code
2465 ADD NOTES IN vessel;
2466 \end_layout
2467
2468 \begin_layout LyX-Code
2469 'description' SELF {This model relates the dimensions of a
2470 \end_layout
2471
2472 \begin_layout LyX-Code
2473 cylindrical vessel -- e.g., diameter, height and wall thickness
2474 \end_layout
2475
2476 \begin_layout LyX-Code
2477 to the volume of metal in the walls.
2478 It uses a thin wall
2479 \end_layout
2480
2481 \begin_layout LyX-Code
2482 assumption -- i.e., that the volume of metal is the area of
2483 \end_layout
2484
2485 \begin_layout LyX-Code
2486 the vessel times the wall thickness.}
2487 \end_layout
2488
2489 \begin_layout LyX-Code
2490 'purpose' SELF {to illustrate the insertion of notes into a model}
2491 \end_layout
2492
2493 \begin_layout LyX-Code
2494 END NOTES;
2495 \end_layout
2496
2497 \begin_layout LyX-Code
2498
2499 \end_layout
2500
2501 \begin_layout LyX-Code
2502 MODEL tabulated_vessel_values;
2503 \end_layout
2504
2505 \begin_layout LyX-Code
2506 vessel_volume "volume of all the tabulated vessels"
2507 \end_layout
2508
2509 \begin_layout LyX-Code
2510 IS_A volume;
2511 \end_layout
2512
2513 \begin_layout LyX-Code
2514 wall_thickness "thickness of all the walls for all the vessels"
2515 \end_layout
2516
2517 \begin_layout LyX-Code
2518 IS_A distance;
2519 \end_layout
2520
2521 \begin_layout LyX-Code
2522 metal_density "density of metal used for all vessels"
2523 \end_layout
2524
2525 \begin_layout LyX-Code
2526 IS_A mass_density;
2527 \end_layout
2528
2529 \begin_layout LyX-Code
2530 n_entries "number of vessels to simulate"
2531 \end_layout
2532
2533 \begin_layout LyX-Code
2534 IS_A integer_constant;
2535 \end_layout
2536
2537 \begin_layout LyX-Code
2538 n_entries :== 20;
2539 \end_layout
2540
2541 \begin_layout LyX-Code
2542 H_to_D_ratio[1..n_entries]"set of H to D ratios for which we are
2543 \end_layout
2544
2545 \begin_layout LyX-Code
2546 computing metal mass"
2547 \end_layout
2548
2549 \begin_layout LyX-Code
2550 IS_A factor;
2551 \end_layout
2552
2553 \begin_layout LyX-Code
2554 metal_mass[1..n_entries]"mass of metal in walls of vessels"
2555 \end_layout
2556
2557 \begin_layout LyX-Code
2558 IS_A mass;
2559 \end_layout
2560
2561 \begin_layout LyX-Code
2562 FOR i IN [1..n_entries] CREATE
2563 \end_layout
2564
2565 \begin_layout LyX-Code
2566 v[i] "the i-th vessel model"
2567 \end_layout
2568
2569 \begin_layout LyX-Code
2570 IS_A vessel(vessel_volume, wall_thickness,
2571 \end_layout
2572
2573 \begin_layout LyX-Code
2574 metal_density, H_to_D_ratio[i], metal_mass[i]);
2575 \end_layout
2576
2577 \begin_layout LyX-Code
2578 END FOR;
2579 \end_layout
2580
2581 \begin_layout LyX-Code
2582
2583 \end_layout
2584
2585 \begin_layout LyX-Code
2586 METHODS
2587 \end_layout
2588
2589 \begin_layout LyX-Code
2590 METHOD default_self;
2591 \end_layout
2592
2593 \begin_layout LyX-Code
2594 END default_self;
2595 \end_layout
2596
2597 \begin_layout LyX-Code
2598
2599 \end_layout
2600
2601 \begin_layout LyX-Code
2602 METHOD specify;
2603 \end_layout
2604
2605 \begin_layout LyX-Code
2606 RUN v[1..n_entries].specify;
2607 \end_layout
2608
2609 \begin_layout LyX-Code
2610 END specify;
2611 \end_layout
2612
2613 \begin_layout LyX-Code
2614 METHOD values;
2615 \end_layout
2616
2617 \begin_layout LyX-Code
2618 NOTES 'purpose' SELF {to set up 20 vessel models having H to D ratios
2619 \end_layout
2620
2621 \begin_layout LyX-Code
2622 ranging from 0.1 to 2.}
2623 \end_layout
2624
2625 \begin_layout LyX-Code
2626 END NOTES;
2627 \end_layout
2628
2629 \begin_layout LyX-Code
2630 vessel_volume := 250 {ft^3};
2631 \end_layout
2632
2633 \begin_layout LyX-Code
2634 wall_thickness := 5 {mm};
2635 \end_layout
2636
2637 \begin_layout LyX-Code
2638 metal_density := 5000 {kg/m^3};
2639 \end_layout
2640
2641 \begin_layout LyX-Code
2642 FOR i IN [1..n_entries] DO
2643 \end_layout
2644
2645 \begin_layout LyX-Code
2646 H_to_D_ratio[i] := i/10.0;
2647 \end_layout
2648
2649 \begin_layout LyX-Code
2650 END FOR;
2651 \end_layout
2652
2653 \begin_layout LyX-Code
2654 END values;
2655 \end_layout
2656
2657 \begin_layout LyX-Code
2658 METHOD scale_self;
2659 \end_layout
2660
2661 \begin_layout LyX-Code
2662 END scale_self;
2663 \end_layout
2664
2665 \begin_layout LyX-Code
2666 END tabulated_vessel_values;
2667 \end_layout
2668
2669 \begin_layout LyX-Code
2670
2671 \end_layout
2672
2673 \begin_layout LyX-Code
2674 ADD NOTES IN tabulated_vessel_values;
2675 \end_layout
2676
2677 \begin_layout LyX-Code
2678 'description' SELF {This model sets up an array of vessels to
2679 \end_layout
2680
2681 \begin_layout LyX-Code
2682 compute a range of metal_mass values for different values
2683 \end_layout
2684
2685 \begin_layout LyX-Code
2686 of H_to_D_ratio.}
2687 \end_layout
2688
2689 \begin_layout LyX-Code
2690 'purpose' SELF {to illustrate the use of arrays in ASCEND}
2691 \end_layout
2692
2693 \begin_layout LyX-Code
2694 END NOTES;
2695 \end_layout
2696
2697 \begin_layout Caption
2698 tabulated_vessel_values model
2699 \begin_inset LatexCommand \label{fig:model2.tabulatedVessel}
2700
2701 \end_inset
2702
2703
2704 \end_layout
2705
2706 \end_inset
2707
2708
2709 \end_layout
2710
2711 \begin_layout Standard
2712 Add this model to the end of the file
2713 \family typewriter
2714 vesselParam.a4c
2715 \family default
2716
2717 \begin_inset LatexCommand \index{vesselTabulated.a4c}
2718
2719 \end_inset
2720
2721 (after the vessel model) and save the file as
2722 \family typewriter
2723 vesselTabulated.a4c
2724 \family default
2725 .
2726 Compile an instance of tabulated_vessel_values (call it tvv), run the values
2727 and specify methods for it, and then solve it.
2728 You will discover that the tenth element of the metal_mass array, corresponding
2729 to an
2730 \family typewriter
2731 H_to_D_ratio
2732 \family default
2733 of 1 has the minimum value of 510.257 kilograms.
2734 \end_layout
2735
2736 \begin_layout Section
2737 Creating a script
2738 \begin_inset LatexCommand \index{script, creating}
2739
2740 \end_inset
2741
2742 to demonstrate this model
2743 \begin_inset LatexCommand \label{sec:model2.creatingScript}
2744
2745 \end_inset
2746
2747
2748 \end_layout
2749
2750 \begin_layout Standard
2751 The last step to make the model reusable is to create a script that anyone
2752 can easily run.
2753 Running the model successfully will allow a user to demonstrate the use
2754 of the model and to explore an instance it by browsing it.
2755 \end_layout
2756
2757 \begin_layout Standard
2758 ASCEND allows one to create such a script using either an editor or the
2759 tools in the Script window.
2760 \end_layout
2761
2762 \begin_layout Standard
2763 Restart the ASCEND system.
2764 You will have three windows open plus the large one which disappears by
2765 itself in a few seconds: the Script, the Library and the Console windows.
2766 \end_layout
2767
2768 \begin_layout Standard
2769 In the
2770 \series bold
2771 Script
2772 \series default
2773 window you will see the license agreement information for ASCEND.
2774 First delete the license agreement
2775 \begin_inset LatexCommand \index{license agreement}
2776
2777 \end_inset
2778
2779 from this window by doing the following two steps:
2780 \end_layout
2781
2782 \begin_layout Itemize
2783 Select the Select all tool under the Edit button.
2784
2785 \end_layout
2786
2787 \begin_layout Itemize
2788 Then select the Delete statements tool under the same button.
2789
2790 \end_layout
2791
2792 \begin_layout Standard
2793 With the window
2794 \series bold
2795 clear
2796 \series default
2797 , select the tool Record actions under the Edit button to start recording
2798 the steps you are about to undertake.
2799 \end_layout
2800
2801 \begin_layout Itemize
2802 In the Library window, under the Edit button, selec Delete all types.
2803 Hit Delete all on the small window that appears.
2804 \end_layout
2805
2806 \begin_layout Itemize
2807 Load the file vesselTabulated.a4c, the file containing the model called tabulated
2808 _vessel_values.
2809 Do this by selecting the Read types from file tool under the File button
2810 and browsing the file system to find it.
2811 If you have trouble finding it, be sure to set the Files of type window
2812 at the bottom of the file browsing window to allow all types of files to
2813 be seen.
2814 \end_layout
2815
2816 \begin_layout Itemize
2817 Select the type tabulated_vessel_values in the right Library window and
2818 compile an instance of it by selecting the Create simulation tool under
2819 the Edit button.
2820 In the small window that appears, enter the name tvv and hit OK.
2821 \end_layout
2822
2823 \begin_layout Itemize
2824 Export the instance to the Browser by selecting the Simulation to Browser
2825 tool under the Export button.
2826 \end_layout
2827
2828 \begin_layout Itemize
2829 Initialize the variable values by running the values method.
2830 Do this by selecting the Run method tool under the Edit button.
2831 Select the values method and hit OK.
2832 \end_layout
2833
2834 \begin_layout Itemize
2835 Set the fixed flags to get a well-posed problem by repeating the last step
2836 but this time select the reset method.
2837 \end_layout
2838
2839 \begin_layout Itemize
2840 Export the instance tvv to the Solver by selecting the to Solver tool under
2841 the Export button.
2842 \end_layout
2843
2844 \begin_layout Itemize
2845 Solve tvv by selecting the Solve tool under the Execute button in the Solver
2846 window.
2847 \end_layout
2848
2849 \begin_layout Itemize
2850 Return to the Script window and turn off the recording by selecting the
2851 Record actions tool under the Edit button.
2852 \end_layout
2853
2854 \begin_layout Itemize
2855 Save the script you have just created by selecting the Save tool under the
2856 File button of the Script window.
2857 Name the file vesselTabulated.a4s (note the 's' ending) to indicate it is
2858 the script to run an example problem for models in the vesselTabulated.a4c
2859 (note the 'c' ending) file.
2860 \end_layout
2861
2862 \begin_layout Itemize
2863 Exit ASCEND by selecting the Exit ASCEND tool under the File button on the
2864 Script window.
2865 The contents of the Script window will be similar to that in Figure
2866 \begin_inset LatexCommand \ref{fig:model2.scriptVesselTabulated}
2867
2868 \end_inset
2869
2870
2871 \noun off
2872 (the path to the file may differ).
2873 \end_layout
2874
2875 \begin_layout Itemize
2876 Restart ASCEND.
2877 \end_layout
2878
2879 \begin_layout Itemize
2880 Open the script you just created by selecting the Read file tool under the
2881 File button on the Script window.
2882 (Be sure you are allowing the system to see files with the ending a4s by
2883 setting the Files of type window at the bottom of the file browsing window.)
2884 \end_layout
2885
2886 \begin_layout Itemize
2887 Highlight all the instructions in this script and then execute the highlighted
2888 instructions by selecting the Statements selected tool under the Execute
2889 button.
2890 \end_layout
2891
2892 \begin_layout Standard
2893 You will run the same sequence of instructions you ran to create the script.
2894 \end_layout
2895
2896 \begin_layout Standard
2897 \begin_inset Float figure
2898 wide false
2899 sideways false
2900 status open
2901
2902 \begin_layout LyX-Code
2903 DELETE TYPES;
2904 \end_layout
2905
2906 \begin_layout LyX-Code
2907 READ FILE "C:/My Documents/1998/ascdata/vesselTabulated.a4c";
2908 \end_layout
2909
2910 \begin_layout LyX-Code
2911 COMPILE tv OF tabulated_vessel_values;
2912 \end_layout
2913
2914 \begin_layout LyX-Code
2915 BROWSE {tv};
2916 \end_layout
2917
2918 \begin_layout LyX-Code
2919 RUN {tv.reset};
2920 \end_layout
2921
2922 \begin_layout LyX-Code
2923 RUN {tv.values};
2924 \end_layout
2925
2926 \begin_layout LyX-Code
2927 SOLVE {tv} WITH QRSlv;
2928 \end_layout
2929
2930 \begin_layout Caption
2931 Script to run vesselTabulated.a4c (this is the contents of the file vesselTabulat
2932 ed.a4s
2933 \begin_inset LatexCommand \index{vesselTabultated.a4s}
2934
2935 \end_inset
2936
2937 )
2938 \begin_inset LatexCommand \label{fig:model2.scriptVesselTabulated}
2939
2940 \end_inset
2941
2942
2943 \end_layout
2944
2945 \end_inset
2946
2947
2948 \end_layout
2949
2950 \begin_layout Section
2951 Discussion
2952 \end_layout
2953
2954 \begin_layout Standard
2955 In this chapter we converted the vessel model into a form where you and
2956 others in the future will have a chance to reuse it.
2957 We did this by first adding methods to make the problem well-posed and
2958 to provide values for the fixed variables for which we readily found a
2959 solution when playing with our original model as we did in the previous
2960 chapter.
2961 We then thought of a typical use for this model and developed a parameterized
2962 version based on that use.
2963 If this model were in a library, a future user of it would most often simply
2964 have to understand the parameters to create an instance of this type of
2965 model.
2966 We next added NOTES, a form of active comments, to the model.
2967 We suggest that notes are much more useful than comments as we can provide
2968 tools that can extract them and allow us to search them, for example, to
2969 find a model with a given functionality.
2970 Finally, we showed you how to create a script by turning on a "phone" session
2971 where ASCEND records the actions one takes when loading, compiling and
2972 solving a model.
2973 One can save and play this script in the future to see a typical use of
2974 the model.
2975 \end_layout
2976
2977 \begin_layout Standard
2978 In the next chapter, we look at how we can plot the results we created in
2979 the model vesselTabulated.a4c.
2980 We will have to reuse a model someone else has put into the library of
2981 available models.
2982 In other words, the "shoe is on the other foot," and we quickly experience
2983 the difficulties with reuse first hand.
2984 We will also learn how to run a case study from which we can extract the
2985 same information with a single vessel model run multiple times.
2986 \end_layout
2987
2988 \end_body
2989 \end_document

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