2.6.7. Expression parsing

Expression parsing takes place in four steps, in the most general case:

  1. An arbitrary Pyhton expression is broken down into words, which may consist of

    • The left hand side of other expressions

    • Variable names

    • Python words – built-in or module objects

  2. If evaluation of such words leads to no result the word is given to the var() function

  3. The var function checks of the word belongs to known key-words, which respresent compound variables, such as ‘T’ for temperature, where each solver may require a different numerical expression, needing as much as 8 primitive variables (in the case of computing temperature when total energy is stored). Expressions in the var function use the mem() function to get actual values (which in fact or memory maps into disk files)

  4. Inside the mem() function, alphabetic keys (such as ‘px’) are translated to integer indices, which in turn determine the offsets of the memory maps into the disk files

The first two steps take place in the expression_parser(), while the third step takes place in the var() function (possibly calling itself recursively), and the 4th step takes place in the mem() function.