Parent Directory
|
Revision Log
Added record of WHILE statement in syntax document.
1 | jpye | 1956 | #LyX 1.5.6 created this file. For more info see http://www.lyx.org/ |
2 | jpye | 1733 | \lyxformat 276 |
3 | johnpye | 828 | \begin_document |
4 | \begin_header | ||
5 | \textclass book | ||
6 | \begin_preamble | ||
7 | \usepackage[bookmarks]{hyperref} | ||
8 | \usepackage{lmodern} | ||
9 | \end_preamble | ||
10 | \language english | ||
11 | \inputencoding auto | ||
12 | jpye | 1733 | \font_roman default |
13 | \font_sans default | ||
14 | \font_typewriter default | ||
15 | \font_default_family default | ||
16 | \font_sc false | ||
17 | \font_osf false | ||
18 | \font_sf_scale 100 | ||
19 | \font_tt_scale 100 | ||
20 | johnpye | 828 | \graphics default |
21 | \paperfontsize default | ||
22 | \spacing single | ||
23 | \papersize default | ||
24 | \use_geometry false | ||
25 | \use_amsmath 1 | ||
26 | jpye | 1733 | \use_esint 0 |
27 | johnpye | 828 | \cite_engine basic |
28 | \use_bibtopic false | ||
29 | \paperorientation portrait | ||
30 | \secnumdepth 3 | ||
31 | \tocdepth 3 | ||
32 | \paragraph_separation indent | ||
33 | \defskip medskip | ||
34 | \quotes_language english | ||
35 | \papercolumns 1 | ||
36 | \papersides 1 | ||
37 | \paperpagestyle default | ||
38 | \tracking_changes false | ||
39 | \output_changes false | ||
40 | jpye | 1733 | \author "" |
41 | jpye | 1956 | \author "" |
42 | johnpye | 828 | \end_header |
43 | |||
44 | \begin_body | ||
45 | |||
46 | \begin_layout Chapter | ||
47 | jpye | 1384 | Syntax reference |
48 | jpye | 1733 | \begin_inset LatexCommand label |
49 | name "cha:ASCENDSyntax" | ||
50 | johnpye | 828 | |
51 | \end_inset | ||
52 | |||
53 | |||
54 | \end_layout | ||
55 | |||
56 | \begin_layout Standard | ||
57 | We shall present an informal description of the ASCEND IV language. | ||
58 | Being informal, we shall usually include examples and descriptions of the | ||
59 | intended semantics along with the syntax of the items. | ||
60 | At times the inclusion of semantics will seem to anticipate later definitions. | ||
61 | We do this because we would also like this chapter to be used as a reference | ||
62 | for the ASCEND language even after one generally understands it. | ||
63 | Often one will need to clarify a point about a particular item and will | ||
64 | not wish to have to search in several places to do so. | ||
65 | \end_layout | ||
66 | |||
67 | \begin_layout Standard | ||
68 | Syntax | ||
69 | jpye | 1733 | \begin_inset LatexCommand index |
70 | name "syntax" | ||
71 | johnpye | 828 | |
72 | \end_inset | ||
73 | |||
74 | is the form or structure for the statements in ASCEND, where one worries | ||
75 | about the exact words one uses, their ordering, the punctuation, etc. | ||
76 | Semantics | ||
77 | jpye | 1733 | \begin_inset LatexCommand index |
78 | name "semantics" | ||
79 | johnpye | 828 | |
80 | \end_inset | ||
81 | |||
82 | describe the meaning of a statement. | ||
83 | \end_layout | ||
84 | |||
85 | \begin_layout Standard | ||
86 | To distinguish between syntax and semantics, consider the statement | ||
87 | \end_layout | ||
88 | |||
89 | \begin_layout LyX-Code | ||
90 | y IS_A fraction; | ||
91 | \end_layout | ||
92 | |||
93 | \begin_layout Standard | ||
94 | Rules on the syntax for this statement tell us we need a user supplied instance | ||
95 | name, y, followed by the ASCEND operator IS_A, followed by a type name | ||
96 | (fraction). | ||
97 | The statement terminates with a semicolon. | ||
98 | The statement semantics says we are declaring the existence of an instance, | ||
99 | locally named y, of the type fraction as a part within the current model | ||
100 | definition and it is to be constructed when an instance of the current | ||
101 | model definition is constructed. | ||
102 | \end_layout | ||
103 | |||
104 | \begin_layout Standard | ||
105 | The syntax for a computer language is often defined by using a Bachus-Naur | ||
106 | jpye | 1733 | \begin_inset LatexCommand index |
107 | name "Bachus-Naur" | ||
108 | johnpye | 828 | |
109 | \end_inset | ||
110 | |||
111 | formal (BNF | ||
112 | jpye | 1733 | \begin_inset LatexCommand index |
113 | name "BNF" | ||
114 | johnpye | 828 | |
115 | \end_inset | ||
116 | |||
117 | ) description. | ||
118 | The complete YACC | ||
119 | jpye | 1733 | \begin_inset LatexCommand index |
120 | name "YACC" | ||
121 | johnpye | 828 | |
122 | \end_inset | ||
123 | |||
124 | and FLEX | ||
125 | jpye | 1733 | \begin_inset LatexCommand index |
126 | name "FLEX" | ||
127 | johnpye | 828 | |
128 | \end_inset | ||
129 | |||
130 | description of the language described (as presently implemented) is available | ||
131 | by FTP and via the World Wide Web. | ||
132 | The semantics of a very high level modeling language such as ASCEND IV | ||
133 | are generally much more restrictive than the syntax. | ||
134 | For this reason we do not include a BNF description in this paper. | ||
135 | ASCEND IV is an experiment. | ||
136 | The language is under constant scrutiny and improvement, so this document | ||
137 | is under constant revision. | ||
138 | |||
139 | \end_layout | ||
140 | |||
141 | \begin_layout List | ||
142 | \labelwidthstring 00000.00000.00000.000 | ||
143 | \InsetSpace ~ | ||
144 | |||
145 | \end_layout | ||
146 | |||
147 | \begin_deeper | ||
148 | jpye | 1384 | \begin_layout Chapter |
149 | johnpye | 828 | Preliminaries |
150 | \end_layout | ||
151 | |||
152 | \begin_layout Standard | ||
153 | We will start off with some background information and some tips that make | ||
154 | the rest of the chapter easier to read. | ||
155 | ASCEND is an object-oriented (OO) language for hierarchical modeling that | ||
156 | has been somewhat specialized for mathematical models. | ||
157 | Most of the specialization is in the implementation and the user interface | ||
158 | rather than the language definition. | ||
159 | |||
160 | \end_layout | ||
161 | |||
162 | \begin_layout Standard | ||
163 | We feel the single most distinguishing feature of mathematical models is | ||
164 | that solving them efficiently requires that the solving algorithms be able | ||
165 | to address the entire problem either simultaneously or in a decomposition | ||
166 | of the natural problem structure that the algorithm determines is best | ||
167 | for the machine(s) in use. | ||
168 | In the ASCEND language object-orientation is used to organize natural structure | ||
169 | s and make them easier to understand. | ||
170 | It is not used to hide the details of the objects. | ||
171 | The user (or machine) is free to ignore uninteresting details, and the | ||
172 | ASCEND environment provides tools for the runtime suppression of these. | ||
173 | \end_layout | ||
174 | |||
175 | \begin_layout Standard | ||
176 | ASCEND is well into its 4th generation. | ||
177 | Some features we will describe are not yet implemented (some merely speculative | ||
178 | ) and these are clearly marked (* 4+ *). | ||
179 | Any feature not marked (* 4+ *)has been completely implemented, and thus | ||
180 | any mismatch between the description given here and the software we distribute | ||
181 | is a bug we want you to tell us about. | ||
182 | |||
183 | \end_layout | ||
184 | |||
185 | \begin_layout Standard | ||
186 | The syntax and semantics of ASCEND may seem at first a bit unusual. | ||
187 | However, do not be afraid to just try what comes naturally if what we write | ||
188 | here is unclear. | ||
189 | The parser and compiler of ASCEND IV really will help you get things right. | ||
190 | Of course if what we write here is unclear, please ask us about it because | ||
191 | we aim to continuously improve both this document and the language system | ||
192 | it describes. | ||
193 | \end_layout | ||
194 | |||
195 | \begin_layout Standard | ||
196 | We will describe, starting in Section | ||
197 | jpye | 1733 | \begin_inset LatexCommand vref |
198 | reference "sub:x.1.2Basic-Elements" | ||
199 | johnpye | 828 | |
200 | \end_inset | ||
201 | |||
202 | , the higher level concepts of ASCEND, but first some important punctuation | ||
203 | rules. | ||
204 | \end_layout | ||
205 | |||
206 | \end_deeper | ||
207 | \begin_layout List | ||
208 | \labelwidthstring 00000.00000.00000.000 | ||
209 | ASCEND\InsetSpace ~ | ||
210 | is\InsetSpace ~ | ||
211 | cAsE\InsetSpace ~ | ||
212 | sensitive | ||
213 | jpye | 1733 | \begin_inset LatexCommand index |
214 | name "case sensitive" | ||
215 | johnpye | 828 | |
216 | \end_inset | ||
217 | |||
218 | ! | ||
219 | \end_layout | ||
220 | |||
221 | \begin_deeper | ||
222 | \begin_layout Standard | ||
223 | The keywords that are shown capitalized (or in lower case) in this chapter | ||
224 | are that way because ASCEND is case sensitive. | ||
225 | IS_A is an ASCEND keyword; isa, Is_a, and all the other permutations you | ||
226 | can think of are NOT equivalent to IS_A. | ||
227 | In declaring new types of models and variables the user is free to use | ||
228 | any style of capitalization he or she may prefer; however, they must remain | ||
229 | consistent or undefined types and instances will result. | ||
230 | \end_layout | ||
231 | |||
232 | \begin_layout Standard | ||
233 | This case restriction makes our code very readable, but hard to type without | ||
234 | a smart editor. | ||
235 | We have kept the case-sensitivity because, like all mathematicians, we | ||
236 | find ourselves running out of good variable names if we are restricted | ||
237 | to a 26 letter alphabet. | ||
238 | We have developed smart add-ins for two UNIX editors, EMACS | ||
239 | jpye | 1733 | \begin_inset LatexCommand index |
240 | name "EMACS" | ||
241 | johnpye | 828 | |
242 | \end_inset | ||
243 | |||
244 | and vi | ||
245 | jpye | 1733 | \begin_inset LatexCommand index |
246 | name "vi" | ||
247 | johnpye | 828 | |
248 | \end_inset | ||
249 | |||
250 | , for handling the upper case keywords and some other syntax elements. | ||
251 | The use of these editors is described in another chapter. | ||
252 | |||
253 | \end_layout | ||
254 | |||
255 | \begin_layout Standard | ||
256 | The ASCEND IV parser is very picky and pedantic. | ||
257 | It also tries to give helpful messages and occasionally even suggestions. | ||
258 | New users should just dive in and make errors, letting the system help | ||
259 | them learn how to avoid errors. | ||
260 | \end_layout | ||
261 | |||
262 | jpye | 1384 | \begin_layout Section |
263 | johnpye | 828 | Punctuation |
264 | jpye | 1733 | \begin_inset LatexCommand index |
265 | name "punctuation" | ||
266 | johnpye | 828 | |
267 | \end_inset | ||
268 | |||
269 | |||
270 | \end_layout | ||
271 | |||
272 | jpye | 1384 | \end_deeper |
273 | johnpye | 828 | \begin_layout Standard |
274 | This section covers both the punctuation that must be understood to read | ||
275 | this document and the punctuation of ASCEND code. | ||
276 | \end_layout | ||
277 | |||
278 | \begin_layout List | ||
279 | \labelwidthstring 00000.00000.00000.000 | ||
280 | keywords | ||
281 | jpye | 1733 | \begin_inset LatexCommand index |
282 | name "keywords" | ||
283 | johnpye | 828 | |
284 | \end_inset | ||
285 | |||
286 | : ASCEND keywords and type names are given in the left column in bold format. | ||
287 | It is generally clear from the main text which are keywords and which are | ||
288 | type names. | ||
289 | \end_layout | ||
290 | |||
291 | \begin_layout List | ||
292 | \labelwidthstring 00000.00000.00000.000 | ||
293 | |||
294 | \bar under | ||
295 | Minor\InsetSpace ~ | ||
296 | items: | ||
297 | \bar default | ||
298 | Minor headings that are helpful in finding details are given in the left | ||
299 | column in underline format. | ||
300 | \end_layout | ||
301 | |||
302 | \begin_layout List | ||
303 | \labelwidthstring 00000.00000.00000.000 | ||
304 | Tips: Special notes and hints are sometimes placed on the left. | ||
305 | \end_layout | ||
306 | |||
307 | \begin_layout List | ||
308 | \labelwidthstring 00000.00000.00000.000 | ||
309 | |||
310 | \bar under | ||
311 | LHS | ||
312 | jpye | 1733 | \begin_inset LatexCommand index |
313 | name "LHS" | ||
314 | johnpye | 828 | |
315 | \end_inset | ||
316 | |||
317 | : | ||
318 | \bar default | ||
319 | Left Hand Side. | ||
320 | Abbreviation used frequently. | ||
321 | \end_layout | ||
322 | |||
323 | \begin_layout List | ||
324 | \labelwidthstring 00000.00000.00000.000 | ||
325 | |||
326 | \bar under | ||
327 | RHS | ||
328 | jpye | 1733 | \begin_inset LatexCommand index |
329 | name "RHS" | ||
330 | johnpye | 828 | |
331 | \end_inset | ||
332 | |||
333 | : | ||
334 | \bar default | ||
335 | Right Hand Side. | ||
336 | Abbreviation used frequently. | ||
337 | \end_layout | ||
338 | |||
339 | \begin_layout List | ||
340 | \labelwidthstring 00000.00000.00000.000 | ||
341 | |||
342 | \bar under | ||
343 | Simple\InsetSpace ~ | ||
344 | names | ||
345 | jpye | 1733 | \begin_inset LatexCommand index |
346 | name "simple names" | ||
347 | johnpye | 828 | |
348 | \end_inset | ||
349 | |||
350 | : | ||
351 | \bar default | ||
352 | In ASCEND simple names are made of the characters a through z, A through | ||
353 | Z, _, (*4+*: $). | ||
354 | The underscore is used as a letter, but it cannot be the first letter in | ||
355 | a name. | ||
356 | The $ | ||
357 | jpye | 1733 | \begin_inset LatexCommand index |
358 | name "\\$" | ||
359 | johnpye | 828 | |
360 | \end_inset | ||
361 | |||
362 | character is used exclusively as the first character in the name of system | ||
363 | defined built-in parts. | ||
364 | "$" is explained in more detail in Section | ||
365 | jpye | 1733 | \begin_inset LatexCommand vref |
366 | reference "sub:x.6.2Supported-attributes" | ||
367 | johnpye | 828 | |
368 | \end_inset | ||
369 | |||
370 | . | ||
371 | Simple names should be no more than 80 characters long. | ||
372 | |||
373 | \end_layout | ||
374 | |||
375 | \begin_layout List | ||
376 | \labelwidthstring 00000.00000.00000.000 | ||
377 | |||
378 | \bar under | ||
379 | Compound\InsetSpace ~ | ||
380 | names | ||
381 | jpye | 1733 | \begin_inset LatexCommand index |
382 | name "compound names" | ||
383 | johnpye | 828 | |
384 | \end_inset | ||
385 | |||
386 | : | ||
387 | \bar default | ||
388 | Compound names are simple names strung together with dots (.). | ||
389 | See the description of "." below. | ||
390 | \end_layout | ||
391 | |||
392 | \begin_layout List | ||
393 | \labelwidthstring 00000.00000.00000.000 | ||
394 | |||
395 | \bar under | ||
396 | Groupings: | ||
397 | \end_layout | ||
398 | |||
399 | \begin_layout List | ||
400 | \labelwidthstring 00000.00000.00000.000 | ||
401 | |||
402 | \bar under | ||
403 | jpye | 1733 | «\InsetSpace ~ |
404 | » | ||
405 | johnpye | 828 | \bar default |
406 | jpye | 1384 | In documentation |
407 | \series bold | ||
408 | optional fields | ||
409 | \series default | ||
410 | |||
411 | jpye | 1733 | \begin_inset LatexCommand index |
412 | name "optional fields" | ||
413 | johnpye | 828 | |
414 | \end_inset | ||
415 | |||
416 | are surrounded by these markers. | ||
417 | \end_layout | ||
418 | |||
419 | \begin_layout List | ||
420 | \labelwidthstring 00000.00000.00000.000 | ||
421 | jpye | 1384 | |
422 | \family typewriter | ||
423 | johnpye | 828 | (*\InsetSpace ~ |
424 | *) | ||
425 | jpye | 1384 | \family default |
426 | |||
427 | jpye | 1733 | \begin_inset LatexCommand index |
428 | name "(* *)" | ||
429 | johnpye | 828 | |
430 | \end_inset | ||
431 | |||
432 | Comment. | ||
433 | jpye | 1384 | Anything inside these is a comment. |
434 | Comments can nest | ||
435 | jpye | 1733 | \begin_inset LatexCommand index |
436 | name "nest" | ||
437 | johnpye | 828 | |
438 | \end_inset | ||
439 | |||
440 | jpye | 1384 | in ASCEND and span several lines. |
441 | johnpye | 828 | \end_layout |
442 | |||
443 | \begin_layout List | ||
444 | \labelwidthstring 00000.00000.00000.000 | ||
445 | jpye | 1384 | |
446 | \family typewriter | ||
447 | johnpye | 828 | (\InsetSpace ~ |
448 | ) | ||
449 | jpye | 1384 | \family default |
450 | |||
451 | jpye | 1733 | \begin_inset LatexCommand index |
452 | name "( )" | ||
453 | johnpye | 828 | |
454 | \end_inset | ||
455 | |||
456 | Rounded parentheses | ||
457 | jpye | 1733 | \begin_inset LatexCommand index |
458 | name "parentheses" | ||
459 | johnpye | 828 | |
460 | \end_inset | ||
461 | |||
462 | |||
463 | jpye | 1733 | \begin_inset LatexCommand index |
464 | name "rounded parentheses" | ||
465 | johnpye | 828 | |
466 | \end_inset | ||
467 | |||
468 | . | ||
469 | Used to enclose arguments for functions or models where the order of the | ||
470 | arguments matters. | ||
471 | Also used to group terms in complex arithmetic, logical, or set expressions | ||
472 | where the order of operations needs to be specified. | ||
473 | |||
474 | \end_layout | ||
475 | |||
476 | \begin_layout List | ||
477 | \labelwidthstring 00000.00000.00000.000 | ||
478 | Efficiency\InsetSpace ~ | ||
479 | tip: The compiler can simplify relation definitions in a particularly | ||
480 | efficient manner if constants are grouped together. | ||
481 | \end_layout | ||
482 | |||
483 | \begin_layout List | ||
484 | \labelwidthstring 00000.00000.00000.000 | ||
485 | jpye | 1384 | |
486 | \family typewriter | ||
487 | johnpye | 828 | {\InsetSpace ~ |
488 | } | ||
489 | jpye | 1384 | \family default |
490 | |||
491 | jpye | 1733 | \begin_inset LatexCommand index |
492 | name "{ }" | ||
493 | johnpye | 828 | |
494 | \end_inset | ||
495 | |||
496 | Curly braces | ||
497 | jpye | 1733 | \begin_inset LatexCommand index |
498 | name "Curly braces" | ||
499 | johnpye | 828 | |
500 | \end_inset | ||
501 | |||
502 | . | ||
503 | Used to enclose units. | ||
504 | For example, 1 {kg_mole/s}. | ||
505 | Also used to enclose the body of annotations. | ||
506 | Note: Curly braces are also used in TCL, the language of the ASCEND user | ||
507 | interface, about which we will say more in another chapter. | ||
508 | \end_layout | ||
509 | |||
510 | \begin_layout List | ||
511 | \labelwidthstring 00000.00000.00000.000 | ||
512 | jpye | 1384 | |
513 | \family typewriter | ||
514 | johnpye | 828 | [\InsetSpace ~ |
515 | ] | ||
516 | jpye | 1384 | \family default |
517 | |||
518 | jpye | 1733 | \begin_inset LatexCommand index |
519 | name "[ ]" | ||
520 | johnpye | 828 | |
521 | \end_inset | ||
522 | |||
523 | Square brackets | ||
524 | jpye | 1733 | \begin_inset LatexCommand index |
525 | name "square brackets" | ||
526 | johnpye | 828 | |
527 | \end_inset | ||
528 | |||
529 | . | ||
530 | Used to enclose sets or elements of sets. | ||
531 | Examples: my_integer_set :== [1,2,3], demonstrates the use of square brackets | ||
532 | in the assignment of a set. | ||
533 | My_array[1] demonstrates the use of square brackets in naming an array | ||
534 | object indexed over an integer set which includes the element 1. | ||
535 | \end_layout | ||
536 | |||
537 | \begin_layout List | ||
538 | \labelwidthstring 00000.00000.00000.000 | ||
539 | jpye | 1384 | |
540 | \family typewriter | ||
541 | johnpye | 828 | . |
542 | jpye | 1384 | \family default |
543 | |||
544 | jpye | 1733 | \begin_inset LatexCommand index |
545 | name "." | ||
546 | johnpye | 828 | |
547 | \end_inset | ||
548 | |||
549 | Dot | ||
550 | jpye | 1733 | \begin_inset LatexCommand index |
551 | name "dot" | ||
552 | johnpye | 828 | |
553 | \end_inset | ||
554 | |||
555 | . | ||
556 | The dot is used, as in PASCAL and C, to construct the names of nested objects. | ||
557 | Examples: if object a has a part b, then the way to refer to b is as a.b. | ||
558 | Tray[1].vle shows a dot following a square bracket; here Tray[1] has a part | ||
559 | named vle. | ||
560 | \end_layout | ||
561 | |||
562 | \begin_layout List | ||
563 | \labelwidthstring 00000.00000.00000.000 | ||
564 | jpye | 1384 | |
565 | \family typewriter | ||
566 | johnpye | 828 | .. |
567 | jpye | 1384 | \family default |
568 | |||
569 | jpye | 1733 | \begin_inset LatexCommand index |
570 | name ".." | ||
571 | johnpye | 828 | |
572 | \end_inset | ||
573 | |||
574 | Dot-dot or double dot | ||
575 | jpye | 1733 | \begin_inset LatexCommand index |
576 | name "double dot" | ||
577 | johnpye | 828 | |
578 | \end_inset | ||
579 | |||
580 | . | ||
581 | Integer range shorthand. | ||
582 | For example, my_integer_set :== [1,2,3] and my_integer_set :== [1..3] are | ||
583 | equivalent. | ||
584 | If .. | ||
585 | appears in a context requiring (), such as the ALIASES/IS_A statement, | ||
586 | then the range is expanded and ordered as we would naturally expect. | ||
587 | \end_layout | ||
588 | |||
589 | \begin_layout List | ||
590 | \labelwidthstring 00000.00000.00000.000 | ||
591 | jpye | 1384 | |
592 | \family typewriter | ||
593 | johnpye | 828 | : |
594 | jpye | 1384 | \family default |
595 | |||
596 | jpye | 1733 | \begin_inset LatexCommand index |
597 | name ":" | ||
598 | johnpye | 828 | |
599 | \end_inset | ||
600 | |||
601 | Colon | ||
602 | jpye | 1733 | \begin_inset LatexCommand index |
603 | name "colon" | ||
604 | johnpye | 828 | |
605 | \end_inset | ||
606 | |||
607 | . | ||
608 | A separator used in various ways, principally to set the name of an arithmetic | ||
609 | relation apart from the definition. | ||
610 | \end_layout | ||
611 | |||
612 | \begin_layout List | ||
613 | \labelwidthstring 00000.00000.00000.000 | ||
614 | jpye | 1384 | |
615 | \family typewriter | ||
616 | johnpye | 828 | :: |
617 | jpye | 1384 | \family default |
618 | |||
619 | jpye | 1733 | \begin_inset LatexCommand index |
620 | name "::" | ||
621 | johnpye | 828 | |
622 | \end_inset | ||
623 | |||
624 | Double colon | ||
625 | jpye | 1733 | \begin_inset LatexCommand index |
626 | name "double colon" | ||
627 | johnpye | 828 | |
628 | \end_inset | ||
629 | |||
630 | . | ||
631 | A separator used in the methods section for accessing methods defined on | ||
632 | types other than the type the method is part of. | ||
633 | Explained in Section | ||
634 | jpye | 1733 | \begin_inset LatexCommand vref |
635 | reference "sec:x.4Procedural-statements" | ||
636 | johnpye | 828 | |
637 | \end_inset | ||
638 | |||
639 | .[ | ||
640 | \end_layout | ||
641 | |||
642 | \begin_layout List | ||
643 | \labelwidthstring 00000.00000.00000.000 | ||
644 | jpye | 1384 | |
645 | \family typewriter | ||
646 | johnpye | 828 | ; |
647 | jpye | 1384 | \family default |
648 | |||
649 | jpye | 1733 | \begin_inset LatexCommand index |
650 | name ";" | ||
651 | johnpye | 828 | |
652 | \end_inset | ||
653 | |||
654 | Semicolon | ||
655 | jpye | 1733 | \begin_inset LatexCommand index |
656 | name "semicolon" | ||
657 | johnpye | 828 | |
658 | \end_inset | ||
659 | |||
660 | . | ||
661 | The separator of statements. | ||
662 | \end_layout | ||
663 | |||
664 | \begin_deeper | ||
665 | jpye | 1384 | \begin_layout Section |
666 | johnpye | 828 | Basic Elements |
667 | jpye | 1733 | \begin_inset LatexCommand index |
668 | name "basic elements" | ||
669 | johnpye | 828 | |
670 | \end_inset | ||
671 | |||
672 | |||
673 | jpye | 1733 | \begin_inset LatexCommand label |
674 | name "sub:x.1.2Basic-Elements" | ||
675 | johnpye | 828 | |
676 | \end_inset | ||
677 | |||
678 | |||
679 | \end_layout | ||
680 | |||
681 | \end_deeper | ||
682 | \begin_layout List | ||
683 | \labelwidthstring 00000.00000.00000.000 | ||
684 | |||
685 | \bar under | ||
686 | Boolean\InsetSpace ~ | ||
687 | value | ||
688 | \bar default | ||
689 | |||
690 | jpye | 1733 | \begin_inset LatexCommand index |
691 | name "value, Boolean" | ||
692 | johnpye | 828 | |
693 | \end_inset | ||
694 | |||
695 | |||
696 | jpye | 1733 | \begin_inset LatexCommand index |
697 | name "Boolean value" | ||
698 | johnpye | 828 | |
699 | \end_inset | ||
700 | |||
701 | jpye | 1384 | |
702 | \family sans | ||
703 | TRUE | ||
704 | \family default | ||
705 | |||
706 | jpye | 1733 | \begin_inset LatexCommand index |
707 | name "TRUE" | ||
708 | johnpye | 828 | |
709 | \end_inset | ||
710 | |||
711 | jpye | 1384 | or |
712 | \family sans | ||
713 | FALSE | ||
714 | \family default | ||
715 | |||
716 | jpye | 1733 | \begin_inset LatexCommand index |
717 | name "FALSE" | ||
718 | johnpye | 828 | |
719 | \end_inset | ||
720 | |||
721 | . | ||
722 | jpye | 1384 | Can't get much simpler, eh? In the language definition |
723 | \family sans | ||
724 | TRUE | ||
725 | \family default | ||
726 | and | ||
727 | \family sans | ||
728 | FALSE | ||
729 | \family default | ||
730 | do not map to 1 and 0 or any other type of numeric value. | ||
731 | johnpye | 828 | (In the implementation, of course, they do.) |
732 | \end_layout | ||
733 | |||
734 | \begin_layout List | ||
735 | \labelwidthstring 00000.00000.00000.000 | ||
736 | User\InsetSpace ~ | ||
737 | interface\InsetSpace ~ | ||
738 | tip: The ASCEND user interface programmers have found it very | ||
739 | convenient, however, to allow T/F, 1/0, Y/N, and other obvious boolean | ||
740 | conventions as interactive input when assigning boolean values. | ||
741 | We are lazy users. | ||
742 | \end_layout | ||
743 | |||
744 | \begin_layout List | ||
745 | \labelwidthstring 00000.00000.00000.000 | ||
746 | |||
747 | \bar under | ||
748 | Integer\InsetSpace ~ | ||
749 | value | ||
750 | \bar default | ||
751 | |||
752 | jpye | 1733 | \begin_inset LatexCommand index |
753 | name "value, integer" | ||
754 | johnpye | 828 | |
755 | \end_inset | ||
756 | |||
757 | |||
758 | jpye | 1733 | \begin_inset LatexCommand index |
759 | name "integer value" | ||
760 | johnpye | 828 | |
761 | \end_inset | ||
762 | |||
763 | A signed whole number up to the maximum that can be represented by the | ||
764 | computer on which one is running ASCEND. | ||
765 | jpye | 1384 | |
766 | \family sans | ||
767 | MAX_INTEGER | ||
768 | \family default | ||
769 | |||
770 | jpye | 1733 | \begin_inset LatexCommand index |
771 | name "MAX\\_INTEGER" | ||
772 | johnpye | 828 | |
773 | \end_inset | ||
774 | |||
775 | is machine dependent. | ||
776 | Examples are: | ||
777 | \end_layout | ||
778 | |||
779 | \begin_deeper | ||
780 | \begin_layout LyX-Code | ||
781 | \align block | ||
782 | 123 | ||
783 | \end_layout | ||
784 | |||
785 | \begin_layout LyX-Code | ||
786 | \align block | ||
787 | -5 | ||
788 | \end_layout | ||
789 | |||
790 | \begin_layout LyX-Code | ||
791 | \align block | ||
792 | MAX_INTEGER, typically 2147483647. | ||
793 | \end_layout | ||
794 | |||
795 | \end_deeper | ||
796 | \begin_layout List | ||
797 | \labelwidthstring 00000.00000.00000.000 | ||
798 | |||
799 | \bar under | ||
800 | Real\InsetSpace ~ | ||
801 | value | ||
802 | \bar default | ||
803 | |||
804 | jpye | 1733 | \begin_inset LatexCommand index |
805 | name "value. real" | ||
806 | johnpye | 828 | |
807 | \end_inset | ||
808 | |||
809 | |||
810 | jpye | 1733 | \begin_inset LatexCommand index |
811 | name "real value" | ||
812 | johnpye | 828 | |
813 | \end_inset | ||
814 | |||
815 | ASCEND represents reals almost exactly as any other mathematically oriented | ||
816 | programming language does. | ||
817 | The mantissa | ||
818 | jpye | 1733 | \begin_inset LatexCommand index |
819 | name "mantissa" | ||
820 | johnpye | 828 | |
821 | \end_inset | ||
822 | |||
823 | has an optional negative sign followed by a string of digits and at most | ||
824 | one decimal point. | ||
825 | jpye | 1384 | The exponent is the letter |
826 | \family typewriter | ||
827 | e | ||
828 | \family default | ||
829 | or | ||
830 | \family typewriter | ||
831 | E | ||
832 | \family default | ||
833 | followed by an integer. | ||
834 | johnpye | 828 | The number must not exceed the largest the computer is able to handle. |
835 | There can be no blank characters in a real. | ||
836 | jpye | 1384 | |
837 | \family sans | ||
838 | MAX_REAL | ||
839 | \family default | ||
840 | |||
841 | jpye | 1733 | \begin_inset LatexCommand index |
842 | name "MAX\\_REAL" | ||
843 | johnpye | 828 | |
844 | \end_inset | ||
845 | |||
846 | is machine dependent. | ||
847 | The following are legitimate reals in ASCEND: | ||
848 | \end_layout | ||
849 | |||
850 | \begin_deeper | ||
851 | \begin_layout LyX-Code | ||
852 | \align block | ||
853 | -1 | ||
854 | \end_layout | ||
855 | |||
856 | \begin_layout LyX-Code | ||
857 | \align block | ||
858 | 1.2 | ||
859 | \end_layout | ||
860 | |||
861 | \begin_layout LyX-Code | ||
862 | \align block | ||
863 | 1.3e-2 | ||
864 | \end_layout | ||
865 | |||
866 | \begin_layout LyX-Code | ||
867 | \align block | ||
868 | 7.888888e+34 | ||
869 | \end_layout | ||
870 | |||
871 | \begin_layout LyX-Code | ||
872 | \align block | ||
873 | .6E21 | ||
874 | \end_layout | ||
875 | |||
876 | \begin_layout LyX-Code | ||
877 | \align block | ||
878 | MAX_REAL, typically about 1.79E+308. | ||
879 | \end_layout | ||
880 | |||
881 | \begin_layout Standard | ||
882 | while the following are not: | ||
883 | \end_layout | ||
884 | |||
885 | \begin_layout LyX-Code | ||
886 | \align block | ||
887 | 1. | ||
888 | jpye | 1384 | 2 (*contains a blank within it*) |
889 | johnpye | 828 | \end_layout |
890 | |||
891 | \begin_layout LyX-Code | ||
892 | \align block | ||
893 | 1.3e2.0 (*exponent has a decimal in it*) | ||
894 | \end_layout | ||
895 | |||
896 | jpye | 1384 | \begin_layout LyX-Code |
897 | |||
898 | \family typewriter | ||
899 | +1.3 (* illegal unary + sign. | ||
900 | johnpye | 828 | x = +1.3 not allowed*) |
901 | \end_layout | ||
902 | |||
903 | \end_deeper | ||
904 | \begin_layout List | ||
905 | \labelwidthstring 00000.00000.00000.000 | ||
906 | |||
907 | \bar under | ||
908 | Reals\InsetSpace ~ | ||
909 | stored\InsetSpace ~ | ||
910 | in\InsetSpace ~ | ||
911 | SI | ||
912 | jpye | 1733 | \begin_inset LatexCommand index |
913 | name "SI" | ||
914 | johnpye | 828 | |
915 | \end_inset | ||
916 | |||
917 | \InsetSpace ~ | ||
918 | units | ||
919 | \bar default | ||
920 | |||
921 | \end_layout | ||
922 | |||
923 | \begin_deeper | ||
924 | \begin_layout Standard | ||
925 | We store all real values as double precision | ||
926 | jpye | 1733 | \begin_inset LatexCommand index |
927 | name "double precision" | ||
928 | johnpye | 828 | |
929 | \end_inset | ||
930 | |||
931 | jpye | 1384 | numbers in the metre-kilogram-second (MKS) |
932 | jpye | 1733 | \begin_inset LatexCommand index |
933 | name "MKS" | ||
934 | johnpye | 828 | |
935 | \end_inset | ||
936 | |||
937 | system of units. | ||
938 | This eliminates many common errors in the modeling of physical systems. | ||
939 | Since we also place the burden of scaling equations on system routines | ||
940 | and a simple modeling methodology, the internal units are not of concern | ||
941 | to most users. | ||
942 | \end_layout | ||
943 | |||
944 | \end_deeper | ||
945 | \begin_layout List | ||
946 | \labelwidthstring 00000.00000.00000.000 | ||
947 | |||
948 | \bar under | ||
949 | Dimensionality | ||
950 | jpye | 1733 | \begin_inset LatexCommand index |
951 | name "dimensionality" | ||
952 | johnpye | 828 | |
953 | \end_inset | ||
954 | |||
955 | : | ||
956 | \bar default | ||
957 | Real values have dimensionality such as length/time for velocity. | ||
958 | jpye | 1384 | |
959 | \series bold | ||
960 | Dimensionality | ||
961 | \series default | ||
962 | is to be distinguished from the | ||
963 | \series bold | ||
964 | units | ||
965 | \series default | ||
966 | such as ft/s. | ||
967 | johnpye | 828 | ASCEND takes care of mapping between units |
968 | jpye | 1733 | \begin_inset LatexCommand index |
969 | name "units" | ||
970 | johnpye | 828 | |
971 | \end_inset | ||
972 | |||
973 | and dimensions. | ||
974 | A value without units (this includes integer values) is taken to be dimensionle | ||
975 | ss | ||
976 | jpye | 1733 | \begin_inset LatexCommand index |
977 | name "dimensionless" | ||
978 | johnpye | 828 | |
979 | \end_inset | ||
980 | |||
981 | . | ||
982 | Dimensionality is built up from the following base dimensions: | ||
983 | \end_layout | ||
984 | |||
985 | \begin_layout List | ||
986 | \labelwidthstring 00000.00000.00000.000 | ||
987 | Name | ||
988 | \bar under | ||
989 | definition; typical units | ||
990 | \end_layout | ||
991 | |||
992 | \begin_layout List | ||
993 | \labelwidthstring 00000.00000.00000.000 | ||
994 | L | ||
995 | jpye | 1733 | \begin_inset LatexCommand index |
996 | name "L, length dimension" | ||
997 | johnpye | 828 | |
998 | \end_inset | ||
999 | |||
1000 | length | ||
1001 | jpye | 1733 | \begin_inset LatexCommand index |
1002 | name "length" | ||
1003 | johnpye | 828 | |
1004 | \end_inset | ||
1005 | |||
1006 | jpye | 1384 | ; metre, m |
1007 | johnpye | 828 | \end_layout |
1008 | |||
1009 | \begin_layout List | ||
1010 | \labelwidthstring 00000.00000.00000.000 | ||
1011 | M | ||
1012 | jpye | 1733 | \begin_inset LatexCommand index |
1013 | name "M, mass dimension" | ||
1014 | johnpye | 828 | |
1015 | \end_inset | ||
1016 | |||
1017 | mass | ||
1018 | jpye | 1733 | \begin_inset LatexCommand index |
1019 | name "mass" | ||
1020 | johnpye | 828 | |
1021 | \end_inset | ||
1022 | |||
1023 | ; kilogram, kg | ||
1024 | \end_layout | ||
1025 | |||
1026 | \begin_layout List | ||
1027 | \labelwidthstring 00000.00000.00000.000 | ||
1028 | T | ||
1029 | jpye | 1733 | \begin_inset LatexCommand index |
1030 | name "T, time dimension" | ||
1031 | johnpye | 828 | |
1032 | \end_inset | ||
1033 | |||
1034 | time | ||
1035 | jpye | 1733 | \begin_inset LatexCommand index |
1036 | name "time" | ||
1037 | johnpye | 828 | |
1038 | \end_inset | ||
1039 | |||
1040 | ; second, s | ||
1041 | \end_layout | ||
1042 | |||
1043 | \begin_layout List | ||
1044 | \labelwidthstring 00000.00000.00000.000 | ||
1045 | E | ||
1046 | jpye | 1733 | \begin_inset LatexCommand index |
1047 | name "E, electric current dimension" | ||
1048 | johnpye | 828 | |
1049 | \end_inset | ||
1050 | |||
1051 | electric current | ||
1052 | jpye | 1733 | \begin_inset LatexCommand index |
1053 | name "electric current" | ||
1054 | johnpye | 828 | |
1055 | \end_inset | ||
1056 | |||
1057 | ; ampere, A | ||
1058 | \end_layout | ||
1059 | |||
1060 | \begin_layout List | ||
1061 | \labelwidthstring 00000.00000.00000.000 | ||
1062 | Q | ||
1063 | jpye | 1733 | \begin_inset LatexCommand index |
1064 | name "Q, quantity dimension" | ||
1065 | johnpye | 828 | |
1066 | \end_inset | ||
1067 | |||
1068 | quantity | ||
1069 | jpye | 1733 | \begin_inset LatexCommand index |
1070 | name "quantity" | ||
1071 | johnpye | 828 | |
1072 | \end_inset | ||
1073 | |||
1074 | ; mole, mole | ||
1075 | \end_layout | ||
1076 | |||
1077 | \begin_layout List | ||
1078 | \labelwidthstring 00000.00000.00000.000 | ||
1079 | TMP | ||
1080 | jpye | 1733 | \begin_inset LatexCommand index |
1081 | name "TMP, temperature dimension" | ||
1082 | johnpye | 828 | |
1083 | \end_inset | ||
1084 | |||
1085 | temperature | ||
1086 | jpye | 1733 | \begin_inset LatexCommand index |
1087 | name "temperature" | ||
1088 | johnpye | 828 | |
1089 | \end_inset | ||
1090 | |||
1091 | ; Kelvin, K | ||
1092 | \end_layout | ||
1093 | |||
1094 | \begin_layout List | ||
1095 | \labelwidthstring 00000.00000.00000.000 | ||
1096 | LUM | ||
1097 | jpye | 1733 | \begin_inset LatexCommand index |
1098 | name "LUM, luminous intensity dimension" | ||
1099 | johnpye | 828 | |
1100 | \end_inset | ||
1101 | |||
1102 | luminous intensity | ||
1103 | jpye | 1733 | \begin_inset LatexCommand index |
1104 | name "luminous intensity" | ||
1105 | johnpye | 828 | |
1106 | \end_inset | ||
1107 | |||
1108 | ; candela, cd | ||
1109 | \end_layout | ||
1110 | |||
1111 | \begin_layout List | ||
1112 | \labelwidthstring 00000.00000.00000.000 | ||
1113 | P | ||
1114 | jpye | 1733 | \begin_inset LatexCommand index |
1115 | name "P, phase angle dimension" | ||
1116 | johnpye | 828 | |
1117 | \end_inset | ||
1118 | |||
1119 | plane angle | ||
1120 | jpye | 1733 | \begin_inset LatexCommand index |
1121 | name "plane angle" | ||
1122 | johnpye | 828 | |
1123 | \end_inset | ||
1124 | |||
1125 | ; radian, rad | ||
1126 | \end_layout | ||
1127 | |||
1128 | \begin_layout List | ||
1129 | \labelwidthstring 00000.00000.00000.000 | ||
1130 | S | ||
1131 | jpye | 1733 | \begin_inset LatexCommand index |
1132 | name "S, solid angle dimension" | ||
1133 | johnpye | 828 | |
1134 | \end_inset | ||
1135 | |||
1136 | solid angle | ||
1137 | jpye | 1733 | \begin_inset LatexCommand index |
1138 | name "solid angle" | ||
1139 | johnpye | 828 | |
1140 | \end_inset | ||
1141 | |||
1142 | ; steradian, srad | ||
1143 | \end_layout | ||
1144 | |||
1145 | \begin_layout List | ||
1146 | \labelwidthstring 00000.00000.00000.000 | ||
1147 | C | ||
1148 | jpye | 1733 | \begin_inset LatexCommand index |
1149 | name "C, currency dimension" | ||
1150 | johnpye | 828 | |
1151 | \end_inset | ||
1152 | |||
1153 | currency | ||
1154 | jpye | 1733 | \begin_inset LatexCommand index |
1155 | name "currency" | ||
1156 | johnpye | 828 | |
1157 | \end_inset | ||
1158 | |||
1159 | ; currency, CR | ||
1160 | \end_layout | ||
1161 | |||
1162 | \begin_deeper | ||
1163 | \begin_layout Standard | ||
1164 | The atom and constant definitions in the library illustrate the use of dimension | ||
1165 | ality. | ||
1166 | \end_layout | ||
1167 | |||
1168 | \begin_layout Standard | ||
1169 | Dimensions may be any combination of these symbols along with rounded parenthese | ||
1170 | jpye | 1384 | s, (), and the operators *, |
1171 | \family typewriter | ||
1172 | ^ | ||
1173 | \family default | ||
1174 | and | ||
1175 | \family typewriter | ||
1176 | / | ||
1177 | \family default | ||
1178 | . | ||
1179 | Examples include | ||
1180 | \family typewriter | ||
1181 | M/T | ||
1182 | \family default | ||
1183 | or | ||
1184 | \family typewriter | ||
1185 | M*L^2/T^2/TMP | ||
1186 | \family default | ||
1187 | {this latter means | ||
1188 | \family typewriter | ||
1189 | (M*(L^2)/(T^2))/TMP | ||
1190 | \family default | ||
1191 | }. | ||
1192 | The second operand for the to-the-power-of operator, | ||
1193 | \family typewriter | ||
1194 | ^ | ||
1195 | \family default | ||
1196 | , must be an integer value (e.g., -2 or 3) because fractional powers of dimensiona | ||
1197 | l numbers are physically undefined | ||
1198 | \begin_inset Note Note | ||
1199 | status open | ||
1200 | |||
1201 | \begin_layout Standard | ||
1202 | although we do seem them occasionally... | ||
1203 | johnpye | 828 | \end_layout |
1204 | |||
1205 | jpye | 1384 | \end_inset |
1206 | |||
1207 | . | ||
1208 | \end_layout | ||
1209 | |||
1210 | johnpye | 828 | \begin_layout Standard |
1211 | If the dimensionality for a real value is undefined, then ASCEND gives it | ||
1212 | jpye | 1384 | a wildcard dimensionality |
1213 | jpye | 1733 | \begin_inset LatexCommand index |
1214 | name "wild card dimensionality" | ||
1215 | johnpye | 828 | |
1216 | \end_inset | ||
1217 | |||
1218 | . | ||
1219 | If ASCEND can later deduce its dimensionality from its use in a model definitio | ||
1220 | n it will do so. | ||
1221 | jpye | 1384 | For example consider the real variable |
1222 | \family typewriter | ||
1223 | a | ||
1224 | \family default | ||
1225 | , suppose | ||
1226 | \family typewriter | ||
1227 | a | ||
1228 | \family default | ||
1229 | has wildcard dimensionality, | ||
1230 | \family typewriter | ||
1231 | b | ||
1232 | \family default | ||
1233 | has dimensionality of | ||
1234 | \family typewriter | ||
1235 | L/T | ||
1236 | \family default | ||
1237 | . | ||
1238 | johnpye | 828 | Then the statement: |
1239 | \end_layout | ||
1240 | |||
1241 | \end_deeper | ||
1242 | \begin_layout List | ||
1243 | \labelwidthstring 00000.00000.00000.000 | ||
1244 | Example\InsetSpace ~ | ||
1245 | of\InsetSpace ~ | ||
1246 | a\InsetSpace ~ | ||
1247 | dimensionally\InsetSpace ~ | ||
1248 | consistent | ||
1249 | jpye | 1733 | \begin_inset LatexCommand index |
1250 | name "dimensionally consistent" | ||
1251 | johnpye | 828 | |
1252 | \end_inset | ||
1253 | |||
1254 | \InsetSpace ~ | ||
1255 | equation. | ||
1256 | |||
1257 | \end_layout | ||
1258 | |||
1259 | \begin_layout List | ||
1260 | \labelwidthstring 00000.00000.00000.000 | ||
1261 | \InsetSpace ~ | ||
1262 | jpye | 1384 | |
1263 | \family typewriter | ||
1264 | a + b = 3 {ft/s}; | ||
1265 | johnpye | 828 | \end_layout |
1266 | |||
1267 | \begin_deeper | ||
1268 | \begin_layout Standard | ||
1269 | jpye | 1384 | requires that |
1270 | \family typewriter | ||
1271 | a | ||
1272 | \family default | ||
1273 | have the same dimensionality as the other two terms, namely, | ||
1274 | \family typewriter | ||
1275 | L/T | ||
1276 | \family default | ||
1277 | . | ||
1278 | ASCEND will assign this dimensionality to | ||
1279 | \family typewriter | ||
1280 | a | ||
1281 | \family default | ||
1282 | . | ||
1283 | johnpye | 828 | The user will be warned of dimensionally inconsistent equations. |
1284 | \end_layout | ||
1285 | |||
1286 | \end_deeper | ||
1287 | \begin_layout List | ||
1288 | \labelwidthstring 00000.00000.00000.000 | ||
1289 | |||
1290 | \bar under | ||
1291 | Unit\InsetSpace ~ | ||
1292 | expression | ||
1293 | \bar default | ||
1294 | A unit expression | ||
1295 | jpye | 1733 | \begin_inset LatexCommand index |
1296 | name "unit expression" | ||
1297 | johnpye | 828 | |
1298 | \end_inset | ||
1299 | |||
1300 | may be composed of any combination of unit names defined by the system | ||
1301 | jpye | 1384 | and any numerical constants combined with times ( |
1302 | \family typewriter | ||
1303 | * | ||
1304 | \family default | ||
1305 | ), divide( | ||
1306 | \family typewriter | ||
1307 | / | ||
1308 | \family default | ||
1309 | ) and to the power ( | ||
1310 | \family typewriter | ||
1311 | ^ | ||
1312 | \family default | ||
1313 | ) operators. | ||
1314 | The RHS of | ||
1315 | \family typewriter | ||
1316 | ^ | ||
1317 | \family default | ||
1318 | must be an integer. | ||
1319 | Parentheses can be used to group subexpressions with the exception that | ||
1320 | a divide operator may | ||
1321 | \emph on | ||
1322 | not | ||
1323 | \emph default | ||
1324 | be followed by a grouped subexpression. | ||
1325 | johnpye | 828 | |
1326 | \end_layout | ||
1327 | |||
1328 | \begin_deeper | ||
1329 | \begin_layout Standard | ||
1330 | jpye | 1384 | So, |
1331 | \family typewriter | ||
1332 | {kg/m/s} | ||
1333 | \family default | ||
1334 | is fine, but | ||
1335 | \family typewriter | ||
1336 | {kg/(m*s)} | ||
1337 | \family default | ||
1338 | is not. | ||
1339 | johnpye | 828 | Although the two expressions are mathematically equivalent, it makes the |
1340 | system programming and output formatting easier to code and faster to execute | ||
1341 | if we disallow expressions of the latter sort. | ||
1342 | \end_layout | ||
1343 | |||
1344 | \begin_layout Standard | ||
1345 | jpye | 1384 | The units understood by the system are defined in the first part of this |
1346 | manual. | ||
1347 | johnpye | 828 | Note that several units defined are really values of interesting constants |
1348 | in SI, e.g. | ||
1349 | jpye | 1384 | |
1350 | \family typewriter | ||
1351 | R :== 1{GAS_C} | ||
1352 | \family default | ||
1353 | yields the correct value of the thermodynamic gas constant. | ||
1354 | johnpye | 828 | Users can define additional units. |
1355 | \end_layout | ||
1356 | |||
1357 | \end_deeper | ||
1358 | \begin_layout List | ||
1359 | \labelwidthstring 00000.00000.00000.000 | ||
1360 | |||
1361 | \bar under | ||
1362 | Units | ||
1363 | \bar default | ||
1364 | |||
1365 | jpye | 1733 | \begin_inset LatexCommand index |
1366 | name "units" | ||
1367 | johnpye | 828 | |
1368 | \end_inset | ||
1369 | |||
1370 | jpye | 1384 | A Unit expression unit expression must be enclosed in curly braces |
1371 | \family typewriter | ||
1372 | {} | ||
1373 | \family default | ||
1374 | . | ||
1375 | johnpye | 828 | When a real number is used in a mathematical expression in ASCEND, it must |
1376 | have a set of units expressed with it. | ||
1377 | If it does not, ASCEND assumes the number is dimensionless, which may not | ||
1378 | be the intent of the modeler. | ||
1379 | An example is shown in the dimensionally consistent equation above where | ||
1380 | jpye | 1384 | the number 3 has the units |
1381 | \family typewriter | ||
1382 | {ft/s} | ||
1383 | \family default | ||
1384 | associated with it. | ||
1385 | johnpye | 828 | |
1386 | \end_layout | ||
1387 | |||
1388 | \begin_deeper | ||
1389 | \begin_layout Standard | ||
1390 | Examples: | ||
1391 | \end_layout | ||
1392 | |||
1393 | \begin_layout LyX-Code | ||
1394 | \align block | ||
1395 | {kg_mole/s/m} same as {(kg_mole/s)/m} | ||
1396 | \end_layout | ||
1397 | |||
1398 | \begin_layout LyX-Code | ||
1399 | \align block | ||
1400 | {m^3/yr} | ||
1401 | \end_layout | ||
1402 | |||
1403 | \begin_layout LyX-Code | ||
1404 | \align block | ||
1405 | {3/100*ft} same as {0.03*ft} | ||
1406 | \end_layout | ||
1407 | |||
1408 | \begin_layout LyX-Code | ||
1409 | \align block | ||
1410 | {s^-1} same as {1/s} | ||
1411 | \end_layout | ||
1412 | |||
1413 | \begin_layout Standard | ||
1414 | Illegal unit examples are | ||
1415 | \end_layout | ||
1416 | |||
1417 | \begin_layout LyX-Code | ||
1418 | \align block | ||
1419 | {m/(K*kg_mole)} | ||
1420 | \end_layout | ||
1421 | |||
1422 | \begin_deeper | ||
1423 | \begin_layout Standard | ||
1424 | grouped subexpression used in the denominator; should be written {m/K/kg_mole}. | ||
1425 | \end_layout | ||
1426 | |||
1427 | \end_deeper | ||
1428 | \begin_layout LyX-Code | ||
1429 | \align block | ||
1430 | {m^3.5} | ||
1431 | \end_layout | ||
1432 | |||
1433 | \begin_deeper | ||
1434 | \begin_layout Standard | ||
1435 | power of units or dimensions must be integer. | ||
1436 | \end_layout | ||
1437 | |||
1438 | \end_deeper | ||
1439 | \end_deeper | ||
1440 | \begin_layout List | ||
1441 | \labelwidthstring 00000.00000.00000.000 | ||
1442 | |||
1443 | \bar under | ||
1444 | Symbol\InsetSpace ~ | ||
1445 | Value | ||
1446 | \bar default | ||
1447 | |||
1448 | jpye | 1733 | \begin_inset LatexCommand index |
1449 | name "value, symbol" | ||
1450 | johnpye | 828 | |
1451 | \end_inset | ||
1452 | |||
1453 | |||
1454 | jpye | 1733 | \begin_inset LatexCommand index |
1455 | name "symbol value" | ||
1456 | johnpye | 828 | |
1457 | \end_inset | ||
1458 | |||
1459 | The format for a symbol is that of an arbitrary character string enclosed | ||
1460 | between two single quotes. | ||
1461 | There is no way to embed a single quote | ||
1462 | jpye | 1733 | \begin_inset LatexCommand index |
1463 | name "'" | ||
1464 | johnpye | 828 | |
1465 | \end_inset | ||
1466 | |||
1467 | |||
1468 | jpye | 1733 | \begin_inset LatexCommand index |
1469 | name "single quote" | ||
1470 | johnpye | 828 | |
1471 | \end_inset | ||
1472 | |||
1473 | in a symbol: we are not in the escape sequence business at this time. | ||
1474 | The following are legal symbols in ASCEND: | ||
1475 | \end_layout | ||
1476 | |||
1477 | \begin_deeper | ||
1478 | \begin_layout LyX-Code | ||
1479 | 'H2O' | ||
1480 | \end_layout | ||
1481 | |||
1482 | \begin_layout LyX-Code | ||
1483 | 'r1' | ||
1484 | \end_layout | ||
1485 | |||
1486 | \begin_layout LyX-Code | ||
1487 | 'Bill said,foo to whom?' | ||
1488 | \end_layout | ||
1489 | |||
1490 | \begin_layout Standard | ||
1491 | while the following are not legal symbol values: | ||
1492 | \end_layout | ||
1493 | |||
1494 | \begin_layout LyX-Code | ||
1495 | "ethanol" (double quotes not allowed) | ||
1496 | \end_layout | ||
1497 | |||
1498 | \begin_layout LyX-Code | ||
1499 | water (no single quotes given) | ||
1500 | \end_layout | ||
1501 | |||
1502 | \begin_layout LyX-Code | ||
1503 | jpye | 1733 | 'i can't do this' (no embedded quotes) |
1504 | johnpye | 828 | \end_layout |
1505 | |||
1506 | \begin_layout Standard | ||
1507 | There is an arbitrary upper limit to the number of characters in a symbol | ||
1508 | (something like 10,000) so that we may detect a missing close quote in | ||
1509 | a bad input file without crashing. | ||
1510 | \end_layout | ||
1511 | |||
1512 | \end_deeper | ||
1513 | \begin_layout List | ||
1514 | \labelwidthstring 00000.00000.00000.000 | ||
1515 | Sets\InsetSpace ~ | ||
1516 | values | ||
1517 | jpye | 1733 | \begin_inset LatexCommand index |
1518 | name "values, set" | ||
1519 | johnpye | 828 | |
1520 | \end_inset | ||
1521 | |||
1522 | |||
1523 | jpye | 1733 | \begin_inset LatexCommand index |
1524 | name "set values" | ||
1525 | johnpye | 828 | |
1526 | \end_inset | ||
1527 | |||
1528 | jpye | 1384 | Set values are lists of elements, all of type |
1529 | \family sans | ||
1530 | integer_constant | ||
1531 | \family default | ||
1532 | or all of type | ||
1533 | \family sans | ||
1534 | symbol_constant | ||
1535 | \family default | ||
1536 | , enclosed between square brackets | ||
1537 | \family typewriter | ||
1538 | [] | ||
1539 | \family default | ||
1540 | . | ||
1541 | johnpye | 828 | The following are examples of sets: |
1542 | \end_layout | ||
1543 | |||
1544 | \begin_deeper | ||
1545 | \begin_layout LyX-Code | ||
1546 | \align block | ||
1547 | ['methane', 'ethane', 'propane'] | ||
1548 | \end_layout | ||
1549 | |||
1550 | \begin_layout LyX-Code | ||
1551 | \align block | ||
1552 | [1..5, 7, 15] | ||
1553 | \end_layout | ||
1554 | |||
1555 | \begin_layout LyX-Code | ||
1556 | \align block | ||
1557 | [2..n_stages] | ||
1558 | \end_layout | ||
1559 | |||
1560 | \begin_layout LyX-Code | ||
1561 | \align block | ||
1562 | [1, 4, 2, 1, 16] | ||
1563 | \end_layout | ||
1564 | |||
1565 | \begin_layout LyX-Code | ||
1566 | \align block | ||
1567 | [] | ||
1568 | \end_layout | ||
1569 | |||
1570 | \end_deeper | ||
1571 | \begin_layout List | ||
1572 | \labelwidthstring 00000.00000.00000.000 | ||
1573 | More\InsetSpace ~ | ||
1574 | about\InsetSpace ~ | ||
1575 | sets | ||
1576 | jpye | 1733 | \begin_inset LatexCommand index |
1577 | name "sets" | ||
1578 | johnpye | 828 | |
1579 | \end_inset | ||
1580 | |||
1581 | \InsetSpace ~ | ||
1582 | in\InsetSpace ~ | ||
1583 | Section\InsetSpace ~ | ||
1584 | |||
1585 | jpye | 1733 | \begin_inset LatexCommand vref |
1586 | reference "sub:x.2.2Sets" | ||
1587 | johnpye | 828 | |
1588 | \end_inset | ||
1589 | |||
1590 | . | ||
1591 | \end_layout | ||
1592 | |||
1593 | \begin_deeper | ||
1594 | \begin_layout Standard | ||
1595 | jpye | 1384 | The value range |
1596 | \family typewriter | ||
1597 | 1..5 | ||
1598 | \family default | ||
1599 | is an allowable shorthand for the integers 1, 2, 3, 4 and 5 while the value | ||
1600 | range | ||
1601 | \family typewriter | ||
1602 | 2..n_stages | ||
1603 | \family default | ||
1604 | (where | ||
1605 | \family typewriter | ||
1606 | n_stages | ||
1607 | \family default | ||
1608 | must be of type | ||
1609 | \family sans | ||
1610 | integer_constant | ||
1611 | \family default | ||
1612 | ) means all integers from 2 to | ||
1613 | \family typewriter | ||
1614 | n_stages | ||
1615 | \family default | ||
1616 | . | ||
1617 | If | ||
1618 | \family typewriter | ||
1619 | n_stages | ||
1620 | \family default | ||
1621 | is less than 2, then the third set is empty. | ||
1622 | The repeated occurrence of | ||
1623 | \family typewriter | ||
1624 | 1 | ||
1625 | \family default | ||
1626 | in the fourth set is ignored. | ||
1627 | johnpye | 828 | The fifth set is the empty set |
1628 | jpye | 1733 | \begin_inset LatexCommand index |
1629 | name "empty set" | ||
1630 | johnpye | 828 | |
1631 | \end_inset | ||
1632 | |||
1633 | |||
1634 | jpye | 1733 | \begin_inset LatexCommand index |
1635 | name "set, empty" | ||
1636 | johnpye | 828 | |
1637 | \end_inset | ||
1638 | |||
1639 | . | ||
1640 | \end_layout | ||
1641 | |||
1642 | \begin_layout Standard | ||
1643 | We use the term set in an almost pure mathematical sense. | ||
1644 | The elements have no order. | ||
1645 | One can only ask two things of a set: (1) if an element is a member of | ||
1646 | it and (2) its cardinality | ||
1647 | jpye | 1733 | \begin_inset LatexCommand index |
1648 | name "cardinality" | ||
1649 | johnpye | 828 | |
1650 | \end_inset | ||
1651 | |||
1652 | jpye | 1384 | ( |
1653 | \family sans | ||
1654 | CARD | ||
1655 | \family default | ||
1656 | |||
1657 | jpye | 1733 | \begin_inset LatexCommand index |
1658 | name "CARD" | ||
1659 | johnpye | 828 | |
1660 | \end_inset | ||
1661 | |||
1662 | jpye | 1384 | |
1663 | \family typewriter | ||
1664 | (set) | ||
1665 | \family default | ||
1666 | ). | ||
1667 | johnpye | 828 | Repeated elements used in defining a set are ignored. |
1668 | The elements of sets cannot themselves be sets in ASCEND; i.e., there can | ||
1669 | be no sets of set. | ||
1670 | \end_layout | ||
1671 | |||
1672 | \end_deeper | ||
1673 | \begin_layout List | ||
1674 | \labelwidthstring 00000.00000.00000.000 | ||
1675 | Sets\InsetSpace ~ | ||
1676 | are\InsetSpace ~ | ||
1677 | unordered. | ||
1678 | A set of integers may appear to be ordered to the modeler as the natural | ||
1679 | numbers have an order. | ||
1680 | However, it is the user imposing and using the ordering, not ASCEND. | ||
1681 | ASCEND sees these integers as elements in the set with NO ordering. | ||
1682 | Therefore, there are no operators in ASCEND such as successor or precursor | ||
1683 | member of a set. | ||
1684 | \end_layout | ||
1685 | |||
1686 | \begin_layout List | ||
1687 | \labelwidthstring 00000.00000.00000.000 | ||
1688 | |||
1689 | \bar under | ||
1690 | Arrays | ||
1691 | \bar default | ||
1692 | |||
1693 | jpye | 1733 | \begin_inset LatexCommand index |
1694 | name "arrays" | ||
1695 | johnpye | 828 | |
1696 | \end_inset | ||
1697 | |||
1698 | An array is a list of instances indexed over a set, in computer-speak, | ||
1699 | an associative array of objects. | ||
1700 | The instances are all of the same base type (as that is the only way they | ||
1701 | can be defined). | ||
1702 | An individual member of a list may later be more refined than the other | ||
1703 | members (we shall illustrate that possibility). | ||
1704 | The following are arrays in ASCEND. | ||
1705 | \end_layout | ||
1706 | |||
1707 | \begin_deeper | ||
1708 | \begin_layout LyX-Code | ||
1709 | \align block | ||
1710 | stage[1..n_stages] | ||
1711 | \end_layout | ||
1712 | |||
1713 | \begin_layout LyX-Code | ||
1714 | \align block | ||
1715 | y[components] | ||
1716 | \end_layout | ||
1717 | |||
1718 | \begin_layout LyX-Code | ||
1719 | \align block | ||
1720 | column[areas][processes] | ||
1721 | \end_layout | ||
1722 | |||
1723 | \begin_layout Standard | ||
1724 | where components, areas and processes are sets. | ||
1725 | jpye | 1384 | For example components could be the set of symbols |
1726 | \family typewriter | ||
1727 | ['ethylene', 'propylene'] | ||
1728 | \family default | ||
1729 | , areas the set of symbols | ||
1730 | \family typewriter | ||
1731 | ['feed_prep', 'prod_purification'] | ||
1732 | \family default | ||
1733 | while processes could be the set | ||
1734 | \family typewriter | ||
1735 | ['alcohol_manuf', 'poly_propropylene_manuf'] | ||
1736 | \family default | ||
1737 | . | ||
1738 | Note that the third example ( | ||
1739 | \family typewriter | ||
1740 | column | ||
1741 | \family default | ||
1742 | ) is a list of lists (the way that ASCEND permits a multiply subscripted | ||
1743 | array). | ||
1744 | johnpye | 828 | |
1745 | \end_layout | ||
1746 | |||
1747 | \begin_layout Standard | ||
1748 | The following are elements in the above arrays: | ||
1749 | \end_layout | ||
1750 | |||
1751 | \begin_layout LyX-Code | ||
1752 | stage[1] | ||
1753 | \end_layout | ||
1754 | |||
1755 | \begin_layout LyX-Code | ||
1756 | y['ethylene'] | ||
1757 | \end_layout | ||
1758 | |||
1759 | \begin_layout LyX-Code | ||
1760 | column['feed_prep'][alcohol_manuf'] | ||
1761 | \end_layout | ||
1762 | |||
1763 | \begin_layout Standard | ||
1764 | jpye | 1384 | provided that |
1765 | \family typewriter | ||
1766 | n_stages | ||
1767 | \family default | ||
1768 | is 1 or larger. | ||
1769 | johnpye | 828 | |
1770 | \end_layout | ||
1771 | |||
1772 | \begin_layout Standard | ||
1773 | There can be any number of subscripts | ||
1774 | jpye | 1733 | \begin_inset LatexCommand index |
1775 | name "subscripts" | ||
1776 | johnpye | 828 | |
1777 | \end_inset | ||
1778 | |||
1779 | for an array. | ||
1780 | We point out, however, that in virtually every application of arrays requiring | ||
1781 | more than two subscripts, there is usually a some underlying concept that | ||
1782 | is much better modeled as an object than as part of a deeply subscripted | ||
1783 | jpye | 1733 | \begin_inset LatexCommand index |
1784 | name "subscripted, deeply" | ||
1785 | johnpye | 828 | |
1786 | \end_inset | ||
1787 | |||
1788 | |||
1789 | jpye | 1733 | \begin_inset LatexCommand index |
1790 | name "deeply subscripted" | ||
1791 | johnpye | 828 | |
1792 | \end_inset | ||
1793 | |||
1794 | array. | ||
1795 | In the following jagged array example, there are really the concepts of | ||
1796 | unit operation and stream that would be better understood if made explicit. | ||
1797 | \end_layout | ||
1798 | |||
1799 | \end_deeper | ||
1800 | \begin_layout List | ||
1801 | \labelwidthstring 00000.00000.00000.000 | ||
1802 | |||
1803 | \bar under | ||
1804 | Arrays\InsetSpace ~ | ||
1805 | can\InsetSpace ~ | ||
1806 | be\InsetSpace ~ | ||
1807 | jagged | ||
1808 | \bar default | ||
1809 | |||
1810 | jpye | 1733 | \begin_inset LatexCommand label |
1811 | name "lyx:Arrays-can-be" | ||
1812 | johnpye | 828 | |
1813 | \end_inset | ||
1814 | |||
1815 | jpye | 1384 | Arrays can be sparse |
1816 | jpye | 1733 | \begin_inset LatexCommand index |
1817 | name "sparse" | ||
1818 | johnpye | 828 | |
1819 | \end_inset | ||
1820 | |||
1821 | or jagged | ||
1822 | jpye | 1733 | \begin_inset LatexCommand index |
1823 | name "jagged" | ||
1824 | johnpye | 828 | |
1825 | \end_inset | ||
1826 | |||
1827 | . | ||
1828 | For example: | ||
1829 | \end_layout | ||
1830 | |||
1831 | \begin_deeper | ||
1832 | \begin_layout LyX-Code | ||
1833 | process[1..3] IS_A set OF integer; | ||
1834 | \end_layout | ||
1835 | |||
1836 | \begin_layout LyX-Code | ||
1837 | process[1] :== [2]; | ||
1838 | \end_layout | ||
1839 | |||
1840 | \begin_layout LyX-Code | ||
1841 | process[2] :== [7,5,3]; | ||
1842 | \end_layout | ||
1843 | |||
1844 | \begin_layout LyX-Code | ||
1845 | process[3] :== [4,6]; | ||
1846 | \end_layout | ||
1847 | |||
1848 | \begin_layout LyX-Code | ||
1849 | FOR i in [1..3] CREATE | ||
1850 | \end_layout | ||
1851 | |||
1852 | \begin_layout LyX-Code | ||
1853 | FOR j IN process[i] CREATE | ||
1854 | \end_layout | ||
1855 | |||
1856 | \begin_layout LyX-Code | ||
1857 | flow[i][j] IS_A mass; | ||
1858 | \end_layout | ||
1859 | |||
1860 | \begin_layout LyX-Code | ||
1861 | END FOR; | ||
1862 | \end_layout | ||
1863 | |||
1864 | \begin_layout LyX-Code | ||
1865 | END FOR; | ||
1866 | \end_layout | ||
1867 | |||
1868 | \begin_layout Standard | ||
1869 | process is an array of sets (not to be confused with a set of sets which | ||
1870 | ASCEND does not have) and flow is an array with six elements spread over | ||
1871 | three rows: | ||
1872 | \end_layout | ||
1873 | |||
1874 | \begin_layout LyX-Code | ||
1875 | flow[1][2] | ||
1876 | \end_layout | ||
1877 | |||
1878 | \begin_layout LyX-Code | ||
1879 | flow[2][7], flow[2][3], flow[2][5] | ||
1880 | \end_layout | ||
1881 | |||
1882 | \begin_layout LyX-Code | ||
1883 | flow[3][4], flow[3][6] | ||
1884 | \end_layout | ||
1885 | |||
1886 | \end_deeper | ||
1887 | \begin_layout List | ||
1888 | \labelwidthstring 00000.00000.00000.000 | ||
1889 | Arrays\InsetSpace ~ | ||
1890 | are\InsetSpace ~ | ||
1891 | also\InsetSpace ~ | ||
1892 | instances | ||
1893 | \end_layout | ||
1894 | |||
1895 | \begin_deeper | ||
1896 | \begin_layout Standard | ||
1897 | Each array is itself an object. | ||
1898 | jpye | 1384 | That is, when you write |
1899 | \family typewriter | ||
1900 | a[1..2] IS_A real | ||
1901 | \family default | ||
1902 | , three objects get created: | ||
1903 | \family typewriter | ||
1904 | a[1] | ||
1905 | \family default | ||
1906 | , | ||
1907 | \family typewriter | ||
1908 | a[2] | ||
1909 | \family default | ||
1910 | , and | ||
1911 | \family typewriter | ||
1912 | a | ||
1913 | \family default | ||
1914 | . | ||
1915 | The object | ||
1916 | \family typewriter | ||
1917 | a | ||
1918 | \family default | ||
1919 | is an array instance which has parts named | ||
1920 | \family typewriter | ||
1921 | [1] | ||
1922 | \family default | ||
1923 | and | ||
1924 | \family typewriter | ||
1925 | [2] | ||
1926 | \family default | ||
1927 | that are real instances. | ||
1928 | johnpye | 828 | When a parameterized model requires an array, you pass it the single item |
1929 | jpye | 1384 | |
1930 | \family typewriter | ||
1931 | a | ||
1932 | \family default | ||
1933 | , not the elements | ||
1934 | \family typewriter | ||
1935 | a[1..2] | ||
1936 | \family default | ||
1937 | . | ||
1938 | johnpye | 828 | \end_layout |
1939 | |||
1940 | \end_deeper | ||
1941 | \begin_layout List | ||
1942 | \labelwidthstring 00000.00000.00000.000 | ||
1943 | No\InsetSpace ~ | ||
1944 | contiguous\InsetSpace ~ | ||
1945 | storage | ||
1946 | jpye | 1733 | \begin_inset LatexCommand index |
1947 | name "contiguous storage, no" | ||
1948 | johnpye | 828 | |
1949 | \end_inset | ||
1950 | |||
1951 | |||
1952 | \end_layout | ||
1953 | |||
1954 | \begin_deeper | ||
1955 | \begin_layout Standard | ||
1956 | Just in case you still have not caught on, ASCEND arrays are not blocks | ||
1957 | of memory such as are seen in low-level languages like C | ||
1958 | jpye | 1733 | \begin_inset LatexCommand index |
1959 | name "C, computer language" | ||
1960 | johnpye | 828 | |
1961 | \end_inset | ||
1962 | |||
1963 | , FORTRAN | ||
1964 | jpye | 1733 | \begin_inset LatexCommand index |
1965 | name "FORTRAN" | ||
1966 | johnpye | 828 | |
1967 | \end_inset | ||
1968 | |||
1969 | , and Matlab | ||
1970 | jpye | 1733 | \begin_inset LatexCommand index |
1971 | name "Matlab" | ||
1972 | johnpye | 828 | |
1973 | \end_inset | ||
1974 | |||
1975 | . | ||
1976 | The modeling language does not provide things like MatMult | ||
1977 | jpye | 1733 | \begin_inset LatexCommand index |
1978 | name "MatMult" | ||
1979 | johnpye | 828 | |
1980 | \end_inset | ||
1981 | |||
1982 | , Transpose | ||
1983 | jpye | 1733 | \begin_inset LatexCommand index |
1984 | name "Transpose" | ||
1985 | johnpye | 828 | |
1986 | \end_inset | ||
1987 | |||
1988 | , and Inverse | ||
1989 | jpye | 1733 | \begin_inset LatexCommand index |
1990 | name "Inverse" | ||
1991 | johnpye | 828 | |
1992 | \end_inset | ||
1993 | |||
1994 | because these are procedural solving tools. | ||
1995 | If you are dedicated, you could write METHODs that implement matrix algebra, | ||
1996 | but this is a really dumb idea. | ||
1997 | We aim to structure our software so that it can interact openly with separate, | ||
1998 | dedicated tools (such as Matlab) when those tools are needed. | ||
1999 | \end_layout | ||
2000 | |||
2001 | \end_deeper | ||
2002 | \begin_layout List | ||
2003 | \labelwidthstring 00000.00000.00000.000 | ||
2004 | Index\InsetSpace ~ | ||
2005 | variable | ||
2006 | jpye | 1733 | \begin_inset LatexCommand index |
2007 | name "index variable" | ||
2008 | johnpye | 828 | |
2009 | \end_inset | ||
2010 | |||
2011 | One can introduce a variable as an index ranging over a set. | ||
2012 | Index variables are local to the statements in which they occur. | ||
2013 | An example of using an index variable is the following FOR statement: | ||
2014 | \end_layout | ||
2015 | |||
2016 | \begin_deeper | ||
2017 | \begin_layout LyX-Code | ||
2018 | FOR i IN components CREATE | ||
2019 | \end_layout | ||
2020 | |||
2021 | \begin_layout LyX-Code | ||
2022 | VLE_equil[i]: y[i] = K[i]*x[i]; | ||
2023 | \end_layout | ||
2024 | |||
2025 | \begin_layout LyX-Code | ||
2026 | END FOR; | ||
2027 | \end_layout | ||
2028 | |||
2029 | \begin_layout Standard | ||
2030 | In this example i implicitly is of the same type as the values in the set | ||
2031 | components. | ||
2032 | If another object i exists in the model containing the FOR loop, it is | ||
2033 | ignored while executing the statements in that loop. | ||
2034 | This may cause unexpected results and the compiler will generate warnings | ||
2035 | about loop index shadowed variables. | ||
2036 | \end_layout | ||
2037 | |||
2038 | \end_deeper | ||
2039 | \begin_layout List | ||
2040 | \labelwidthstring 00000.00000.00000.000 | ||
2041 | Label | ||
2042 | jpye | 1733 | \begin_inset LatexCommand index |
2043 | name "label" | ||
2044 | johnpye | 828 | |
2045 | \end_inset | ||
2046 | |||
2047 | : One can label statements which define arithmetic relationships (objective | ||
2048 | functions, equalities, and inequalities) in ASCEND. | ||
2049 | Labeling is highly recommended because it makes models much more readable | ||
2050 | and more easily debugged. | ||
2051 | Labels are also necessary for relations which are going to be used in condition | ||
2052 | al modeling or differentiation functions. | ||
2053 | A label is a sequence of alphanumeric characters ending in a colon. | ||
2054 | An example of a labeled equation is: | ||
2055 | \end_layout | ||
2056 | |||
2057 | \begin_deeper | ||
2058 | \begin_layout LyX-Code | ||
2059 | mass_balance: m_in = m_out; | ||
2060 | \end_layout | ||
2061 | |||
2062 | \begin_layout Standard | ||
2063 | An example of a labeled objective function is: | ||
2064 | \end_layout | ||
2065 | |||
2066 | \begin_layout LyX-Code | ||
2067 | obj1: MAXIMIZE revenue - cost; | ||
2068 | \end_layout | ||
2069 | |||
2070 | \begin_layout Standard | ||
2071 | If a relation is defined within a FOR statement, it must have an array indexed | ||
2072 | label so that each instance created using the statement is distinguishable | ||
2073 | from the others. | ||
2074 | An example is: | ||
2075 | \end_layout | ||
2076 | |||
2077 | \begin_layout LyX-Code | ||
2078 | FOR i IN components CREATE | ||
2079 | \end_layout | ||
2080 | |||
2081 | \begin_layout LyX-Code | ||
2082 | equil[i]: y[i] = K[i]*x[i]; | ||
2083 | \end_layout | ||
2084 | |||
2085 | \begin_layout LyX-Code | ||
2086 | END FOR; | ||
2087 | \end_layout | ||
2088 | |||
2089 | \begin_layout Standard | ||
2090 | The ASCEND interactive user interface identifies relationships by their | ||
2091 | labels. | ||
2092 | If one has not provided such a label, the system generates the label: | ||
2093 | \end_layout | ||
2094 | |||
2095 | \begin_layout LyX-Code | ||
2096 | |||
2097 | \emph on | ||
2098 | modelname_equationnumber | ||
2099 | \end_layout | ||
2100 | |||
2101 | \begin_layout Standard | ||
2102 | where modelname and equationnumber are the name of the model and the equation | ||
2103 | number in the model. | ||
2104 | An example is | ||
2105 | \end_layout | ||
2106 | |||
2107 | \begin_layout LyX-Code | ||
2108 | mixture_14 | ||
2109 | \end_layout | ||
2110 | |||
2111 | \begin_layout Standard | ||
2112 | for the unlabeled 14th relation in the mixture definition. | ||
2113 | If there is a conflict caused with an existing name, the generated name | ||
2114 | has enough letters added after equationnumber to make it a unique name. | ||
2115 | Remember that each model in a refinement hierarchy inherits the equations | ||
2116 | of its less refined ancestors, so the first equation appearing in the source | ||
2117 | code of a refining model may actually be the nth relation in that model. | ||
2118 | \end_layout | ||
2119 | |||
2120 | \end_deeper | ||
2121 | \begin_layout List | ||
2122 | \labelwidthstring 00000.00000.00000.000 | ||
2123 | |||
2124 | \bar under | ||
2125 | Lists | ||
2126 | \bar default | ||
2127 | |||
2128 | jpye | 1733 | \begin_inset LatexCommand index |
2129 | name "lists" | ||
2130 | johnpye | 828 | |
2131 | \end_inset | ||
2132 | |||
2133 | Often in a statement one can include a list of names or expression. | ||
2134 | A name list is one or more names where multiple list entries are separated | ||
2135 | from each other by commas. | ||
2136 | Examples of a list of names are: | ||
2137 | \end_layout | ||
2138 | |||
2139 | \begin_deeper | ||
2140 | \begin_layout LyX-Code | ||
2141 | \align block | ||
2142 | T1, inlet_T, outlet_T | ||
2143 | \end_layout | ||
2144 | |||
2145 | \begin_layout LyX-Code | ||
2146 | \align block | ||
2147 | y[components], y_in | ||
2148 | \end_layout | ||
2149 | |||
2150 | \begin_layout LyX-Code | ||
2151 | \align block | ||
2152 | stage[1..n_stages] | ||
2153 | \end_layout | ||
2154 | |||
2155 | \end_deeper | ||
2156 | \begin_layout List | ||
2157 | \labelwidthstring 00000.00000.00000.000 | ||
2158 | |||
2159 | \bar under | ||
2160 | Ordered\InsetSpace ~ | ||
2161 | lists | ||
2162 | jpye | 1733 | \begin_inset LatexCommand index |
2163 | name "lists, ordered" | ||
2164 | johnpye | 828 | |
2165 | \end_inset | ||
2166 | |||
2167 | |||
2168 | jpye | 1733 | \begin_inset LatexCommand index |
2169 | name "ordered lists" | ||
2170 | johnpye | 828 | |
2171 | \end_inset | ||
2172 | |||
2173 | : | ||
2174 | \bar default | ||
2175 | If the ordering of names in a list matters, that list is enclosed in (). | ||
2176 | Order matters in: calling externally defined methods or models, calling | ||
2177 | most real-valued functions, passing parameters to ASCEND models or methods, | ||
2178 | and declaring the controlling parameters that SELECT, SWITCH, and WHEN | ||
2179 | statements make decisions on. | ||
2180 | \end_layout | ||
2181 | |||
2182 | \begin_deeper | ||
2183 | jpye | 1384 | \begin_layout Section |
2184 | johnpye | 828 | Basic Concepts |
2185 | \end_layout | ||
2186 | |||
2187 | \end_deeper | ||
2188 | \begin_layout List | ||
2189 | \labelwidthstring 00000.00000.00000.000 | ||
2190 | |||
2191 | \bar under | ||
2192 | Instances | ||
2193 | jpye | 1733 | \begin_inset LatexCommand index |
2194 | name "instances" | ||
2195 | johnpye | 828 | |
2196 | \end_inset | ||
2197 | |||
2198 | \InsetSpace ~ | ||
2199 | and\InsetSpace ~ | ||
2200 | types | ||
2201 | \bar default | ||
2202 | |||
2203 | jpye | 1733 | \begin_inset LatexCommand index |
2204 | name "types" | ||
2205 | johnpye | 828 | |
2206 | \end_inset | ||
2207 | |||
2208 | This is an opportune time to emphasize the distinction between the terms | ||
2209 | instance and type. | ||
2210 | A type in ASCEND is what we define when we declare an ASCEND model or atom. | ||
2211 | It is the formal definition of the attributes (parts) and attribute default | ||
2212 | values that an object will have if it is created using the type definition. | ||
2213 | Methods are associated with types. | ||
2214 | \end_layout | ||
2215 | |||
2216 | \begin_deeper | ||
2217 | \begin_layout Standard | ||
2218 | In ASCEND there are two meanings (closely related) of an instance. | ||
2219 | |||
2220 | \end_layout | ||
2221 | |||
2222 | \begin_layout Itemize | ||
2223 | An instance is a named part that exists within a type definition. | ||
2224 | |||
2225 | \end_layout | ||
2226 | |||
2227 | \begin_layout Itemize | ||
2228 | An instance is a compiled object. | ||
2229 | |||
2230 | \end_layout | ||
2231 | |||
2232 | \begin_layout Standard | ||
2233 | If one is in the context of the ASCEND interface, the system compiles an | ||
2234 | instance of a model type to create an object with which one carries out | ||
2235 | computations. | ||
2236 | The system requires the user to give a simple name for this simulation | ||
2237 | instance. | ||
2238 | This name given is then the first part of the qualified name for all the | ||
2239 | parts of the compiled object. | ||
2240 | \end_layout | ||
2241 | |||
2242 | \end_deeper | ||
2243 | \begin_layout List | ||
2244 | \labelwidthstring 00000.00000.00000.000 | ||
2245 | |||
2246 | \bar under | ||
2247 | Implicit\InsetSpace ~ | ||
2248 | types | ||
2249 | \bar default | ||
2250 | |||
2251 | jpye | 1733 | \begin_inset LatexCommand index |
2252 | name "types, implicit" | ||
2253 | johnpye | 828 | |
2254 | \end_inset | ||
2255 | |||
2256 | |||
2257 | jpye | 1733 | \begin_inset LatexCommand index |
2258 | name "types, implicit" | ||
2259 | johnpye | 828 | |
2260 | \end_inset | ||
2261 | |||
2262 | It is possible to create an instance that does not have a corresponding | ||
2263 | type definition in the library. | ||
2264 | jpye | 1384 | The type of such an instance is said to be |
2265 | \series bold | ||
2266 | implicit | ||
2267 | \series default | ||
2268 | |||
2269 | \begin_inset Foot | ||
2270 | status collapsed | ||
2271 | |||
2272 | \begin_layout Standard | ||
2273 | (Some people use the word | ||
2274 | \emph on | ||
2275 | anonymous | ||
2276 | \emph default | ||
2277 | |||
2278 | jpye | 1733 | \begin_inset LatexCommand index |
2279 | name "type, anonymous" | ||
2280 | johnpye | 828 | |
2281 | \end_inset | ||
2282 | |||
2283 | |||
2284 | jpye | 1733 | \begin_inset LatexCommand index |
2285 | name "anonymous type" | ||
2286 | johnpye | 828 | |
2287 | \end_inset | ||
2288 | |||
2289 | . | ||
2290 | However, no computable type is anonymous and the implicit type of an instance | ||
2291 | jpye | 1384 | is theoretically computable) |
2292 | \end_layout | ||
2293 | |||
2294 | \end_inset | ||
2295 | |||
2296 | . | ||
2297 | johnpye | 828 | The simplest example of an implicit type is the type of an instance compiled |
2298 | jpye | 1384 | from the built-in definition |
2299 | \family sans | ||
2300 | integer_constant | ||
2301 | \family default | ||
2302 | . | ||
2303 | johnpye | 828 | For example: |
2304 | \end_layout | ||
2305 | |||
2306 | \begin_deeper | ||
2307 | \begin_layout LyX-Code | ||
2308 | i, j IS_A integer_constant; | ||
2309 | \end_layout | ||
2310 | |||
2311 | \begin_layout LyX-Code | ||
2312 | i:== 2; | ||
2313 | \end_layout | ||
2314 | |||
2315 | \begin_layout LyX-Code | ||
2316 | j:== 3; | ||
2317 | \end_layout | ||
2318 | |||
2319 | \begin_layout Standard | ||
2320 | jpye | 1384 | Instances |
2321 | \family typewriter | ||
2322 | i | ||
2323 | \family default | ||
2324 | and | ||
2325 | \family typewriter | ||
2326 | j | ||
2327 | \family default | ||
2328 | , though of the same formal type, are implicit type incompatible because | ||
2329 | they have been assigned distinct values. | ||
2330 | johnpye | 828 | \end_layout |
2331 | |||
2332 | \begin_layout Standard | ||
2333 | Instances which are either formally or implicitly type incompatible cannot | ||
2334 | be merged. | ||
2335 | This will be discussed further in Section | ||
2336 | jpye | 1733 | \begin_inset LatexCommand vref |
2337 | reference "sec:x.3Declarative-statements" | ||
2338 | johnpye | 828 | |
2339 | \end_inset | ||
2340 | |||
2341 | . | ||
2342 | \end_layout | ||
2343 | |||
2344 | \end_deeper | ||
2345 | \begin_layout List | ||
2346 | \labelwidthstring 00000.00000.00000.000 | ||
2347 | Parsing | ||
2348 | jpye | 1733 | \begin_inset LatexCommand index |
2349 | name "parsing" | ||
2350 | johnpye | 828 | |
2351 | \end_inset | ||
2352 | |||
2353 | Most errors in the declaration of an ASCEND model can be caught at parse | ||
2354 | time because the object type of any well-formed name in an ASCEND definition | ||
2355 | can be resolved or proved ambiguous. | ||
2356 | We cannot prove at parse time whether a specific array element will exist, | ||
2357 | but we can know that should such an element exist, it must be of the type | ||
2358 | with which the array is defined. | ||
2359 | |||
2360 | \end_layout | ||
2361 | |||
2362 | \begin_deeper | ||
2363 | \begin_layout Standard | ||
2364 | Ambiguity is warned about loudly because it is caused by either misspelling | ||
2365 | or poor modeling style. | ||
2366 | The simplest example of ambiguity follows. | ||
2367 | \end_layout | ||
2368 | |||
2369 | \begin_layout Standard | ||
2370 | Assume a type, stream, and a refinement of stream, heat_stream, which adds | ||
2371 | jpye | 1384 | the new variable |
2372 | \family typewriter | ||
2373 | H | ||
2374 | \family default | ||
2375 | . | ||
2376 | johnpye | 828 | Now, if we write: |
2377 | \end_layout | ||
2378 | |||
2379 | \begin_layout LyX-Code | ||
2380 | MODEL mixer; | ||
2381 | \end_layout | ||
2382 | |||
2383 | \begin_layout LyX-Code | ||
2384 | input[1..2] IS_A stream; | ||
2385 | \end_layout | ||
2386 | |||
2387 | \begin_layout LyX-Code | ||
2388 | output IS_A heat_stream; | ||
2389 | \end_layout | ||
2390 | |||
2391 | \begin_layout LyX-Code | ||
2392 | input[1].H + input[2].H = output.H; | ||
2393 | \end_layout | ||
2394 | |||
2395 | \begin_layout LyX-Code | ||
2396 | END mixer; | ||
2397 | \end_layout | ||
2398 | |||
2399 | \begin_layout Standard | ||
2400 | We see the parser can find the definition of H in the type heat_stream, | ||
2401 | jpye | 1384 | so |
2402 | \family typewriter | ||
2403 | output.H | ||
2404 | \family default | ||
2405 | is well defined. | ||
2406 | The author of the mixer model may intend to refine | ||
2407 | \family typewriter | ||
2408 | input[1] | ||
2409 | \family default | ||
2410 | and | ||
2411 | \family typewriter | ||
2412 | input[2] | ||
2413 | \family default | ||
2414 | johnpye | 828 | to be objects of different types, say steam_stream and electric_stream, |
2415 | jpye | 1384 | where each defines an |
2416 | \family typewriter | ||
2417 | H | ||
2418 | \family default | ||
2419 | suitable for use in the equation. | ||
2420 | The parser cannot read the authors mind, so it warns that | ||
2421 | \family typewriter | ||
2422 | input[1].H | ||
2423 | \family default | ||
2424 | and | ||
2425 | \family typewriter | ||
2426 | input[2].H | ||
2427 | \family default | ||
2428 | are ambiguous in the mixer definition. | ||
2429 | johnpye | 828 | The mixer model is not highly reusable except by the author, but sometimes |
2430 | reusability is not a high priority objective. | ||
2431 | The mixer definition is allowed, but it may cause problems in instantiation | ||
2432 | if the author has forgotten the assumption that is not explicitly stated | ||
2433 | in the model and neglects to refine the input streams appropriately. | ||
2434 | \end_layout | ||
2435 | |||
2436 | \end_deeper | ||
2437 | \begin_layout List | ||
2438 | \labelwidthstring 00000.00000.00000.000 | ||
2439 | |||
2440 | \bar under | ||
2441 | Instantiation | ||
2442 | \bar default | ||
2443 | |||
2444 | jpye | 1733 | \begin_inset LatexCommand index |
2445 | name "instantiation" | ||
2446 | johnpye | 828 | |
2447 | \end_inset | ||
2448 | |||
2449 | Creating an simulation based on a type definition is a multi-phase | ||
2450 | jpye | 1733 | \begin_inset LatexCommand index |
2451 | name "multi-phase" | ||
2452 | johnpye | 828 | |
2453 | \end_inset | ||
2454 | |||
2455 | process called compiling | ||
2456 | jpye | 1733 | \begin_inset LatexCommand index |
2457 | name "compiling" | ||
2458 | johnpye | 828 | |
2459 | \end_inset | ||
2460 | |||
2461 | (or instantiation). | ||
2462 | When an instantiation cannot be completed because some structural parameter | ||
2463 | (a symbol_constant, real_constant, boolean_constant, integer_constant, | ||
2464 | or set) does not have a value there will be PENDING | ||
2465 | jpye | 1733 | \begin_inset LatexCommand index |
2466 | name "PENDING" | ||
2467 | johnpye | 828 | |
2468 | \end_inset | ||
2469 | |||
2470 | statements. | ||
2471 | The user interface will warn that something is incomplete. | ||
2472 | \end_layout | ||
2473 | |||
2474 | \begin_deeper | ||
2475 | \begin_layout Standard | ||
2476 | In phase | ||
2477 | jpye | 1733 | \begin_inset LatexCommand index |
2478 | name "phases, compiler" | ||
2479 | johnpye | 828 | |
2480 | \end_inset | ||
2481 | |||
2482 | 1 all statements that create instance structures or assign constant values | ||
2483 | are executed. | ||
2484 | This phase theoretically requires an infinite number of passes through | ||
2485 | the structural statements of a definition. | ||
2486 | We allow a maximum of 5 and have never needed more than 3. | ||
2487 | There may be pending statements at the end of phase 1. | ||
2488 | The compiler or interface will issue warnings about pending statements, | ||
2489 | starting with warnings about unassigned constants. | ||
2490 | \end_layout | ||
2491 | |||
2492 | \begin_layout Standard | ||
2493 | Phase 2 compiles as many real arithmetic relation definitions as possible. | ||
2494 | Some relations may be impossible to compile because the constants or sets | ||
2495 | they depend on do not have values assigned. | ||
2496 | Other relations may be impossible because they reference variables that | ||
2497 | do not exist. | ||
2498 | This is determined in a single pass. | ||
2499 | \end_layout | ||
2500 | |||
2501 | \begin_layout Standard | ||
2502 | Phase 3 compiles as many logical arithmetic relation definitions as possible. | ||
2503 | Some relations may be impossible to compile because the constants or sets | ||
2504 | they depend on do not have values assigned. | ||
2505 | Other relations may be impossible because they reference real arithmetic | ||
2506 | relations that do not exist. | ||
2507 | This is determined in a single pass. | ||
2508 | \end_layout | ||
2509 | |||
2510 | \begin_layout Standard | ||
2511 | jpye | 1384 | Phase 4 compiles as many conditional programming statements ( |
2512 | \family sans | ||
2513 | WHEN | ||
2514 | \family default | ||
2515 | s) as possible. | ||
2516 | Some | ||
2517 | \family sans | ||
2518 | WHEN | ||
2519 | \family default | ||
2520 | relations may be impossible to compile because the discrete variables, | ||
2521 | models, or relations they depend on do not exist. | ||
2522 | johnpye | 828 | This is determined in a single pass. |
2523 | \end_layout | ||
2524 | |||
2525 | \begin_layout Standard | ||
2526 | Phase 5 executes the variable defaulting statements made in the declarative | ||
2527 | jpye | 1384 | section of each model |
2528 | \emph on | ||
2529 | if and only if | ||
2530 | \emph default | ||
2531 | there are no pending statements from phases 1-4 anywhere in the simulation. | ||
2532 | johnpye | 828 | \end_layout |
2533 | |||
2534 | \end_deeper | ||
2535 | \begin_layout List | ||
2536 | \labelwidthstring 00000.00000.00000.000 | ||
2537 | default_self | ||
2538 | jpye | 1733 | \begin_inset LatexCommand index |
2539 | name "default\\_self" | ||
2540 | johnpye | 828 | |
2541 | \end_inset | ||
2542 | |||
2543 | After all phases are done, the method default_self is called in the top-most | ||
2544 | model of the simulation, if this method exists. | ||
2545 | \end_layout | ||
2546 | |||
2547 | \begin_deeper | ||
2548 | \begin_layout Standard | ||
2549 | The first occurrence of each impossible statement will be explained during | ||
2550 | a failed compilation. | ||
2551 | Impossible statements include: | ||
2552 | \end_layout | ||
2553 | |||
2554 | \begin_layout Itemize | ||
2555 | Relations containing undefinable variables (often misspellings). | ||
2556 | \end_layout | ||
2557 | |||
2558 | \begin_layout Itemize | ||
2559 | Assignments that are dimensionally inconsistent or containing mismatched | ||
2560 | types. | ||
2561 | \end_layout | ||
2562 | |||
2563 | \begin_layout Itemize | ||
2564 | Structure building or modifying statements that refer to model parts which | ||
2565 | cannot exist or that require a type-incompatible argument, refinement, | ||
2566 | or merge. | ||
2567 | \end_layout | ||
2568 | |||
2569 | jpye | 1384 | \begin_layout Chapter |
2570 | johnpye | 828 | Data Type Declarations |
2571 | jpye | 1733 | \begin_inset LatexCommand index |
2572 | name "data type declarations" | ||
2573 | johnpye | 828 | |
2574 | \end_inset | ||
2575 | |||
2576 | |||
2577 | \end_layout | ||
2578 | |||
2579 | \begin_layout Standard | ||
2580 | In the spectrum of OO languages, ASCEND is best considered as being class-based | ||
2581 | jpye | 1733 | \begin_inset LatexCommand index |
2582 | name "class-based" | ||
2583 | johnpye | 828 | |
2584 | \end_inset | ||
2585 | |||
2586 | , though it is rather more a hybrid. | ||
2587 | jpye | 1384 | We have atom and model definitions, called |
2588 | \series bold | ||
2589 | types | ||
2590 | \series default | ||
2591 | , and the compiled objects themselves, called | ||
2592 | \series bold | ||
2593 | instances | ||
2594 | \series default | ||
2595 | . | ||
2596 | johnpye | 828 | ASCEND instances have a record of what type they were constructed from. |
2597 | \end_layout | ||
2598 | |||
2599 | \end_deeper | ||
2600 | \begin_layout List | ||
2601 | \labelwidthstring 00000.00000.00000.000 | ||
2602 | |||
2603 | \bar under | ||
2604 | Type\InsetSpace ~ | ||
2605 | qualifiers | ||
2606 | jpye | 1733 | \begin_inset LatexCommand index |
2607 | name "type qualifiers" | ||
2608 | johnpye | 828 | |
2609 | \end_inset | ||
2610 | |||
2611 | : | ||
2612 | \end_layout | ||
2613 | |||
2614 | \begin_layout List | ||
2615 | \labelwidthstring 00000.00000.00000.000 | ||
2616 | jpye | 1384 | |
2617 | \family sans | ||
2618 | johnpye | 828 | UNIVERSAL |
2619 | jpye | 1384 | \family default |
2620 | |||
2621 | jpye | 1733 | \begin_inset LatexCommand index |
2622 | name "UNIVERSAL" | ||
2623 | johnpye | 828 | |
2624 | \end_inset | ||
2625 | |||
2626 | jpye | 1384 | Universal is an optional modifier of all |
2627 | \family sans | ||
2628 | ATOM | ||
2629 | \family default | ||
2630 | , | ||
2631 | \family sans | ||
2632 | CONSTANT | ||
2633 | \family default | ||
2634 | and | ||
2635 | \family sans | ||
2636 | MODEL | ||
2637 | \family default | ||
2638 | definitions. | ||
2639 | If | ||
2640 | \family sans | ||
2641 | UNIVERSAL | ||
2642 | \family default | ||
2643 | precedes the definition, then | ||
2644 | \emph on | ||
2645 | all | ||
2646 | \emph default | ||
2647 | instances of that type will actually refer to the first instance of the | ||
2648 | type that is created. | ||
2649 | johnpye | 828 | This saves memory and ensures global consistency of data. |
2650 | |||
2651 | \end_layout | ||
2652 | |||
2653 | \begin_deeper | ||
2654 | \begin_layout Standard | ||
2655 | Examples of universal type definitions are | ||
2656 | \end_layout | ||
2657 | |||
2658 | \begin_layout LyX-Code | ||
2659 | UNIVERSAL MODEL methane | ||
2660 | \end_layout | ||
2661 | |||
2662 | \begin_layout LyX-Code | ||
2663 | REFINES generic_component_model; | ||
2664 | \end_layout | ||
2665 | |||
2666 | \begin_layout LyX-Code | ||
2667 | UNIVERSAL CONSTANT circle_constant | ||
2668 | \end_layout | ||
2669 | |||
2670 | \begin_layout LyX-Code | ||
2671 | REFINES real_constant :== 1{PI}; | ||
2672 | \end_layout | ||
2673 | |||
2674 | \begin_layout LyX-Code | ||
2675 | UNIVERSAL ATOM counter_1 | ||
2676 | \end_layout | ||
2677 | |||
2678 | \begin_layout LyX-Code | ||
2679 | REFINES integer; | ||
2680 | \end_layout | ||
2681 | |||
2682 | \end_deeper | ||
2683 | \begin_layout List | ||
2684 | \labelwidthstring 00000.00000.00000.000 | ||
2685 | Tip:\InsetSpace ~ | ||
2686 | Do\InsetSpace ~ | ||
2687 | not\InsetSpace ~ | ||
2688 | use\InsetSpace ~ | ||
2689 | jpye | 1384 | |
2690 | \family sans | ||
2691 | UNIVERSAL | ||
2692 | \family default | ||
2693 | \InsetSpace ~ | ||
2694 | johnpye | 828 | variables\InsetSpace ~ |
2695 | in\InsetSpace ~ | ||
2696 | relations. | ||
2697 | \end_layout | ||
2698 | |||
2699 | \begin_deeper | ||
2700 | \begin_layout Standard | ||
2701 | jpye | 1384 | It is important to note that, because |
2702 | \emph on | ||
2703 | variables | ||
2704 | \emph default | ||
2705 | must store information about which relations they occur in, it is a very | ||
2706 | bad idea to use | ||
2707 | \family sans | ||
2708 | UNIVERSAL | ||
2709 | \family default | ||
2710 | typed variables in relations. | ||
2711 | johnpye | 828 | The construction and maintenance of the relation list becomes very expensive |
2712 | for universal variables. | ||
2713 | jpye | 1384 | |
2714 | \family sans | ||
2715 | UNIVERSAL | ||
2716 | \family default | ||
2717 | |||
2718 | \emph on | ||
2719 | constants | ||
2720 | \emph default | ||
2721 | are fine to use, though, because there are no relation links for constants. | ||
2722 | johnpye | 828 | \end_layout |
2723 | |||
2724 | jpye | 1384 | \begin_layout Section |
2725 | johnpye | 828 | Models |
2726 | \end_layout | ||
2727 | |||
2728 | \end_deeper | ||
2729 | \begin_layout List | ||
2730 | \labelwidthstring 00000.00000.00000.000 | ||
2731 | jpye | 1384 | |
2732 | \family sans | ||
2733 | johnpye | 828 | MODEL |
2734 | jpye | 1384 | \family default |
2735 | |||
2736 | jpye | 1733 | \begin_inset LatexCommand index |
2737 | name "MODEL" | ||
2738 | johnpye | 828 | |
2739 | \end_inset | ||
2740 | |||
2741 | An ASCEND model has a declarative part and an optional procedural part | ||
2742 | headed by the METHODS word. | ||
2743 | Models are essentially containers for variables and relations. | ||
2744 | We will explain the various statements that can be made within models in | ||
2745 | Section | ||
2746 | jpye | 1733 | \begin_inset LatexCommand vref |
2747 | reference "sec:x.3Declarative-statements" | ||
2748 | johnpye | 828 | |
2749 | \end_inset | ||
2750 | |||
2751 | and Section | ||
2752 | jpye | 1733 | \begin_inset LatexCommand vref |
2753 | reference "sec:x.4Procedural-statements" | ||
2754 | johnpye | 828 | |
2755 | \end_inset | ||
2756 | |||
2757 | . | ||
2758 | \end_layout | ||
2759 | |||
2760 | \begin_layout Standard | ||
2761 | Simple\InsetSpace ~ | ||
2762 | models | ||
2763 | jpye | 1733 | \begin_inset LatexCommand index |
2764 | name "models, simple" | ||
2765 | johnpye | 828 | |
2766 | \end_inset | ||
2767 | |||
2768 | : | ||
2769 | \end_layout | ||
2770 | |||
2771 | \begin_layout List | ||
2772 | \labelwidthstring 00000.00000.00000.000 | ||
2773 | foo | ||
2774 | \family typewriter | ||
2775 | \InsetSpace ~ | ||
2776 | \InsetSpace ~ | ||
2777 | \InsetSpace ~ | ||
2778 | \InsetSpace ~ | ||
2779 | MODEL foo; | ||
2780 | \end_layout | ||
2781 | |||
2782 | \begin_deeper | ||
2783 | \begin_layout LyX-Code | ||
2784 | (* statements about foo go here*) | ||
2785 | \end_layout | ||
2786 | |||
2787 | \begin_layout LyX-Code | ||
2788 | METHODS | ||
2789 | \end_layout | ||
2790 | |||
2791 | \begin_layout LyX-Code | ||
2792 | (* METHODs for foo go here*) | ||
2793 | \end_layout | ||
2794 | |||
2795 | \begin_layout LyX-Code | ||
2796 | END foo; | ||
2797 | \end_layout | ||
2798 | |||
2799 | \end_deeper | ||
2800 | \begin_layout List | ||
2801 | \labelwidthstring 00000.00000.00000.000 | ||
2802 | bar | ||
2803 | \family typewriter | ||
2804 | \InsetSpace ~ | ||
2805 | \InsetSpace ~ | ||
2806 | \InsetSpace ~ | ||
2807 | \InsetSpace ~ | ||
2808 | MODEL bar REFINES foo; | ||
2809 | \end_layout | ||
2810 | |||
2811 | \begin_deeper | ||
2812 | \begin_layout LyX-Code | ||
2813 | (*additional statements about foo *) | ||
2814 | \end_layout | ||
2815 | |||
2816 | \begin_layout LyX-Code | ||
2817 | METHODS | ||
2818 | \end_layout | ||
2819 | |||
2820 | \begin_layout LyX-Code | ||
2821 | (* additional METHODs for bar *) | ||
2822 | \end_layout | ||
2823 | |||
2824 | \begin_layout LyX-Code | ||
2825 | END bar; | ||
2826 | \end_layout | ||
2827 | |||
2828 | \end_deeper | ||
2829 | \begin_layout List | ||
2830 | \labelwidthstring 00000.00000.00000.000 | ||
2831 | |||
2832 | \bar under | ||
2833 | Parameterized\InsetSpace ~ | ||
2834 | Models | ||
2835 | \bar default | ||
2836 | |||
2837 | jpye | 1733 | \begin_inset LatexCommand index |
2838 | name "models, parameterized" | ||
2839 | johnpye | 828 | |
2840 | \end_inset | ||
2841 | |||
2842 | jpye | 1384 | Parameterizing models makes them easier to understand and faster for the |
2843 | system to compile. | ||
2844 | johnpye | 828 | The syntax for a parameterized model vaguely resembles a function call |
2845 | in imperative languages, but it is NOT. | ||
2846 | When constructing a reusable model, all the constants that determine the | ||
2847 | sizes of arrays and other structures should be declared in the parameter | ||
2848 | list so that | ||
2849 | \end_layout | ||
2850 | |||
2851 | \begin_deeper | ||
2852 | \begin_layout Itemize | ||
2853 | the user knows what is required to reuse the model. | ||
2854 | \end_layout | ||
2855 | |||
2856 | \begin_layout Itemize | ||
2857 | the compiler knows what values must be set before it should bother attempting | ||
2858 | to compile the model. | ||
2859 | \end_layout | ||
2860 | |||
2861 | \begin_layout Standard | ||
2862 | There is no reason that other items could not also go in the parameter list, | ||
2863 | such as key variables which might be considered inputs or outputs or control | ||
2864 | parameters in the mathematical application of the model. | ||
2865 | A simple example of parameterization would be: | ||
2866 | \end_layout | ||
2867 | |||
2868 | \end_deeper | ||
2869 | \begin_layout List | ||
2870 | \labelwidthstring 00000.00000.00000.000 | ||
2871 | column(n,s) | ||
2872 | \end_layout | ||
2873 | |||
2874 | \begin_deeper | ||
2875 | \begin_layout LyX-Code | ||
2876 | MODEL column( | ||
2877 | \end_layout | ||
2878 | |||
2879 | \begin_layout LyX-Code | ||
2880 | ntrays WILL_BE integer_constant; | ||
2881 | \end_layout | ||
2882 | |||
2883 | \begin_layout LyX-Code | ||
2884 | components IS_A set of symbol_constant; | ||
2885 | \end_layout | ||
2886 | |||
2887 | \begin_layout LyX-Code | ||
2888 | ); | ||
2889 | \end_layout | ||
2890 | |||
2891 | \begin_layout LyX-Code | ||
2892 | stage[1..ntrays] IS_A simple_tray; | ||
2893 | \end_layout | ||
2894 | |||
2895 | \begin_layout LyX-Code | ||
2896 | END column; | ||
2897 | \end_layout | ||
2898 | |||
2899 | \end_deeper | ||
2900 | \begin_layout List | ||
2901 | \labelwidthstring 00000.00000.00000.000 | ||
2902 | flowsheet | ||
2903 | \end_layout | ||
2904 | |||
2905 | \begin_deeper | ||
2906 | \begin_layout LyX-Code | ||
2907 | MODEL flowsheet; | ||
2908 | \end_layout | ||
2909 | |||
2910 | \begin_layout LyX-Code | ||
2911 | tower4size IS_A integer_constant; | ||
2912 | \end_layout | ||
2913 | |||
2914 | \begin_layout LyX-Code | ||
2915 | tower4size :== 22; | ||
2916 | \end_layout | ||
2917 | |||
2918 | \begin_layout LyX-Code | ||
2919 | ct IS_A column(tower4size,[c5,c6]); | ||
2920 | \end_layout | ||
2921 | |||
2922 | \begin_layout LyX-Code | ||
2923 | (* additional flowsheet statements *) | ||
2924 | \end_layout | ||
2925 | |||
2926 | \begin_layout LyX-Code | ||
2927 | END flowsheet; | ||
2928 | \end_layout | ||
2929 | |||
2930 | \begin_layout Standard | ||
2931 | In this example, the column model takes the first argument, ntrays, by reference. | ||
2932 | jpye | 1733 | That is, |
2933 | jpye | 1384 | \family typewriter |
2934 | jpye | 1733 | ct.ntrays |
2935 | jpye | 1384 | \family default |
2936 | is an alias for the flowsheet instance | ||
2937 | \family typewriter | ||
2938 | tower4size | ||
2939 | \family default | ||
2940 | . | ||
2941 | johnpye | 828 | |
2942 | jpye | 1384 | \family typewriter |
2943 | tower4size | ||
2944 | \family default | ||
2945 | must be compiled and assigned a value before we will attempt to compile | ||
2946 | the column model instance | ||
2947 | \family typewriter | ||
2948 | ct | ||
2949 | \family default | ||
2950 | . | ||
2951 | The second argument is taken by value, | ||
2952 | \family typewriter | ||
2953 | [c5,c6] | ||
2954 | \family default | ||
2955 | , and assigned to components, a column part that was declared with | ||
2956 | \family sans | ||
2957 | IS_A | ||
2958 | \family default | ||
2959 | in the parameter list. | ||
2960 | There is only one name for this set, | ||
2961 | \family typewriter | ||
2962 | ct.components | ||
2963 | \family default | ||
2964 | . | ||
2965 | Note that in the | ||
2966 | \family typewriter | ||
2967 | flowsheet | ||
2968 | \family default | ||
2969 | model there is no part that is a set of | ||
2970 | \family sans | ||
2971 | symbol_constant | ||
2972 | \family default | ||
2973 | . | ||
2974 | |||
2975 | johnpye | 828 | \end_layout |
2976 | |||
2977 | \begin_layout Standard | ||
2978 | The use of parameters in ASCEND modeling requires some thought, and we will | ||
2979 | present that set of thoughts in Section | ||
2980 | jpye | 1733 | \begin_inset LatexCommand vref |
2981 | reference "sec:x.5Parameterized-models" | ||
2982 | johnpye | 828 | |
2983 | \end_inset | ||
2984 | |||
2985 | . | ||
2986 | Beginners may wish to create new models without parameters until they are | ||
2987 | comfortable using the existing parameterized library definitions. | ||
2988 | Parameters are intended to support model reuse and efficient compilation | ||
2989 | which are not issues in the very earliest phase of developing novel models. | ||
2990 | \end_layout | ||
2991 | |||
2992 | jpye | 1384 | \begin_layout Section |
2993 | johnpye | 828 | Sets |
2994 | jpye | 1733 | \begin_inset LatexCommand index |
2995 | name "sets" | ||
2996 | johnpye | 828 | |
2997 | \end_inset | ||
2998 | |||
2999 | |||
3000 | jpye | 1733 | \begin_inset LatexCommand label |
3001 | name "sub:x.2.2Sets" | ||
3002 | johnpye | 828 | |
3003 | \end_inset | ||
3004 | |||
3005 | |||
3006 | \end_layout | ||
3007 | |||
3008 | \begin_layout Standard | ||
3009 | Arrays in ASCEND, as already discussed in Section | ||
3010 | jpye | 1733 | \begin_inset LatexCommand vref |
3011 | reference "sub:x.1.2Basic-Elements" | ||
3012 | johnpye | 828 | |
3013 | \end_inset | ||
3014 | |||
3015 | , are defined over sets. | ||
3016 | A set is simply an instance with a set value. | ||
3017 | jpye | 1384 | The elements of sets are |
3018 | \emph on | ||
3019 | not | ||
3020 | \emph default | ||
3021 | instances or sets. | ||
3022 | johnpye | 828 | \end_layout |
3023 | |||
3024 | \end_deeper | ||
3025 | \begin_layout List | ||
3026 | \labelwidthstring 00000.00000.00000.000 | ||
3027 | |||
3028 | \bar under | ||
3029 | Set\InsetSpace ~ | ||
3030 | Declaration: | ||
3031 | \bar default | ||
3032 | A set is made of either symbol_constants or integer_constants, so a set | ||
3033 | object is declared in one of two ways: | ||
3034 | \end_layout | ||
3035 | |||
3036 | \begin_deeper | ||
3037 | \begin_layout LyX-Code | ||
3038 | my_integer_set IS_A set OF integer_constant; | ||
3039 | \end_layout | ||
3040 | |||
3041 | \begin_layout Standard | ||
3042 | or | ||
3043 | \end_layout | ||
3044 | |||
3045 | \begin_layout LyX-Code | ||
3046 | my_symbol_set IS_A set OF symbol_constant; | ||
3047 | \end_layout | ||
3048 | |||
3049 | \end_deeper | ||
3050 | \begin_layout List | ||
3051 | \labelwidthstring 00000.00000.00000.000 | ||
3052 | jpye | 1384 | |
3053 | \family typewriter | ||
3054 | johnpye | 828 | :== |
3055 | jpye | 1384 | \family default |
3056 | |||
3057 | jpye | 1733 | \begin_inset LatexCommand index |
3058 | name ":==" | ||
3059 | johnpye | 828 | |
3060 | \end_inset | ||
3061 | |||
3062 | A set is assigned a value like so: | ||
3063 | \end_layout | ||
3064 | |||
3065 | \begin_deeper | ||
3066 | \begin_layout LyX-Code | ||
3067 | my_integer_set :== [1,4]; | ||
3068 | \end_layout | ||
3069 | |||
3070 | \begin_layout Standard | ||
3071 | The RHS of such an assignment must be either the name of another set instance | ||
3072 | or an expression enclosed in square brackets and made up of only set operators, | ||
3073 | other sets, and the names of integer_constants or symbol_constants. | ||
3074 | Sets can only be assigned once. | ||
3075 | \end_layout | ||
3076 | |||
3077 | \end_deeper | ||
3078 | \begin_layout List | ||
3079 | \labelwidthstring 00000.00000.00000.000 | ||
3080 | |||
3081 | \bar under | ||
3082 | Set\InsetSpace ~ | ||
3083 | Operations | ||
3084 | \bar default | ||
3085 | jpye | 1384 | |
3086 | \family sans | ||
3087 | UNION | ||
3088 | \family default | ||
3089 | |||
3090 | jpye | 1733 | \begin_inset LatexCommand index |
3091 | name "UNION" | ||
3092 | johnpye | 828 | |
3093 | \end_inset | ||
3094 | |||
3095 | jpye | 1384 | |
3096 | \family typewriter | ||
3097 | johnpye | 828 | [setlist] |
3098 | \end_layout | ||
3099 | |||
3100 | \begin_deeper | ||
3101 | \begin_layout Standard | ||
3102 | A function taken over a list of sets. | ||
3103 | The result is the set that includes all the members of all the sets in | ||
3104 | the list. | ||
3105 | jpye | 1384 | Note that the result of the |
3106 | \family sans | ||
3107 | UNION | ||
3108 | \family default | ||
3109 | operation is an unordered set and the argument order to the union function | ||
3110 | does not matter. | ||
3111 | johnpye | 828 | The syntax is: |
3112 | \end_layout | ||
3113 | |||
3114 | \end_deeper | ||
3115 | \begin_layout List | ||
3116 | \labelwidthstring 00000.00000.00000.000 | ||
3117 | + | ||
3118 | jpye | 1733 | \begin_inset LatexCommand index |
3119 | name "+, sets" | ||
3120 | johnpye | 828 | |
3121 | \end_inset | ||
3122 | |||
3123 | jpye | 1384 | |
3124 | \family typewriter | ||
3125 | UNION[list_of_sets] | ||
3126 | johnpye | 828 | \end_layout |
3127 | |||
3128 | \begin_layout List | ||
3129 | \labelwidthstring 00000.00000.00000.000 | ||
3130 | jpye | 1384 | |
3131 | \family typewriter | ||
3132 | A+B | ||
3133 | \family default | ||
3134 | \InsetSpace ~ | ||
3135 | johnpye | 828 | is\InsetSpace ~ |
3136 | shorthand\InsetSpace ~ | ||
3137 | jpye | 1384 | for |
3138 | \family typewriter | ||
3139 | UNION[A,B] | ||
3140 | johnpye | 828 | \end_layout |
3141 | |||
3142 | \begin_deeper | ||
3143 | \begin_layout Standard | ||
3144 | Consider the following sets for the examples to follow. | ||
3145 | \end_layout | ||
3146 | |||
3147 | \begin_layout LyX-Code | ||
3148 | A := [1, 2, 3, 5, 9]; | ||
3149 | \end_layout | ||
3150 | |||
3151 | \begin_layout LyX-Code | ||
3152 | B := [2, 4, 6, 8]; | ||
3153 | \end_layout | ||
3154 | |||
3155 | \begin_layout Standard | ||
3156 | jpye | 1384 | Then |
3157 | \family typewriter | ||
3158 | UNION[A, B] | ||
3159 | \family default | ||
3160 | is equal to the set | ||
3161 | \family typewriter | ||
3162 | [1, 2, 3, 4, 5, 6, 8, 9] | ||
3163 | \family default | ||
3164 | which equals | ||
3165 | \family typewriter | ||
3166 | [1..6, 8, 9] | ||
3167 | \family default | ||
3168 | which equals | ||
3169 | \family typewriter | ||
3170 | [[1..9] - [7]] | ||
3171 | \family default | ||
3172 | . | ||
3173 | johnpye | 828 | \end_layout |
3174 | |||
3175 | \end_deeper | ||
3176 | \begin_layout List | ||
3177 | \labelwidthstring 00000.00000.00000.000 | ||
3178 | jpye | 1384 | |
3179 | \family sans | ||
3180 | johnpye | 828 | INTERSECTION |
3181 | jpye | 1384 | \family default |
3182 | |||
3183 | jpye | 1733 | \begin_inset LatexCommand index |
3184 | name "INTERSECTION" | ||
3185 | johnpye | 828 | |
3186 | \end_inset | ||
3187 | |||
3188 | [] INTERSECTION[list of set expressions]. | ||
3189 | Finds the intersection (and) of the sets listed. | ||
3190 | |||
3191 | \end_layout | ||
3192 | |||
3193 | \begin_layout List | ||
3194 | \labelwidthstring 00000.00000.00000.000 | ||
3195 | * | ||
3196 | jpye | 1733 | \begin_inset LatexCommand index |
3197 | name "*, sets" | ||
3198 | johnpye | 828 | |
3199 | \end_inset | ||
3200 | |||
3201 | jpye | 1384 | Equivalent to |
3202 | \family sans | ||
3203 | INTERSECTION | ||
3204 | \family typewriter | ||
3205 | [list_of_sets] | ||
3206 | \family default | ||
3207 | . | ||
3208 | johnpye | 828 | \end_layout |
3209 | |||
3210 | \begin_layout List | ||
3211 | \labelwidthstring 00000.00000.00000.000 | ||
3212 | jpye | 1384 | |
3213 | \family typewriter | ||
3214 | A*B | ||
3215 | \family default | ||
3216 | \InsetSpace ~ | ||
3217 | johnpye | 828 | is\InsetSpace ~ |
3218 | shorthand\InsetSpace ~ | ||
3219 | for\InsetSpace ~ | ||
3220 | jpye | 1384 | I |
3221 | \family typewriter | ||
3222 | NTERSECTION[A,B] | ||
3223 | johnpye | 828 | \end_layout |
3224 | |||
3225 | \begin_deeper | ||
3226 | \begin_layout Standard | ||
3227 | jpye | 1384 | For the sets A and B defined just above, |
3228 | \family typewriter | ||
3229 | INTERSECTION[A, B] | ||
3230 | \family default | ||
3231 | is the set | ||
3232 | \family typewriter | ||
3233 | [2] | ||
3234 | \family default | ||
3235 | . | ||
3236 | The | ||
3237 | \family typewriter | ||
3238 | * | ||
3239 | \family default | ||
3240 | shorthand for intersection is | ||
3241 | \emph on | ||
3242 | not | ||
3243 | \emph default | ||
3244 | recommended for use except in libraries no one will look at. | ||
3245 | johnpye | 828 | \end_layout |
3246 | |||
3247 | \end_deeper | ||
3248 | \begin_layout List | ||
3249 | \labelwidthstring 00000.00000.00000.000 | ||
3250 | Set\InsetSpace ~ | ||
3251 | difference | ||
3252 | jpye | 1733 | \begin_inset LatexCommand index |
3253 | name "set difference" | ||
3254 | johnpye | 828 | |
3255 | \end_inset | ||
3256 | |||
3257 | : One can subtract one set from another. | ||
3258 | The result is the first set less any members in the set union of the first | ||
3259 | and second set. | ||
3260 | The syntax is | ||
3261 | \end_layout | ||
3262 | |||
3263 | jpye | 1384 | \begin_deeper |
3264 | \begin_layout LyX-Code | ||
3265 | |||
3266 | \family typewriter | ||
3267 | jpye | 1733 | first_set |
3268 | jpye | 1384 | \family default |
3269 | jpye | 1733 | - |
3270 | \begin_inset LatexCommand index | ||
3271 | name "-, sets" | ||
3272 | johnpye | 828 | |
3273 | \end_inset | ||
3274 | |||
3275 | jpye | 1733 | |
3276 | johnpye | 828 | \family typewriter |
3277 | jpye | 1733 | second_set |
3278 | johnpye | 828 | \end_layout |
3279 | |||
3280 | \begin_layout Standard | ||
3281 | jpye | 1384 | For the sets |
3282 | \family typewriter | ||
3283 | A | ||
3284 | \family default | ||
3285 | and | ||
3286 | \family typewriter | ||
3287 | B | ||
3288 | \family default | ||
3289 | defined above, the set difference | ||
3290 | \family typewriter | ||
3291 | A - B | ||
3292 | \family default | ||
3293 | is the set | ||
3294 | \family typewriter | ||
3295 | [1, 3, 5, 9] | ||
3296 | \family default | ||
3297 | while the set difference | ||
3298 | \family typewriter | ||
3299 | B - A | ||
3300 | \family default | ||
3301 | is the set | ||
3302 | \family typewriter | ||
3303 | [4, 6, 8] | ||
3304 | \family default | ||
3305 | . | ||
3306 | johnpye | 828 | \end_layout |
3307 | |||
3308 | \end_deeper | ||
3309 | \begin_layout List | ||
3310 | \labelwidthstring 00000.00000.00000.000 | ||
3311 | jpye | 1384 | |
3312 | \family sans | ||
3313 | johnpye | 828 | CARD |
3314 | jpye | 1384 | \family default |
3315 | |||
3316 | jpye | 1733 | \begin_inset LatexCommand index |
3317 | name "CARD" | ||
3318 | johnpye | 828 | |
3319 | \end_inset | ||
3320 | |||
3321 | [set] Cardinality | ||
3322 | jpye | 1733 | \begin_inset LatexCommand index |
3323 | name "cardinality" | ||
3324 | johnpye | 828 | |
3325 | \end_inset | ||
3326 | |||
3327 | . | ||
3328 | Returns an integer constant value that is the number of items in the set. | ||
3329 | \end_layout | ||
3330 | |||
3331 | \begin_layout List | ||
3332 | \labelwidthstring 00000.00000.00000.000 | ||
3333 | jpye | 1384 | |
3334 | \family sans | ||
3335 | johnpye | 828 | CHOICE |
3336 | jpye | 1384 | \family default |
3337 | |||
3338 | jpye | 1733 | \begin_inset LatexCommand index |
3339 | name "CHOICE" | ||
3340 | johnpye | 828 | |
3341 | \end_inset | ||
3342 | |||
3343 | [set] Choose one. | ||
3344 | jpye | 1384 | The result of running the |
3345 | \family sans | ||
3346 | CHOICE | ||
3347 | \family default | ||
3348 | function over a set is an arbitrary (but consistent: for any set instance | ||
3349 | you always get the same result) single element of that set. | ||
3350 | johnpye | 828 | |
3351 | \end_layout | ||
3352 | |||
3353 | \begin_deeper | ||
3354 | \begin_layout Standard | ||
3355 | jpye | 1384 | Running |
3356 | \family typewriter | ||
3357 | CHOICE[A] | ||
3358 | \family default | ||
3359 | gives any member from the set A. | ||
3360 | johnpye | 828 | The result is a member, not a set. |
3361 | To make the result into a set, it must be enclosed in square brackets. | ||
3362 | jpye | 1384 | Thus |
3363 | \family typewriter | ||
3364 | [CHOICE[A]] | ||
3365 | \family default | ||
3366 | is a set with a single element arbitrarily chosen from the set A. | ||
3367 | johnpye | 828 | Good modelers do not leave modeling decisions to the compiler; they do |
3368 | jpye | 1384 | not use |
3369 | \family sans | ||
3370 | CHOICE | ||
3371 | \family default | ||
3372 | . | ||
3373 | johnpye | 828 | We are stuck with it for historical reasons. |
3374 | \end_layout | ||
3375 | |||
3376 | \begin_layout Standard | ||
3377 | To reduce a set by one element, one can use the following | ||
3378 | \end_layout | ||
3379 | |||
3380 | \begin_layout LyX-Code | ||
3381 | A_less_one IS_A set OF integer; | ||
3382 | \end_layout | ||
3383 | |||
3384 | \begin_layout LyX-Code | ||
3385 | A_less_one :== A - [CHOICE[A]]; | ||
3386 | \end_layout | ||
3387 | |||
3388 | \end_deeper | ||
3389 | \begin_layout List | ||
3390 | \labelwidthstring 00000.00000.00000.000 | ||
3391 | jpye | 1384 | |
3392 | \family sans | ||
3393 | johnpye | 828 | IN |
3394 | jpye | 1384 | \family default |
3395 | |||
3396 | jpye | 1733 | \begin_inset LatexCommand index |
3397 | name "IN" | ||
3398 | johnpye | 828 | |
3399 | \end_inset | ||
3400 | |||
3401 | jpye | 1384 | |
3402 | \family typewriter | ||
3403 | lhs IN rhs | ||
3404 | \family default | ||
3405 | can only be well explained by examples. | ||
3406 | |||
3407 | \family sans | ||
3408 | IN | ||
3409 | \family default | ||
3410 | is used in index expressions. | ||
3411 | If | ||
3412 | \family typewriter | ||
3413 | lhs | ||
3414 | \family default | ||
3415 | is a simple and not previously defined name, it is created as a temporary | ||
3416 | loop index which will take on the values of the rhs set definition. | ||
3417 | If lhs is something that already exists, the result of | ||
3418 | \family typewriter | ||
3419 | lhs IN rhs | ||
3420 | \family default | ||
3421 | is a boolean value; stare at the model | ||
3422 | \family typewriter | ||
3423 | set_example | ||
3424 | \family default | ||
3425 | below which demonstrates both | ||
3426 | \family sans | ||
3427 | IN | ||
3428 | \family default | ||
3429 | and | ||
3430 | \family sans | ||
3431 | SUCH_THAT | ||
3432 | \family default | ||
3433 | . | ||
3434 | If you still are not satisfied, you might examine [[westerbergksets]] | ||
3435 | \begin_inset Note Note | ||
3436 | status open | ||
3437 | |||
3438 | \begin_layout Standard | ||
3439 | fix this reference | ||
3440 | johnpye | 828 | \end_layout |
3441 | |||
3442 | jpye | 1384 | \end_inset |
3443 | |||
3444 | . | ||
3445 | \end_layout | ||
3446 | |||
3447 | johnpye | 828 | \begin_layout List |
3448 | \labelwidthstring 00000.00000.00000.000 | ||
3449 | jpye | 1384 | |
3450 | \family sans | ||
3451 | johnpye | 828 | SUCH_THAT |
3452 | jpye | 1384 | \family default |
3453 | |||
3454 | jpye | 1733 | \begin_inset LatexCommand index |
3455 | name "SUCH\\_THAT" | ||
3456 | johnpye | 828 | |
3457 | \end_inset | ||
3458 | |||
3459 | jpye | 1384 | Set expressions can be rather clever. |
3460 | johnpye | 828 | We will give a detailed example from chemistry because unordered sets are |
3461 | unfamiliar to most people and set arithmetic is quite powerful. | ||
3462 | In this example we see arrays of sets and sparse arrays. | ||
3463 | |||
3464 | \end_layout | ||
3465 | |||
3466 | \begin_layout LyX-Code | ||
3467 | MODEL set_example; | ||
3468 | \end_layout | ||
3469 | |||
3470 | \begin_layout LyX-Code | ||
3471 | jpye | 1384 | (* we define a sparse matrix of reaction |
3472 | johnpye | 828 | \end_layout |
3473 | |||
3474 | \begin_layout LyX-Code | ||
3475 | jpye | 1384 | coefficient information and the species |
3476 | johnpye | 828 | \end_layout |
3477 | |||
3478 | \begin_layout LyX-Code | ||
3479 | jpye | 1384 | balance equations. |
3480 | johnpye | 828 | *) |
3481 | \end_layout | ||
3482 | |||
3483 | \begin_layout LyX-Code | ||
3484 | jpye | 1384 | rxns IS_A set OF integer_constant; |
3485 | johnpye | 828 | \end_layout |
3486 | |||
3487 | \begin_layout LyX-Code | ||
3488 | jpye | 1384 | rxns :== [1..3]; |
3489 | johnpye | 828 | \end_layout |
3490 | |||
3491 | \begin_layout LyX-Code | ||
3492 | jpye | 1384 | species IS_A set OF symbol_constant; |
3493 | johnpye | 828 | \end_layout |
3494 | |||
3495 | \begin_layout LyX-Code | ||
3496 | jpye | 1384 | species :== ['A','B','C','D']; |
3497 | johnpye | 828 | \end_layout |
3498 | |||
3499 | \begin_layout LyX-Code | ||
3500 | jpye | 1384 | reactants[rxns] IS_A set OF symbol_constant; (* species |
3501 | johnpye | 828 | \end_layout |
3502 | |||
3503 | \begin_layout LyX-Code | ||
3504 | jpye | 1384 | in each rxn_j *) |
3505 | johnpye | 828 | \end_layout |
3506 | |||
3507 | \begin_layout LyX-Code | ||
3508 | jpye | 1384 | reactants[1] :== ['A','B','C']; |
3509 | johnpye | 828 | \end_layout |
3510 | |||
3511 | \begin_layout LyX-Code | ||
3512 | jpye | 1384 | reactants[2] :== ['A','C']; |
3513 | johnpye | 828 | \end_layout |
3514 | |||
3515 | \begin_layout LyX-Code | ||
3516 | jpye | 1384 | reactants[3] :== ['A','B','D']; |
3517 | johnpye | 828 | \end_layout |
3518 | |||
3519 | \begin_layout LyX-Code | ||
3520 | jpye | 1384 | reactions[species] IS_A set OF integer_constant; |
3521 | johnpye | 828 | \end_layout |
3522 | |||
3523 | \begin_layout LyX-Code | ||
3524 | jpye | 1384 | FOR i IN species CREATE (* rxns for each species i *) |
3525 | johnpye | 828 | \end_layout |
3526 | |||
3527 | \begin_layout LyX-Code | ||
3528 | jpye | 1384 | reactions[i] :== [j IN rxns SUCH_THAT i IN reactants[j]]; |
3529 | johnpye | 828 | \end_layout |
3530 | |||
3531 | \begin_layout LyX-Code | ||
3532 | jpye | 1384 | END FOR; |
3533 | johnpye | 828 | \end_layout |
3534 | |||
3535 | \begin_layout LyX-Code | ||
3536 | jpye | 1384 | (* Define sparse stoichiometric matrix. |
3537 | johnpye | 828 | Values of eta_ij |
3538 | \end_layout | ||
3539 | |||
3540 | \begin_layout LyX-Code | ||
3541 | jpye | 1384 | set later.*) |
3542 | johnpye | 828 | \end_layout |
3543 | |||
3544 | \begin_layout LyX-Code | ||
3545 | jpye | 1384 | FOR j IN rxns CREATE |
3546 | johnpye | 828 | \end_layout |
3547 | |||
3548 | \begin_layout LyX-Code | ||
3549 | jpye | 1384 | FOR i IN reactants[j] CREATE |
3550 | johnpye | 828 | \end_layout |
3551 | |||
3552 | \begin_layout LyX-Code | ||
3553 | jpye | 1384 | (* eta_ij --> mole i/mole rxn j*) |
3554 | johnpye | 828 | \end_layout |
3555 | |||
3556 | \begin_layout LyX-Code | ||
3557 | jpye | 1384 | eta[i][j] IS_A real_constant; |
3558 | johnpye | 828 | \end_layout |
3559 | |||
3560 | \begin_layout LyX-Code | ||
3561 | jpye | 1384 | END FOR; |
3562 | johnpye | 828 | \end_layout |
3563 | |||
3564 | \begin_layout LyX-Code | ||
3565 | jpye | 1384 | END FOR; |
3566 | johnpye | 828 | \end_layout |
3567 | |||
3568 | \begin_layout LyX-Code | ||
3569 | jpye | 1384 | production[species] IS_A molar_rate; |
3570 | johnpye | 828 | \end_layout |
3571 | |||
3572 | \begin_layout LyX-Code | ||
3573 | jpye | 1384 | rate[rxns] IS_A molar_rate; (* mole rxn j/time *) |
3574 | johnpye | 828 | \end_layout |
3575 | |||
3576 | \begin_layout LyX-Code | ||
3577 | jpye | 1384 | FOR i IN species CREATE |
3578 | johnpye | 828 | \end_layout |
3579 | |||
3580 | \begin_layout LyX-Code | ||
3581 | jpye | 1384 | gen_eqn[i]: production[i] = |
3582 | johnpye | 828 | \end_layout |
3583 | |||
3584 | \begin_layout LyX-Code | ||
3585 | jpye | 1384 | SUM[eta[i][j]*rate[j] | j IN reactions[i]]; |
3586 | johnpye | 828 | \end_layout |
3587 | |||
3588 | \begin_layout LyX-Code | ||
3589 | jpye | 1384 | END FOR; |
3590 | johnpye | 828 | \end_layout |
3591 | |||
3592 | \begin_layout LyX-Code | ||
3593 | END set_example; | ||
3594 | \end_layout | ||
3595 | |||
3596 | \begin_layout List | ||
3597 | \labelwidthstring 00000.00000.00000.000 | ||
3598 | jpye | 1384 | " |
3599 | \family typewriter | ||
3600 | | | ||
3601 | \family default | ||
3602 | |||
3603 | jpye | 1733 | \begin_inset LatexCommand index |
3604 | name "|" | ||
3605 | johnpye | 828 | |
3606 | \end_inset | ||
3607 | |||
3608 | jpye | 1384 | " is shorthand for |
3609 | \family sans | ||
3610 | SUCH_THAT | ||
3611 | \family default | ||
3612 | . | ||
3613 | johnpye | 828 | \end_layout |
3614 | |||
3615 | \begin_deeper | ||
3616 | \begin_layout Standard | ||
3617 | jpye | 1384 | The array |
3618 | \family typewriter | ||
3619 | eta | ||
3620 | \family default | ||
3621 | has only 8 elements, and we defined those elements in a set for each reaction. | ||
3622 | The equation needs to know about the set of reactions for a species | ||
3623 | \family typewriter | ||
3624 | i | ||
3625 | \family default | ||
3626 | , and that set is calculated automatically in the models first | ||
3627 | \family sans | ||
3628 | FOR/CREATE | ||
3629 | \family default | ||
3630 | johnpye | 828 | statement. |
3631 | |||
3632 | \end_layout | ||
3633 | |||
3634 | jpye | 1384 | \begin_layout Standard |
3635 | The | ||
3636 | \family typewriter | ||
3637 | johnpye | 828 | | |
3638 | jpye | 1384 | \family default |
3639 | symbol is the ASCEND III notation for | ||
3640 | \family sans | ||
3641 | SUCH_THAT | ||
3642 | \family default | ||
3643 | . | ||
3644 | We noted that " | ||
3645 | \family typewriter | ||
3646 | | | ||
3647 | \family default | ||
3648 | " is often read as "for all", which is different in that "for all" makes | ||
3649 | one think of a | ||
3650 | \family sans | ||
3651 | FOR | ||
3652 | \family default | ||
3653 | loop where the loop index is on the left of an | ||
3654 | \family sans | ||
3655 | IN | ||
3656 | \family default | ||
3657 | operator. | ||
3658 | For example, the | ||
3659 | \family typewriter | ||
3660 | j | ||
3661 | \family default | ||
3662 | loop in the | ||
3663 | \family sans | ||
3664 | SUM | ||
3665 | \family default | ||
3666 | of | ||
3667 | \family typewriter | ||
3668 | gen_eqn[i] | ||
3669 | \family default | ||
3670 | above. | ||
3671 | johnpye | 828 | |
3672 | \end_layout | ||
3673 | |||
3674 | jpye | 1384 | \begin_layout Section |
3675 | johnpye | 828 | Constants |
3676 | jpye | 1733 | \begin_inset LatexCommand index |
3677 | name "constants" | ||
3678 | johnpye | 828 | |
3679 | \end_inset | ||
3680 | |||
3681 | |||
3682 | \end_layout | ||
3683 | |||
3684 | \begin_layout Standard | ||
3685 | ASCEND supports real, integer, boolean and character string constants. | ||
3686 | Constants in ASCEND do not have any attributes other than their value. | ||
3687 | Constants are scalar quantities that can be assigned exactly once. | ||
3688 | jpye | 1384 | Constants may only be assigned using the |
3689 | \family typewriter | ||
3690 | :== | ||
3691 | \family default | ||
3692 | operator and the RHS expression they are assigned from must itself be constant. | ||
3693 | johnpye | 828 | Constants do not have subparts. |
3694 | Integer and symbol constants may be used in determining the definitions | ||
3695 | of sets. | ||
3696 | |||
3697 | \end_layout | ||
3698 | |||
3699 | \begin_layout Standard | ||
3700 | Explicit refinements of the built-in constant types may be defined as exemplifie | ||
3701 | d in the description of real_constant. | ||
3702 | Implicit type refinements may be done by instantiating an incompletely | ||
3703 | defined constant and assigning its final value. | ||
3704 | |||
3705 | \end_layout | ||
3706 | |||
3707 | \begin_layout Standard | ||
3708 | Sets could be considered constant because they are assigned only once, however | ||
3709 | sets are described separately because they are not quite scalar quantities. | ||
3710 | \end_layout | ||
3711 | |||
3712 | \end_deeper | ||
3713 | \begin_layout List | ||
3714 | \labelwidthstring 00000.00000.00000.000 | ||
3715 | jpye | 1384 | |
3716 | \family sans | ||
3717 | johnpye | 828 | real_constant |
3718 | jpye | 1384 | \family default |
3719 | |||
3720 | jpye | 1733 | \begin_inset LatexCommand index |
3721 | name "real\\_constant" | ||
3722 | johnpye | 828 | |
3723 | \end_inset | ||
3724 | |||
3725 | Real number with dimensionality. | ||
3726 | Note that the dimensionality of a real constant can be specified via the | ||
3727 | type definition without immediately defining the value, as in the following | ||
3728 | pair of definitions. | ||
3729 | \end_layout | ||
3730 | |||
3731 | \begin_layout List | ||
3732 | \labelwidthstring 00000.00000.00000.000 | ||
3733 | |||
3734 | \bar under | ||
3735 | CONSTANT\InsetSpace ~ | ||
3736 | declaration\InsetSpace ~ | ||
3737 | example: | ||
3738 | \end_layout | ||
3739 | |||
3740 | \begin_deeper | ||
3741 | \begin_layout LyX-Code | ||
3742 | CONSTANT molar_weight | ||
3743 | \end_layout | ||
3744 | |||
3745 | \begin_layout LyX-Code | ||
3746 | REFINES real_constant DIMENSION M/Q; | ||
3747 | \end_layout | ||
3748 | |||
3749 | \begin_layout LyX-Code | ||
3750 | CONSTANT hydrogen_weight | ||
3751 | \end_layout | ||
3752 | |||
3753 | \begin_layout LyX-Code | ||
3754 | REFINES molar_weight :== 1.004{g/mole}; | ||
3755 | \end_layout | ||
3756 | |||
3757 | \end_deeper | ||
3758 | \begin_layout List | ||
3759 | \labelwidthstring 00000.00000.00000.000 | ||
3760 | jpye | 1384 | |
3761 | \family sans | ||
3762 | johnpye | 828 | integer_constant |
3763 | jpye | 1384 | \family default |
3764 | |||
3765 | jpye | 1733 | \begin_inset LatexCommand index |
3766 | name "integer\\_constant" | ||
3767 | johnpye | 828 | |
3768 | \end_inset | ||
3769 | |||
3770 | Integer number. | ||
3771 | Principally used in determining model structure. | ||
3772 | If appearing in equations, integers are evaluated as dimensionless reals. | ||
3773 | jpye | 1384 | Typical use is inside a |
3774 | \family sans | ||
3775 | MODEL | ||
3776 | \family default | ||
3777 | definition and looks like: | ||
3778 | johnpye | 828 | \end_layout |
3779 | |||
3780 | \begin_deeper | ||
3781 | \begin_layout LyX-Code | ||
3782 | n_trays IS_A integer_constant; | ||
3783 | \end_layout | ||
3784 | |||
3785 | \begin_layout LyX-Code | ||
3786 | n_trays :== 50; | ||
3787 | \end_layout | ||
3788 | |||
3789 | \begin_layout LyX-Code | ||
3790 | tray[1..n_trays] IS_A vl_equilibrium_tray; | ||
3791 | \end_layout | ||
3792 | |||
3793 | \end_deeper | ||
3794 | \begin_layout List | ||
3795 | \labelwidthstring 00000.00000.00000.000 | ||
3796 | jpye | 1384 | |
3797 | \family sans | ||
3798 | johnpye | 828 | symbol_constant |
3799 | jpye | 1384 | \family default |
3800 | |||
3801 | jpye | 1733 | \begin_inset LatexCommand index |
3802 | name "symbol\\_constant" | ||
3803 | johnpye | 828 | |
3804 | \end_inset | ||
3805 | |||
3806 | Object with a symbol value. | ||
3807 | May be used in determining model structure. | ||
3808 | \end_layout | ||
3809 | |||
3810 | \begin_layout List | ||
3811 | \labelwidthstring 00000.00000.00000.000 | ||
3812 | jpye | 1384 | |
3813 | \family sans | ||
3814 | johnpye | 828 | boolean_constant |
3815 | jpye | 1384 | \family default |
3816 | |||
3817 | jpye | 1733 | \begin_inset LatexCommand index |
3818 | name "boolean\\_constant" | ||
3819 | johnpye | 828 | |
3820 | \end_inset | ||
3821 | |||
3822 | Logical value. | ||
3823 | May be used in determining model structure. | ||
3824 | \end_layout | ||
3825 | |||
3826 | \begin_layout List | ||
3827 | \labelwidthstring 00000.00000.00000.000 | ||
3828 | |||
3829 | \bar under | ||
3830 | Setting\InsetSpace ~ | ||
3831 | constants | ||
3832 | \bar default | ||
3833 | |||
3834 | jpye | 1733 | \begin_inset LatexCommand index |
3835 | name "constants, setting" | ||
3836 | johnpye | 828 | |
3837 | \end_inset | ||
3838 | |||
3839 | |||
3840 | \end_layout | ||
3841 | |||
3842 | \begin_layout List | ||
3843 | \labelwidthstring 00000.00000.00000.000 | ||
3844 | :== | ||
3845 | jpye | 1733 | \begin_inset LatexCommand index |
3846 | name ":==" | ||
3847 | johnpye | 828 | |
3848 | \end_inset | ||
3849 | |||
3850 | Constant and set assignment operator. | ||
3851 | |||
3852 | \end_layout | ||
3853 | |||
3854 | \begin_deeper | ||
3855 | \begin_layout Standard | ||
3856 | It is suggested, but not required, that names of all types that refine the | ||
3857 | built-in constant types have names that end in _constant. | ||
3858 | \end_layout | ||
3859 | |||
3860 | \begin_layout LyX-Code | ||
3861 | LHS_list :== RHS; | ||
3862 | \end_layout | ||
3863 | |||
3864 | \begin_layout Standard | ||
3865 | Here it is required that the one or more items in the LHS be of the same | ||
3866 | constant type and that RHS is a single-valued expression made up of values, | ||
3867 | operators, and other constants. | ||
3868 | jpye | 1384 | The |
3869 | \family typewriter | ||
3870 | :== | ||
3871 | \family default | ||
3872 | is used to make clear to both the user and the system what scalar objects | ||
3873 | are constants. | ||
3874 | johnpye | 828 | |
3875 | \end_layout | ||
3876 | |||
3877 | jpye | 1384 | \begin_layout Section |
3878 | johnpye | 828 | Variables |
3879 | jpye | 1733 | \begin_inset LatexCommand index |
3880 | name "variables" | ||
3881 | johnpye | 828 | |
3882 | \end_inset | ||
3883 | |||
3884 | |||
3885 | \end_layout | ||
3886 | |||
3887 | \begin_layout Standard | ||
3888 | There are four built-in types which may be used to construct variables: | ||
3889 | symbol, boolean, integer, and real. | ||
3890 | At this time symbol types have special restrictions. | ||
3891 | jpye | 1384 | Refinements of these variable base types are defined with the |
3892 | \family sans | ||
3893 | ATOM | ||
3894 | \family default | ||
3895 | statement. | ||
3896 | johnpye | 828 | Atom types may declare attribute fields with types real, integer, boolean, |
3897 | symbol, and set. | ||
3898 | jpye | 1384 | These attributes are |
3899 | \emph on | ||
3900 | not | ||
3901 | \emph default | ||
3902 | independent objects and therefore cannot be refined, merged, or put in | ||
3903 | a refinement clique ( | ||
3904 | \family sans | ||
3905 | ARE_ALIKE | ||
3906 | \family default | ||
3907 | d). | ||
3908 | johnpye | 828 | \end_layout |
3909 | |||
3910 | \end_deeper | ||
3911 | \begin_layout List | ||
3912 | \labelwidthstring 00000.00000.00000.000 | ||
3913 | jpye | 1384 | |
3914 | \family sans | ||
3915 | johnpye | 828 | ATOM |
3916 | jpye | 1384 | \family default |
3917 | |||
3918 | jpye | 1733 | \begin_inset LatexCommand index |
3919 | name "ATOM" | ||
3920 | johnpye | 828 | |
3921 | \end_inset | ||
3922 | |||
3923 | The syntax for declaring a new atom type is | ||
3924 | \end_layout | ||
3925 | |||
3926 | \begin_deeper | ||
3927 | \begin_layout LyX-Code | ||
3928 | ATOM | ||
3929 | \emph on | ||
3930 | atom_type_name | ||
3931 | \emph default | ||
3932 | REFINES | ||
3933 | \emph on | ||
3934 | variable_type | ||
3935 | \end_layout | ||
3936 | |||
3937 | \begin_layout LyX-Code | ||
3938 | jpye | 1733 | «DIMENSION |
3939 | johnpye | 828 | \emph on |
3940 | dimension_expression | ||
3941 | \emph default | ||
3942 | jpye | 1733 | » |
3943 | johnpye | 828 | \end_layout |
3944 | |||
3945 | \begin_layout LyX-Code | ||
3946 | jpye | 1733 | «DEFAULT |
3947 | johnpye | 828 | \emph on |
3948 | value | ||
3949 | \emph default | ||
3950 | jpye | 1733 | »; (* note the ; *) |
3951 | johnpye | 828 | \end_layout |
3952 | |||
3953 | \begin_layout LyX-Code | ||
3954 | jpye | 1733 | « |
3955 | johnpye | 828 | \emph on |
3956 | initial attribute assignment | ||
3957 | \emph default | ||
3958 | jpye | 1733 | ;» |
3959 | johnpye | 828 | \end_layout |
3960 | |||
3961 | \begin_layout LyX-Code | ||
3962 | END | ||
3963 | \emph on | ||
3964 | atom_type_name | ||
3965 | \emph default | ||
3966 | ; | ||
3967 | \end_layout | ||
3968 | |||
3969 | \end_deeper | ||
3970 | \begin_layout List | ||
3971 | \labelwidthstring 00000.00000.00000.000 | ||
3972 | jpye | 1384 | |
3973 | \family sans | ||
3974 | johnpye | 828 | DEFAULT |
3975 | jpye | 1384 | \family default |
3976 | |||
3977 | jpye | 1733 | \begin_inset LatexCommand index |
3978 | name "DEFAULT" | ||
3979 | johnpye | 828 | |
3980 | \end_inset | ||
3981 | |||
3982 | jpye | 1384 | , |
3983 | \family sans | ||
3984 | \InsetSpace ~ | ||
3985 | johnpye | 828 | DIMENSION |
3986 | jpye | 1384 | \family default |
3987 | |||
3988 | jpye | 1733 | \begin_inset LatexCommand index |
3989 | name "DIMENSION" | ||
3990 | johnpye | 828 | |
3991 | \end_inset | ||
3992 | |||
3993 | ,\InsetSpace ~ | ||
3994 | and\InsetSpace ~ | ||
3995 | jpye | 1384 | |
3996 | \family sans | ||
3997 | johnpye | 828 | DIMENSIONLESS |
3998 | jpye | 1384 | \family default |
3999 | |||
4000 | jpye | 1733 | \begin_inset LatexCommand index |
4001 | name "DIMENSIONLESS" | ||
4002 | johnpye | 828 | |
4003 | \end_inset | ||
4004 | |||
4005 | |||
4006 | \end_layout | ||
4007 | |||
4008 | \begin_deeper | ||
4009 | \begin_layout Standard | ||
4010 | jpye | 1384 | The |
4011 | \family sans | ||
4012 | DIMENSION | ||
4013 | \family default | ||
4014 | attribute is for variables whose base type is real. | ||
4015 | johnpye | 828 | It is an optional field. |
4016 | If not defined for any atom with base type real, the dimensions will be | ||
4017 | left as undefined. | ||
4018 | Any variable which is later declared to be one of these types will be given | ||
4019 | wild card dimensionality (represented in the interactive display by an | ||
4020 | asterisk (*)). | ||
4021 | The system will deduce the dimensionality from its use in the relationships | ||
4022 | in which it appears or in the declaring of default values for it, if possible. | ||
4023 | \end_layout | ||
4024 | |||
4025 | \end_deeper | ||
4026 | \begin_layout List | ||
4027 | \labelwidthstring 00000.00000.00000.000 | ||
4028 | jpye | 1384 | |
4029 | \family sans | ||
4030 | johnpye | 828 | solver_var |
4031 | jpye | 1384 | \family default |
4032 | |||
4033 | jpye | 1733 | \begin_inset LatexCommand index |
4034 | name "solver\\_var" | ||
4035 | johnpye | 828 | |
4036 | \end_inset | ||
4037 | |||
4038 | jpye | 1384 | is a special case of |
4039 | \family sans | ||
4040 | ATOM | ||
4041 | \family default | ||
4042 | and we will say much more about it in Section | ||
4043 | jpye | 1733 | \begin_inset LatexCommand vref |
4044 | reference "sub:x.6.1Variables-for-solvers" | ||
4045 | johnpye | 828 | |
4046 | \end_inset | ||
4047 | |||
4048 | . | ||