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

Contents of /trunk/doc/syntax.lyx

Parent Directory Parent Directory | Revision Log Revision Log


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