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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1384 by jpye, Fri Mar 30 01:55:53 2007 UTC revision 1385 by jpye, Sat Apr 7 09:13:41 2007 UTC
# Line 3  Line 3 
3  \begin_document  \begin_document
4  \begin_header  \begin_header
5  \textclass book  \textclass book
6    \begin_preamble
7    \usepackage[bookmarks,bookmarksnumbered=true]{hyperref}
8    \usepackage{lmodern}
9    \usepackage{color}
10    \definecolor{darkred}{rgb}{0.55,0,0}
11    \definecolor{darkgreen}{rgb}{0,0.55,0}
12    
13    \usepackage{listings}
14    
15    \lstdefinelanguage{ascend}{
16      morekeywords=[1]{
17         REQUIRE,IMPORT,NOTES,
18         ATOM,MODEL,METHOD,METHODS,
19         UNIVERSAL,CONSTANT,DIMENSION,DEFAULT,
20         END,FOR,CREATE,DO,EXTERNAL,  
21         CONDITIONAL,SATISFIED,WHEN,CASE,OTHERWISE,TRUE,
22         FALSE,SELF,
23      },
24      morekeywords=[2]{
25         REFINES,IS_A,WILL_BE,ALIASES,INPUT,OUTPUT,DATA,
26         FIX,FREE,RUN,ARE_THE_SAME
27      },
28      morekeywords=[3]{
29         solver_var,integer_constant
30      },
31      sensitive=true,
32      morecomment=[s][\color{blue}]{(*}{*)},
33      morestring=[b][\color{darkgreen}]',
34      morestring=[b][\color{darkgreen}]",
35      morecomment=[s][\color{darkgreen}]{\{}{\}},
36    }
37    
38    \lstnewenvironment{ascend}
39      {\lstset{basicstyle=\ttfamily\small, keywordstyle=\color{darkred}}}
40      {}
41    
42    \lstdefinestyle{ascendlisting}{
43      style=ascendlisting,
44      basicstyle=\small\ttfamily,
45      numbers=left,
46      numbersep=5pt,
47      numberstyle=\tiny,
48      escapeinside={(*@}{@*)}
49      backgroundcolor=\color{lightgrey}
50    }
51    \end_preamble
52  \language english  \language english
53  \inputencoding auto  \inputencoding auto
54  \fontscheme default  \fontscheme default
# Line 133  In ASCEND we can create traditional comm Line 179  In ASCEND we can create traditional comm
179  \end_layout  \end_layout
180    
181  \begin_layout LyX-Code  \begin_layout LyX-Code
182    \begin_inset ERT
183    status open
184    
185    \begin_layout Standard
186    
187    
188    \backslash
189    begin{ascend}
190    \end_layout
191    
192    \begin_layout Standard
193    
194  (* This is a comment *)  (* This is a comment *)
195  \end_layout  \end_layout
196    
197  \begin_layout Standard  \begin_layout Standard
198    
199    
200    \backslash
201    end{ascend}
202    \end_layout
203    
204    \end_inset
205    
206    
207    \end_layout
208    
209    \begin_layout Standard
210  is a comment in ASCEND.  is a comment in ASCEND.
211   Traditional comments are only visible when we display the code using the   Traditional comments are only visible when we display the code using the
212   Display code tool   Display code tool
# Line 161  We suggest we can do more for the modele Line 231  We suggest we can do more for the modele
231  \end_layout  \end_layout
232    
233  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 notes are active comments  
234  \begin_inset LatexCommand \index{comments, active}  \begin_inset LatexCommand \index{comments, active}
235    
236  \end_inset  \end_inset
237    
   
 \end_layout  
   
 \end_inset  
   
238  In Figure  In Figure
239  \begin_inset LatexCommand \ref{fig:model2.vesselWithNotes}  \begin_inset LatexCommand \ref{fig:model2.vesselWithNotes}
240    
# Line 183  In Figure Line 243  In Figure
243    
244  \noun off  \noun off
245   we show two types of notes the modeler can add.   we show two types of notes the modeler can add.
246   Longer notes are set off in block style starting with the keyword  
247  \family typewriter  \series bold
248    \noun default
249    Longer notes
250    \series default
251    \noun off
252     are set off in block style starting with the keyword
253    \family sans
254  \noun default  \noun default
255  NOTES  NOTES
256  \family default  \family default
257  \noun off  \noun off
258   and ending with   and ending with
259  \family typewriter  \family sans
260  \noun default  \noun default
261  END NOTES  END NOTES
262  \family default  \family default
# Line 198  END NOTES Line 264  END NOTES
264  .  .
265   In this model, we declare two notes in this manner: (1) to indicate who   In this model, we declare two notes in this manner: (1) to indicate who
266   the author is and (2) to indicate the creation date for this model.   the author is and (2) to indicate the creation date for this model.
267   Note that the notes are director to documenting SELF, which is the model   Note that the notes are director to documenting
268   itself -- i.e., the vessel model as a whole object.  \family sans
269    \noun default
270    SELF
271    \family default
272    \noun off
273    , which is the model itself -- i.e., the vessel model as a whole object.
274   The object one documents can be any instance in the model -- any variable,   The object one documents can be any instance in the model -- any variable,
275   equation or part.   equation or part.
276   The tools for handling notes can sort on the terms enclosed in single quotes   The tools for handling notes can sort on the terms enclosed in single quotes
# Line 207  END NOTES Line 278  END NOTES
278  \end_layout  \end_layout
279    
280  \begin_layout Standard  \begin_layout Standard
281  \begin_inset Float figure  Vessel model with
282  wide false  \family sans
283  sideways false  NOTES
284  status open  \family default
285     added (model
286  \begin_layout LyX-Code  \family typewriter
287  REQUIRE "atoms.a4l";  vesselNotes.a4c
288  \end_layout  \family default
   
 \begin_layout LyX-Code  
 MODEL vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
     NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
         'author'SELF {Arthur W.  
  Westerberg}  
 \end_layout  
   
 \begin_layout LyX-Code  
         'creation date' SELF {May, 1998}  
 \end_layout  
   
 \begin_layout LyX-Code  
     END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
     (* variables *)  
 \end_layout  
   
 \begin_layout LyX-Code  
     side_area "the area of the cylindrical side wall of the vessel",  
 \end_layout  
   
 \begin_layout LyX-Code  
     end_area "the area of the flat ends of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A area;  
 \end_layout  
   
 \begin_layout LyX-Code  
     vessel_vol "the volume contained within the cylindrical vessel",  
 \end_layout  
   
 \begin_layout LyX-Code  
     wall_vol "the volume of the walls for the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A volume;  
 \end_layout  
   
 \begin_layout LyX-Code  
     wall_thickness "the thickness of all of the vessel walls",  
 \end_layout  
   
 \begin_layout LyX-Code  
     H "the vessel height (of the cylindrical side walls)",  
 \end_layout  
   
 \begin_layout LyX-Code  
     D "the vessel diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A distance;  
 \end_layout  
   
 \begin_layout LyX-Code  
     H_to_D_ratio "the ratio of vessel height to diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A factor;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_density "density of the metal from which the vessel  
 \end_layout  
   
 \begin_layout LyX-Code  
                  is constructed"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A mass_density;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_mass "the mass of the metal in the walls of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A mass;  
 \end_layout  
   
 \begin_layout LyX-Code  
     (* equations *)  
 \end_layout  
   
 \begin_layout LyX-Code  
     FlatEnds:end_area = 1{PI} * D^2 / 4;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Sides:side_area = 1{PI} * D * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Cylinder:vessel_vol = end_area * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
     HD_definition:D * H_to_D_ratio = H;  
 \end_layout  
289    
290  \begin_layout LyX-Code  \begin_inset LatexCommand \index{vesselNotes.a4c}
     VesselMass:metal_mass = metal_density * wall_vol;  
 \end_layout  
291    
292  \begin_layout LyX-Code  \end_inset
 END vessel;  
 \end_layout  
293    
294  \begin_layout LyX-Code  )
295    \begin_inset LatexCommand \label{fig:model2.vesselWithNotes}
296    
297  \end_layout  \end_inset
298    
 \begin_layout LyX-Code  
 ADD NOTES IN vessel;  
 \end_layout  
299    
 \begin_layout LyX-Code  
     'description' SELF {This model relates the dimensions of a  
300  \end_layout  \end_layout
301    
302  \begin_layout LyX-Code  \begin_layout Standard
303          cylindrical vessel -- e.g., diameter,  \begin_inset ERT
304  \end_layout  status open
305    
306  \begin_layout LyX-Code  \begin_layout Standard
         height and wall thicknes to the volume of metal  
 \end_layout  
307    
 \begin_layout LyX-Code  
         in the walls.  
   It uses a thin wall assumption  
 \end_layout  
308    
309  \begin_layout LyX-Code  \backslash
310          -- i.e., that the volume of metal is the area of  lstset{language=ASCEND}
311  \end_layout  \end_layout
312    
313  \begin_layout LyX-Code  \begin_layout Standard
         the vessel times the wall thickness.}  
 \end_layout  
314    
 \begin_layout LyX-Code  
     'purpose' SELF {to illustrate the insertion of notes into a model}  
 \end_layout  
315    
316  \begin_layout LyX-Code  \backslash
317  END NOTES;  lstinputlisting[firstline=24]{../models/vesselNotes.a4c}
318  \end_layout  \end_layout
319    
320  \begin_layout Caption  \begin_layout Standard
 Vessel model with Notes added (model vesselNotes.a4c  
 \begin_inset LatexCommand \index{vesselNotes.a4c}  
   
 \end_inset  
   
 )  
 \begin_inset LatexCommand \label{fig:model2.vesselWithNotes}  
   
 \end_inset  
   
321    
322  \end_layout  \end_layout
323    
# Line 410  A user may use any term desired in the s Line 335  A user may use any term desired in the s
335  \end_layout  \end_layout
336    
337  \begin_layout Standard  \begin_layout Standard
338  \begin_inset Marginal  There are also
339  status collapsed  \series bold
340    short notes
341  \begin_layout Standard  \series default
342  there are short notes, long notes and separate notes   we can attach to every variable in the model.
 \end_layout  
   
 \end_inset  
   
 There are also short notes we can attach to every variable in the model.  
343   A "one liner   A "one liner
344  \begin_inset LatexCommand \index{notes, one liner}  \begin_inset LatexCommand \index{notes, one liner}
345    
# Line 442  The last few lines of Figure Line 362  The last few lines of Figure
362    
363    
364  \noun off  \noun off
365   shows adding notes we write in a separate ADD NOTES IN object   shows adding
366    \series bold
367    \noun default
368    separate notes
369    \series default
370    \noun off
371     we write using
372    \family sans
373    \noun default
374    ADD NOTES IN
375    \family default
376    \noun off
377     syntax
378  \begin_inset LatexCommand \index{ADD NOTES IN object}  \begin_inset LatexCommand \index{ADD NOTES IN object}
379    
380  \end_inset  \end_inset
# Line 791  a method to establish typical values for Line 723  a method to establish typical values for
723  \end_layout  \end_layout
724    
725  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 writing the specify and values methods  
 \end_layout  
   
 \end_inset  
   
726  To write the  To write the
727  \family typewriter  \family typewriter
728  specify  specify
# Line 810  values Line 733  values
733  \family default  \family default
734   methods for our vessel model, we note that we have successfully solved   methods for our vessel model, we note that we have successfully solved
735   the vessel model in at least two different ways above.   the vessel model in at least two different ways above.
736   Thus both variations are examples of being ‚well-posed.‚ We can choose which   Thus both variations are examples of being `well-posed'.
737   variation we shall use when creating the   We can choose which variation we shall use when creating the
738  \family typewriter  \family typewriter
739  specify  specify
740  \family default  \family default
# Line 832  metal_density Line 755  metal_density
755  \family typewriter  \family typewriter
756  wall_thickness  wall_thickness
757  \family default  \family default
758   and provided them with the values of 250 ft^3, 3, 5000 kg/m^3 and 5 mm   and provided them with the values of
759   respectively to be our ‚standard‚ specification.  \family typewriter
760    250 ft^3
761    \family default
762    ,
763    \family typewriter
764    3
765    \family default
766    ,
767    \family typewriter
768    5000 kg/m^3
769    \family default
770     and
771    \family typewriter
772    5 mm
773    \family default
774     respectively to be our `standard' specification.
775   Default methods   Default methods
776  \family typewriter  \family typewriter
777  ClearAll  ClearAll
# Line 846  reset Line 784  reset
784  \end_layout  \end_layout
785    
786  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 default methods ClearAll and reset are appropriate  
 \end_layout  
   
 \end_inset  
   
787  As already noted, the purpose of  As already noted, the purpose of
788  \family typewriter  \family typewriter
789  ClearAll  ClearAll
790  \family default  \family default
791   is to set all the fixed flags to FALSE, a well-defined state from which   is to set all the variables to
792   we can start over to set these flags as we wish them set.  \family sans
793    FREE
794    \family default
795    , a well-defined state from which we can start over to set variables
796    \family sans
797    FIX
798    \family default
799    ed as we wish.
800     The method
801  \family typewriter  \family typewriter
802  reset  reset
803  \family default  \family default
# Line 869  reset Line 805  reset
805  \family typewriter  \family typewriter
806  ClearAll  ClearAll
807  \family default  \family default
808   and then   followed by the
809  \family typewriter  \family typewriter
810  specify  specify
811  \family default  \family default
812   for a model.   method for a model.
813   The default versions for these two methods are generally exactly what one   The default versions for these two methods are generally exactly what one
814   wants so one need not write these.   wants so one need not write these.
815  \end_layout  \end_layout
# Line 905  values Line 841  values
841  \end_layout  \end_layout
842    
843  \begin_layout Standard  \begin_layout Standard
844  \begin_inset Float figure  Version of vessel with
845  wide false  \family sans
846  sideways false  METHODS
847  status open  \family default
848     added (
849    \family typewriter
850    vesselMethods.a4c
851    \family default
852    
853  \begin_layout LyX-Code  \begin_inset LatexCommand \index{vesselMethods.a4c}
 REQUIRE "atoms.a4l";  
 \end_layout  
854    
855  \begin_layout LyX-Code  \end_inset
 MODEL vessel;  
 \end_layout  
856    
857  \begin_layout LyX-Code  )
858      NOTES  \begin_inset LatexCommand \label{fig:model2.vesselWithMethods}
 \end_layout  
859    
860  \begin_layout LyX-Code  \end_inset
         'author' SELF {Arthur W.  
  Westerberg}  
 \end_layout  
861    
 \begin_layout LyX-Code  
         'creation date' SELF {May, 1998}  
 \end_layout  
862    
 \begin_layout LyX-Code  
     END NOTES;  
863  \end_layout  \end_layout
864    
865  \begin_layout LyX-Code  \begin_layout Standard
866        \begin_inset ERT
867  \end_layout  status open
868    
869  \begin_layout LyX-Code  \begin_layout Standard
     (* variables *)  
 \end_layout  
870    
 \begin_layout LyX-Code  
     side_area "the area of the cylindrical side wall of the vessel",  
 \end_layout  
871    
872  \begin_layout LyX-Code  \backslash
873      end_area "the area of the flat ends of the vessel"  lstset{language=ASCEND}
874  \end_layout  \end_layout
875    
876  \begin_layout LyX-Code  \begin_layout Standard
                 IS_A area;  
 \end_layout  
   
 \begin_layout LyX-Code  
     vessel_vol "the volume contained within the cylindrical vessel",  
 \end_layout  
   
 \begin_layout LyX-Code  
     wall_vol "the volume of the walls for the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A volume;  
 \end_layout  
   
 \begin_layout LyX-Code  
     wall_thickness "the thickness of all of the vessel walls",  
 \end_layout  
   
 \begin_layout LyX-Code  
     H "the vessel height (of the cylindrical side walls)",  
 \end_layout  
   
 \begin_layout LyX-Code  
     D "the vessel diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A distance;  
 \end_layout  
   
 \begin_layout LyX-Code  
     H_to_D_ratio "the ratio of vessel height to diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A factor;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_density "density of the metal from which the vessel  
 \end_layout  
   
 \begin_layout LyX-Code  
                  is constructed"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A mass_density;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_mass "the mass of the metal in the walls of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A mass;  
 \end_layout  
   
 \begin_layout LyX-Code  
     (* equations *)  
 \end_layout  
   
 \begin_layout LyX-Code  
     FlatEnds:end_area = 1{PI} * D^2 / 4;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Sides:side_area = 1{PI} * D * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Cylinder:vessel_vol = end_area * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
     HD_definition:D * H_to_D_ratio = H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     VesselMass:metal_mass = metal_density * wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
   
 \end_layout  
   
 \begin_layout LyX-Code  
 METHODS  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD specify;  
 \end_layout  
   
 \begin_layout LyX-Code  
         NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
             'purpose' SELF {to fix four variables and make the problem well-pose  
 d}  
 \end_layout  
   
 \begin_layout LyX-Code  
         END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
         vessel_vol.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
         H_to_D_ratio.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
         wall_thickness.fixed  :=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
         metal_density.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END specify;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD values;  
 \end_layout  
   
 \begin_layout LyX-Code  
         NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
             'purpose' SELF {to set the values for the fixed variables}  
 \end_layout  
   
 \begin_layout LyX-Code  
         END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
         H_to_D_ratio            :=   2;  
 \end_layout  
   
 \begin_layout LyX-Code  
         vessel_vol              :=   250 {ft^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
         wall_thickness          :=      5 {mm};  
 \end_layout  
   
 \begin_layout LyX-Code  
         metal_density           :=   5000 {kg/m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
     END values;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
         D:=1 {m};  
 \end_layout  
   
 \begin_layout LyX-Code  
         H:=1 {m};  
 \end_layout  
   
 \begin_layout LyX-Code  
         H_to_D_ratio            :=1;  
 \end_layout  
   
 \begin_layout LyX-Code  
         vessel_vol              := 1 {m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
         wall_thickness          :=5 {mm};  
 \end_layout  
   
 \begin_layout LyX-Code  
         metal_density           :=5000 {kg/m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
     END default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
   
 \end_layout  
   
 \begin_layout LyX-Code  
 ADD NOTES IN vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
     'description' SELF {This model relates the dimensions of a  
 \end_layout  
   
 \begin_layout LyX-Code  
         cylindrical vessel -- e.g., diameter, height and wall thickness  
 \end_layout  
   
 \begin_layout LyX-Code  
         to the volume of metal in the walls.  
   It uses a thin wall  
 \end_layout  
   
 \begin_layout LyX-Code  
         assumption -- i.e., that the volume of metal is the area of  
 \end_layout  
   
 \begin_layout LyX-Code  
         the vessel times the wall thickness.}  
 \end_layout  
   
 \begin_layout LyX-Code  
     'purpose' SELF {to illustrate the insertion of notes into a model}  
 \end_layout  
   
 \begin_layout LyX-Code  
 END NOTES;  
 \end_layout  
   
 \begin_layout Caption  
 Version of vessel with methods added (vesselMethods.a4c  
 \begin_inset LatexCommand \index{vesselMethods.a4c}  
   
 \end_inset  
   
 )  
 \begin_inset LatexCommand \label{fig:model2.vesselWithMethods}  
   
 \end_inset  
877    
878    
879    \backslash
880    lstinputlisting[firstline=23]{../models/vesselMethods.a4c}
881  \end_layout  \end_layout
882    
883  \end_inset  \end_inset
# Line 1534  a method to check that the computations Line 1191  a method to check that the computations
1191  \end_layout  \end_layout
1192    
1193  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 standard methods to a model definition  
 \end_layout  
   
 \end_inset  
   
1194  The  The
1195  \family typewriter  \family typewriter
1196  bound_self  bound_self
# Line 1572  defaults_self Line 1220  defaults_self
1220  \end_layout  \end_layout
1221    
1222  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status open  
   
 \begin_layout Standard  
 using methods when solving  
 \end_layout  
   
 \end_inset  
   
1223  Exit ASCEND and repeat all the steps above to edit, load and compile this  Exit ASCEND and repeat all the steps above to edit, load and compile this
1224   new vessel type definition.   new vessel type definition.
1225   Then proceed as follows.   Then proceed as follows.
# Line 1648  Parameterizing the vessel model Line 1287  Parameterizing the vessel model
1287  \end_layout  \end_layout
1288    
1289  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 let's compute metal_mass vs.  
  H_to_D_ratio  
 \end_layout  
   
 \end_inset  
   
1290  Reuse generally implies creating a model which will have as a part an instance  Reuse generally implies creating a model which will have as a part an instance
1291   of a previously defined type.   of a previously defined type.
1292   For example, let us compute metal_mass as a function of the H_to_D_ratio   For example, let us compute metal_mass as a function of the H_to_D_ratio
# Line 1673  Creating a parameterized version of vess Line 1302  Creating a parameterized version of vess
1302  \end_layout  \end_layout
1303    
1304  \begin_layout Standard  \begin_layout Standard
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 parameters indicate likely object sharing  
 \end_layout  
   
 \end_inset  
   
1305  To use instances of our model as parts in another model, we can parameterize  To use instances of our model as parts in another model, we can parameterize
1306   it.   it.
1307   We use parameterization to tell a future user that the parameters are objects   We use parameterization to tell a future user that the parameters are objects
# Line 1747  The code in Figure Line 1367  The code in Figure
1367  \end_layout  \end_layout
1368    
1369  \begin_layout Standard  \begin_layout Standard
1370  \begin_inset Float figure  \begin_inset LatexCommand \label{fig:model2.parameterizedVessel}
 wide false  
 sideways false  
 status open  
1371    
1372  \begin_layout LyX-Code  \end_inset
 REQUIRE "atoms.a4l";  
 \end_layout  
1373    
1374  \begin_layout LyX-Code  The parameterized version of vessel model (
1375  MODEL vessel(  \begin_inset LatexCommand \index{1014608}
 \end_layout  
1376    
1377  \begin_layout LyX-Code  \end_inset
     vessel_vol "the volume contained within the cylindrical vessel"  
 \end_layout  
1378    
1379  \begin_layout LyX-Code  vesselParams.a4c)
         WILL_BE volume;  
1380  \end_layout  \end_layout
1381    
1382  \begin_layout LyX-Code  \begin_layout Standard
1383      wall_thickness "the thickness of all of the vessel walls"  \begin_inset ERT
1384  \end_layout  status open
1385    
1386  \begin_layout LyX-Code  \begin_layout Standard
         WILL_BE distance;  
 \end_layout  
1387    
 \begin_layout LyX-Code  
     metal_density "density of the metal from which the vessel  
 \end_layout  
1388    
1389  \begin_layout LyX-Code  \backslash
1390              is constructed"  lstset{language=ASCEND}
1391  \end_layout  \end_layout
1392    
1393  \begin_layout LyX-Code  \begin_layout Standard
         WILL_BE mass_density;  
 \end_layout  
1394    
 \begin_layout LyX-Code  
     H_to_D_ratio "the ratio of vessel height to diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
         WILL_BE factor;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_mass "the mass of the metal in the walls of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
         WILL_BE mass;  
 \end_layout  
   
 \begin_layout LyX-Code  
 );  
 \end_layout  
   
 \begin_layout LyX-Code  
     NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
         'author' SELF {Arthur W.  
  Westerberg}  
 \end_layout  
   
 \begin_layout LyX-Code  
         'creation date' SELF {May, 1998}  
 \end_layout  
   
 \begin_layout LyX-Code  
     END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
       
 \end_layout  
   
 \begin_layout LyX-Code  
     (* variables *)  
 \end_layout  
   
 \begin_layout LyX-Code  
     side_area "the area of the cylindrical side wall of the vessel",  
 \end_layout  
   
 \begin_layout LyX-Code  
     end_area "the area of the flat ends of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A area;  
 \end_layout  
   
 \begin_layout LyX-Code  
     wall_vol "the volume of the walls for the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A volume;  
 \end_layout  
   
 \begin_layout LyX-Code  
     H "the vessel height (of the cylindrical side walls)",  
 \end_layout  
   
 \begin_layout LyX-Code  
     D "the vessel diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A distance;  
 \end_layout  
   
 \begin_layout LyX-Code  
     (* equations *)  
 \end_layout  
   
 \begin_layout LyX-Code  
     FlatEnds:end_area = 1{PI} * D^2 / 4;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Sides:side_area = 1{PI} * D * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Cylinder:vessel_vol = end_area * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
     HD_definition:D * H_to_D_ratio = H;  
 \end_layout  
   
 \begin_layout LyX-Code  
     VesselMass:metal_mass = metal_density * wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
   
 \end_layout  
   
 \begin_layout LyX-Code  
 METHODS  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD specify;  
 \end_layout  
   
 \begin_layout LyX-Code  
         NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
             'purpose' SELF {to fix four variables and make the problem well-pose  
 d}  
 \end_layout  
   
 \begin_layout LyX-Code  
         END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
         vessel_vol.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
         H_to_D_ratio.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
         wall_thickness.fixed  :=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
         metal_density.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END specify;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD values;  
 \end_layout  
   
 \begin_layout LyX-Code  
         NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
            'purpose' SELF {to set the values for the fixed variables}  
 \end_layout  
   
 \begin_layout LyX-Code  
         END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
         H_to_D_ratio:=2;  
 \end_layout  
   
 \begin_layout LyX-Code  
         vessel_vol:=250 {ft^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
         wall_thickness:=5 {mm};  
 \end_layout  
   
 \begin_layout LyX-Code  
         metal_density:=5000 {kg/m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
     END values;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD bound_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
         RUN bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END bound_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD scale_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
         RUN scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END scale_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
         D:=1 {m};  
 \end_layout  
   
 \begin_layout LyX-Code  
         H:=1 {m};  
 \end_layout  
   
 \begin_layout LyX-Code  
     END default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
     METHOD default_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
        RUN default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
        vessel_vol:=1 {m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
        wall_thickness:=5 {mm};  
 \end_layout  
   
 \begin_layout LyX-Code  
        metal_density:=5000 {kg/m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
        H_to_D_ratio:=1;  
 \end_layout  
   
 \begin_layout LyX-Code  
     END default_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
 ADD NOTES IN vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
     'description' SELF {This model relates the dimensions of a  
 \end_layout  
   
 \begin_layout LyX-Code  
         cylindrical vessel -- e.g., diameter, height and wall thickness  
 \end_layout  
   
 \begin_layout LyX-Code  
         to the volume of metal in the walls.  
   It uses a thin wall  
 \end_layout  
   
 \begin_layout LyX-Code  
         assumption -- i.e., that the volume of metal is the area of  
 \end_layout  
   
 \begin_layout LyX-Code  
         the vessel times the wall thickness.}  
 \end_layout  
   
 \begin_layout LyX-Code  
     'purpose' SELF {to illustrate the insertion of notes into a model}  
 \end_layout  
   
 \begin_layout LyX-Code  
 END NOTES;  
 \end_layout  
   
 \begin_layout Caption  
 \begin_inset LatexCommand \label{fig:model2.parameterizedVessel}  
   
 \end_inset  
   
 The parameterized version of vessel model (  
 \begin_inset LatexCommand \index{1014608}  
   
 \end_inset  
   
 vesselParams.a4c)  
 \end_layout  
   
 \end_inset  
   
   
 \end_layout  
   
 \begin_layout Standard  
 Substitute the statements in Figure  
 \begin_inset LatexCommand \ref{fig:model2.parameterizedVessel}  
   
 \end_inset  
   
   
 \noun off  
  for lines 2 through 9 in  
 \noun default  
 Figure  
 \noun off  
   
 \begin_inset LatexCommand \ref{fig:model2.vesselWithMethods}  
   
 \end_inset  
   
 .  
  Save the result in the file vesselParam.a4c.  
 \end_layout  
   
 \begin_layout Standard  
 Note the use of the  
 \begin_inset LatexCommand \index{1014610}  
   
 \end_inset  
   
   
 \begin_inset LatexCommand \index{1014609}  
   
 \end_inset  
   
   
 \family typewriter  
 WILL_BE  
 \family default  
  statement in the parameter list.  
  By declaring that the type of a parameter will be compatible with the types  
  shown, the compiler can tell immediately if a user of this model is passing  
  the wrong type of object when defining an instance of a vessel.  
 \end_layout  
   
 \begin_layout Subsection  
 Using the parameterized vessel model  
 \end_layout  
   
 \begin_layout Standard  
 \begin_inset Marginal  
 status collapsed  
   
 \begin_layout Standard  
 Creating a  
 \begin_inset LatexCommand \index{1014611}  
   
 \end_inset  
   
 table of metal_mass values vs.  
  H_to_D_ratio  
 \end_layout  
   
 \end_inset  
   
 A type definition  will set up our table of H_to_D_ratio values vs.  
  metal_mass so we can observe approximately where it attains a minimum value.  
  ASCEND allows us to create arrays of instances of any type.  
  Here we shall create an array of vessels.  
  The type definition is shown in Figure  
 \begin_inset LatexCommand \ref{fig:model2.tabulatedVessel}  
   
 \end_inset  
   
   
 \noun off  
 .  
  Note that the line numbers are not a part of the actual code.  
  We include them here only so we can reference them as needed later.  
 \end_layout  
   
 \begin_layout Standard  
 \begin_inset Float figure  
 wide false  
 sideways false  
 status open  
   
 \begin_layout LyX-Code  
 REQUIRE "atoms.a4l";  
 \end_layout  
   
 \begin_layout LyX-Code  
 MODEL vessel(  
 \end_layout  
   
 \begin_layout LyX-Code  
 vessel_vol "the volume contained within the cylindrical vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
 WILL_BE volume;  
 \end_layout  
   
 \begin_layout LyX-Code  
 wall_thickness "the thickness of all of the vessel walls"  
 \end_layout  
   
 \begin_layout LyX-Code  
 WILL_BE distance;  
 \end_layout  
   
 \begin_layout LyX-Code  
 metal_density "density of the metal from which the vessel  
 \end_layout  
   
 \begin_layout LyX-Code  
                  is constructed"  
 \end_layout  
   
 \begin_layout LyX-Code  
 WILL_BE mass_density;  
 \end_layout  
   
 \begin_layout LyX-Code  
 H_to_D_ratio "the ratio of vessel height to diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
 WILL_BE factor;  
 \end_layout  
   
 \begin_layout LyX-Code  
 metal_mass "the mass of the metal in the walls of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
 WILL_BE mass;  
 \end_layout  
   
 \begin_layout LyX-Code  
 );  
 \end_layout  
   
 \begin_layout LyX-Code  
     NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
 'author' SELF {Arthur W.  
  Westerberg}  
 \end_layout  
   
 \begin_layout LyX-Code  
 'creation date' SELF {May, 1998}  
 \end_layout  
   
 \begin_layout LyX-Code  
     END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
       
 \end_layout  
   
 \begin_layout LyX-Code  
 (* variables *)  
 \end_layout  
   
 \begin_layout LyX-Code  
 side_area "the area of the cylindrical side wall of the vessel",  
 \end_layout  
   
 \begin_layout LyX-Code  
 end_area "the area of the flat ends of the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A area;  
 \end_layout  
   
 \begin_layout LyX-Code  
 wall_vol "the volume of the walls for the vessel"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A volume;  
 \end_layout  
   
 \begin_layout LyX-Code  
 H "the vessel height (of the cylindrical side walls)",  
 \end_layout  
   
 \begin_layout LyX-Code  
 D "the vessel diameter"  
 \end_layout  
   
 \begin_layout LyX-Code  
                 IS_A distance;  
 \end_layout  
   
 \begin_layout LyX-Code  
 (* equations *)  
 \end_layout  
   
 \begin_layout LyX-Code  
 FlatEnds:end_area = 1{PI} * D^2 / 4;  
 \end_layout  
   
 \begin_layout LyX-Code  
 Sides:side_area = 1{PI} * D * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
 Cylinder:vessel_vol = end_area * H;  
 \end_layout  
   
 \begin_layout LyX-Code  
 Metal_volume:(side_area + 2 * end_area) * wall_thickness = wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
 HD_definition:D * H_to_D_ratio = H;  
 \end_layout  
   
 \begin_layout LyX-Code  
 VesselMass:metal_mass = metal_density * wall_vol;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHODS  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD specify;  
 \end_layout  
   
 \begin_layout LyX-Code  
     NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
 'purpose' SELF {to fix four variables and make the problem well-posed}  
 \end_layout  
   
 \begin_layout LyX-Code  
     END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
 vessel_vol.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
 H_to_D_ratio.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
 wall_thickness.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
 metal_density.fixed:=TRUE;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END specify;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD values;  
 \end_layout  
   
 \begin_layout LyX-Code  
     NOTES  
 \end_layout  
   
 \begin_layout LyX-Code  
 'purpose' SELF {to set the values for the fixed variables}  
 \end_layout  
   
 \begin_layout LyX-Code  
     END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
 H_to_D_ratio:=2;  
 \end_layout  
   
 \begin_layout LyX-Code  
 vessel_vol:=250 {ft^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
 wall_thickness:=5 {mm};  
 \end_layout  
   
 \begin_layout LyX-Code  
 metal_density:=5000 {kg/m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
 END values;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD bound_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
     RUN bound_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END bound_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD scale_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
     RUN scale_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END scale_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 D:= 1 {m};  
 \end_layout  
   
 \begin_layout LyX-Code  
 H:=1 {m};  
 \end_layout  
   
 \begin_layout LyX-Code  
 END default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 METHOD default_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
     RUN default_self;  
 \end_layout  
   
 \begin_layout LyX-Code  
 vessel_vol:=1 {m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
 wall_thickness:=5 {mm};  
 \end_layout  
   
 \begin_layout LyX-Code  
 metal_density:=5000 {kg/m^3};  
 \end_layout  
   
 \begin_layout LyX-Code  
 H_to_D_ratio:=1;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END default_all;  
 \end_layout  
   
 \begin_layout LyX-Code  
 END vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
   
 \end_layout  
   
 \begin_layout LyX-Code  
 ADD NOTES IN vessel;  
 \end_layout  
   
 \begin_layout LyX-Code  
 'description' SELF {This model relates the dimensions of a  
 \end_layout  
   
 \begin_layout LyX-Code  
            cylindrical vessel -- e.g., diameter, height and wall thickness  
 \end_layout  
   
 \begin_layout LyX-Code  
            to the volume of metal in the walls.  
   It uses a thin wall  
 \end_layout  
   
 \begin_layout LyX-Code  
            assumption -- i.e., that the volume of metal is the area of  
 \end_layout  
   
 \begin_layout LyX-Code  
            the vessel times the wall thickness.}  
 \end_layout  
   
 \begin_layout LyX-Code  
 'purpose' SELF {to illustrate the insertion of notes into a model}  
 \end_layout  
   
 \begin_layout LyX-Code  
 END NOTES;  
 \end_layout  
   
 \begin_layout LyX-Code  
   
 \end_layout  
   
 \begin_layout LyX-Code  
 MODEL tabulated_vessel_values;  
 \end_layout  
   
 \begin_layout LyX-Code  
     vessel_volume "volume of all the tabulated vessels"  
 \end_layout  
   
 \begin_layout LyX-Code  
             IS_A volume;  
 \end_layout  
1395    
1396  \begin_layout LyX-Code  \backslash
1397      wall_thickness "thickness of all the walls for all the vessels"  lstinputlisting[firstline=24]{../models/vesselParams.a4c}
 \end_layout  
   
 \begin_layout LyX-Code  
     IS_A distance;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_density "density of metal used for all vessels"  
 \end_layout  
   
 \begin_layout LyX-Code  
     IS_A mass_density;  
 \end_layout  
   
 \begin_layout LyX-Code  
     n_entries "number of vessels to simulate"  
 \end_layout  
   
 \begin_layout LyX-Code  
             IS_A integer_constant;  
 \end_layout  
   
 \begin_layout LyX-Code  
     n_entries :== 20;  
 \end_layout  
   
 \begin_layout LyX-Code  
     H_to_D_ratio[1..n_entries]"set of H to D ratios for which we are  
 \end_layout  
   
 \begin_layout LyX-Code  
                  computing metal mass"  
 \end_layout  
   
 \begin_layout LyX-Code  
             IS_A factor;  
 \end_layout  
   
 \begin_layout LyX-Code  
     metal_mass[1..n_entries]"mass of metal in walls of vessels"  
 \end_layout  
   
 \begin_layout LyX-Code  
     IS_A mass;  
 \end_layout  
   
 \begin_layout LyX-Code  
     FOR i IN [1..n_entries] CREATE  
 \end_layout  
   
 \begin_layout LyX-Code  
         v[i] "the i-th vessel model"  
 \end_layout  
   
 \begin_layout LyX-Code  
         IS_A  vessel(vessel_volume, wall_thickness,  
 \end_layout  
   
 \begin_layout LyX-Code  
                  metal_density, H_to_D_ratio[i], metal_mass[i]);  
1398  \end_layout  \end_layout
1399    
1400  \begin_layout LyX-Code  \end_inset
     END FOR;  
 \end_layout  
1401    
 \begin_layout LyX-Code  
1402    
1403  \end_layout  \end_layout
1404    
1405  \begin_layout LyX-Code  \begin_layout Standard
1406  METHODS  Substitute the statements in Figure
1407  \end_layout  \begin_inset LatexCommand \ref{fig:model2.parameterizedVessel}
1408    
1409  \begin_layout LyX-Code  \end_inset
 METHOD default_self;  
 \end_layout  
1410    
 \begin_layout LyX-Code  
 END default_self;  
 \end_layout  
1411    
1412  \begin_layout LyX-Code  \noun off
1413     for lines 2 through 9 in
1414    \noun default
1415    Figure
1416    \noun off
1417    
1418  \end_layout  \begin_inset LatexCommand \ref{fig:model2.vesselWithMethods}
1419    
1420  \begin_layout LyX-Code  \end_inset
 METHOD specify;  
 \end_layout  
1421    
1422  \begin_layout LyX-Code  .
1423  RUN v[1..n_entries].specify;   Save the result in the file vesselParam.a4c.
1424  \end_layout  \end_layout
1425    
1426  \begin_layout LyX-Code  \begin_layout Standard
1427  END specify;  Note the use of the
1428  \end_layout  \begin_inset LatexCommand \index{1014610}
1429    
1430  \begin_layout LyX-Code  \end_inset
 METHOD values;  
 \end_layout  
1431    
 \begin_layout LyX-Code  
     NOTES 'purpose' SELF {to set up 20 vessel models having H to D ratios  
 \end_layout  
1432    
1433  \begin_layout LyX-Code  \begin_inset LatexCommand \index{1014609}
         ranging from 0.1 to 2.}  
 \end_layout  
1434    
1435  \begin_layout LyX-Code  \end_inset
     END NOTES;  
 \end_layout  
1436    
 \begin_layout LyX-Code  
 vessel_volume := 250 {ft^3};  
 \end_layout  
1437    
1438  \begin_layout LyX-Code  \family typewriter
1439  wall_thickness := 5 {mm};  WILL_BE
1440    \family default
1441     statement in the parameter list.
1442     By declaring that the type of a parameter will be compatible with the types
1443     shown, the compiler can tell immediately if a user of this model is passing
1444     the wrong type of object when defining an instance of a vessel.
1445  \end_layout  \end_layout
1446    
1447  \begin_layout LyX-Code  \begin_layout Subsection
1448  metal_density := 5000 {kg/m^3};  Using the parameterized vessel model
1449  \end_layout  \end_layout
1450    
1451  \begin_layout LyX-Code  \begin_layout Standard
1452  FOR i IN [1..n_entries] DO  A type definition  will set up our
1453  \end_layout  \begin_inset LatexCommand \index{1014611}
1454    
1455  \begin_layout LyX-Code  \end_inset
 H_to_D_ratio[i] := i/10.0;  
 \end_layout  
1456    
1457  \begin_layout LyX-Code  table of H_to_D_ratio values vs.
1458  END FOR;   metal_mass so we can observe approximately where it attains a minimum value.
1459  \end_layout   ASCEND allows us to create arrays of instances of any type.
1460     Here we shall create an array of vessels.
1461     The type definition is shown in Figure
1462    \begin_inset LatexCommand \ref{fig:model2.tabulatedVessel}
1463    
1464  \begin_layout LyX-Code  \end_inset
 END values;  
 \end_layout  
1465    
 \begin_layout LyX-Code  
 METHOD scale_self;  
 \end_layout  
1466    
1467  \begin_layout LyX-Code  \noun off
1468  END scale_self;  .
1469     Note that the line numbers are not a part of the actual code.
1470     We include them here only so we can reference them as needed later.
1471  \end_layout  \end_layout
1472    
1473  \begin_layout LyX-Code  \begin_layout Standard
1474  END tabulated_vessel_values;  tabulated_vessel_values model
1475  \end_layout  \begin_inset LatexCommand \label{fig:model2.tabulatedVessel}
1476    
1477  \begin_layout LyX-Code  \end_inset
       
 \end_layout  
1478    
 \begin_layout LyX-Code  
 ADD NOTES IN tabulated_vessel_values;  
 \end_layout  
1479    
 \begin_layout LyX-Code  
 'description' SELF {This model sets up an array of vessels to  
1480  \end_layout  \end_layout
1481    
1482  \begin_layout LyX-Code  \begin_layout Standard
1483             compute a range of metal_mass values for different values  \begin_inset ERT
1484  \end_layout  status open
1485    
1486  \begin_layout LyX-Code  \begin_layout Standard
            of H_to_D_ratio.}  
 \end_layout  
1487    
 \begin_layout LyX-Code  
 'purpose' SELF {to illustrate the use of arrays in ASCEND}  
 \end_layout  
1488    
1489  \begin_layout LyX-Code  \backslash
1490  END NOTES;  lstset{language=ASCEND}
1491  \end_layout  \end_layout
1492    
1493  \begin_layout Caption  \begin_layout Standard
 tabulated_vessel_values model  
 \begin_inset LatexCommand \label{fig:model2.tabulatedVessel}  
   
 \end_inset  
1494    
1495    
1496    \backslash
1497    lstinputlisting[firstline=26]{../models/vesselTabulated.a4c}
1498  \end_layout  \end_layout
1499    
1500  \end_inset  \end_inset
# Line 3119  You will run the same sequence of instru Line 1868  You will run the same sequence of instru
1868  \end_layout  \end_layout
1869    
1870  \begin_layout Standard  \begin_layout Standard
1871  \begin_inset Float figure  \begin_inset LatexCommand \label{fig:model2.scriptVesselTabulated}
 wide false  
 sideways false  
 status open  
   
 \begin_layout LyX-Code  
 DELETE TYPES;  
 \end_layout  
   
 \begin_layout LyX-Code  
 READ FILE "C:/My Documents/1998/ascdata/vesselTabulated.a4c";  
 \end_layout  
   
 \begin_layout LyX-Code  
 COMPILE tv OF tabulated_vessel_values;  
 \end_layout  
   
 \begin_layout LyX-Code  
 BROWSE {tv};  
 \end_layout  
   
 \begin_layout LyX-Code  
 RUN {tv.reset};  
 \end_layout  
   
 \begin_layout LyX-Code  
 RUN {tv.values};  
 \end_layout  
1872    
1873  \begin_layout LyX-Code  \end_inset
 SOLVE {tv} WITH QRSlv;  
 \end_layout  
1874    
 \begin_layout Caption  
1875  Script to run  Script to run
1876  \family typewriter  \family typewriter
1877  vesselTabulated.a4c  vesselTabulated.a4c
# Line 3167  vesselTabulated.a4s Line 1886  vesselTabulated.a4s
1886  \end_inset  \end_inset
1887    
1888  )  )
1889  \begin_inset LatexCommand \label{fig:model2.scriptVesselTabulated}  \end_layout
1890    
1891  \end_inset  \begin_layout Standard
1892    \begin_inset ERT
1893    status open
1894    
1895    \begin_layout Standard
1896    
1897    
1898    \backslash
1899    lstinputlisting[firstline=29]{../models/vesselTabulated.a4s}
1900  \end_layout  \end_layout
1901    
1902  \end_inset  \end_inset

Legend:
Removed from v.1384  
changed lines
  Added in v.1385

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