**Optional element**

### Purpose

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. MOSAICmodeling functions have two different purposes:

- They can replace explicit equations, e.g., an equation to calculate the investment costs within your model.
- They provide an interface to external software via external function calls, e.g., to calculate thermodynamic calculations.

### Explanation of the editor

In general, the notation of a function is independent of the notation used in the equation system. However, 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.

The function editor is shown in Figure 1.

Element | Explanation |
---|---|

File | Filename of your function once you have saved or loaded it |

Notation | Notation on which your function is based |

Parameters | Optionally defined parameters from a parameter list |

Description | Description of the function |

Keywords | Optional keywords for the current function |

Usages | Model elements, i.e., equations or functions, in which the function is used |

Interface & Body Settings | Lets you set the interface and body settings below |

Interface Settings | Select whether you want to define a free interface or load a previously defined interface |

Body Settings | Select whether you want to supply a specific formula or use an empty body (for now) |

Interface Specification | Add all input and output variables for the function. The used symbols must be defined in the loaded notation |

Body Specification | Should you have selected “specific formula” in the body settings, you can supply the respective function here |

### Workflow

Figure 2 illustrates the workflow to set up a function.