Functions are very useful when values need to be calculated and it is undesirable to introduce additional variables or equations. Possible applications include calculation of enthalpy, phase equilibrium factors, etc. Functions in MOSAICmodeling have one output value and several input values.
Appliances In general, the Notation of a Function is independent from the Notation used in the Equation System. There must be a mechanism to define which of the variables in the Equation System are the input values and which is the output value. In programming languages the input values are assigned according to the order in which they appear within the function call. The modeling in MOSAICmodeling, however, is focused on the Variable Naming and pursues the concept of synonymous Variable Namings. Thus, the function is applied by assigning the Variable Namings of the input variables and the output variable of the Function explicitly to the namings of the corresponding variables in the Equation System. The advantage of applying the Function in this way is that the focus is kept on the physical meaning of the variable. Errors from handing over variables in the wrong order are thus eliminated.
In this section, it is explained how to use functions in MOSAICmodeling. In the section “Use of functions I – basic principles” it is explained how a simple function can be defined in MOSAICmodeling. In the section “Use of functions II – applications using indices“, the use of indices in functions is explained. The section “Use of functions III – parameter lists and indices” explain the use of parameter lists in functions. Coming soon: The section “Use of functions IV – definition by interface” shows how interfaces can be used to define functions in MOSAICmodeling.
NOTE: Please make sure that you work through the section “Basics” completely before starting with the “Functions” section.
More on function examples: