/[ascend]/trunk/doc/syntax.lyx
ViewVC logotype

Contents of /trunk/doc/syntax.lyx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1733 - (show annotations) (download) (as text)
Wed Feb 6 00:18:31 2008 UTC (14 years, 8 months ago) by jpye
File MIME type: application/x-lyx
File size: 179854 byte(s)
In process of moving DOPRI5 solver to 'solvers' dir.
1 #LyX 1.5.1 created this file. For more info see http://www.lyx.org/
2 \lyxformat 276
3 \begin_document
4 \begin_header
5 \textclass book
6 \begin_preamble
7 \usepackage[bookmarks]{hyperref}
8 \usepackage{lmodern}
9 \end_preamble
10 \language english
11 \inputencoding auto
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_default_family default
16 \font_sc false
17 \font_osf false
18 \font_sf_scale 100
19 \font_tt_scale 100
20 \graphics default
21 \paperfontsize default
22 \spacing single
23 \papersize default
24 \use_geometry false
25 \use_amsmath 1
26 \use_esint 0
27 \cite_engine basic
28 \use_bibtopic false
29 \paperorientation portrait
30 \secnumdepth 3
31 \tocdepth 3
32 \paragraph_separation indent
33 \defskip medskip
34 \quotes_language english
35 \papercolumns 1
36 \papersides 1
37 \paperpagestyle default
38 \tracking_changes false
39 \output_changes false
40 \author ""
41 \end_header
42
43 \begin_body
44
45 \begin_layout Chapter
46 Syntax reference
47 \begin_inset LatexCommand label
48 name "cha:ASCENDSyntax"
49
50 \end_inset
51
52
53 \end_layout
54
55 \begin_layout Standard
56 We shall present an informal description of the ASCEND IV language.
57 Being informal, we shall usually include examples and descriptions of the
58 intended semantics along with the syntax of the items.
59 At times the inclusion of semantics will seem to anticipate later definitions.
60 We do this because we would also like this chapter to be used as a reference
61 for the ASCEND language even after one generally understands it.
62 Often one will need to clarify a point about a particular item and will
63 not wish to have to search in several places to do so.
64 \end_layout
65
66 \begin_layout Standard
67 Syntax
68 \begin_inset LatexCommand index
69 name "syntax"
70
71 \end_inset
72
73 is the form or structure for the statements in ASCEND, where one worries
74 about the exact words one uses, their ordering, the punctuation, etc.
75 Semantics
76 \begin_inset LatexCommand index
77 name "semantics"
78
79 \end_inset
80
81 describe the meaning of a statement.
82 \end_layout
83
84 \begin_layout Standard
85 To distinguish between syntax and semantics, consider the statement
86 \end_layout
87
88 \begin_layout LyX-Code
89 y IS_A fraction;
90 \end_layout
91
92 \begin_layout Standard
93 Rules on the syntax for this statement tell us we need a user supplied instance
94 name, y, followed by the ASCEND operator IS_A, followed by a type name
95 (fraction).
96 The statement terminates with a semicolon.
97 The statement semantics says we are declaring the existence of an instance,
98 locally named y, of the type fraction as a part within the current model
99 definition and it is to be constructed when an instance of the current
100 model definition is constructed.
101 \end_layout
102
103 \begin_layout Standard
104 The syntax for a computer language is often defined by using a Bachus-Naur
105 \begin_inset LatexCommand index
106 name "Bachus-Naur"
107
108 \end_inset
109
110 formal (BNF
111 \begin_inset LatexCommand index
112 name "BNF"
113
114 \end_inset
115
116 ) description.
117 The complete YACC
118 \begin_inset LatexCommand index
119 name "YACC"
120
121 \end_inset
122
123 and FLEX
124 \begin_inset LatexCommand index
125 name "FLEX"
126
127 \end_inset
128
129 description of the language described (as presently implemented) is available
130 by FTP and via the World Wide Web.
131 The semantics of a very high level modeling language such as ASCEND IV
132 are generally much more restrictive than the syntax.
133 For this reason we do not include a BNF description in this paper.
134 ASCEND IV is an experiment.
135 The language is under constant scrutiny and improvement, so this document
136 is under constant revision.
137
138 \end_layout
139
140 \begin_layout List
141 \labelwidthstring 00000.00000.00000.000
142 \InsetSpace ~
143
144 \end_layout
145
146 \begin_deeper
147 \begin_layout Chapter
148 Preliminaries
149 \end_layout
150
151 \begin_layout Standard
152 We will start off with some background information and some tips that make
153 the rest of the chapter easier to read.
154 ASCEND is an object-oriented (OO) language for hierarchical modeling that
155 has been somewhat specialized for mathematical models.
156 Most of the specialization is in the implementation and the user interface
157 rather than the language definition.
158
159 \end_layout
160
161 \begin_layout Standard
162 We feel the single most distinguishing feature of mathematical models is
163 that solving them efficiently requires that the solving algorithms be able
164 to address the entire problem either simultaneously or in a decomposition
165 of the natural problem structure that the algorithm determines is best
166 for the machine(s) in use.
167 In the ASCEND language object-orientation is used to organize natural structure
168 s and make them easier to understand.
169 It is not used to hide the details of the objects.
170 The user (or machine) is free to ignore uninteresting details, and the
171 ASCEND environment provides tools for the runtime suppression of these.
172 \end_layout
173
174 \begin_layout Standard
175 ASCEND is well into its 4th generation.
176 Some features we will describe are not yet implemented (some merely speculative
177 ) and these are clearly marked (* 4+ *).
178 Any feature not marked (* 4+ *)has been completely implemented, and thus
179 any mismatch between the description given here and the software we distribute
180 is a bug we want you to tell us about.
181
182 \end_layout
183
184 \begin_layout Standard
185 The syntax and semantics of ASCEND may seem at first a bit unusual.
186 However, do not be afraid to just try what comes naturally if what we write
187 here is unclear.
188 The parser and compiler of ASCEND IV really will help you get things right.
189 Of course if what we write here is unclear, please ask us about it because
190 we aim to continuously improve both this document and the language system
191 it describes.
192 \end_layout
193
194 \begin_layout Standard
195 We will describe, starting in Section
196 \begin_inset LatexCommand vref
197 reference "sub:x.1.2Basic-Elements"
198
199 \end_inset
200
201 , the higher level concepts of ASCEND, but first some important punctuation
202 rules.
203 \end_layout
204
205 \end_deeper
206 \begin_layout List
207 \labelwidthstring 00000.00000.00000.000
208 ASCEND\InsetSpace ~
209 is\InsetSpace ~
210 cAsE\InsetSpace ~
211 sensitive
212 \begin_inset LatexCommand index
213 name "case sensitive"
214
215 \end_inset
216
217 !
218 \end_layout
219
220 \begin_deeper
221 \begin_layout Standard
222 The keywords that are shown capitalized (or in lower case) in this chapter
223 are that way because ASCEND is case sensitive.
224 IS_A is an ASCEND keyword; isa, Is_a, and all the other permutations you
225 can think of are NOT equivalent to IS_A.
226 In declaring new types of models and variables the user is free to use
227 any style of capitalization he or she may prefer; however, they must remain
228 consistent or undefined types and instances will result.
229 \end_layout
230
231 \begin_layout Standard
232 This case restriction makes our code very readable, but hard to type without
233 a smart editor.
234 We have kept the case-sensitivity because, like all mathematicians, we
235 find ourselves running out of good variable names if we are restricted
236 to a 26 letter alphabet.
237 We have developed smart add-ins for two UNIX editors, EMACS
238 \begin_inset LatexCommand index
239 name "EMACS"
240
241 \end_inset
242
243 and vi
244 \begin_inset LatexCommand index
245 name "vi"
246
247 \end_inset
248
249 , for handling the upper case keywords and some other syntax elements.
250 The use of these editors is described in another chapter.
251
252 \end_layout
253
254 \begin_layout Standard
255 The ASCEND IV parser is very picky and pedantic.
256 It also tries to give helpful messages and occasionally even suggestions.
257 New users should just dive in and make errors, letting the system help
258 them learn how to avoid errors.
259 \end_layout
260
261 \begin_layout Section
262 Punctuation
263 \begin_inset LatexCommand index
264 name "punctuation"
265
266 \end_inset
267
268
269 \end_layout
270
271 \end_deeper
272 \begin_layout Standard
273 This section covers both the punctuation that must be understood to read
274 this document and the punctuation of ASCEND code.
275 \end_layout
276
277 \begin_layout List
278 \labelwidthstring 00000.00000.00000.000
279 keywords
280 \begin_inset LatexCommand index
281 name "keywords"
282
283 \end_inset
284
285 : ASCEND keywords and type names are given in the left column in bold format.
286 It is generally clear from the main text which are keywords and which are
287 type names.
288 \end_layout
289
290 \begin_layout List
291 \labelwidthstring 00000.00000.00000.000
292
293 \bar under
294 Minor\InsetSpace ~
295 items:
296 \bar default
297 Minor headings that are helpful in finding details are given in the left
298 column in underline format.
299 \end_layout
300
301 \begin_layout List
302 \labelwidthstring 00000.00000.00000.000
303 Tips: Special notes and hints are sometimes placed on the left.
304 \end_layout
305
306 \begin_layout List
307 \labelwidthstring 00000.00000.00000.000
308
309 \bar under
310 LHS
311 \begin_inset LatexCommand index
312 name "LHS"
313
314 \end_inset
315
316 :
317 \bar default
318 Left Hand Side.
319 Abbreviation used frequently.
320 \end_layout
321
322 \begin_layout List
323 \labelwidthstring 00000.00000.00000.000
324
325 \bar under
326 RHS
327 \begin_inset LatexCommand index
328 name "RHS"
329
330 \end_inset
331
332 :
333 \bar default
334 Right Hand Side.
335 Abbreviation used frequently.
336 \end_layout
337
338 \begin_layout List
339 \labelwidthstring 00000.00000.00000.000
340
341 \bar under
342 Simple\InsetSpace ~
343 names
344 \begin_inset LatexCommand index
345 name "simple names"
346
347 \end_inset
348
349 :
350 \bar default
351 In ASCEND simple names are made of the characters a through z, A through
352 Z, _, (*4+*: $).
353 The underscore is used as a letter, but it cannot be the first letter in
354 a name.
355 The $
356 \begin_inset LatexCommand index
357 name "\\$"
358
359 \end_inset
360
361 character is used exclusively as the first character in the name of system
362 defined built-in parts.
363 "$" is explained in more detail in Section
364 \begin_inset LatexCommand vref
365 reference "sub:x.6.2Supported-attributes"
366
367 \end_inset
368
369 .
370 Simple names should be no more than 80 characters long.
371
372 \end_layout
373
374 \begin_layout List
375 \labelwidthstring 00000.00000.00000.000
376
377 \bar under
378 Compound\InsetSpace ~
379 names
380 \begin_inset LatexCommand index
381 name "compound names"
382
383 \end_inset
384
385 :
386 \bar default
387 Compound names are simple names strung together with dots (.).
388 See the description of "." below.
389 \end_layout
390
391 \begin_layout List
392 \labelwidthstring 00000.00000.00000.000
393
394 \bar under
395 Groupings:
396 \end_layout
397
398 \begin_layout List
399 \labelwidthstring 00000.00000.00000.000
400
401 \bar under
402 «\InsetSpace ~
403 »
404 \bar default
405 In documentation
406 \series bold
407 optional fields
408 \series default
409
410 \begin_inset LatexCommand index
411 name "optional fields"
412
413 \end_inset
414
415 are surrounded by these markers.
416 \end_layout
417
418 \begin_layout List
419 \labelwidthstring 00000.00000.00000.000
420
421 \family typewriter
422 (*\InsetSpace ~
423 *)
424 \family default
425
426 \begin_inset LatexCommand index
427 name "(* *)"
428
429 \end_inset
430
431 Comment.
432 Anything inside these is a comment.
433 Comments can nest
434 \begin_inset LatexCommand index
435 name "nest"
436
437 \end_inset
438
439 in ASCEND and span several lines.
440 \end_layout
441
442 \begin_layout List
443 \labelwidthstring 00000.00000.00000.000
444
445 \family typewriter
446 (\InsetSpace ~
447 )
448 \family default
449
450 \begin_inset LatexCommand index
451 name "( )"
452
453 \end_inset
454
455 Rounded parentheses
456 \begin_inset LatexCommand index
457 name "parentheses"
458
459 \end_inset
460
461
462 \begin_inset LatexCommand index
463 name "rounded parentheses"
464
465 \end_inset
466
467 .
468 Used to enclose arguments for functions or models where the order of the
469 arguments matters.
470 Also used to group terms in complex arithmetic, logical, or set expressions
471 where the order of operations needs to be specified.
472
473 \end_layout
474
475 \begin_layout List
476 \labelwidthstring 00000.00000.00000.000
477 Efficiency\InsetSpace ~
478 tip: The compiler can simplify relation definitions in a particularly
479 efficient manner if constants are grouped together.
480 \end_layout
481
482 \begin_layout List
483 \labelwidthstring 00000.00000.00000.000
484
485 \family typewriter
486 {\InsetSpace ~
487 }
488 \family default
489
490 \begin_inset LatexCommand index
491 name "{ }"
492
493 \end_inset
494
495 Curly braces
496 \begin_inset LatexCommand index
497 name "Curly braces"
498
499 \end_inset
500
501 .
502 Used to enclose units.
503 For example, 1 {kg_mole/s}.
504 Also used to enclose the body of annotations.
505 Note: Curly braces are also used in TCL, the language of the ASCEND user
506 interface, about which we will say more in another chapter.
507 \end_layout
508
509 \begin_layout List
510 \labelwidthstring 00000.00000.00000.000
511
512 \family typewriter
513 [\InsetSpace ~
514 ]
515 \family default
516
517 \begin_inset LatexCommand index
518 name "[ ]"
519
520 \end_inset
521
522 Square brackets
523 \begin_inset LatexCommand index
524 name "square brackets"
525
526 \end_inset
527
528 .
529 Used to enclose sets or elements of sets.
530 Examples: my_integer_set :== [1,2,3], demonstrates the use of square brackets
531 in the assignment of a set.
532 My_array[1] demonstrates the use of square brackets in naming an array
533 object indexed over an integer set which includes the element 1.
534 \end_layout
535
536 \begin_layout List
537 \labelwidthstring 00000.00000.00000.000
538
539 \family typewriter
540 .
541 \family default
542
543 \begin_inset LatexCommand index
544 name "."
545
546 \end_inset
547
548 Dot
549 \begin_inset LatexCommand index
550 name "dot"
551
552 \end_inset
553
554 .
555 The dot is used, as in PASCAL and C, to construct the names of nested objects.
556 Examples: if object a has a part b, then the way to refer to b is as a.b.
557 Tray[1].vle shows a dot following a square bracket; here Tray[1] has a part
558 named vle.
559 \end_layout
560
561 \begin_layout List
562 \labelwidthstring 00000.00000.00000.000
563
564 \family typewriter
565 ..
566 \family default
567
568 \begin_inset LatexCommand index
569 name ".."
570
571 \end_inset
572
573 Dot-dot or double dot
574 \begin_inset LatexCommand index
575 name "double dot"
576
577 \end_inset
578
579 .
580 Integer range shorthand.
581 For example, my_integer_set :== [1,2,3] and my_integer_set :== [1..3] are
582 equivalent.
583 If ..
584 appears in a context requiring (), such as the ALIASES/IS_A statement,
585 then the range is expanded and ordered as we would naturally expect.
586 \end_layout
587
588 \begin_layout List
589 \labelwidthstring 00000.00000.00000.000
590
591 \family typewriter
592 :
593 \family default
594
595 \begin_inset LatexCommand index
596 name ":"
597
598 \end_inset
599
600 Colon
601 \begin_inset LatexCommand index
602 name "colon"
603
604 \end_inset
605
606 .
607 A separator used in various ways, principally to set the name of an arithmetic
608 relation apart from the definition.
609 \end_layout
610
611 \begin_layout List
612 \labelwidthstring 00000.00000.00000.000
613
614 \family typewriter
615 ::
616 \family default
617
618 \begin_inset LatexCommand index
619 name "::"
620
621 \end_inset
622
623 Double colon
624 \begin_inset LatexCommand index
625 name "double colon"
626
627 \end_inset
628
629 .
630 A separator used in the methods section for accessing methods defined on
631 types other than the type the method is part of.
632 Explained in Section
633 \begin_inset LatexCommand vref
634 reference "sec:x.4Procedural-statements"
635
636 \end_inset
637
638 .[
639 \end_layout
640
641 \begin_layout List
642 \labelwidthstring 00000.00000.00000.000
643
644 \family typewriter
645 ;
646 \family default
647
648 \begin_inset LatexCommand index
649 name ";"
650
651 \end_inset
652
653 Semicolon
654 \begin_inset LatexCommand index
655 name "semicolon"
656
657 \end_inset
658
659 .
660 The separator of statements.
661 \end_layout
662
663 \begin_deeper
664 \begin_layout Section
665 Basic Elements
666 \begin_inset LatexCommand index
667 name "basic elements"
668
669 \end_inset
670
671
672 \begin_inset LatexCommand label
673 name "sub:x.1.2Basic-Elements"
674
675 \end_inset
676
677
678 \end_layout
679
680 \end_deeper
681 \begin_layout List
682 \labelwidthstring 00000.00000.00000.000
683
684 \bar under
685 Boolean\InsetSpace ~
686 value
687 \bar default
688
689 \begin_inset LatexCommand index
690 name "value, Boolean"
691
692 \end_inset
693
694
695 \begin_inset LatexCommand index
696 name "Boolean value"
697
698 \end_inset
699
700
701 \family sans
702 TRUE
703 \family default
704
705 \begin_inset LatexCommand index
706 name "TRUE"
707
708 \end_inset
709
710 or
711 \family sans
712 FALSE
713 \family default
714
715 \begin_inset LatexCommand index
716 name "FALSE"
717
718 \end_inset
719
720 .
721 Can't get much simpler, eh? In the language definition
722 \family sans
723 TRUE
724 \family default
725 and
726 \family sans
727 FALSE
728 \family default
729 do not map to 1 and 0 or any other type of numeric value.
730 (In the implementation, of course, they do.)
731 \end_layout
732
733 \begin_layout List
734 \labelwidthstring 00000.00000.00000.000
735 User\InsetSpace ~
736 interface\InsetSpace ~
737 tip: The ASCEND user interface programmers have found it very
738 convenient, however, to allow T/F, 1/0, Y/N, and other obvious boolean
739 conventions as interactive input when assigning boolean values.
740 We are lazy users.
741 \end_layout
742
743 \begin_layout List
744 \labelwidthstring 00000.00000.00000.000
745
746 \bar under
747 Integer\InsetSpace ~
748 value
749 \bar default
750
751 \begin_inset LatexCommand index
752 name "value, integer"
753
754 \end_inset
755
756
757 \begin_inset LatexCommand index
758 name "integer value"
759
760 \end_inset
761
762 A signed whole number up to the maximum that can be represented by the
763 computer on which one is running ASCEND.
764
765 \family sans
766 MAX_INTEGER
767 \family default
768
769 \begin_inset LatexCommand index
770 name "MAX\\_INTEGER"
771
772 \end_inset
773
774 is machine dependent.
775 Examples are:
776 \end_layout
777
778 \begin_deeper
779 \begin_layout LyX-Code
780 \align block
781 123
782 \end_layout
783
784 \begin_layout LyX-Code
785 \align block
786 -5
787 \end_layout
788
789 \begin_layout LyX-Code
790 \align block
791 MAX_INTEGER, typically 2147483647.
792 \end_layout
793
794 \end_deeper
795 \begin_layout List
796 \labelwidthstring 00000.00000.00000.000
797
798 \bar under
799 Real\InsetSpace ~
800 value
801 \bar default
802
803 \begin_inset LatexCommand index
804 name "value. real"
805
806 \end_inset
807
808
809 \begin_inset LatexCommand index
810 name "real value"
811
812 \end_inset
813
814 ASCEND represents reals almost exactly as any other mathematically oriented
815 programming language does.
816 The mantissa
817 \begin_inset LatexCommand index
818 name "mantissa"
819
820 \end_inset
821
822 has an optional negative sign followed by a string of digits and at most
823 one decimal point.
824 The exponent is the letter
825 \family typewriter
826 e
827 \family default
828 or
829 \family typewriter
830 E
831 \family default
832 followed by an integer.
833 The number must not exceed the largest the computer is able to handle.
834 There can be no blank characters in a real.
835
836 \family sans
837 MAX_REAL
838 \family default
839
840 \begin_inset LatexCommand index
841 name "MAX\\_REAL"
842
843 \end_inset
844
845 is machine dependent.
846 The following are legitimate reals in ASCEND:
847 \end_layout
848
849 \begin_deeper
850 \begin_layout LyX-Code
851 \align block
852 -1
853 \end_layout
854
855 \begin_layout LyX-Code
856 \align block
857 1.2
858 \end_layout
859
860 \begin_layout LyX-Code
861 \align block
862 1.3e-2
863 \end_layout
864
865 \begin_layout LyX-Code
866 \align block
867 7.888888e+34
868 \end_layout
869
870 \begin_layout LyX-Code
871 \align block
872 .6E21
873 \end_layout
874
875 \begin_layout LyX-Code
876 \align block
877 MAX_REAL, typically about 1.79E+308.
878 \end_layout
879
880 \begin_layout Standard
881 while the following are not:
882 \end_layout
883
884 \begin_layout LyX-Code
885 \align block
886 1.
887 2 (*contains a blank within it*)
888 \end_layout
889
890 \begin_layout LyX-Code
891 \align block
892 1.3e2.0 (*exponent has a decimal in it*)
893 \end_layout
894
895 \begin_layout LyX-Code
896
897 \family typewriter
898 +1.3 (* illegal unary + sign.
899 x = +1.3 not allowed*)
900 \end_layout
901
902 \end_deeper
903 \begin_layout List
904 \labelwidthstring 00000.00000.00000.000
905
906 \bar under
907 Reals\InsetSpace ~
908 stored\InsetSpace ~
909 in\InsetSpace ~
910 SI
911 \begin_inset LatexCommand index
912 name "SI"
913
914 \end_inset
915
916 \InsetSpace ~
917 units
918 \bar default
919
920 \end_layout
921
922 \begin_deeper
923 \begin_layout Standard
924 We store all real values as double precision
925 \begin_inset LatexCommand index
926 name "double precision"
927
928 \end_inset
929
930 numbers in the metre-kilogram-second (MKS)
931 \begin_inset LatexCommand index
932 name "MKS"
933
934 \end_inset
935
936 system of units.
937 This eliminates many common errors in the modeling of physical systems.
938 Since we also place the burden of scaling equations on system routines
939 and a simple modeling methodology, the internal units are not of concern
940 to most users.
941 \end_layout
942
943 \end_deeper
944 \begin_layout List
945 \labelwidthstring 00000.00000.00000.000
946
947 \bar under
948 Dimensionality
949 \begin_inset LatexCommand index
950 name "dimensionality"
951
952 \end_inset
953
954 :
955 \bar default
956 Real values have dimensionality such as length/time for velocity.
957
958 \series bold
959 Dimensionality
960 \series default
961 is to be distinguished from the
962 \series bold
963 units
964 \series default
965 such as ft/s.
966 ASCEND takes care of mapping between units
967 \begin_inset LatexCommand index
968 name "units"
969
970 \end_inset
971
972 and dimensions.
973 A value without units (this includes integer values) is taken to be dimensionle
974 ss
975 \begin_inset LatexCommand index
976 name "dimensionless"
977
978 \end_inset
979
980 .
981 Dimensionality is built up from the following base dimensions:
982 \end_layout
983
984 \begin_layout List
985 \labelwidthstring 00000.00000.00000.000
986 Name
987 \bar under
988 definition; typical units
989 \end_layout
990
991 \begin_layout List
992 \labelwidthstring 00000.00000.00000.000
993 L
994 \begin_inset LatexCommand index
995 name "L, length dimension"
996
997 \end_inset
998
999 length
1000 \begin_inset LatexCommand index
1001 name "length"
1002
1003 \end_inset
1004
1005 ; metre, m
1006 \end_layout
1007
1008 \begin_layout List
1009 \labelwidthstring 00000.00000.00000.000
1010 M
1011 \begin_inset LatexCommand index
1012 name "M, mass dimension"
1013
1014 \end_inset
1015
1016 mass
1017 \begin_inset LatexCommand index
1018 name "mass"
1019
1020 \end_inset
1021
1022 ; kilogram, kg
1023 \end_layout
1024
1025 \begin_layout List
1026 \labelwidthstring 00000.00000.00000.000
1027 T
1028 \begin_inset LatexCommand index
1029 name "T, time dimension"
1030
1031 \end_inset
1032
1033 time
1034 \begin_inset LatexCommand index
1035 name "time"
1036
1037 \end_inset
1038
1039 ; second, s
1040 \end_layout
1041
1042 \begin_layout List
1043 \labelwidthstring 00000.00000.00000.000
1044 E
1045 \begin_inset LatexCommand index
1046 name "E, electric current dimension"
1047
1048 \end_inset
1049
1050 electric current
1051 \begin_inset LatexCommand index
1052 name "electric current"
1053
1054 \end_inset
1055
1056 ; ampere, A
1057 \end_layout
1058
1059 \begin_layout List
1060 \labelwidthstring 00000.00000.00000.000
1061 Q
1062 \begin_inset LatexCommand index
1063 name "Q, quantity dimension"
1064
1065 \end_inset
1066
1067 quantity
1068 \begin_inset LatexCommand index
1069 name "quantity"
1070
1071 \end_inset
1072
1073 ; mole, mole
1074 \end_layout
1075
1076 \begin_layout List
1077 \labelwidthstring 00000.00000.00000.000
1078 TMP
1079 \begin_inset LatexCommand index
1080 name "TMP, temperature dimension"
1081
1082 \end_inset
1083
1084 temperature
1085 \begin_inset LatexCommand index
1086 name "temperature"
1087
1088 \end_inset
1089
1090 ; Kelvin, K
1091 \end_layout
1092
1093 \begin_layout List
1094 \labelwidthstring 00000.00000.00000.000
1095 LUM
1096 \begin_inset LatexCommand index
1097 name "LUM, luminous intensity dimension"
1098
1099 \end_inset
1100
1101 luminous intensity
1102 \begin_inset LatexCommand index
1103 name "luminous intensity"
1104
1105 \end_inset
1106
1107 ; candela, cd
1108 \end_layout
1109
1110 \begin_layout List
1111 \labelwidthstring 00000.00000.00000.000
1112 P
1113 \begin_inset LatexCommand index
1114 name "P, phase angle dimension"
1115
1116 \end_inset
1117
1118 plane angle
1119 \begin_inset LatexCommand index
1120 name "plane angle"
1121
1122 \end_inset
1123
1124 ; radian, rad
1125 \end_layout
1126
1127 \begin_layout List
1128 \labelwidthstring 00000.00000.00000.000
1129 S
1130 \begin_inset LatexCommand index
1131 name "S, solid angle dimension"
1132
1133 \end_inset
1134
1135 solid angle
1136 \begin_inset LatexCommand index
1137 name "solid angle"
1138
1139 \end_inset
1140
1141 ; steradian, srad
1142 \end_layout
1143
1144 \begin_layout List
1145 \labelwidthstring 00000.00000.00000.000
1146 C
1147 \begin_inset LatexCommand index
1148 name "C, currency dimension"
1149
1150 \end_inset
1151
1152 currency
1153 \begin_inset LatexCommand index
1154 name "currency"
1155
1156 \end_inset
1157
1158 ; currency, CR
1159 \end_layout
1160
1161 \begin_deeper
1162 \begin_layout Standard
1163 The atom and constant definitions in the library illustrate the use of dimension
1164 ality.
1165 \end_layout
1166
1167 \begin_layout Standard
1168 Dimensions may be any combination of these symbols along with rounded parenthese
1169 s, (), and the operators *,
1170 \family typewriter
1171 ^
1172 \family default
1173 and
1174 \family typewriter
1175 /
1176 \family default
1177 .
1178 Examples include
1179 \family typewriter
1180 M/T
1181 \family default
1182 or
1183 \family typewriter
1184 M*L^2/T^2/TMP
1185 \family default
1186 {this latter means
1187 \family typewriter
1188 (M*(L^2)/(T^2))/TMP
1189 \family default
1190 }.
1191 The second operand for the to-the-power-of operator,
1192 \family typewriter
1193 ^
1194 \family default
1195 , must be an integer value (e.g., -2 or 3) because fractional powers of dimensiona
1196 l numbers are physically undefined
1197 \begin_inset Note Note
1198 status open
1199
1200 \begin_layout Standard
1201 although we do seem them occasionally...
1202 \end_layout
1203
1204 \end_inset
1205
1206 .
1207 \end_layout
1208
1209 \begin_layout Standard
1210 If the dimensionality for a real value is undefined, then ASCEND gives it
1211 a wildcard dimensionality
1212 \begin_inset LatexCommand index
1213 name "wild card dimensionality"
1214
1215 \end_inset
1216
1217 .
1218 If ASCEND can later deduce its dimensionality from its use in a model definitio
1219 n it will do so.
1220 For example consider the real variable
1221 \family typewriter
1222 a
1223 \family default
1224 , suppose
1225 \family typewriter
1226 a
1227 \family default
1228 has wildcard dimensionality,
1229 \family typewriter
1230 b
1231 \family default
1232 has dimensionality of
1233 \family typewriter
1234 L/T
1235 \family default
1236 .
1237 Then the statement:
1238 \end_layout
1239
1240 \end_deeper
1241 \begin_layout List
1242 \labelwidthstring 00000.00000.00000.000
1243 Example\InsetSpace ~
1244 of\InsetSpace ~
1245 a\InsetSpace ~
1246 dimensionally\InsetSpace ~
1247 consistent
1248 \begin_inset LatexCommand index
1249 name "dimensionally consistent"
1250
1251 \end_inset
1252
1253 \InsetSpace ~
1254 equation.
1255
1256 \end_layout
1257
1258 \begin_layout List
1259 \labelwidthstring 00000.00000.00000.000
1260 \InsetSpace ~
1261
1262 \family typewriter
1263 a + b = 3 {ft/s};
1264 \end_layout
1265
1266 \begin_deeper
1267 \begin_layout Standard
1268 requires that
1269 \family typewriter
1270 a
1271 \family default
1272 have the same dimensionality as the other two terms, namely,
1273 \family typewriter
1274 L/T
1275 \family default
1276 .
1277 ASCEND will assign this dimensionality to
1278 \family typewriter
1279 a
1280 \family default
1281 .
1282 The user will be warned of dimensionally inconsistent equations.
1283 \end_layout
1284
1285 \end_deeper
1286 \begin_layout List
1287 \labelwidthstring 00000.00000.00000.000
1288
1289 \bar under
1290 Unit\InsetSpace ~
1291 expression
1292 \bar default
1293 A unit expression
1294 \begin_inset LatexCommand index
1295 name "unit expression"
1296
1297 \end_inset
1298
1299 may be composed of any combination of unit names defined by the system
1300 and any numerical constants combined with times (
1301 \family typewriter
1302 *
1303 \family default
1304 ), divide(
1305 \family typewriter
1306 /
1307 \family default
1308 ) and to the power (
1309 \family typewriter
1310 ^
1311 \family default
1312 ) operators.
1313 The RHS of
1314 \family typewriter
1315 ^
1316 \family default
1317 must be an integer.
1318 Parentheses can be used to group subexpressions with the exception that
1319 a divide operator may
1320 \emph on
1321 not
1322 \emph default
1323 be followed by a grouped subexpression.
1324
1325 \end_layout
1326
1327 \begin_deeper
1328 \begin_layout Standard
1329 So,
1330 \family typewriter
1331 {kg/m/s}
1332 \family default
1333 is fine, but
1334 \family typewriter
1335 {kg/(m*s)}
1336 \family default
1337 is not.
1338 Although the two expressions are mathematically equivalent, it makes the
1339 system programming and output formatting easier to code and faster to execute
1340 if we disallow expressions of the latter sort.
1341 \end_layout
1342
1343 \begin_layout Standard
1344 The units understood by the system are defined in the first part of this
1345 manual.
1346 Note that several units defined are really values of interesting constants
1347 in SI, e.g.
1348
1349 \family typewriter
1350 R :== 1{GAS_C}
1351 \family default
1352 yields the correct value of the thermodynamic gas constant.
1353 Users can define additional units.
1354 \end_layout
1355
1356 \end_deeper
1357 \begin_layout List
1358 \labelwidthstring 00000.00000.00000.000
1359
1360 \bar under
1361 Units
1362 \bar default
1363
1364 \begin_inset LatexCommand index
1365 name "units"
1366
1367 \end_inset
1368
1369 A Unit expression unit expression must be enclosed in curly braces
1370 \family typewriter
1371 {}
1372 \family default
1373 .
1374 When a real number is used in a mathematical expression in ASCEND, it must
1375 have a set of units expressed with it.
1376 If it does not, ASCEND assumes the number is dimensionless, which may not
1377 be the intent of the modeler.
1378 An example is shown in the dimensionally consistent equation above where
1379 the number 3 has the units
1380 \family typewriter
1381 {ft/s}
1382 \family default
1383 associated with it.
1384
1385 \end_layout
1386
1387 \begin_deeper
1388 \begin_layout Standard
1389 Examples:
1390 \end_layout
1391
1392 \begin_layout LyX-Code
1393 \align block
1394 {kg_mole/s/m} same as {(kg_mole/s)/m}
1395 \end_layout
1396
1397 \begin_layout LyX-Code
1398 \align block
1399 {m^3/yr}
1400 \end_layout
1401
1402 \begin_layout LyX-Code
1403 \align block
1404 {3/100*ft} same as {0.03*ft}
1405 \end_layout
1406
1407 \begin_layout LyX-Code
1408 \align block
1409 {s^-1} same as {1/s}
1410 \end_layout
1411
1412 \begin_layout Standard
1413 Illegal unit examples are
1414 \end_layout
1415
1416 \begin_layout LyX-Code
1417 \align block
1418 {m/(K*kg_mole)}
1419 \end_layout
1420
1421 \begin_deeper
1422 \begin_layout Standard
1423 grouped subexpression used in the denominator; should be written {m/K/kg_mole}.
1424 \end_layout
1425
1426 \end_deeper
1427 \begin_layout LyX-Code
1428 \align block
1429 {m^3.5}
1430 \end_layout
1431
1432 \begin_deeper
1433 \begin_layout Standard
1434 power of units or dimensions must be integer.
1435 \end_layout
1436
1437 \end_deeper
1438 \end_deeper
1439 \begin_layout List
1440 \labelwidthstring 00000.00000.00000.000
1441
1442 \bar under
1443 Symbol\InsetSpace ~
1444 Value
1445 \bar default
1446
1447 \begin_inset LatexCommand index
1448 name "value, symbol"
1449
1450 \end_inset
1451
1452
1453 \begin_inset LatexCommand index
1454 name "symbol value"
1455
1456 \end_inset
1457
1458 The format for a symbol is that of an arbitrary character string enclosed
1459 between two single quotes.
1460 There is no way to embed a single quote
1461 \begin_inset LatexCommand index
1462 name "'"
1463
1464 \end_inset
1465
1466
1467 \begin_inset LatexCommand index
1468 name "single quote"
1469
1470 \end_inset
1471
1472 in a symbol: we are not in the escape sequence business at this time.
1473 The following are legal symbols in ASCEND:
1474 \end_layout
1475
1476 \begin_deeper
1477 \begin_layout LyX-Code
1478 'H2O'
1479 \end_layout
1480
1481 \begin_layout LyX-Code
1482 'r1'
1483 \end_layout
1484
1485 \begin_layout LyX-Code
1486 'Bill said,foo to whom?'
1487 \end_layout
1488
1489 \begin_layout Standard
1490 while the following are not legal symbol values:
1491 \end_layout
1492
1493 \begin_layout LyX-Code
1494 "ethanol" (double quotes not allowed)
1495 \end_layout
1496
1497 \begin_layout LyX-Code
1498 water (no single quotes given)
1499 \end_layout
1500
1501 \begin_layout LyX-Code
1502 'i can't do this' (no embedded quotes)
1503 \end_layout
1504
1505 \begin_layout Standard
1506 There is an arbitrary upper limit to the number of characters in a symbol
1507 (something like 10,000) so that we may detect a missing close quote in
1508 a bad input file without crashing.
1509 \end_layout
1510
1511 \end_deeper
1512 \begin_layout List
1513 \labelwidthstring 00000.00000.00000.000
1514 Sets\InsetSpace ~
1515 values
1516 \begin_inset LatexCommand index
1517 name "values, set"
1518
1519 \end_inset
1520
1521
1522 \begin_inset LatexCommand index
1523 name "set values"
1524
1525 \end_inset
1526
1527 Set values are lists of elements, all of type
1528 \family sans
1529 integer_constant
1530 \family default
1531 or all of type
1532 \family sans
1533 symbol_constant
1534 \family default
1535 , enclosed between square brackets
1536 \family typewriter
1537 []
1538 \family default
1539 .
1540 The following are examples of sets:
1541 \end_layout
1542
1543 \begin_deeper
1544 \begin_layout LyX-Code
1545 \align block
1546 ['methane', 'ethane', 'propane']
1547 \end_layout
1548
1549 \begin_layout LyX-Code
1550 \align block
1551 [1..5, 7, 15]
1552 \end_layout
1553
1554 \begin_layout LyX-Code
1555 \align block
1556 [2..n_stages]
1557 \end_layout
1558
1559 \begin_layout LyX-Code
1560 \align block
1561 [1, 4, 2, 1, 16]
1562 \end_layout
1563
1564 \begin_layout LyX-Code
1565 \align block
1566 []
1567 \end_layout
1568
1569 \end_deeper
1570 \begin_layout List
1571 \labelwidthstring 00000.00000.00000.000
1572 More\InsetSpace ~
1573 about\InsetSpace ~
1574 sets
1575 \begin_inset LatexCommand index
1576 name "sets"
1577
1578 \end_inset
1579
1580 \InsetSpace ~
1581 in\InsetSpace ~
1582 Section\InsetSpace ~
1583
1584 \begin_inset LatexCommand vref
1585 reference "sub:x.2.2Sets"
1586
1587 \end_inset
1588
1589 .
1590 \end_layout
1591
1592 \begin_deeper
1593 \begin_layout Standard
1594 The value range
1595 \family typewriter
1596 1..5
1597 \family default
1598 is an allowable shorthand for the integers 1, 2, 3, 4 and 5 while the value
1599 range
1600 \family typewriter
1601 2..n_stages
1602 \family default
1603 (where
1604 \family typewriter
1605 n_stages
1606 \family default
1607 must be of type
1608 \family sans
1609 integer_constant
1610 \family default
1611 ) means all integers from 2 to
1612 \family typewriter
1613 n_stages
1614 \family default
1615 .
1616 If
1617 \family typewriter
1618 n_stages
1619 \family default
1620 is less than 2, then the third set is empty.
1621 The repeated occurrence of
1622 \family typewriter
1623 1
1624 \family default
1625 in the fourth set is ignored.
1626 The fifth set is the empty set
1627 \begin_inset LatexCommand index
1628 name "empty set"
1629
1630 \end_inset
1631
1632
1633 \begin_inset LatexCommand index
1634 name "set, empty"
1635
1636 \end_inset
1637
1638 .
1639 \end_layout
1640
1641 \begin_layout Standard
1642 We use the term set in an almost pure mathematical sense.
1643 The elements have no order.
1644 One can only ask two things of a set: (1) if an element is a member of
1645 it and (2) its cardinality
1646 \begin_inset LatexCommand index
1647 name "cardinality"
1648
1649 \end_inset
1650
1651 (
1652 \family sans
1653 CARD
1654 \family default
1655
1656 \begin_inset LatexCommand index
1657 name "CARD"
1658
1659 \end_inset
1660
1661
1662 \family typewriter
1663 (set)
1664 \family default
1665 ).
1666 Repeated elements used in defining a set are ignored.
1667 The elements of sets cannot themselves be sets in ASCEND; i.e., there can
1668 be no sets of set.
1669 \end_layout
1670
1671 \end_deeper
1672 \begin_layout List
1673 \labelwidthstring 00000.00000.00000.000
1674 Sets\InsetSpace ~
1675 are\InsetSpace ~
1676 unordered.
1677 A set of integers may appear to be ordered to the modeler as the natural
1678 numbers have an order.
1679 However, it is the user imposing and using the ordering, not ASCEND.
1680 ASCEND sees these integers as elements in the set with NO ordering.
1681 Therefore, there are no operators in ASCEND such as successor or precursor
1682 member of a set.
1683 \end_layout
1684
1685 \begin_layout List
1686 \labelwidthstring 00000.00000.00000.000
1687
1688 \bar under
1689 Arrays
1690 \bar default
1691
1692 \begin_inset LatexCommand index
1693 name "arrays"
1694
1695 \end_inset
1696
1697 An array is a list of instances indexed over a set, in computer-speak,
1698 an associative array of objects.
1699 The instances are all of the same base type (as that is the only way they
1700 can be defined).
1701 An individual member of a list may later be more refined than the other
1702 members (we shall illustrate that possibility).
1703 The following are arrays in ASCEND.
1704 \end_layout
1705
1706 \begin_deeper
1707 \begin_layout LyX-Code
1708 \align block
1709 stage[1..n_stages]
1710 \end_layout
1711
1712 \begin_layout LyX-Code
1713 \align block
1714 y[components]
1715 \end_layout
1716
1717 \begin_layout LyX-Code
1718 \align block
1719 column[areas][processes]
1720 \end_layout
1721
1722 \begin_layout Standard
1723 where components, areas and processes are sets.
1724 For example components could be the set of symbols
1725 \family typewriter
1726 ['ethylene', 'propylene']
1727 \family default
1728 , areas the set of symbols
1729 \family typewriter
1730 ['feed_prep', 'prod_purification']
1731 \family default
1732 while processes could be the set
1733 \family typewriter
1734 ['alcohol_manuf', 'poly_propropylene_manuf']
1735 \family default
1736 .
1737 Note that the third example (
1738 \family typewriter
1739 column
1740 \family default
1741 ) is a list of lists (the way that ASCEND permits a multiply subscripted
1742 array).
1743
1744 \end_layout
1745
1746 \begin_layout Standard
1747 The following are elements in the above arrays:
1748 \end_layout
1749
1750 \begin_layout LyX-Code
1751 stage[1]
1752 \end_layout
1753
1754 \begin_layout LyX-Code
1755 y['ethylene']
1756 \end_layout
1757
1758 \begin_layout LyX-Code
1759 column['feed_prep'][alcohol_manuf']
1760 \end_layout
1761
1762 \begin_layout Standard
1763 provided that
1764 \family typewriter
1765 n_stages
1766 \family default
1767 is 1 or larger.
1768
1769 \end_layout
1770
1771 \begin_layout Standard
1772 There can be any number of subscripts
1773 \begin_inset LatexCommand index
1774 name "subscripts"
1775
1776 \end_inset
1777
1778 for an array.
1779 We point out, however, that in virtually every application of arrays requiring
1780 more than two subscripts, there is usually a some underlying concept that
1781 is much better modeled as an object than as part of a deeply subscripted
1782 \begin_inset LatexCommand index
1783 name "subscripted, deeply"
1784
1785 \end_inset
1786
1787
1788 \begin_inset LatexCommand index
1789 name "deeply subscripted"
1790
1791 \end_inset
1792
1793 array.
1794 In the following jagged array example, there are really the concepts of
1795 unit operation and stream that would be better understood if made explicit.
1796 \end_layout
1797
1798 \end_deeper
1799 \begin_layout List
1800 \labelwidthstring 00000.00000.00000.000
1801
1802 \bar under
1803 Arrays\InsetSpace ~
1804 can\InsetSpace ~
1805 be\InsetSpace ~
1806 jagged
1807 \bar default
1808
1809 \begin_inset LatexCommand label
1810 name "lyx:Arrays-can-be"
1811
1812 \end_inset
1813
1814 Arrays can be sparse
1815 \begin_inset LatexCommand index
1816 name "sparse"
1817
1818 \end_inset
1819
1820 or jagged
1821 \begin_inset LatexCommand index
1822 name "jagged"
1823
1824 \end_inset
1825
1826 .
1827 For example:
1828 \end_layout
1829
1830 \begin_deeper
1831 \begin_layout LyX-Code
1832 process[1..3] IS_A set OF integer;
1833 \end_layout
1834
1835 \begin_layout LyX-Code
1836 process[1] :== [2];
1837 \end_layout
1838
1839 \begin_layout LyX-Code
1840 process[2] :== [7,5,3];
1841 \end_layout
1842
1843 \begin_layout LyX-Code
1844 process[3] :== [4,6];
1845 \end_layout
1846
1847 \begin_layout LyX-Code
1848 FOR i in [1..3] CREATE
1849 \end_layout
1850
1851 \begin_layout LyX-Code
1852 FOR j IN process[i] CREATE
1853 \end_layout
1854
1855 \begin_layout LyX-Code
1856 flow[i][j] IS_A mass;
1857 \end_layout
1858
1859 \begin_layout LyX-Code
1860 END FOR;
1861 \end_layout
1862
1863 \begin_layout LyX-Code
1864 END FOR;
1865 \end_layout
1866
1867 \begin_layout Standard
1868 process is an array of sets (not to be confused with a set of sets which
1869 ASCEND does not have) and flow is an array with six elements spread over
1870 three rows:
1871 \end_layout
1872
1873 \begin_layout LyX-Code
1874 flow[1][2]
1875 \end_layout
1876
1877 \begin_layout LyX-Code
1878 flow[2][7], flow[2][3], flow[2][5]
1879 \end_layout
1880
1881 \begin_layout LyX-Code
1882 flow[3][4], flow[3][6]
1883 \end_layout
1884
1885 \end_deeper
1886 \begin_layout List
1887 \labelwidthstring 00000.00000.00000.000
1888 Arrays\InsetSpace ~
1889 are\InsetSpace ~
1890 also\InsetSpace ~
1891 instances
1892 \end_layout
1893
1894 \begin_deeper
1895 \begin_layout Standard
1896 Each array is itself an object.
1897 That is, when you write
1898 \family typewriter
1899 a[1..2] IS_A real
1900 \family default
1901 , three objects get created:
1902 \family typewriter
1903 a[1]
1904 \family default
1905 ,
1906 \family typewriter
1907 a[2]
1908 \family default
1909 , and
1910 \family typewriter
1911 a
1912 \family default
1913 .
1914 The object
1915 \family typewriter
1916 a
1917 \family default
1918 is an array instance which has parts named
1919 \family typewriter
1920 [1]
1921 \family default
1922 and
1923 \family typewriter
1924 [2]
1925 \family default
1926 that are real instances.
1927 When a parameterized model requires an array, you pass it the single item
1928
1929 \family typewriter
1930 a
1931 \family default
1932 , not the elements
1933 \family typewriter
1934 a[1..2]
1935 \family default
1936 .
1937 \end_layout
1938
1939 \end_deeper
1940 \begin_layout List
1941 \labelwidthstring 00000.00000.00000.000
1942 No\InsetSpace ~
1943 contiguous\InsetSpace ~
1944 storage
1945 \begin_inset LatexCommand index
1946 name "contiguous storage, no"
1947
1948 \end_inset
1949
1950
1951 \end_layout
1952
1953 \begin_deeper
1954 \begin_layout Standard
1955 Just in case you still have not caught on, ASCEND arrays are not blocks
1956 of memory such as are seen in low-level languages like C
1957 \begin_inset LatexCommand index
1958 name "C, computer language"
1959
1960 \end_inset
1961
1962 , FORTRAN
1963 \begin_inset LatexCommand index
1964 name "FORTRAN"
1965
1966 \end_inset
1967
1968 , and Matlab
1969 \begin_inset LatexCommand index
1970 name "Matlab"
1971
1972 \end_inset
1973
1974 .
1975 The modeling language does not provide things like MatMult
1976 \begin_inset LatexCommand index
1977 name "MatMult"
1978
1979 \end_inset
1980
1981 , Transpose
1982 \begin_inset LatexCommand index
1983 name "Transpose"
1984
1985 \end_inset
1986
1987 , and Inverse
1988 \begin_inset LatexCommand index
1989 name "Inverse"
1990
1991 \end_inset
1992
1993 because these are procedural solving tools.
1994 If you are dedicated, you could write METHODs that implement matrix algebra,
1995 but this is a really dumb idea.
1996 We aim to structure our software so that it can interact openly with separate,
1997 dedicated tools (such as Matlab) when those tools are needed.
1998 \end_layout
1999
2000 \end_deeper
2001 \begin_layout List
2002 \labelwidthstring 00000.00000.00000.000
2003 Index\InsetSpace ~
2004 variable
2005 \begin_inset LatexCommand index
2006 name "index variable"
2007
2008 \end_inset
2009
2010 One can introduce a variable as an index ranging over a set.
2011 Index variables are local to the statements in which they occur.
2012 An example of using an index variable is the following FOR statement:
2013 \end_layout
2014
2015 \begin_deeper
2016 \begin_layout LyX-Code
2017 FOR i IN components CREATE
2018 \end_layout
2019
2020 \begin_layout LyX-Code
2021 VLE_equil[i]: y[i] = K[i]*x[i];
2022 \end_layout
2023
2024 \begin_layout LyX-Code
2025 END FOR;
2026 \end_layout
2027
2028 \begin_layout Standard
2029 In this example i implicitly is of the same type as the values in the set
2030 components.
2031 If another object i exists in the model containing the FOR loop, it is
2032 ignored while executing the statements in that loop.
2033 This may cause unexpected results and the compiler will generate warnings
2034 about loop index shadowed variables.
2035 \end_layout
2036
2037 \end_deeper
2038 \begin_layout List
2039 \labelwidthstring 00000.00000.00000.000
2040 Label
2041 \begin_inset LatexCommand index
2042 name "label"
2043
2044 \end_inset
2045
2046 : One can label statements which define arithmetic relationships (objective
2047 functions, equalities, and inequalities) in ASCEND.
2048 Labeling is highly recommended because it makes models much more readable
2049 and more easily debugged.
2050 Labels are also necessary for relations which are going to be used in condition
2051 al modeling or differentiation functions.
2052 A label is a sequence of alphanumeric characters ending in a colon.
2053 An example of a labeled equation is:
2054 \end_layout
2055
2056 \begin_deeper
2057 \begin_layout LyX-Code
2058 mass_balance: m_in = m_out;
2059 \end_layout
2060
2061 \begin_layout Standard
2062 An example of a labeled objective function is:
2063 \end_layout
2064
2065 \begin_layout LyX-Code
2066 obj1: MAXIMIZE revenue - cost;
2067 \end_layout
2068
2069 \begin_layout Standard
2070 If a relation is defined within a FOR statement, it must have an array indexed
2071 label so that each instance created using the statement is distinguishable
2072 from the others.
2073 An example is:
2074 \end_layout
2075
2076 \begin_layout LyX-Code
2077 FOR i IN components CREATE
2078 \end_layout
2079
2080 \begin_layout LyX-Code
2081 equil[i]: y[i] = K[i]*x[i];
2082 \end_layout
2083
2084 \begin_layout LyX-Code
2085 END FOR;
2086 \end_layout
2087
2088 \begin_layout Standard
2089 The ASCEND interactive user interface identifies relationships by their
2090 labels.
2091 If one has not provided such a label, the system generates the label:
2092 \end_layout
2093
2094 \begin_layout LyX-Code
2095
2096 \emph on
2097 modelname_equationnumber
2098 \end_layout
2099
2100 \begin_layout Standard
2101 where modelname and equationnumber are the name of the model and the equation
2102 number in the model.
2103 An example is
2104 \end_layout
2105
2106 \begin_layout LyX-Code
2107 mixture_14
2108 \end_layout
2109
2110 \begin_layout Standard
2111 for the unlabeled 14th relation in the mixture definition.
2112 If there is a conflict caused with an existing name, the generated name
2113 has enough letters added after equationnumber to make it a unique name.
2114 Remember that each model in a refinement hierarchy inherits the equations
2115 of its less refined ancestors, so the first equation appearing in the source
2116 code of a refining model may actually be the nth relation in that model.
2117 \end_layout
2118
2119 \end_deeper
2120 \begin_layout List
2121 \labelwidthstring 00000.00000.00000.000
2122
2123 \bar under
2124 Lists
2125 \bar default
2126
2127 \begin_inset LatexCommand index
2128 name "lists"
2129
2130 \end_inset
2131
2132 Often in a statement one can include a list of names or expression.
2133 A name list is one or more names where multiple list entries are separated
2134 from each other by commas.
2135 Examples of a list of names are:
2136 \end_layout
2137
2138 \begin_deeper
2139 \begin_layout LyX-Code
2140 \align block
2141 T1, inlet_T, outlet_T
2142 \end_layout
2143
2144 \begin_layout LyX-Code
2145 \align block
2146 y[components], y_in
2147 \end_layout
2148
2149 \begin_layout LyX-Code
2150 \align block
2151 stage[1..n_stages]
2152 \end_layout
2153
2154 \end_deeper
2155 \begin_layout List
2156 \labelwidthstring 00000.00000.00000.000
2157
2158 \bar under
2159 Ordered\InsetSpace ~
2160 lists
2161 \begin_inset LatexCommand index
2162 name "lists, ordered"
2163
2164 \end_inset
2165
2166
2167 \begin_inset LatexCommand index
2168 name "ordered lists"
2169
2170 \end_inset
2171
2172 :
2173 \bar default
2174 If the ordering of names in a list matters, that list is enclosed in ().
2175 Order matters in: calling externally defined methods or models, calling
2176 most real-valued functions, passing parameters to ASCEND models or methods,
2177 and declaring the controlling parameters that SELECT, SWITCH, and WHEN
2178 statements make decisions on.
2179 \end_layout
2180
2181 \begin_deeper
2182 \begin_layout Section
2183 Basic Concepts
2184 \end_layout
2185
2186 \end_deeper
2187 \begin_layout List
2188 \labelwidthstring 00000.00000.00000.000
2189
2190 \bar under
2191 Instances
2192 \begin_inset LatexCommand index
2193 name "instances"
2194
2195 \end_inset
2196
2197 \InsetSpace ~
2198 and\InsetSpace ~
2199 types
2200 \bar default
2201
2202 \begin_inset LatexCommand index
2203 name "types"
2204
2205 \end_inset
2206
2207 This is an opportune time to emphasize the distinction between the terms
2208 instance and type.
2209 A type in ASCEND is what we define when we declare an ASCEND model or atom.
2210 It is the formal definition of the attributes (parts) and attribute default
2211 values that an object will have if it is created using the type definition.
2212 Methods are associated with types.
2213 \end_layout
2214
2215 \begin_deeper
2216 \begin_layout Standard
2217 In ASCEND there are two meanings (closely related) of an instance.
2218
2219 \end_layout
2220
2221 \begin_layout Itemize
2222 An instance is a named part that exists within a type definition.
2223
2224 \end_layout
2225
2226 \begin_layout Itemize
2227 An instance is a compiled object.
2228
2229 \end_layout
2230
2231 \begin_layout Standard
2232 If one is in the context of the ASCEND interface, the system compiles an
2233 instance of a model type to create an object with which one carries out
2234 computations.
2235 The system requires the user to give a simple name for this simulation
2236 instance.
2237 This name given is then the first part of the qualified name for all the
2238 parts of the compiled object.
2239 \end_layout
2240
2241 \end_deeper
2242 \begin_layout List
2243 \labelwidthstring 00000.00000.00000.000
2244
2245 \bar under
2246 Implicit\InsetSpace ~
2247 types
2248 \bar default
2249
2250 \begin_inset LatexCommand index
2251 name "types, implicit"
2252
2253 \end_inset
2254
2255
2256 \begin_inset LatexCommand index
2257 name "types, implicit"
2258
2259 \end_inset
2260
2261 It is possible to create an instance that does not have a corresponding
2262 type definition in the library.
2263 The type of such an instance is said to be
2264 \series bold
2265 implicit
2266 \series default
2267
2268 \begin_inset Foot
2269 status collapsed
2270
2271 \begin_layout Standard
2272 (Some people use the word
2273 \emph on
2274 anonymous
2275 \emph default
2276
2277 \begin_inset LatexCommand index
2278 name "type, anonymous"
2279
2280 \end_inset
2281
2282
2283 \begin_inset LatexCommand index
2284 name "anonymous type"
2285
2286 \end_inset
2287
2288 .
2289 However, no computable type is anonymous and the implicit type of an instance
2290 is theoretically computable)
2291 \end_layout
2292
2293 \end_inset
2294
2295 .
2296 The simplest example of an implicit type is the type of an instance compiled
2297 from the built-in definition
2298 \family sans
2299 integer_constant
2300 \family default
2301 .
2302 For example:
2303 \end_layout
2304
2305 \begin_deeper
2306 \begin_layout LyX-Code
2307 i, j IS_A integer_constant;
2308 \end_layout
2309
2310 \begin_layout LyX-Code
2311 i:== 2;
2312 \end_layout
2313
2314 \begin_layout LyX-Code
2315 j:== 3;
2316 \end_layout
2317
2318 \begin_layout Standard
2319 Instances
2320 \family typewriter
2321 i
2322 \family default
2323 and
2324 \family typewriter
2325 j
2326 \family default
2327 , though of the same formal type, are implicit type incompatible because
2328 they have been assigned distinct values.
2329 \end_layout
2330
2331 \begin_layout Standard
2332 Instances which are either formally or implicitly type incompatible cannot
2333 be merged.
2334 This will be discussed further in Section
2335 \begin_inset LatexCommand vref
2336 reference "sec:x.3Declarative-statements"
2337
2338 \end_inset
2339
2340 .
2341 \end_layout
2342
2343 \end_deeper
2344 \begin_layout List
2345 \labelwidthstring 00000.00000.00000.000
2346 Parsing
2347 \begin_inset LatexCommand index
2348 name "parsing"
2349
2350 \end_inset
2351
2352 Most errors in the declaration of an ASCEND model can be caught at parse
2353 time because the object type of any well-formed name in an ASCEND definition
2354 can be resolved or proved ambiguous.
2355 We cannot prove at parse time whether a specific array element will exist,
2356 but we can know that should such an element exist, it must be of the type
2357 with which the array is defined.
2358
2359 \end_layout
2360
2361 \begin_deeper
2362 \begin_layout Standard
2363 Ambiguity is warned about loudly because it is caused by either misspelling
2364 or poor modeling style.
2365 The simplest example of ambiguity follows.
2366 \end_layout
2367
2368 \begin_layout Standard
2369 Assume a type, stream, and a refinement of stream, heat_stream, which adds
2370 the new variable
2371 \family typewriter
2372 H
2373 \family default
2374 .
2375 Now, if we write:
2376 \end_layout
2377
2378 \begin_layout LyX-Code
2379 MODEL mixer;
2380 \end_layout
2381
2382 \begin_layout LyX-Code
2383 input[1..2] IS_A stream;
2384 \end_layout
2385
2386 \begin_layout LyX-Code
2387 output IS_A heat_stream;
2388 \end_layout
2389
2390 \begin_layout LyX-Code
2391 input[1].H + input[2].H = output.H;
2392 \end_layout
2393
2394 \begin_layout LyX-Code
2395 END mixer;
2396 \end_layout
2397
2398 \begin_layout Standard
2399 We see the parser can find the definition of H in the type heat_stream,
2400 so
2401 \family typewriter
2402 output.H
2403 \family default
2404 is well defined.
2405 The author of the mixer model may intend to refine
2406 \family typewriter
2407 input[1]
2408 \family default
2409 and
2410 \family typewriter
2411 input[2]
2412 \family default
2413 to be objects of different types, say steam_stream and electric_stream,
2414 where each defines an
2415 \family typewriter
2416 H
2417 \family default
2418 suitable for use in the equation.
2419 The parser cannot read the authors mind, so it warns that
2420 \family typewriter
2421 input[1].H
2422 \family default
2423 and
2424 \family typewriter
2425 input[2].H
2426 \family default
2427 are ambiguous in the mixer definition.
2428 The mixer model is not highly reusable except by the author, but sometimes
2429 reusability is not a high priority objective.
2430 The mixer definition is allowed, but it may cause problems in instantiation
2431 if the author has forgotten the assumption that is not explicitly stated
2432 in the model and neglects to refine the input streams appropriately.
2433 \end_layout
2434
2435 \end_deeper
2436 \begin_layout List
2437 \labelwidthstring 00000.00000.00000.000
2438
2439 \bar under
2440 Instantiation
2441 \bar default
2442
2443 \begin_inset LatexCommand index
2444 name "instantiation"
2445
2446 \end_inset
2447
2448 Creating an simulation based on a type definition is a multi-phase
2449 \begin_inset LatexCommand index
2450 name "multi-phase"
2451
2452 \end_inset
2453
2454 process called compiling
2455 \begin_inset LatexCommand index
2456 name "compiling"
2457
2458 \end_inset
2459
2460 (or instantiation).
2461 When an instantiation cannot be completed because some structural parameter
2462 (a symbol_constant, real_constant, boolean_constant, integer_constant,
2463 or set) does not have a value there will be PENDING
2464 \begin_inset LatexCommand index
2465 name "PENDING"
2466
2467 \end_inset
2468
2469 statements.
2470 The user interface will warn that something is incomplete.
2471 \end_layout
2472
2473 \begin_deeper
2474 \begin_layout Standard
2475 In phase
2476 \begin_inset LatexCommand index
2477 name "phases, compiler"
2478
2479 \end_inset
2480
2481 1 all statements that create instance structures or assign constant values
2482 are executed.
2483 This phase theoretically requires an infinite number of passes through
2484 the structural statements of a definition.
2485 We allow a maximum of 5 and have never needed more than 3.
2486 There may be pending statements at the end of phase 1.
2487 The compiler or interface will issue warnings about pending statements,
2488 starting with warnings about unassigned constants.
2489 \end_layout
2490
2491 \begin_layout Standard
2492 Phase 2 compiles as many real arithmetic relation definitions as possible.
2493 Some relations may be impossible to compile because the constants or sets
2494 they depend on do not have values assigned.
2495 Other relations may be impossible because they reference variables that
2496 do not exist.
2497 This is determined in a single pass.
2498 \end_layout
2499
2500 \begin_layout Standard
2501 Phase 3 compiles as many logical arithmetic relation definitions as possible.
2502 Some relations may be impossible to compile because the constants or sets
2503 they depend on do not have values assigned.
2504 Other relations may be impossible because they reference real arithmetic
2505 relations that do not exist.
2506 This is determined in a single pass.
2507 \end_layout
2508
2509 \begin_layout Standard
2510 Phase 4 compiles as many conditional programming statements (
2511 \family sans
2512 WHEN
2513 \family default
2514 s) as possible.
2515 Some
2516 \family sans
2517 WHEN
2518 \family default
2519 relations may be impossible to compile because the discrete variables,
2520 models, or relations they depend on do not exist.
2521 This is determined in a single pass.
2522 \end_layout
2523
2524 \begin_layout Standard
2525 Phase 5 executes the variable defaulting statements made in the declarative
2526 section of each model
2527 \emph on
2528 if and only if
2529 \emph default
2530 there are no pending statements from phases 1-4 anywhere in the simulation.
2531 \end_layout
2532
2533 \end_deeper
2534 \begin_layout List
2535 \labelwidthstring 00000.00000.00000.000
2536 default_self
2537 \begin_inset LatexCommand index
2538 name "default\\_self"
2539
2540 \end_inset
2541
2542 After all phases are done, the method default_self is called in the top-most
2543 model of the simulation, if this method exists.
2544 \end_layout
2545
2546 \begin_deeper
2547 \begin_layout Standard
2548 The first occurrence of each impossible statement will be explained during
2549 a failed compilation.
2550 Impossible statements include:
2551 \end_layout
2552
2553 \begin_layout Itemize
2554 Relations containing undefinable variables (often misspellings).
2555 \end_layout
2556
2557 \begin_layout Itemize
2558 Assignments that are dimensionally inconsistent or containing mismatched
2559 types.
2560 \end_layout
2561
2562 \begin_layout Itemize
2563 Structure building or modifying statements that refer to model parts which
2564 cannot exist or that require a type-incompatible argument, refinement,
2565 or merge.
2566 \end_layout
2567
2568 \begin_layout Chapter
2569 Data Type Declarations
2570 \begin_inset LatexCommand index
2571 name "data type declarations"
2572
2573 \end_inset
2574
2575
2576 \end_layout
2577
2578 \begin_layout Standard
2579 In the spectrum of OO languages, ASCEND is best considered as being class-based
2580 \begin_inset LatexCommand index
2581 name "class-based"
2582
2583 \end_inset
2584
2585 , though it is rather more a hybrid.
2586 We have atom and model definitions, called
2587 \series bold
2588 types
2589 \series default
2590 , and the compiled objects themselves, called
2591 \series bold
2592 instances
2593 \series default
2594 .
2595 ASCEND instances have a record of what type they were constructed from.
2596 \end_layout
2597
2598 \end_deeper
2599 \begin_layout List
2600 \labelwidthstring 00000.00000.00000.000
2601
2602 \bar under
2603 Type\InsetSpace ~
2604 qualifiers
2605 \begin_inset LatexCommand index
2606 name "type qualifiers"
2607
2608 \end_inset
2609
2610 :
2611 \end_layout
2612
2613 \begin_layout List
2614 \labelwidthstring 00000.00000.00000.000
2615
2616 \family sans
2617 UNIVERSAL
2618 \family default
2619
2620 \begin_inset LatexCommand index
2621 name "UNIVERSAL"
2622
2623 \end_inset
2624
2625 Universal is an optional modifier of all
2626 \family sans
2627 ATOM
2628 \family default
2629 ,
2630 \family sans
2631 CONSTANT
2632 \family default
2633 and
2634 \family sans
2635 MODEL
2636 \family default
2637 definitions.
2638 If
2639 \family sans
2640 UNIVERSAL
2641 \family default
2642 precedes the definition, then
2643 \emph on
2644 all
2645 \emph default
2646 instances of that type will actually refer to the first instance of the
2647 type that is created.
2648 This saves memory and ensures global consistency of data.
2649
2650 \end_layout
2651
2652 \begin_deeper
2653 \begin_layout Standard
2654 Examples of universal type definitions are
2655 \end_layout
2656
2657 \begin_layout LyX-Code
2658 UNIVERSAL MODEL methane
2659 \end_layout
2660
2661 \begin_layout LyX-Code
2662 REFINES generic_component_model;
2663 \end_layout
2664
2665 \begin_layout LyX-Code
2666 UNIVERSAL CONSTANT circle_constant
2667 \end_layout
2668
2669 \begin_layout LyX-Code
2670 REFINES real_constant :== 1{PI};
2671 \end_layout
2672
2673 \begin_layout LyX-Code
2674 UNIVERSAL ATOM counter_1
2675 \end_layout
2676
2677 \begin_layout LyX-Code
2678 REFINES integer;
2679 \end_layout
2680
2681 \end_deeper
2682 \begin_layout List
2683 \labelwidthstring 00000.00000.00000.000
2684 Tip:\InsetSpace ~
2685 Do\InsetSpace ~
2686 not\InsetSpace ~
2687 use\InsetSpace ~
2688
2689 \family sans
2690 UNIVERSAL
2691 \family default
2692 \InsetSpace ~
2693 variables\InsetSpace ~
2694 in\InsetSpace ~
2695 relations.
2696 \end_layout
2697
2698 \begin_deeper
2699 \begin_layout Standard
2700 It is important to note that, because
2701 \emph on
2702 variables
2703 \emph default
2704 must store information about which relations they occur in, it is a very
2705 bad idea to use
2706 \family sans
2707 UNIVERSAL
2708 \family default
2709 typed variables in relations.
2710 The construction and maintenance of the relation list becomes very expensive
2711 for universal variables.
2712
2713 \family sans
2714 UNIVERSAL
2715 \family default
2716
2717 \emph on
2718 constants
2719 \emph default
2720 are fine to use, though, because there are no relation links for constants.
2721 \end_layout
2722
2723 \begin_layout Section
2724 Models
2725 \end_layout
2726
2727 \end_deeper
2728 \begin_layout List
2729 \labelwidthstring 00000.00000.00000.000
2730
2731 \family sans
2732 MODEL
2733 \family default
2734
2735 \begin_inset LatexCommand index
2736 name "MODEL"
2737
2738 \end_inset
2739
2740 An ASCEND model has a declarative part and an optional procedural part
2741 headed by the METHODS word.
2742 Models are essentially containers for variables and relations.
2743 We will explain the various statements that can be made within models in
2744 Section
2745 \begin_inset LatexCommand vref
2746 reference "sec:x.3Declarative-statements"
2747
2748 \end_inset
2749
2750 and Section
2751 \begin_inset LatexCommand vref
2752 reference "sec:x.4Procedural-statements"
2753
2754 \end_inset
2755
2756 .
2757 \end_layout
2758
2759 \begin_layout Standard
2760 Simple\InsetSpace ~
2761 models
2762 \begin_inset LatexCommand index
2763 name "models, simple"
2764
2765 \end_inset
2766
2767 :
2768 \end_layout
2769
2770 \begin_layout List
2771 \labelwidthstring 00000.00000.00000.000
2772 foo
2773 \family typewriter
2774 \InsetSpace ~
2775 \InsetSpace ~
2776 \InsetSpace ~
2777 \InsetSpace ~
2778 MODEL foo;
2779 \end_layout
2780
2781 \begin_deeper
2782 \begin_layout LyX-Code
2783 (* statements about foo go here*)
2784 \end_layout
2785
2786 \begin_layout LyX-Code
2787 METHODS
2788 \end_layout
2789
2790 \begin_layout LyX-Code
2791 (* METHODs for foo go here*)
2792 \end_layout
2793
2794 \begin_layout LyX-Code
2795 END foo;
2796 \end_layout
2797
2798 \end_deeper
2799 \begin_layout List
2800 \labelwidthstring 00000.00000.00000.000
2801 bar
2802 \family typewriter
2803 \InsetSpace ~
2804 \InsetSpace ~
2805 \InsetSpace ~
2806 \InsetSpace ~
2807 MODEL bar REFINES foo;
2808 \end_layout
2809
2810 \begin_deeper
2811 \begin_layout LyX-Code
2812 (*additional statements about foo *)
2813 \end_layout
2814
2815 \begin_layout LyX-Code
2816 METHODS
2817 \end_layout
2818
2819 \begin_layout LyX-Code
2820 (* additional METHODs for bar *)
2821 \end_layout
2822
2823 \begin_layout LyX-Code
2824 END bar;
2825 \end_layout
2826
2827 \end_deeper
2828 \begin_layout List
2829 \labelwidthstring 00000.00000.00000.000
2830
2831 \bar under
2832 Parameterized\InsetSpace ~
2833 Models
2834 \bar default
2835
2836 \begin_inset LatexCommand index
2837 name "models, parameterized"
2838
2839 \end_inset
2840
2841 Parameterizing models makes them easier to understand and faster for the
2842 system to compile.
2843 The syntax for a parameterized model vaguely resembles a function call
2844 in imperative languages, but it is NOT.
2845 When constructing a reusable model, all the constants that determine the
2846 sizes of arrays and other structures should be declared in the parameter
2847 list so that
2848 \end_layout
2849
2850 \begin_deeper
2851 \begin_layout Itemize
2852 the user knows what is required to reuse the model.
2853 \end_layout
2854
2855 \begin_layout Itemize
2856 the compiler knows what values must be set before it should bother attempting
2857 to compile the model.
2858 \end_layout
2859
2860 \begin_layout Standard
2861 There is no reason that other items could not also go in the parameter list,
2862 such as key variables which might be considered inputs or outputs or control
2863 parameters in the mathematical application of the model.
2864 A simple example of parameterization would be:
2865 \end_layout
2866
2867 \end_deeper
2868 \begin_layout List
2869 \labelwidthstring 00000.00000.00000.000
2870 column(n,s)
2871 \end_layout
2872
2873 \begin_deeper
2874 \begin_layout LyX-Code
2875 MODEL column(
2876 \end_layout
2877
2878 \begin_layout LyX-Code
2879 ntrays WILL_BE integer_constant;
2880 \end_layout
2881
2882 \begin_layout LyX-Code
2883 components IS_A set of symbol_constant;
2884 \end_layout
2885
2886 \begin_layout LyX-Code
2887 );
2888 \end_layout
2889
2890 \begin_layout LyX-Code
2891 stage[1..ntrays] IS_A simple_tray;
2892 \end_layout
2893
2894 \begin_layout LyX-Code
2895 END column;
2896 \end_layout
2897
2898 \end_deeper
2899 \begin_layout List
2900 \labelwidthstring 00000.00000.00000.000
2901 flowsheet
2902 \end_layout
2903
2904 \begin_deeper
2905 \begin_layout LyX-Code
2906 MODEL flowsheet;
2907 \end_layout
2908
2909 \begin_layout LyX-Code
2910 tower4size IS_A integer_constant;
2911 \end_layout
2912
2913 \begin_layout LyX-Code
2914 tower4size :== 22;
2915 \end_layout
2916
2917 \begin_layout LyX-Code
2918 ct IS_A column(tower4size,[c5,c6]);
2919 \end_layout
2920
2921 \begin_layout LyX-Code
2922 (* additional flowsheet statements *)
2923 \end_layout
2924
2925 \begin_layout LyX-Code
2926 END flowsheet;
2927 \end_layout
2928
2929 \begin_layout Standard
2930 In this example, the column model takes the first argument, ntrays, by reference.
2931 That is,
2932 \family typewriter
2933 ct.ntrays
2934 \family default
2935 is an alias for the flowsheet instance
2936 \family typewriter
2937 tower4size
2938 \family default
2939 .
2940
2941 \family typewriter
2942 tower4size
2943 \family default
2944 must be compiled and assigned a value before we will attempt to compile
2945 the column model instance
2946 \family typewriter
2947 ct
2948 \family default
2949 .
2950 The second argument is taken by value,
2951 \family typewriter
2952 [c5,c6]
2953 \family default
2954 , and assigned to components, a column part that was declared with
2955 \family sans
2956 IS_A
2957 \family default
2958 in the parameter list.
2959 There is only one name for this set,
2960 \family typewriter
2961 ct.components
2962 \family default
2963 .
2964 Note that in the
2965 \family typewriter
2966 flowsheet
2967 \family default
2968 model there is no part that is a set of
2969 \family sans
2970 symbol_constant
2971 \family default
2972 .
2973
2974 \end_layout
2975
2976 \begin_layout Standard
2977 The use of parameters in ASCEND modeling requires some thought, and we will
2978 present that set of thoughts in Section
2979 \begin_inset LatexCommand vref
2980 reference "sec:x.5Parameterized-models"
2981
2982 \end_inset
2983
2984 .
2985 Beginners may wish to create new models without parameters until they are
2986 comfortable using the existing parameterized library definitions.
2987 Parameters are intended to support model reuse and efficient compilation
2988 which are not issues in the very earliest phase of developing novel models.
2989 \end_layout
2990
2991 \begin_layout Section
2992 Sets
2993 \begin_inset LatexCommand index
2994 name "sets"
2995
2996 \end_inset
2997
2998
2999 \begin_inset LatexCommand label
3000 name "sub:x.2.2Sets"
3001
3002 \end_inset
3003
3004
3005 \end_layout
3006
3007 \begin_layout Standard
3008 Arrays in ASCEND, as already discussed in Section
3009 \begin_inset LatexCommand vref
3010 reference "sub:x.1.2Basic-Elements"
3011
3012 \end_inset
3013
3014 , are defined over sets.
3015 A set is simply an instance with a set value.
3016 The elements of sets are
3017 \emph on
3018 not
3019 \emph default
3020 instances or sets.
3021 \end_layout
3022
3023 \end_deeper
3024 \begin_layout List
3025 \labelwidthstring 00000.00000.00000.000
3026
3027 \bar under
3028 Set\InsetSpace ~
3029 Declaration:
3030 \bar default
3031 A set is made of either symbol_constants or integer_constants, so a set
3032 object is declared in one of two ways:
3033 \end_layout
3034
3035 \begin_deeper
3036 \begin_layout LyX-Code
3037 my_integer_set IS_A set OF integer_constant;
3038 \end_layout
3039
3040 \begin_layout Standard
3041 or
3042 \end_layout
3043
3044 \begin_layout LyX-Code
3045 my_symbol_set IS_A set OF symbol_constant;
3046 \end_layout
3047
3048 \end_deeper
3049 \begin_layout List
3050 \labelwidthstring 00000.00000.00000.000
3051
3052 \family typewriter
3053 :==
3054 \family default
3055
3056 \begin_inset LatexCommand index
3057 name ":=="
3058
3059 \end_inset
3060
3061 A set is assigned a value like so:
3062 \end_layout
3063
3064 \begin_deeper
3065 \begin_layout LyX-Code
3066 my_integer_set :== [1,4];
3067 \end_layout
3068
3069 \begin_layout Standard
3070 The RHS of such an assignment must be either the name of another set instance
3071 or an expression enclosed in square brackets and made up of only set operators,
3072 other sets, and the names of integer_constants or symbol_constants.
3073 Sets can only be assigned once.
3074 \end_layout
3075
3076 \end_deeper
3077 \begin_layout List
3078 \labelwidthstring 00000.00000.00000.000
3079
3080 \bar under
3081 Set\InsetSpace ~
3082 Operations
3083 \bar default
3084
3085 \family sans
3086 UNION
3087 \family default
3088
3089 \begin_inset LatexCommand index
3090 name "UNION"
3091
3092 \end_inset
3093
3094
3095 \family typewriter
3096 [setlist]
3097 \end_layout
3098
3099 \begin_deeper
3100 \begin_layout Standard
3101 A function taken over a list of sets.
3102 The result is the set that includes all the members of all the sets in
3103 the list.
3104 Note that the result of the
3105 \family sans
3106 UNION
3107 \family default
3108 operation is an unordered set and the argument order to the union function
3109 does not matter.
3110 The syntax is:
3111 \end_layout
3112
3113 \end_deeper
3114 \begin_layout List
3115 \labelwidthstring 00000.00000.00000.000
3116 +
3117 \begin_inset LatexCommand index
3118 name "+, sets"
3119
3120 \end_inset
3121
3122
3123 \family typewriter
3124 UNION[list_of_sets]
3125 \end_layout
3126
3127 \begin_layout List
3128 \labelwidthstring 00000.00000.00000.000
3129
3130 \family typewriter
3131 A+B
3132 \family default
3133 \InsetSpace ~
3134 is\InsetSpace ~
3135 shorthand\InsetSpace ~
3136 for
3137 \family typewriter
3138 UNION[A,B]
3139 \end_layout
3140
3141 \begin_deeper
3142 \begin_layout Standard
3143 Consider the following sets for the examples to follow.
3144 \end_layout
3145
3146 \begin_layout LyX-Code
3147 A := [1, 2, 3, 5, 9];
3148 \end_layout
3149
3150 \begin_layout LyX-Code
3151 B := [2, 4, 6, 8];
3152 \end_layout
3153
3154 \begin_layout Standard
3155 Then
3156 \family typewriter
3157 UNION[A, B]
3158 \family default
3159 is equal to the set
3160 \family typewriter
3161 [1, 2, 3, 4, 5, 6, 8, 9]
3162 \family default
3163 which equals
3164 \family typewriter
3165 [1..6, 8, 9]
3166 \family default
3167 which equals
3168 \family typewriter
3169 [[1..9] - [7]]
3170 \family default
3171 .
3172 \end_layout
3173
3174 \end_deeper
3175 \begin_layout List
3176 \labelwidthstring 00000.00000.00000.000
3177
3178 \family sans
3179 INTERSECTION
3180 \family default
3181
3182 \begin_inset LatexCommand index
3183 name "INTERSECTION"
3184
3185 \end_inset
3186
3187 [] INTERSECTION[list of set expressions].
3188 Finds the intersection (and) of the sets listed.
3189
3190 \end_layout
3191
3192 \begin_layout List
3193 \labelwidthstring 00000.00000.00000.000
3194 *
3195 \begin_inset LatexCommand index
3196 name "*, sets"
3197
3198 \end_inset
3199
3200 Equivalent to
3201 \family sans
3202 INTERSECTION
3203 \family typewriter
3204 [list_of_sets]
3205 \family default
3206 .
3207 \end_layout
3208
3209 \begin_layout List
3210 \labelwidthstring 00000.00000.00000.000
3211
3212 \family typewriter
3213 A*B
3214 \family default
3215 \InsetSpace ~
3216 is\InsetSpace ~
3217 shorthand\InsetSpace ~
3218 for\InsetSpace ~
3219 I
3220 \family typewriter
3221 NTERSECTION[A,B]
3222 \end_layout
3223
3224 \begin_deeper
3225 \begin_layout Standard
3226 For the sets A and B defined just above,
3227 \family typewriter
3228 INTERSECTION[A, B]
3229 \family default
3230 is the set
3231 \family typewriter
3232 [2]
3233 \family default
3234 .
3235 The
3236 \family typewriter
3237 *
3238 \family default
3239 shorthand for intersection is
3240 \emph on
3241 not
3242 \emph default
3243 recommended for use except in libraries no one will look at.
3244 \end_layout
3245
3246 \end_deeper
3247 \begin_layout List
3248 \labelwidthstring 00000.00000.00000.000
3249 Set\InsetSpace ~
3250 difference
3251 \begin_inset LatexCommand index
3252 name "set difference"
3253
3254 \end_inset
3255
3256 : One can subtract one set from another.
3257 The result is the first set less any members in the set union of the first
3258 and second set.
3259 The syntax is
3260 \end_layout
3261
3262 \begin_deeper
3263 \begin_layout LyX-Code
3264
3265 \family typewriter
3266 first_set
3267 \family default
3268 -
3269 \begin_inset LatexCommand index
3270 name "-, sets"
3271
3272 \end_inset
3273
3274
3275 \family typewriter
3276 second_set
3277 \end_layout
3278
3279 \begin_layout Standard
3280 For the sets
3281 \family typewriter
3282 A
3283 \family default
3284 and
3285 \family typewriter
3286 B
3287 \family default
3288 defined above, the set difference
3289 \family typewriter
3290 A - B
3291 \family default
3292 is the set
3293 \family typewriter
3294 [1, 3, 5, 9]
3295 \family default
3296 while the set difference
3297 \family typewriter
3298 B - A
3299 \family default
3300 is the set
3301 \family typewriter
3302 [4, 6, 8]
3303 \family default
3304 .
3305 \end_layout
3306
3307 \end_deeper
3308 \begin_layout List
3309 \labelwidthstring 00000.00000.00000.000
3310
3311 \family sans
3312 CARD
3313 \family default
3314
3315 \begin_inset LatexCommand index
3316 name "CARD"
3317
3318 \end_inset
3319
3320 [set] Cardinality
3321 \begin_inset LatexCommand index
3322 name "cardinality"
3323
3324 \end_inset
3325
3326 .
3327 Returns an integer constant value that is the number of items in the set.
3328 \end_layout
3329
3330 \begin_layout List
3331 \labelwidthstring 00000.00000.00000.000
3332
3333 \family sans
3334 CHOICE
3335 \family default
3336
3337 \begin_inset LatexCommand index
3338 name "CHOICE"
3339
3340 \end_inset
3341
3342 [set] Choose one.
3343 The result of running the
3344 \family sans
3345 CHOICE
3346 \family default
3347 function over a set is an arbitrary (but consistent: for any set instance
3348 you always get the same result) single element of that set.
3349
3350 \end_layout
3351
3352 \begin_deeper
3353 \begin_layout Standard
3354 Running
3355 \family typewriter
3356 CHOICE[A]
3357 \family default
3358 gives any member from the set A.
3359 The result is a member, not a set.
3360 To make the result into a set, it must be enclosed in square brackets.
3361 Thus
3362 \family typewriter
3363 [CHOICE[A]]
3364 \family default
3365 is a set with a single element arbitrarily chosen from the set A.
3366 Good modelers do not leave modeling decisions to the compiler; they do
3367 not use
3368 \family sans
3369 CHOICE
3370 \family default
3371 .
3372 We are stuck with it for historical reasons.
3373 \end_layout
3374
3375 \begin_layout Standard
3376 To reduce a set by one element, one can use the following
3377 \end_layout
3378
3379 \begin_layout LyX-Code
3380 A_less_one IS_A set OF integer;
3381 \end_layout
3382
3383 \begin_layout LyX-Code
3384 A_less_one :== A - [CHOICE[A]];
3385 \end_layout
3386
3387 \end_deeper
3388 \begin_layout List
3389 \labelwidthstring 00000.00000.00000.000
3390
3391 \family sans
3392 IN
3393 \family default
3394
3395 \begin_inset LatexCommand index
3396 name "IN"
3397
3398 \end_inset
3399
3400
3401 \family typewriter
3402 lhs IN rhs
3403 \family default
3404 can only be well explained by examples.
3405
3406 \family sans
3407 IN
3408 \family default
3409 is used in index expressions.
3410 If
3411 \family typewriter
3412 lhs
3413 \family default
3414 is a simple and not previously defined name, it is created as a temporary
3415 loop index which will take on the values of the rhs set definition.
3416 If lhs is something that already exists, the result of
3417 \family typewriter
3418 lhs IN rhs
3419 \family default
3420 is a boolean value; stare at the model
3421 \family typewriter
3422 set_example
3423 \family default
3424 below which demonstrates both
3425 \family sans
3426 IN
3427 \family default
3428 and
3429 \family sans
3430 SUCH_THAT
3431 \family default
3432 .
3433 If you still are not satisfied, you might examine [[westerbergksets]]
3434 \begin_inset Note Note
3435 status open
3436
3437 \begin_layout Standard
3438 fix this reference
3439 \end_layout
3440
3441 \end_inset
3442
3443 .
3444 \end_layout
3445
3446 \begin_layout List
3447 \labelwidthstring 00000.00000.00000.000
3448
3449 \family sans
3450 SUCH_THAT
3451 \family default
3452
3453 \begin_inset LatexCommand index
3454 name "SUCH\\_THAT"
3455
3456 \end_inset
3457
3458 Set expressions can be rather clever.
3459 We will give a detailed example from chemistry because unordered sets are
3460 unfamiliar to most people and set arithmetic is quite powerful.
3461 In this example we see arrays of sets and sparse arrays.
3462
3463 \end_layout
3464
3465 \begin_layout LyX-Code
3466 MODEL set_example;
3467 \end_layout
3468
3469 \begin_layout LyX-Code
3470 (* we define a sparse matrix of reaction
3471 \end_layout
3472
3473 \begin_layout LyX-Code
3474 coefficient information and the species
3475 \end_layout
3476
3477 \begin_layout LyX-Code
3478 balance equations.
3479 *)
3480 \end_layout
3481
3482 \begin_layout LyX-Code
3483 rxns IS_A set OF integer_constant;
3484 \end_layout
3485
3486 \begin_layout LyX-Code
3487 rxns :== [1..3];
3488 \end_layout
3489
3490 \begin_layout LyX-Code
3491 species IS_A set OF symbol_constant;
3492 \end_layout
3493
3494 \begin_layout LyX-Code
3495 species :== ['A','B','C','D'];
3496 \end_layout
3497
3498 \begin_layout LyX-Code
3499 reactants[rxns] IS_A set OF symbol_constant; (* species
3500 \end_layout
3501
3502 \begin_layout LyX-Code
3503 in each rxn_j *)
3504 \end_layout
3505
3506 \begin_layout LyX-Code
3507 reactants[1] :== ['A','B','C'];
3508 \end_layout
3509
3510 \begin_layout LyX-Code
3511 reactants[2] :== ['A','C'];
3512 \end_layout
3513
3514 \begin_layout LyX-Code
3515 reactants[3] :== ['A','B','D'];
3516 \end_layout
3517
3518 \begin_layout LyX-Code
3519 reactions[species] IS_A set OF integer_constant;
3520 \end_layout
3521
3522 \begin_layout LyX-Code
3523 FOR i IN species CREATE (* rxns for each species i *)
3524 \end_layout
3525
3526 \begin_layout LyX-Code
3527 reactions[i] :== [j IN rxns SUCH_THAT i IN reactants[j]];
3528 \end_layout
3529
3530 \begin_layout LyX-Code
3531 END FOR;
3532 \end_layout
3533
3534 \begin_layout LyX-Code
3535 (* Define sparse stoichiometric matrix.
3536 Values of eta_ij
3537 \end_layout
3538
3539 \begin_layout LyX-Code
3540 set later.*)
3541 \end_layout
3542
3543 \begin_layout LyX-Code
3544 FOR j IN rxns CREATE
3545 \end_layout
3546
3547 \begin_layout LyX-Code
3548 FOR i IN reactants[j] CREATE
3549 \end_layout
3550
3551 \begin_layout LyX-Code
3552 (* eta_ij --> mole i/mole rxn j*)
3553 \end_layout
3554
3555 \begin_layout LyX-Code
3556 eta[i][j] IS_A real_constant;
3557 \end_layout
3558
3559 \begin_layout LyX-Code
3560 END FOR;
3561 \end_layout
3562
3563 \begin_layout LyX-Code
3564 END FOR;
3565 \end_layout
3566
3567 \begin_layout LyX-Code
3568 production[species] IS_A molar_rate;
3569 \end_layout
3570
3571 \begin_layout LyX-Code
3572 rate[rxns] IS_A molar_rate; (* mole rxn j/time *)
3573 \end_layout
3574
3575 \begin_layout LyX-Code
3576 FOR i IN species CREATE
3577 \end_layout
3578
3579 \begin_layout LyX-Code
3580 gen_eqn[i]: production[i] =
3581 \end_layout
3582
3583 \begin_layout LyX-Code
3584 SUM[eta[i][j]*rate[j] | j IN reactions[i]];
3585 \end_layout
3586
3587 \begin_layout LyX-Code
3588 END FOR;
3589 \end_layout
3590
3591 \begin_layout LyX-Code
3592 END set_example;
3593 \end_layout
3594
3595 \begin_layout List
3596 \labelwidthstring 00000.00000.00000.000
3597 "
3598 \family typewriter
3599 |
3600 \family default
3601
3602 \begin_inset LatexCommand index
3603 name "|"
3604
3605 \end_inset
3606
3607 " is shorthand for
3608 \family sans
3609 SUCH_THAT
3610 \family default
3611 .
3612 \end_layout
3613
3614 \begin_deeper
3615 \begin_layout Standard
3616 The array
3617 \family typewriter
3618 eta
3619 \family default
3620 has only 8 elements, and we defined those elements in a set for each reaction.
3621 The equation needs to know about the set of reactions for a species
3622 \family typewriter
3623 i
3624 \family default
3625 , and that set is calculated automatically in the models first
3626 \family sans
3627 FOR/CREATE
3628 \family default
3629 statement.
3630
3631 \end_layout
3632
3633 \begin_layout Standard
3634 The
3635 \family typewriter
3636 |
3637 \family default
3638 symbol is the ASCEND III notation for
3639 \family sans
3640 SUCH_THAT
3641 \family default
3642 .
3643 We noted that "
3644 \family typewriter
3645 |
3646 \family default
3647 " is often read as "for all", which is different in that "for all" makes
3648 one think of a
3649 \family sans
3650 FOR
3651 \family default
3652 loop where the loop index is on the left of an
3653 \family sans
3654 IN
3655 \family default
3656 operator.
3657 For example, the
3658 \family typewriter
3659 j
3660 \family default
3661 loop in the
3662 \family sans
3663 SUM
3664 \family default
3665 of
3666 \family typewriter
3667 gen_eqn[i]
3668 \family default
3669 above.
3670
3671 \end_layout
3672
3673 \begin_layout Section
3674 Constants
3675 \begin_inset LatexCommand index
3676 name "constants"
3677
3678 \end_inset
3679
3680
3681 \end_layout
3682
3683 \begin_layout Standard
3684 ASCEND supports real, integer, boolean and character string constants.
3685 Constants in ASCEND do not have any attributes other than their value.
3686 Constants are scalar quantities that can be assigned exactly once.
3687 Constants may only be assigned using the
3688 \family typewriter
3689 :==
3690 \family default
3691 operator and the RHS expression they are assigned from must itself be constant.
3692 Constants do not have subparts.
3693 Integer and symbol constants may be used in determining the definitions
3694 of sets.
3695
3696 \end_layout
3697
3698 \begin_layout Standard
3699 Explicit refinements of the built-in constant types may be defined as exemplifie
3700 d in the description of real_constant.
3701 Implicit type refinements may be done by instantiating an incompletely
3702 defined constant and assigning its final value.
3703
3704 \end_layout
3705
3706 \begin_layout Standard
3707 Sets could be considered constant because they are assigned only once, however
3708 sets are described separately because they are not quite scalar quantities.
3709 \end_layout
3710
3711 \end_deeper
3712 \begin_layout List
3713 \labelwidthstring 00000.00000.00000.000
3714
3715 \family sans
3716 real_constant
3717 \family default
3718
3719 \begin_inset LatexCommand index
3720 name "real\\_constant"
3721
3722 \end_inset
3723
3724 Real number with dimensionality.
3725 Note that the dimensionality of a real constant can be specified via the
3726 type definition without immediately defining the value, as in the following
3727 pair of definitions.
3728 \end_layout
3729
3730 \begin_layout List
3731 \labelwidthstring 00000.00000.00000.000
3732
3733 \bar under
3734 CONSTANT\InsetSpace ~
3735 declaration\InsetSpace ~
3736 example:
3737 \end_layout
3738
3739 \begin_deeper
3740 \begin_layout LyX-Code
3741 CONSTANT molar_weight
3742 \end_layout
3743
3744 \begin_layout LyX-Code
3745 REFINES real_constant DIMENSION M/Q;
3746 \end_layout
3747
3748 \begin_layout LyX-Code
3749 CONSTANT hydrogen_weight
3750 \end_layout
3751
3752 \begin_layout LyX-Code
3753 REFINES molar_weight :== 1.004{g/mole};
3754 \end_layout
3755
3756 \end_deeper
3757 \begin_layout List
3758 \labelwidthstring 00000.00000.00000.000
3759
3760 \family sans
3761 integer_constant
3762 \family default
3763
3764 \begin_inset LatexCommand index
3765 name "integer\\_constant"
3766
3767 \end_inset
3768
3769 Integer number.
3770 Principally used in determining model structure.
3771 If appearing in equations, integers are evaluated as dimensionless reals.
3772 Typical use is inside a
3773 \family sans
3774 MODEL
3775 \family default
3776 definition and looks like:
3777 \end_layout
3778
3779 \begin_deeper
3780 \begin_layout LyX-Code
3781 n_trays IS_A integer_constant;
3782 \end_layout
3783
3784 \begin_layout LyX-Code
3785 n_trays :== 50;
3786 \end_layout
3787
3788 \begin_layout LyX-Code
3789 tray[1..n_trays] IS_A vl_equilibrium_tray;
3790 \end_layout
3791
3792 \end_deeper
3793 \begin_layout List
3794 \labelwidthstring 00000.00000.00000.000
3795
3796 \family sans
3797 symbol_constant
3798 \family default
3799
3800 \begin_inset LatexCommand index
3801 name "symbol\\_constant"
3802
3803 \end_inset
3804
3805 Object with a symbol value.
3806 May be used in determining model structure.
3807 \end_layout
3808
3809 \begin_layout List
3810 \labelwidthstring 00000.00000.00000.000
3811
3812 \family sans
3813 boolean_constant
3814 \family default
3815
3816 \begin_inset LatexCommand index
3817 name "boolean\\_constant"
3818
3819 \end_inset
3820
3821 Logical value.
3822 May be used in determining model structure.
3823 \end_layout
3824
3825 \begin_layout List
3826 \labelwidthstring 00000.00000.00000.000
3827
3828 \bar under
3829 Setting\InsetSpace ~
3830 constants
3831 \bar default
3832
3833 \begin_inset LatexCommand index
3834 name "constants, setting"
3835
3836 \end_inset
3837
3838
3839 \end_layout
3840
3841 \begin_layout List
3842 \labelwidthstring 00000.00000.00000.000
3843 :==
3844 \begin_inset LatexCommand index
3845 name ":=="
3846
3847 \end_inset
3848
3849 Constant and set assignment operator.
3850
3851 \end_layout
3852
3853 \begin_deeper
3854 \begin_layout Standard
3855 It is suggested, but not required, that names of all types that refine the
3856 built-in constant types have names that end in _constant.
3857 \end_layout
3858
3859 \begin_layout LyX-Code
3860 LHS_list :== RHS;
3861 \end_layout
3862
3863 \begin_layout Standard
3864 Here it is required that the one or more items in the LHS be of the same
3865 constant type and that RHS is a single-valued expression made up of values,
3866 operators, and other constants.
3867 The
3868 \family typewriter
3869 :==
3870 \family default
3871 is used to make clear to both the user and the system what scalar objects
3872 are constants.
3873
3874 \end_layout
3875
3876 \begin_layout Section
3877 Variables
3878 \begin_inset LatexCommand index
3879 name "variables"
3880
3881 \end_inset
3882
3883
3884 \end_layout
3885
3886 \begin_layout Standard
3887 There are four built-in types which may be used to construct variables:
3888 symbol, boolean, integer, and real.
3889 At this time symbol types have special restrictions.
3890 Refinements of these variable base types are defined with the
3891 \family sans
3892 ATOM
3893 \family default
3894 statement.
3895 Atom types may declare attribute fields with types real, integer, boolean,
3896 symbol, and set.
3897 These attributes are
3898 \emph on
3899 not
3900 \emph default
3901 independent objects and therefore cannot be refined, merged, or put in
3902 a refinement clique (
3903 \family sans
3904 ARE_ALIKE
3905 \family default
3906 d).
3907 \end_layout
3908
3909 \end_deeper
3910 \begin_layout List
3911 \labelwidthstring 00000.00000.00000.000
3912
3913 \family sans
3914 ATOM
3915 \family default
3916
3917 \begin_inset LatexCommand index
3918 name "ATOM"
3919
3920 \end_inset
3921
3922 The syntax for declaring a new atom type is
3923 \end_layout
3924
3925 \begin_deeper
3926 \begin_layout LyX-Code
3927 ATOM
3928 \emph on
3929 atom_type_name
3930 \emph default
3931 REFINES
3932 \emph on
3933 variable_type
3934 \end_layout
3935
3936 \begin_layout LyX-Code
3937 «DIMENSION
3938 \emph on
3939 dimension_expression
3940 \emph default
3941 »
3942 \end_layout
3943
3944 \begin_layout LyX-Code
3945 «DEFAULT
3946 \emph on
3947 value
3948 \emph default
3949 »; (* note the ; *)
3950 \end_layout
3951
3952 \begin_layout LyX-Code
3953 «
3954 \emph on
3955 initial attribute assignment
3956 \emph default
3957
3958 \end_layout
3959
3960 \begin_layout LyX-Code
3961 END
3962 \emph on
3963 atom_type_name
3964 \emph default
3965 ;
3966 \end_layout
3967
3968 \end_deeper
3969 \begin_layout List
3970 \labelwidthstring 00000.00000.00000.000
3971
3972 \family sans
3973 DEFAULT
3974 \family default
3975
3976 \begin_inset LatexCommand index
3977 name "DEFAULT"
3978
3979 \end_inset
3980
3981 ,
3982 \family sans
3983 \InsetSpace ~
3984 DIMENSION
3985 \family default
3986
3987 \begin_inset LatexCommand index
3988 name "DIMENSION"
3989
3990 \end_inset
3991
3992 ,\InsetSpace ~
3993 and\InsetSpace ~
3994
3995 \family sans
3996 DIMENSIONLESS
3997 \family default
3998
3999 \begin_inset LatexCommand index
4000 name "DIMENSIONLESS"
4001
4002 \end_inset
4003
4004
4005 \end_layout
4006
4007 \begin_deeper
4008 \begin_layout Standard
4009 The
4010 \family sans
4011 DIMENSION
4012 \family default
4013 attribute is for variables whose base type is real.
4014 It is an optional field.
4015 If not defined for any atom with base type real, the dimensions will be
4016 left as undefined.
4017 Any variable which is later declared to be one of these types will be given
4018 wild card dimensionality (represented in the interactive display by an
4019 asterisk (*)).
4020 The system will deduce the dimensionality from its use in the relationships
4021 in which it appears or in the declaring of default values for it, if possible.
4022 \end_layout
4023
4024 \end_deeper
4025 \begin_layout List
4026 \labelwidthstring 00000.00000.00000.000
4027
4028 \family sans
4029 solver_var
4030 \family default
4031
4032 \begin_inset LatexCommand index
4033 name "solver\\_var"
4034
4035 \end_inset
4036
4037 is a special case of
4038 \family sans
4039 ATOM
4040 \family default
4041 and we will say much more about it in Section
4042 \begin_inset LatexCommand vref
4043 reference "sub:x.6.1Variables-for-solvers"
4044
4045 \end_inset
4046
4047 .
4048 \end_layout
4049
4050 \begin_deeper
4051 \begin_layout LyX-Code
4052 ATOM solver_var REFINES real DEFAULT 0.5 {?
4053 \begin_inset LatexCommand index
4054 name "?"
4055
4056 \end_inset
4057
4058 };
4059 \end_layout
4060
4061 \begin_layout LyX-Code
4062 lower_bound IS_A real;
4063 \end_layout
4064
4065 \begin_layout LyX-Code
4066 upper_bound IS_A real;
4067 \end_layout
4068
4069 \begin_layout LyX-Code
4070 nominal IS_A real;
4071 \end_layout
4072
4073 \begin_layout LyX-Code
4074 fixed IS_A boolean;
4075 \end_layout
4076
4077 \begin_layout LyX-Code
4078 fixed := FALSE;
4079 \end_layout
4080
4081 \begin_layout LyX-Code
4082 lower_bound := -1e20 {?};
4083 \end_layout
4084
4085 \begin_layout LyX-Code
4086 upper_bound := 1e20 {?};
4087 \end_layout
4088
4089 \begin_layout LyX-Code
4090 nominal := 0.5 {?};
4091 \end_layout
4092
4093 \begin_layout LyX-Code
4094 END solver_var;
4095 \end_layout
4096
4097 \begin_layout Standard
4098 The default field is also optional.
4099 If the atom has a declared dimensionality, then this value must be expressed
4100 with units which are compatible with this dimensionality.
4101 In the solver_var example, we see a DEFAULT value of 0.5 with the unspecified
4102 unit
4103 \begin_inset LatexCommand index
4104 name "unit, unspecified"
4105
4106 \end_inset
4107
4108
4109 \begin_inset LatexCommand index
4110 name "unspecified unit"
4111
4112 \end_inset
4113
4114 {?
4115 \begin_inset LatexCommand index
4116
4117 \end_inset
4118
4119 } which leaves the dimensionality wild
4120 \begin_inset LatexCommand index
4121 name "wild dimensionality"
4122
4123 \end_inset
4124
4125 .
4126 \end_layout
4127
4128 \end_deeper
4129 \begin_layout List
4130 \labelwidthstring 00000.00000.00000.000
4131 real
4132 \begin_inset LatexCommand index
4133 name "real"
4134
4135 \end_inset
4136
4137 Real valued variable quantity.
4138 At present, all variables that you want to be attended to by solver tools
4139 must be refinements of the type solver_var.
4140 This is so that modifiable parametric values can be included in equations
4141 without treating them as variables.
4142 Strictly speaking, this is a characteristic of the solver interface and
4143 not the ASCEND language.
4144 Each tool in the total ASCEND system may have its own semantics that go
4145 beyond the ASCEND object definition language.
4146 \end_layout
4147
4148 \begin_layout List
4149 \labelwidthstring 00000.00000.00000.000
4150 integer
4151 \begin_inset LatexCommand index
4152 name "integer"
4153
4154 \end_inset
4155
4156 Integer valued variable quantity.
4157 We find these mighty convenient for use in certain procedural computations
4158 and as attributes of solver_var atoms.
4159 \end_layout
4160
4161 \begin_layout List
4162 \labelwidthstring 00000.00000.00000.000
4163 boolean
4164 \begin_inset LatexCommand index
4165 name "boolean"
4166
4167 \end_inset
4168
4169 Truth valued variable quantity.
4170 These are principally used as flags on solver_vars and relations.
4171 They can also be used procedurally and as variables in logical programming
4172 models, subject to the logical solver tools semantics.
4173 (Compare solver_boolean and boolean_var in Section
4174 \begin_inset LatexCommand vref
4175 reference "sec:x.6Miscellany"
4176
4177 \end_inset
4178
4179 .)
4180 \end_layout
4181
4182 \begin_layout List
4183 \labelwidthstring 00000.00000.00000.000
4184 symbol
4185 \begin_inset LatexCommand index
4186 name "symbol"
4187
4188 \end_inset
4189
4190 Symbol valued variable quantity.
4191 We do not yet have operators for building symbols out of other symbols.
4192 \end_layout
4193
4194 \begin_layout List
4195 \labelwidthstring 00000.00000.00000.000
4196
4197 \bar under
4198 Setting\InsetSpace ~
4199 variables
4200 \bar default
4201
4202 \begin_inset LatexCommand index
4203 name "variables, setting"
4204
4205 \end_inset
4206
4207
4208 \end_layout
4209
4210 \begin_layout List
4211 \labelwidthstring 00000.00000.00000.000
4212 :=
4213 \begin_inset LatexCommand index
4214 name ":="
4215
4216 \end_inset
4217
4218 Procedural equals
4219 \begin_inset LatexCommand index
4220 name "equals, procedural"
4221
4222 \end_inset
4223
4224 differs from the ordinary equals (=) in that it means the left-hand-side
4225 (LHS) variables are to be assigned the value of the right-hand-side (RHS)
4226 expression when this statement is processed.
4227 Processing happens in the last phase of compiling (instantiation) or when
4228 executing a method interactively through the ASCEND user interface.
4229 The order the system encounters these statements matters, therefore, with
4230 a later result overwriting an earlier one if both statements have the same
4231 the same LHS variable.
4232
4233 \end_layout
4234
4235 \begin_deeper
4236 \begin_layout Standard
4237 Note that variable assignments (also known as defaulting statements) written
4238 in the declarative section are executed only after an instance has been
4239 fully created.
4240 This is a frequent source of confusion and errors, therefore we recommend
4241 that you DO NOT ASSIGN VARIABLES IN THE DECLARATIVE SECTION.
4242
4243 \end_layout
4244
4245 \end_deeper
4246 \begin_layout List
4247 \labelwidthstring 00000.00000.00000.000
4248 Note\InsetSpace ~
4249 that\InsetSpace ~
4250 :=\InsetSpace ~
4251 IS\InsetSpace ~
4252 NOT\InsetSpace ~
4253 =.
4254 \end_layout
4255
4256 \begin_deeper
4257 \begin_layout Standard
4258 We use an ordinary equals (=) when defining a real valued equation to state
4259 that the LHS expression is to equal the RHS expression at the solution
4260 for the model.
4261 We use == for logical equations.
4262 \end_layout
4263
4264 \end_deeper
4265 \begin_layout List
4266 \labelwidthstring 00000.00000.00000.000
4267 \begin_inset Note Note
4268 status open
4269
4270 \begin_layout List
4271 \labelwidthstring 00000.00000.00000.000
4272
4273 \bar under
4274 Tabular\InsetSpace ~
4275 assignments
4276 \bar default
4277
4278 \begin_inset LatexCommand index
4279 name "assignments, tabular"
4280
4281 \end_inset
4282
4283 (* 4+ *) Assigning values en masse to arrays of variables that are defined
4284 associatively on sets without order presents a minor challenge.
4285 The solution proposed in ASCEND IV (but not yet implemented as weve not
4286 had time or significant user demand) is to allow a tabular data statement
4287 to be used to assign the elements of arrays of variables or constants.
4288 The DATA statement may be used to assign variables in the declarative or
4289 methods section of a model (though we discourage its use declaratively
4290 for variable initialization) or to assign constant arrays of any type,
4291 including sets, in the declarative section.
4292 Here are some examples:
4293 \end_layout
4294
4295 \begin_layout LyX-Code
4296 DATA ~(* ~4+ ~*)
4297 \end_layout
4298
4299 \begin_deeper
4300 \begin_layout LyX-Code
4301 MODEL tabular_ex;
4302 \end_layout
4303
4304 \begin_layout LyX-Code
4305 lset,rset,cset IS_A set OF integer_constant;
4306 \end_layout
4307
4308 \begin_layout LyX-Code
4309 rset :== [1..3];
4310 \end_layout
4311
4312 \begin_layout LyX-Code
4313 cset :== rset - [2];
4314 \end_layout
4315
4316 \begin_layout LyX-Code
4317 lset :== [5,7];
4318 \end_layout
4319
4320 \begin_layout LyX-Code
4321 a[rset][cset] IS_A real;
4322 \end_layout
4323
4324 \begin_layout LyX-Code
4325 b[lset][cset][rset] IS_A real_constant;
4326 \end_layout
4327
4328 \begin_layout LyX-Code
4329 (* rectangle table *)
4330 \end_layout
4331
4332 \begin_layout LyX-Code
4333 DATA FOR a:
4334 \end_layout
4335
4336 \begin_layout LyX-Code
4337 COLUMNS 1,3; (*order last subscript cset*)
4338 \end_layout
4339
4340 \begin_layout LyX-Code
4341 UNITS {kg/s}, {s}; (* columnar units *)
4342 \end_layout
4343
4344 \begin_layout LyX-Code
4345 (* give leading subscripts *)
4346 \end_layout
4347
4348 \begin_layout LyX-Code
4349 [1] 2.8, 0.3;
4350 \end_layout
4351
4352 \begin_layout LyX-Code
4353 [2] 2.7, 1.3;
4354 \end_layout
4355
4356 \begin_layout LyX-Code
4357 [3] 3.3, 0.6;
4358 \end_layout
4359
4360 \begin_layout LyX-Code
4361 END DATA;
4362 \end_layout
4363
4364 \begin_layout LyX-Code
4365 (* 2 layer rectangle table *)
4366 \end_layout
4367
4368 \begin_layout LyX-Code
4369 CONSTANT DATA FOR b:
4370 \end_layout
4371
4372 \begin_layout LyX-Code
4373 COLUMNS 1..3; (* order last subscript
4374 \end_layout
4375
4376 \begin_layout LyX-Code
4377 rset *)
4378 \end_layout
4379
4380 \begin_layout LyX-Code
4381 (* UNITS omitted, so either the user gives
4382 \end_layout
4383
4384 \begin_layout LyX-Code
4385 value in the table or values given are
4386 \end_layout
4387
4388 \begin_layout LyX-Code
4389 DIMENSIONLESS.
4390 *)
4391 \end_layout
4392
4393 \begin_layout LyX-Code
4394 (* ordering over [lset][cset] required *)
4395 \end_layout
4396
4397 \begin_layout LyX-Code
4398 [5][1] 3 {m}, 2{m}, 1{m};
4399 \end_layout
4400
4401 \begin_layout LyX-Code
4402 [5][3] 0.1, 0.2, 0.3;
4403 \end_layout
4404
4405 \begin_layout LyX-Code
4406 [7][1] -3 {m/s}, -2{m/s}, -1{m/s};
4407 \end_layout
4408
4409 \begin_layout LyX-Code
4410 [7][3] 4.1 {1/s}, 4.2 {1/s}, 4.3 {1/s};
4411 \end_layout
4412
4413 \begin_layout LyX-Code
4414 END DATA;
4415 \end_layout
4416
4417 \begin_layout LyX-Code
4418 END tabular_ex;
4419 \end_layout
4420
4421 \begin_layout Standard
4422 For sparse arrays of variables or constants, the COLUMNS and (possibly)
4423 UNITS keywords are omitted and the array subscripts are simply enumerated
4424 along with the values to be assigned.
4425 \end_layout
4426
4427 \end_inset
4428
4429
4430 \end_layout
4431
4432 \begin_deeper
4433 \begin_layout Standard
4434
4435 \end_layout
4436
4437 \begin_layout Section
4438 Relations
4439 \begin_inset LatexCommand index
4440 name "relations"
4441
4442 \end_inset
4443
4444
4445 \end_layout
4446
4447 \end_deeper
4448 \begin_layout List
4449 \labelwidthstring 00000.00000.00000.000
4450
4451 \bar under
4452 Mathematical\InsetSpace ~
4453 expression
4454 \begin_inset LatexCommand index
4455 name "mathematical expression"
4456
4457 \end_inset
4458
4459
4460 \begin_inset LatexCommand index
4461 name "expression, math"
4462
4463 \end_inset
4464
4465 :
4466 \end_layout
4467
4468 \begin_deeper
4469 \begin_layout Standard
4470 The syntax for a mathematical expression is any legal combination of variable
4471 names and arithmetic operators in the normal notation.
4472 An expression may contain any number of matched rounded parentheses, (),
4473 to clarify meaning.
4474 The following is a legal arithmetic expression:
4475 \end_layout
4476
4477 \begin_layout LyX-Code
4478 y^2+(sin(x)-tan(z))*q
4479 \end_layout
4480
4481 \begin_layout Standard
4482 Each additive term in a mathematical expression (terms are separated by
4483 + or - operators) must have the same dimensionality.
4484 \end_layout
4485
4486 \begin_layout Standard
4487 An expression may contain an index variable as a part of the calculation
4488 if that index variable is over a set whose elements are of type integer.
4489 (See the
4490 \family sans
4491 FOR/CREATE
4492 \family default
4493 and
4494 \family sans
4495 FOR/DO
4496 \family default
4497 statements below.) An example is:
4498 \end_layout
4499
4500 \begin_layout LyX-Code
4501 term[i] = a[i]*x^(i-1);
4502 \end_layout
4503
4504 \end_deeper
4505 \begin_layout List
4506 \labelwidthstring 00000.00000.00000.000
4507
4508 \bar under
4509 Numerical\InsetSpace ~
4510 relations
4511 \bar default
4512
4513 \begin_inset LatexCommand index
4514 name "relations, numerical"
4515
4516 \end_inset
4517
4518
4519 \begin_inset LatexCommand index
4520 name "numerical relations"
4521
4522 \end_inset
4523
4524
4525 \end_layout
4526
4527 \begin_deeper
4528 \begin_layout Standard
4529 The syntax for a numeric relation is either
4530 \end_layout
4531
4532 \begin_layout LyX-Code
4533
4534 \emph on
4535 optional_label
4536 \emph default
4537 :
4538 \emph on
4539 LHS relational_operator RHS
4540 \emph default
4541 ;
4542 \end_layout
4543
4544 \begin_layout Standard
4545 or
4546 \end_layout
4547
4548 \begin_layout LyX-Code
4549
4550 \emph on
4551 optional_label
4552 \emph default
4553 :
4554 \emph on
4555 objective_type LHS
4556 \emph default
4557 ;
4558 \end_layout
4559
4560 \begin_layout Standard
4561 Objective_type is either
4562 \family sans
4563 MAXIMIZE
4564 \family default
4565 or
4566 \family sans
4567 MINIMIZE
4568 \family default
4569 .
4570 RHS and LHS must be one or more variables, constants, and operators in
4571 a normal algebraic expression.
4572 The operators allowed are defined below and in Section
4573 \begin_inset LatexCommand vref
4574 reference "sub:x.6.3Single-operand-real"
4575
4576 \end_inset
4577
4578 .
4579 Variable integers, booleans, and symbols are not allowed as operands in
4580 numerical relations, nor are boolean constants.
4581 Integer indices declared in
4582 \family sans
4583 FOR/CREATE
4584 \family default
4585 loops are allowed in relations, and they are treated as integer constants.
4586 \end_layout
4587
4588 \end_deeper
4589 \begin_layout List
4590 \labelwidthstring 00000.00000.00000.000
4591
4592 \bar under
4593 Relational\InsetSpace ~
4594 operators
4595 \begin_inset LatexCommand index
4596 name "operators, relational"
4597
4598 \end_inset
4599
4600
4601 \begin_inset LatexCommand index
4602 name "relational operators"
4603
4604 \end_inset
4605
4606 :
4607 \end_layout
4608
4609 \begin_layout List
4610 \labelwidthstring 00000.00000.00000.000
4611 =
4612 \begin_inset LatexCommand index
4613 name "="
4614
4615 \end_inset
4616
4617 ,\InsetSpace ~
4618 >=
4619 \begin_inset LatexCommand index
4620 name " >="
4621
4622 \end_inset
4623
4624 ,\InsetSpace ~
4625 <=
4626 \begin_inset LatexCommand index
4627 name "<="
4628
4629 \end_inset
4630
4631 ,\InsetSpace ~
4632 <
4633 \begin_inset LatexCommand index
4634 name "<"
4635
4636 \end_inset
4637
4638 ,\InsetSpace ~
4639 >
4640 \begin_inset LatexCommand index
4641 name ">"
4642
4643 \end_inset
4644
4645 ,\InsetSpace ~
4646 <>
4647 \begin_inset LatexCommand index
4648 name "<>"
4649
4650 \end_inset
4651
4652 These are the numerical relational operators for declarative use.
4653 \end_layout
4654
4655 \begin_deeper
4656 \begin_layout LyX-Code
4657 Ftot*y['methane'] = m['methane'];
4658 \end_layout
4659
4660 \begin_layout LyX-Code
4661 y['ethanol'] >= 0;
4662 \end_layout
4663
4664 \begin_layout Standard
4665 Equations must be dimensionally correct.
4666 \end_layout
4667
4668 \end_deeper
4669 \begin_layout List
4670 \labelwidthstring 00000.00000.00000.000
4671
4672 \family sans
4673 MAXIMIZE
4674 \family default
4675
4676 \begin_inset LatexCommand index
4677 name "MAXIMIZE"
4678
4679 \end_inset
4680
4681 ,\InsetSpace ~
4682
4683 \family sans
4684 MINIMIZE
4685 \family default
4686
4687 \begin_inset LatexCommand index
4688 name "MINIMIZE"
4689
4690 \end_inset
4691
4692
4693 \end_layout
4694
4695 \begin_deeper
4696 \begin_layout Standard
4697 Objective function indicators.
4698
4699 \end_layout
4700
4701 \end_deeper
4702 \begin_layout List
4703 \labelwidthstring 00000.00000.00000.000
4704
4705 \bar under
4706 Binary\InsetSpace ~
4707 Operators
4708 \begin_inset LatexCommand index
4709 name "operators, binary"
4710
4711 \end_inset
4712
4713
4714 \begin_inset LatexCommand index
4715 name "binary operators"
4716
4717 \end_inset
4718
4719 :
4720 \bar default
4721 +, -, *, /, ^.
4722 We follow the usual algebraic order of operations for binary operators.
4723 \end_layout
4724
4725 \begin_layout List
4726 \labelwidthstring 00000.00000.00000.000
4727 +
4728 \begin_inset LatexCommand index
4729 name "+, binary math"
4730
4731 \end_inset
4732
4733 Plus.
4734 Numerical addition or set union.
4735 \end_layout
4736
4737 \begin_layout List
4738 \labelwidthstring 00000.00000.00000.000
4739 -
4740 \begin_inset LatexCommand index
4741 name "-, binary math"
4742
4743 \end_inset
4744
4745 Minus.
4746 Numerical subtraction or set difference.
4747 \end_layout
4748
4749 \begin_layout List
4750 \labelwidthstring 00000.00000.00000.000
4751 *
4752 \begin_inset LatexCommand index
4753 name "*, binary math"
4754
4755 \end_inset
4756
4757 Times.
4758 Numerical multiplication or set intersection.
4759 \end_layout
4760
4761 \begin_layout List
4762 \labelwidthstring 00000.00000.00000.000
4763 /
4764 \begin_inset LatexCommand index
4765 name "/"
4766
4767 \end_inset
4768
4769 Divide.
4770 Numeric division.
4771 In most cases it implies real division and not integer division.
4772 \end_layout
4773
4774 \begin_layout List
4775 \labelwidthstring 00000.00000.00000.000
4776 ^ Power
4777 \begin_inset LatexCommand index
4778 name "power"
4779
4780 \end_inset
4781
4782 .
4783 Numeric exponentiation.
4784 If the value of y in x^y is not integer, then x must be greater than 0.0
4785 and dimensionless.
4786 \end_layout
4787
4788 \begin_layout List
4789 \labelwidthstring 00000.00000.00000.000
4790
4791 \bar under
4792 Unary\InsetSpace ~
4793 Operators
4794 \begin_inset LatexCommand index
4795 name "operators, unary"
4796
4797 \end_inset
4798
4799
4800 \begin_inset LatexCommand index
4801 name "unary operators"
4802
4803 \end_inset
4804
4805 :
4806 \bar default
4807 -
4808 \begin_inset LatexCommand index
4809 name "-, unary"
4810
4811 \end_inset
4812
4813 , ordered_function()
4814 \end_layout
4815
4816 \begin_layout List
4817 \labelwidthstring 00000.00000.00000.000
4818 - Unary minus.
4819 Numeric negation.
4820 There is no unary +
4821 \begin_inset LatexCommand index
4822 name "+, math unary"
4823
4824 \end_inset
4825
4826 operator.
4827 \end_layout
4828
4829 \begin_layout List
4830 \labelwidthstring 00000.00000.00000.000
4831
4832 \family typewriter
4833 ordered_function
4834 \begin_inset LatexCommand index
4835 name "ordered\\_function"
4836
4837 \end_inset
4838
4839 ()
4840 \family default
4841 unary real valued functions.
4842 The unary real functions we support are given in section Section
4843 \begin_inset LatexCommand vref
4844 reference "sub:x.6.3Single-operand-real"
4845
4846 \end_inset
4847
4848 .
4849 \end_layout
4850
4851 \begin_layout List
4852 \labelwidthstring 00000.00000.00000.000
4853 Real\InsetSpace ~
4854 functions\InsetSpace ~
4855 of\InsetSpace ~
4856 sets\InsetSpace ~
4857 of\InsetSpace ~
4858 real\InsetSpace ~
4859 terms:
4860 \end_layout
4861
4862 \begin_layout List
4863 \labelwidthstring 00000.00000.00000.000
4864
4865 \family sans
4866 SUM
4867 \family default
4868
4869 \begin_inset LatexCommand index
4870 name "SUM"
4871
4872 \end_inset
4873
4874
4875 \family typewriter
4876 [term\InsetSpace ~
4877 set]
4878 \family default
4879 Add all expressions in the functions list.
4880 \end_layout
4881
4882 \begin_deeper
4883 \begin_layout Standard
4884 For the
4885 \family sans
4886 SUM
4887 \family default
4888 , the base type real items can be arbitrary arithmetic expressions.
4889 The resulting items must all be dimensionally compatible.
4890 \end_layout
4891
4892 \begin_layout Standard
4893 An examples of the use is:
4894 \end_layout
4895
4896 \begin_layout LyX-Code
4897 SUM[y[components]] = 1;
4898 \end_layout
4899
4900 \begin_layout Standard
4901 or, equivalently, one could write:
4902 \end_layout
4903
4904 \begin_layout LyX-Code
4905 SUM[y[i] | i IN components] = 1;
4906 \end_layout
4907
4908 \end_deeper
4909 \begin_layout List
4910 \labelwidthstring 00000.00000.00000.000
4911
4912 \bar under
4913 Empty\InsetSpace ~
4914
4915 \family sans
4916 SUM
4917 \family default
4918 \InsetSpace ~
4919 yields\InsetSpace ~
4920 wildcard\InsetSpace ~
4921
4922 \family typewriter
4923 0
4924 \family default
4925 .
4926 \end_layout
4927
4928 \begin_deeper
4929 \begin_layout Standard
4930 When a
4931 \family sans
4932 SUM
4933 \family default
4934 is compiled over a list which is empty it generates a wildcard-dimensioned
4935
4936 \family typewriter
4937 0
4938 \family default
4939 .
4940 This will sometimes cause our dimension checking routines to fail.
4941 The best way to prevent this is to make sure the SUM never actually encounters
4942 an empty list.
4943 For example:
4944 \end_layout
4945
4946 \begin_layout LyX-Code
4947 SUM[Q[possibly_empty_set], 0{watt}];
4948 \end_layout
4949
4950 \begin_layout Standard
4951 In the above, the variables
4952 \family typewriter
4953 Q[i]
4954 \family default
4955 (if they exist) have the dimensionality associated with an energy rate.
4956 When the set is empty, the
4957 \family typewriter
4958 0
4959 \family default
4960 is the only term in the
4961 \family sans
4962 SUM
4963 \family default
4964 and establishes the dimensionality of the result.
4965 When the set is
4966 \emph on
4967 not
4968 \emph default
4969 empty the compiler will simplify away the trailing
4970 \family typewriter
4971 0
4972 \family default
4973 in the sum.
4974 \end_layout
4975
4976 \end_deeper
4977 \begin_layout List
4978 \labelwidthstring 00000.00000.00000.000
4979 PROD
4980 \begin_inset LatexCommand index
4981 name "PROD"
4982
4983 \end_inset
4984
4985 [term\InsetSpace ~
4986 set] Multiply all the expressions in the products list.
4987 The product of an empty list is a dimensionless value, 1.0.
4988 \end_layout
4989
4990 \begin_layout List
4991 \labelwidthstring 00000.00000.00000.000
4992
4993 \bar under
4994 Possible\InsetSpace ~
4995 future\InsetSpace ~
4996 functions:
4997 \end_layout
4998
4999 \begin_deeper
5000 \begin_layout Standard
5001 (Not implemented - only under confused consideration at this time.) The following
5002 functions only work in methods as they are not smooth function and would
5003 destroy a Newton-based solution algorithm if used in defining a model equation:
5004 \begin_inset Note Note
5005 status open
5006
5007 \begin_layout Standard
5008 Clarification required
5009 \end_layout
5010
5011 \end_inset
5012
5013
5014 \end_layout
5015
5016 \end_deeper
5017 \begin_layout List
5018 \labelwidthstring 00000.00000.00000.000
5019 MAX
5020 \begin_inset LatexCommand index
5021 name "MAX"
5022
5023 \end_inset
5024
5025 [term\InsetSpace ~
5026 set] (* 4+ *) maximum value on list of arguments
5027 \end_layout
5028
5029 \begin_layout List
5030 \labelwidthstring 00000.00000.00000.000
5031 MIN
5032 \begin_inset LatexCommand index
5033 name "MIN"
5034
5035 \end_inset
5036
5037 [term\InsetSpace ~
5038 set] (* 4+ *) minimum value on list of arguments
5039 \end_layout
5040
5041 \begin_deeper
5042 \begin_layout Standard
5043 \begin_inset Note Note
5044 status open
5045
5046 \begin_layout Section
5047 Derivatives
5048 \begin_inset LatexCommand index
5049 name "derivatives"
5050
5051 \end_inset
5052
5053 in relations
5054 \end_layout
5055
5056 \begin_layout Standard
5057 Simply put, we would like to have general partial and full derivatives usable
5058 in writing equations, as there are many mathematically interesting things
5059 that can be said about both.
5060 We have not implemented such things yet for lack of time and because with
5061 several implementations (see gPROMS and OMOLA, among others) already out
5062 there we cant see too many research points to be gained by more derivative
5063 work.
5064 \end_layout
5065
5066 \end_inset
5067
5068
5069 \end_layout
5070
5071 \begin_layout Section
5072 External relations
5073 \begin_inset LatexCommand index
5074 name "relations, external"
5075
5076 \end_inset
5077
5078
5079 \begin_inset LatexCommand index
5080 name "external relations"
5081
5082 \end_inset
5083
5084
5085 \end_layout
5086
5087 \begin_layout Standard
5088 We cannot document these at the present time.
5089 Some details are available in Kirk Abbott's thesis
5090 \begin_inset LatexCommand cite
5091 key "Abbott1996a"
5092
5093 \end_inset
5094
5095 , or check the wiki at
5096 \family sans
5097 http://ascendwiki.cheme.cmu.edu/
5098 \end_layout
5099
5100 \begin_layout Section
5101 Conditional modelling
5102 \begin_inset LatexCommand index
5103 name "relations, conditional"
5104
5105 \end_inset
5106
5107
5108 \begin_inset LatexCommand index
5109 name "conditional relations"
5110
5111 \end_inset
5112
5113
5114 \end_layout
5115
5116 \begin_layout Subsection
5117 Conditional relations
5118 \end_layout
5119
5120 \begin_layout Standard
5121 The syntax is
5122 \end_layout
5123
5124 \begin_layout LyX-Code
5125 CONDITIONAL
5126 \end_layout
5127
5128 \begin_layout LyX-Code
5129
5130 \emph on
5131 list_of_relation_statements
5132 \end_layout
5133
5134 \begin_layout LyX-Code
5135 END CONDITIONAL;
5136 \end_layout
5137
5138 \begin_layout Standard
5139 A
5140 \family sans
5141 CONDITIONAL
5142 \family default
5143 statement can appear anywhere in the declarative portion of the model and
5144 it contains only relations to be used as boundaries.
5145 That is, these real arithmetic equations are used in expressing logical
5146 condition equations via the
5147 \family sans
5148 SATISFIED
5149 \family default
5150 operator.
5151 \end_layout
5152
5153 \begin_layout Subsection
5154 Logical relations
5155 \end_layout
5156
5157 \end_deeper
5158 \begin_layout List
5159 \labelwidthstring 00000.00000.00000.000
5160
5161 \bar under
5162 Logical\InsetSpace ~
5163 expression
5164 \bar default
5165
5166 \begin_inset LatexCommand index
5167 name "expression, logical"
5168
5169 \end_inset
5170
5171
5172 \begin_inset LatexCommand index
5173 name "logical expression"
5174
5175 \end_inset
5176
5177 An expression whose value is
5178 \family sans
5179 TRUE
5180 \family default
5181 or
5182 \family sans
5183 FALSE
5184 \family default
5185 is a logical expression.
5186 Such expressions may contain boolean variables.
5187 If A,B, and laminar are boolean, then the following is a logical expression:
5188 \end_layout
5189
5190 \begin_deeper
5191 \begin_layout LyX-Code
5192 A + (B * laminar)
5193 \end_layout
5194
5195 \begin_layout Standard
5196 as is (and probably more clearly)
5197 \end_layout
5198
5199 \begin_layout LyX-Code
5200 A OR (B AND laminar)
5201 \end_layout
5202
5203 \begin_layout Standard
5204 The plus operator acts like an OR among the terms while the times operator
5205 acts like an
5206 \family sans
5207 AND
5208 \family default
5209 .
5210 Think of
5211 \family sans
5212 TRUE
5213 \family default
5214 being equal to 1 and
5215 \family sans
5216 FALSE
5217 \family default
5218 being equal to 0 with the 1+1=0+1=1+0=1, 0+0=0, 1*1=1 and 0*1=1*0=0*0=0.
5219 If A =
5220 \family sans
5221 FALSE
5222 \family default
5223 , B=
5224 \family sans
5225 TRUE
5226 \family default
5227 and laminar is
5228 \family sans
5229 TRUE
5230 \family default
5231 , this expression has the value
5232 \end_layout
5233
5234 \begin_layout LyX-Code
5235 FALSE OR (TRUE AND TRUE) -->TRUE
5236 \end_layout
5237
5238 \begin_layout Standard
5239 or in terms of ones and zeros
5240 \end_layout
5241
5242 \begin_layout LyX-Code
5243 0 + (1 * 1) --> 1.
5244 \end_layout
5245
5246 \begin_layout Standard
5247 Logical relations are then made by putting together logical expressions
5248 with the boolean relational operators
5249 \family typewriter
5250 ==
5251 \family default
5252 and
5253 \family typewriter
5254 !=
5255 \family default
5256 .
5257 Since we have no logical solving engine we have not pushed the implementation
5258 of logical relations very hard yet.
5259 \end_layout
5260
5261 \begin_layout Section
5262
5263 \family sans
5264 NOTES
5265 \family default
5266
5267 \begin_inset LatexCommand index
5268 name "NOTES"
5269
5270 \end_inset
5271
5272
5273 \end_layout
5274
5275 \begin_layout Standard
5276 Within a
5277 \family sans
5278 MODEL
5279 \family default
5280 (or
5281 \family sans
5282 METHOD
5283 \family default
5284 ) definition annotations (hereafter called notes) may be made on a part
5285 declared in the
5286 \family sans
5287 MODEL
5288 \family default
5289 , or on the
5290 \family sans
5291 MODEL
5292 \family default
5293 (or
5294 \family sans
5295 METHOD
5296 \family default
5297 ) itself.
5298 Short notes may be made when defining or refining an object by enclosing
5299 the note in double quotes (
5300 \family typewriter
5301 "
5302 \family default
5303 ).
5304 Longer notes may be made in a block statement.
5305 \end_layout
5306
5307 \begin_layout Standard
5308 Each note is entered in a database with the name of the file, name of
5309 \family sans
5310 MODEL
5311 \family default
5312 , name of
5313 \family sans
5314 METHOD
5315 \family default
5316 if applicable, and the language (a kind of keyword) in which the note is
5317 written.
5318 Users, user interfaces, and other programs may query this database for
5319 information on models and simulations.
5320 The block notes may include code fragments in other languages that you
5321 wish to embed in your
5322 \family sans
5323 MODEL
5324 \family default
5325 or any other kind of text.
5326 \end_layout
5327
5328 \begin_layout Standard
5329 Short notes should be included as you write any model to clarify the roles
5330 of parts and variables.
5331 All short notes have the language 'inline.' Here are some examples of short
5332 notes:
5333 \end_layout
5334
5335 \begin_layout LyX-Code
5336 L[1..10] "L[i] is the length of the ith rod"
5337 \end_layout
5338
5339 \begin_layout LyX-Code
5340 IS_A distance;
5341 \end_layout
5342
5343 \begin_layout LyX-Code
5344 thetaM "angle between horizon and moon",
5345 \end_layout
5346
5347 \begin_layout LyX-Code
5348 thetaJ "angle between horizon and jupiter"
5349 \end_layout
5350
5351 \begin_layout LyX-Code
5352 IS_A angle;
5353 \end_layout
5354
5355 \begin_layout LyX-Code
5356 car.tires "using car in Minnesota, you betcha"
5357 \end_layout
5358
5359 \begin_layout LyX-Code
5360 IS_REFINED_TO snow_tire;
5361 \end_layout
5362
5363 \begin_layout Standard
5364 In the second
5365 \family sans
5366 IS_A
5367 \family default
5368 statement concerning two angles, we see that a short note in double quotes
5369 goes with the name immediately to its left.
5370 We also see that the note comes before the comma if the name is part of
5371 a list of names.
5372 In the third statement, we see that not only simple names but also qualified
5373 names may be annotated.
5374
5375 \end_layout
5376
5377 \begin_layout Standard
5378 Longer notes are made in block statements of the form below.
5379 These blocks can appear in a
5380 \family sans
5381 METHOD
5382 \family default
5383 or
5384 \family sans
5385 MODEL
5386 \family default
5387 .
5388 These blocks can also be written separately before or after a model as
5389 we shall see.
5390 \end_layout
5391
5392 \begin_layout LyX-Code
5393 NOTES
5394 \end_layout
5395
5396 \begin_layout LyX-Code
5397 'language or keyword' list.of, names {
5398 \end_layout
5399
5400 \begin_layout LyX-Code
5401 free-form block of text to store in the
5402 \end_layout
5403
5404 \begin_layout LyX-Code
5405 database exactly as written.
5406 \end_layout
5407
5408 \begin_layout LyX-Code
5409 }
5410 \end_layout
5411
5412 \begin_layout LyX-Code
5413 some.other.name {
5414 \end_layout
5415
5416 \begin_layout LyX-Code
5417 this note has the same language or keyword as
5418 \end_layout
5419
5420 \begin_layout LyX-Code
5421 the first since we didn't define a new keyword
5422 \end_layout
5423
5424 \begin_layout LyX-Code
5425 in single quotes before the name list.
5426 \end_layout
5427
5428 \begin_layout LyX-Code
5429 }
5430 \end_layout
5431
5432 \begin_layout LyX-Code
5433 'another language' some.other.name {
5434 \end_layout
5435
5436 \begin_layout LyX-Code
5437 en espanol
5438 \end_layout
5439
5440 \begin_layout LyX-Code
5441 }
5442 \end_layout
5443
5444 \begin_layout LyX-Code
5445 'fortran' SELF {
5446 \end_layout
5447
5448 \begin_layout LyX-Code
5449 This model should be solved with subroutine
5450 \end_layout
5451
5452 \begin_layout LyX-Code
5453 LSODE.
5454 \end_layout
5455
5456 \begin_layout LyX-Code
5457 This note demonstrates that "SELF" can be used
5458 \end_layout
5459
5460 \begin_layout LyX-Code
5461 to annotate the entire model instead of a
5462 \end_layout
5463
5464 \begin_layout LyX-Code
5465 named part.
5466 \end_layout
5467
5468 \begin_layout LyX-Code
5469 }
5470 \end_layout
5471
5472 \begin_layout LyX-Code
5473 END NOTES;
5474 \end_layout
5475
5476 \begin_layout Standard
5477 Notes made outside the scope of a model definition look like one of the
5478 following:
5479 \end_layout
5480
5481 \begin_layout LyX-Code
5482 ADD NOTES IN name_of_model;
5483 \end_layout
5484
5485 \begin_layout LyX-Code
5486 'language or keyword' list.of, names {
5487 \end_layout
5488
5489 \begin_layout LyX-Code
5490 more text
5491 \end_layout
5492
5493 \begin_layout LyX-Code
5494 } (* more than one note may be made in this
5495 \end_layout
5496
5497 \begin_layout LyX-Code
5498 block if desired.
5499 *)
5500 \end_layout
5501
5502 \begin_layout LyX-Code
5503 END NOTES;
5504 \end_layout
5505
5506 \begin_layout LyX-Code
5507 ADD NOTES IN name_of_model METHOD name_of_method;
5508 \end_layout
5509
5510 \begin_layout LyX-Code
5511 'language or keyword' SELF {
5512 \end_layout
5513
5514 \begin_layout LyX-Code
5515 This method proves Fermat's last theorem and
5516 \end_layout
5517
5518 \begin_layout LyX-Code
5519 makes toast.
5520 \end_layout
5521
5522 \begin_layout LyX-Code
5523 }
5524 \end_layout
5525
5526 \begin_layout LyX-Code
5527 'humor' SELF {
5528 \end_layout
5529
5530 \begin_layout LyX-Code
5531 ASCEND is not expected to make either proving
5532 \end_layout
5533
5534 \begin_layout LyX-Code
5535 FLT or toasting possible.
5536 \end_layout
5537
5538 \begin_layout LyX-Code
5539 }
5540 \end_layout
5541
5542 \begin_layout LyX-Code
5543 END NOTES;
5544 \end_layout
5545
5546 \begin_layout Standard
5547 We can add notes to the database before or after defining the annotated
5548 model.
5549 This is handy for several reasons including:
5550 \end_layout
5551
5552 \begin_layout Itemize
5553 Lengthy notes mixed with model and method code can make that code very hard
5554 to read.
5555
5556 \end_layout
5557
5558 \begin_layout Itemize
5559 Separate notes describing a family of models can be loaded and browsed before
5560 loading that library family.
5561 \end_layout
5562
5563 \begin_layout Itemize
5564 Users other than the author of a model can annotate that model without fear
5565 of introducing typographical errors into the model.
5566 \end_layout
5567
5568 \begin_layout Standard
5569 These advantages come with a disadvantage that all documentation has.
5570 If you change the model, you ought to change the documentation at the same
5571 time.
5572 To make finding these documentation locations in need of change easier,
5573 the name of the file containing each note is included in the loaded database.
5574 \end_layout
5575
5576 \begin_layout Standard
5577 Experience has shown that even documentation embedded directly in models
5578 or in other computer programs gets out-dated if the person changing the
5579 program is in a hurry and is not required to document properly as part
5580 of the task at hand.
5581 Neither ASCEND nor any other software system can eliminate the garbage
5582 code and documentation that results from undisciplined modeling.
5583 \end_layout
5584
5585 \begin_layout Chapter
5586 Declarative statements
5587 \begin_inset LatexCommand index
5588 name "statements, declarative"
5589
5590 \end_inset
5591
5592
5593 \begin_inset LatexCommand index
5594 name "declarative statements"
5595
5596 \end_inset
5597
5598
5599 \begin_inset LatexCommand label
5600 name "sec:x.3Declarative-statements"
5601
5602 \end_inset
5603
5604
5605 \end_layout
5606
5607 \begin_layout Standard
5608 We have already seen several examples that included declarative statements.
5609 Here we will be more systematic in defining things.
5610 The statements we describe are legal within the declarative portion of
5611 an
5612 \family sans
5613 ATOM
5614 \family default
5615 or
5616 \family sans
5617 MODEL
5618 \family default
5619 definition.
5620 The declarative portion stops at the keyword
5621 \family sans
5622 METHODS
5623 \family default
5624 if it is present in the definition or at the end of the definition.
5625 \end_layout
5626
5627 \end_deeper
5628 \begin_layout List
5629 \labelwidthstring 00000.00000.00000.000
5630
5631 \bar under
5632 Statements
5633 \bar default
5634
5635 \begin_inset LatexCommand index
5636 name "statements"
5637
5638 \end_inset
5639
5640 Statements in ASCEND terminate with a semicolon (
5641 \family typewriter
5642 ;
5643 \family default
5644 ).
5645 Statements may extend over any number of lines.
5646 They may have blank lines in the middle of them.
5647 There may be several statements on a single line.
5648
5649 \end_layout
5650
5651 \begin_layout List
5652 \labelwidthstring 00000.00000.00000.000
5653
5654 \bar under
5655 Compound\InsetSpace ~
5656 statements
5657 \bar default
5658
5659 \begin_inset LatexCommand index
5660 name "statements, compound"
5661
5662 \end_inset
5663
5664
5665 \begin_inset LatexCommand index
5666 name "compound statements"
5667
5668 \end_inset
5669
5670 Some statements in ASCEND can contain other statements as a part of them.
5671 The declarative compound statements are the
5672 \family sans
5673 ALIASES
5674 \family default
5675 /
5676 \family sans
5677 IS_A
5678 \family default
5679 ,
5680 \family sans
5681 CONDITIONAL
5682 \family default
5683 ,
5684 \family sans
5685 FOR/CREATE
5686 \family default
5687 ,
5688 \family sans
5689 SELECT/CASE
5690 \family default
5691 , and
5692 \family sans
5693 WHEN/CASE
5694 \family default
5695 statements.
5696 The procedural compound statements allowed only in methods are the
5697 \family sans
5698 FOR/DO
5699 \family default
5700 ,
5701 \family sans
5702 FOR/CHECK
5703 \family default
5704 ,
5705 \family sans
5706 SWITCH
5707 \family default
5708 and the
5709 \family sans
5710 IF
5711 \family default
5712 statements.
5713 Compound statements end with "
5714 \family sans
5715 END
5716 \family default
5717
5718 \family typewriter
5719 word
5720 \family default
5721 ;", where word matches the beginning of the syntax block, e.g.
5722
5723 \family sans
5724 END FOR
5725 \family default
5726 .and they can be nested, with some exceptions which are noted later.
5727
5728 \end_layout
5729
5730 \begin_layout List
5731 \labelwidthstring 00000.00000.00000.000
5732
5733 \family sans
5734 \bar under
5735 CASE
5736 \family default
5737 \InsetSpace ~
5738 statements
5739 \bar default
5740
5741 \begin_inset LatexCommand index
5742 name "statements, CASE"
5743
5744 \end_inset
5745
5746
5747 \begin_inset LatexCommand index
5748 name "CASE statements"
5749
5750 \end_inset
5751
5752
5753 \family sans
5754 WHEN/CASE
5755 \family default
5756 ,
5757 \family sans
5758 CONDITIONAL
5759 \family default
5760 , and
5761 \family sans
5762 SELECT/CASE
5763 \family default
5764 handle modeling alternatives within a single definition.
5765 The easy way to remember the difference is that the first picks which equations
5766 to solve
5767 \family sans
5768 WHEN
5769 \family default
5770 discrete variables have certain values, while the second
5771 \family sans
5772 SELECT
5773 \family default
5774 s which statements to compile based on discrete constants.
5775 SWITCH statements handle flow of control in methods, in a slightly more
5776 generalized form than the C language switch statement.
5777 \end_layout
5778
5779 \begin_layout List
5780 \labelwidthstring 00000.00000.00000.000
5781 Type\InsetSpace ~
5782 declarations
5783 \begin_inset LatexCommand index
5784 name "declarations, type"
5785
5786 \end_inset
5787
5788
5789 \begin_inset LatexCommand index
5790 name "yype declarations"
5791
5792 \end_inset
5793
5794 are not compound statements.
5795 \end_layout
5796
5797 \begin_deeper
5798 \begin_layout Standard
5799
5800 \family sans
5801 MODEL
5802 \family default
5803 and
5804 \family sans
5805 ATOM
5806 \family default
5807 type definitions and
5808 \family sans
5809 METHOD
5810 \family default
5811 definitions are not really compound statements because they require a name
5812 following their
5813 \family sans
5814 END
5815 \family default
5816 word that matches the name given at the beginning of the definition.
5817 These definitions cannot be nested.
5818 \end_layout
5819
5820 \end_deeper
5821 \begin_layout List
5822 \labelwidthstring 00000.00000.00000.000
5823 ASCEND\InsetSpace ~
5824 operator\InsetSpace ~
5825 synopses:
5826 \end_layout
5827
5828 \begin_deeper
5829 \begin_layout Standard
5830 Well start with an extremely brief synopsis of what each does and then give
5831 detailed descriptions.
5832 It is helpful to remember that an instance may have many names, even in
5833 the same scope, but each name may only be defined once.
5834 \end_layout
5835
5836 \end_deeper
5837 \begin_layout List
5838 \labelwidthstring 00000.00000.00000.000
5839
5840 \family sans
5841 IS_A
5842 \family default
5843
5844 \begin_inset LatexCommand index
5845 name "IS\\_A"
5846
5847 \end_inset
5848
5849 Constructor.
5850 Calls for one or more named instances to be compiled using the type specified.
5851 If the type is one that requires parameters, the parameters must be supplied
5852 in
5853 \family typewriter
5854 ()
5855 \family default
5856 following the type name.
5857 \end_layout
5858
5859 \begin_layout List
5860 \labelwidthstring 00000.00000.00000.000
5861
5862 \family sans
5863 IS_REFINED_TO
5864 \family default
5865
5866 \begin_inset LatexCommand index
5867 name "IS\\_REFINED\\_TO"
5868
5869 \end_inset
5870
5871 Reconstructor.
5872 Causes the already compiled instance(s) named to have their type changed
5873 to a more refined type.
5874 This causes an incremental recompilation of the instance(s).
5875
5876 \family sans
5877 IS_REFINED_TO
5878 \family default
5879 is not a redefinition of the named instances because refinement can only
5880 add compatible information.
5881 The instances retain all the structure that originally defined them.
5882 If the type being refined to requires arguments, these must be supplied,
5883 even if the same arguments were required in the
5884 \family sans
5885 IS_A
5886 \family default
5887 of the originally less refined declaration of the instance.
5888
5889 \end_layout
5890
5891 \begin_layout List
5892 \labelwidthstring 00000.00000.00000.000
5893
5894 \family sans
5895 ALIASES
5896 \family default
5897
5898 \begin_inset LatexCommand index
5899 name "ALIASES"
5900
5901 \end_inset
5902
5903 Part alternate naming statement.
5904 Establishes another name for an instance at the same scope or in a child
5905 instance.
5906 \begin_inset Foot
5907 status collapsed
5908
5909 \begin_layout Standard
5910 The equivalent of an
5911 \family sans
5912 ALIASES
5913 \family default
5914 in ASCEND III was to create another part with the desired name and merge
5915 it immediately via
5916 \family sans
5917 ARE_THE_SAME
5918 \family default
5919 with the part being renamed, a rather expensive and unintuitive process.
5920 \end_layout
5921
5922 \end_inset
5923
5924
5925 \end_layout
5926
5927 \begin_layout List
5928 \labelwidthstring 00000.00000.00000.000
5929
5930 \family sans
5931 ALIASES/IS_A
5932 \family default
5933
5934 \begin_inset LatexCommand index
5935 name "ALIASES/IS\\_A"
5936
5937 \end_inset
5938
5939
5940 \end_layout
5941
5942 \begin_deeper
5943 \begin_layout Standard
5944 Creates an array of alternate names for a list of existing instances with
5945 some common base type and creates the set over which the elements of the
5946 array are indexed.
5947 Useful for making collections of related objects in ways the original author
5948 of the model didnt anticipate.
5949 Also useful for assembling array arguments to parameterized type definitions.
5950 \end_layout
5951
5952 \end_deeper
5953 \begin_layout List
5954 \labelwidthstring 00000.00000.00000.000
5955
5956 \family sans
5957 WILL_BE
5958 \family default
5959
5960 \begin_inset LatexCommand index
5961 name "WILL\\_BE"
5962
5963 \end_inset
5964
5965 Forward declaration statement.
5966 Promises that a part with the given type will be constructed by an as yet
5967 unknown IS_A statement above the current scope.
5968 At present
5969 \family sans
5970 WILL_BE
5971 \family default
5972 is legal only in defining parameters.
5973 Were it legal in the body of a model, compiling models would be very expensive.
5974 \end_layout
5975
5976 \begin_layout List
5977 \labelwidthstring 00000.00000.00000.000
5978
5979 \family sans
5980 ARE_THE_SAME
5981 \family default
5982
5983 \begin_inset LatexCommand index
5984 name "ARE\\_THE\\_SAME"
5985
5986 \end_inset
5987
5988 Merge.
5989 Calls for two or more instances already compiled to be merged recursively.
5990 This essentially means combining all the values in the instances into the
5991 most refined of the instances and then destroying all the extra, possibly
5992 less refined, instances.
5993 The remaining instance has its original name and also all the names of
5994 the instances destroyed during the merge.
5995 \end_layout
5996
5997 \begin_layout List
5998 \labelwidthstring 00000.00000.00000.000
5999
6000 \family sans
6001 WILL_BE_THE_SAME
6002 \family default
6003
6004 \begin_inset LatexCommand index
6005 name "WILL\\_BE\\_THE\\_SAME"
6006
6007 \end_inset
6008
6009
6010 \end_layout
6011
6012 \begin_deeper
6013 \begin_layout Standard
6014 Structural condition statement restricting objects in a forward declaration.
6015 The objects passed to a parameterized type definition can be constrained
6016 to have arbitrary parts in common before the parameterized object is constructe
6017 d.
6018 \end_layout
6019
6020 \end_deeper
6021 \begin_layout List
6022 \labelwidthstring 00000.00000.00000.000
6023
6024 \family sans
6025 WILL_NOT_BE_THE_SAME
6026 \family default
6027
6028 \begin_inset LatexCommand index
6029 name "WILL\\_NOT\\_BE\\_THE\\_SAME"
6030
6031 \end_inset
6032
6033
6034 \end_layout
6035
6036 \begin_deeper
6037 \begin_layout Standard
6038 Structural condition statement restricting objects in a forward declaration.
6039 We apologize for the length of this key word, but we bet it is easy to
6040 remember.
6041 The objects passed to a parameterized type definition can be constrained
6042 to have arbitrary parts be distinct instances before the parameterized
6043 object is constructed.
6044 At present the constraint is only enforced when the objects are being passed.
6045 \end_layout
6046
6047 \end_deeper
6048 \begin_layout List
6049 \labelwidthstring 00000.00000.00000.000
6050 \begin_inset Note Note
6051 status open
6052
6053 \begin_layout List
6054 \labelwidthstring 00000.00000.00000.000
6055
6056 \family sans
6057 ARE_NOT_THE_SAME
6058 \family default
6059
6060 \begin_inset LatexCommand index
6061 name "ARE\\_NOT\\_THE\\_SAME"
6062
6063 \end_inset
6064
6065
6066 \end_layout
6067
6068 \begin_layout Standard
6069 Cannot be merged.
6070 We believe it is useful to say that two objects cannot be merged and still
6071 represent a valid model.
6072 This is not yet implemented, however, mainly for lack of time.
6073 The implementation is simple.
6074 \end_layout
6075
6076 \end_inset
6077
6078
6079 \end_layout
6080
6081 \begin_layout List
6082 \labelwidthstring 00000.00000.00000.000
6083
6084 \family sans
6085 ARE_ALIKE
6086 \family default
6087
6088 \begin_inset LatexCommand index
6089 name "ARE\\_ALIKE"
6090
6091 \end_inset
6092
6093 Refinement clique
6094 \begin_inset LatexCommand index
6095 name "clique"
6096
6097 \end_inset
6098
6099 constructor.
6100 Causes a group of instances to always be of the same formal type.
6101 Refining one of them causes a refinement of all the others.
6102 Does not propagate implicit type information, such as assignments to constants
6103 or part refinements made from a scope other than the scope of the formal
6104 definition.
6105 \end_layout
6106
6107 \begin_layout List
6108 \labelwidthstring 00000.00000.00000.000
6109
6110 \family sans
6111 FOR/CREATE
6112 \family default
6113
6114 \begin_inset LatexCommand index
6115 name "FOR/CREATE"
6116
6117 \end_inset
6118
6119 Indexed execution of other declarative statements.
6120 Required for creating arrays of relations and sparse arrays of other types.
6121 \end_layout
6122
6123 \begin_layout List
6124 \labelwidthstring 00000.00000.00000.000
6125
6126 \family sans
6127 FOR/CHECK
6128 \family default
6129
6130 \begin_inset LatexCommand index
6131 name "FOR/CHECK"
6132
6133 \end_inset
6134
6135 Indexed checking of the conditions (WHERE
6136 \begin_inset LatexCommand index
6137 name "WHERE"
6138
6139 \end_inset
6140
6141 statements) of a parameterized model.
6142 \end_layout
6143
6144 \begin_layout List
6145 \labelwidthstring 00000.00000.00000.000
6146
6147 \family sans
6148 SELECT/CASE
6149 \family default
6150
6151 \begin_inset LatexCommand index
6152 name "SELECT/CASE"
6153
6154 \end_inset
6155
6156
6157 \end_layout
6158
6159 \begin_deeper
6160 \begin_layout Standard
6161 Select a subset of statements to compile.
6162 Given the values of the specified constants,
6163 \family sans
6164 SELECT
6165 \family default
6166 compiles all cases that match those values.
6167 A name cannot be defined two different ways inside the
6168 \family sans
6169 SELECT
6170 \family default
6171 statement, but it may be defined outside the case statement and then refined
6172 in different ways in separate cases.
6173 \end_layout
6174
6175 \end_deeper
6176 \begin_layout List
6177 \labelwidthstring 00000.00000.00000.000
6178
6179 \family sans
6180 CONDITIONAL
6181 \family default
6182
6183 \begin_inset LatexCommand index
6184 name "CONDITIONAL"
6185
6186 \end_inset
6187
6188
6189 \end_layout
6190
6191 \begin_deeper
6192 \begin_layout Standard
6193 Describe bounding relations.
6194 The relations written inside a
6195 \family sans
6196 CONDITIONAL
6197 \family default
6198 statement must all be labelled.
6199 These relations can be used to define regions in which alternate sets of
6200 equations apply using the
6201 \family sans
6202 WHEN
6203 \family default
6204 statement.
6205 \end_layout
6206
6207 \end_deeper
6208 \begin_layout List
6209 \labelwidthstring 00000.00000.00000.000
6210
6211 \family sans
6212 WHEN/CASE
6213 \family default
6214
6215 \begin_inset LatexCommand index
6216 name "WHEN/CASE"
6217
6218 \end_inset
6219
6220 When logical variables have certain values, use certain relations or model
6221 parts in defining a mathematical problem.
6222 The relations are not defined inside the WHEN statement because all the
6223 relations must be compiled regardless of which values the logical variables
6224 have at any given moment.
6225
6226 \end_layout
6227
6228 \begin_layout List
6229 \labelwidthstring 00000.00000.00000.000
6230 Reminder: In the following detailed statement descriptions, we show keywords
6231 in capital letters.
6232 These words must appear in capital letters as shown in ASCEND statements.
6233 We show optional parts to a statement enclosed in double angle brackets
6234 (« ») and user supplied names in lower-case italic letters.
6235 (Remember that ASCEND treats the underscore (_) as a letter).
6236 The user may substitute any name desired for these names.
6237 We use names that describe the kind of name the user should use.
6238 \end_layout
6239
6240 \begin_layout List
6241 \labelwidthstring 00000.00000.00000.000
6242
6243 \bar under
6244 Operators\InsetSpace ~
6245 in\InsetSpace ~
6246 detail:
6247 \end_layout
6248
6249 \begin_layout List
6250 \labelwidthstring 00000.00000.00000.000
6251 IS_A
6252 \begin_inset LatexCommand index
6253 name "IS\\_A"
6254
6255 \end_inset
6256
6257 This statement has the syntax
6258 \end_layout
6259
6260 \begin_deeper
6261 \begin_layout LyX-Code
6262
6263 \emph on
6264 list_of_instance_names
6265 \emph default
6266 IS_A
6267 \emph on
6268 model_name
6269 \end_layout
6270
6271 \begin_layout LyX-Code
6272 «(arguments_if_needed)»;
6273 \end_layout
6274
6275 \begin_layout Standard
6276 The IS_A statement allows us to declare instances of a given type to exist
6277 within a model definition.
6278 If type has not been defined (loaded in the ASCEND environment) then this
6279 statement is an error and the MODEL it appears in is irreparably damaged
6280 (at least until you delete the type definitions and reload a corrected
6281 file).
6282 Similarly, if the arguments needed are not supplied or if provably incorrect
6283 arguments are supplied, the statement is in error.
6284 The construction of the instances does not occur until all the arguments
6285 satisfy the definition of type.
6286 \end_layout
6287
6288 \begin_layout Standard
6289 If a name is used twice in WILL_BE/IS_A/ALIASES statements of the same model,
6290 ASCEND will complain bitterly when the definition is parsed.
6291 Duplicate naming is a serious error.
6292 Labels on relations share the same name space as other objects.
6293 \end_layout
6294
6295 \end_deeper
6296 \begin_layout List
6297 \labelwidthstring 00000.00000.00000.000
6298 IS_REFINED_TO
6299 \begin_inset LatexCommand index
6300 name "IS\\_REFINED\\_TO"
6301
6302 \end_inset
6303
6304 This statement has the syntax
6305 \end_layout
6306
6307 \begin_deeper
6308 \begin_layout LyX-Code
6309 list_of_instances IS_REFINED_TO
6310 \emph on
6311 type_name
6312 \end_layout
6313
6314 \begin_layout LyX-Code
6315 «(arguments_if_needed)»;
6316 \end_layout
6317
6318 \begin_layout Standard
6319 We use this statement to change the type of each of the instances listed
6320 to the type type_name.
6321 The modeler has to have defined each member on the list of instances.
6322 The type_name has to be a type which refines the types of all the instances
6323 on the list.
6324 \end_layout
6325
6326 \begin_layout Standard
6327 An example of its use is as follows.
6328 First we define the parts called fl1, fl2 and fl3 which are of type flash.
6329 \end_layout
6330
6331 \begin_layout LyX-Code
6332 fl1, fl2, fl3 IS_A flash;
6333 \end_layout
6334
6335 \begin_layout Standard
6336 Assume that there exists in the previously defined model definitions the
6337 type adiabatic_flash that is a refinement of flash.
6338 Then we can make fl1 and fl3 into more refined types by stating:
6339 \end_layout
6340
6341 \begin_layout LyX-Code
6342 fl1, fl3 IS_REFINED_TO adiabatic_flash;
6343 \end_layout
6344
6345 \begin_layout Standard
6346 This reconstruction does not occur until the arguments to the type satisfy
6347 the definition type_name.
6348 \end_layout
6349
6350 \end_deeper
6351 \begin_layout List
6352 \labelwidthstring 00000.00000.00000.000
6353 ALIASES
6354 \begin_inset LatexCommand index
6355 name "ALIASES"
6356
6357 \end_inset
6358
6359 \InsetSpace ~
6360 (*\InsetSpace ~
6361 4\InsetSpace ~
6362 *) This statement has the syntax
6363 \end_layout
6364
6365 \begin_deeper
6366 \begin_layout LyX-Code
6367
6368 \emph on
6369 list_of_instances
6370 \emph default
6371 ALIASES
6372 \emph on
6373 instance_name
6374 \emph default
6375 ;
6376 \end_layout
6377
6378 \begin_layout Standard
6379 We use this statement to point at an already existing instance of any type
6380 other than relation, logical_relation, or when.
6381 For example, say we want a flash tank model to have a variable T, the temperatu
6382 re of the vapor-liquid equilibrium mixture in the tank.
6383 \end_layout
6384
6385 \begin_layout LyX-Code
6386 MODEL tank;
6387 \end_layout
6388
6389 \begin_layout LyX-Code
6390 feed, liquid, vapor IS_A stream;
6391 \end_layout
6392
6393 \begin_layout LyX-Code
6394 state IS_A VLE_mixture;
6395 \end_layout
6396
6397 \begin_layout LyX-Code
6398 T ALIASES state.T;
6399 \end_layout
6400
6401 \begin_layout LyX-Code
6402 liquor_temperature ALIASES T;
6403 \end_layout
6404
6405 \begin_layout LyX-Code
6406 END tank;
6407 \end_layout
6408
6409 \begin_layout Standard
6410 We might also want a more descriptive name than T, so ALIASES can also be
6411 used to establish a second name at the same scope, e.g.
6412 liquor_temperature.
6413 \end_layout
6414
6415 \begin_layout Standard
6416 An ALIASES statement will not be executed until the RHS instance has been
6417 created with an IS_A.
6418 The compiler schedules ALIASES instructions appropriately and issues warnings
6419 if recursion is detected.
6420 An array of aliases, e.g.
6421
6422 \end_layout
6423