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

Contents of /trunk/doc/syntax.lyx

Parent Directory Parent Directory | Revision Log Revision Log


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