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