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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 826 - (hide annotations) (download) (as text)
Tue Aug 22 01:34:33 2006 UTC (18 years, 4 months ago) by johnpye
File MIME type: application/x-lyx
File size: 58771 byte(s)
Increased max ext relations to 50.
Changed default web browser on linux to firefox.
Copied documentation files into source tree
Added build script to allow HTML and PDF generation via SCons.

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

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