Model: Function

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:

  1. They can replace explicit equations, e.g., an equation to calculate the investment costs within your model.
  2. 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.

Figure 1: The function editor inside MOSAICmodeling lets you define the function body, i.e., the calculating equation, that returns the output based on the given inputs.
ElementExplanation
FileFilename of your function once you have saved or loaded it
NotationNotation on which your function is based
ParametersOptionally defined parameters from a parameter list
DescriptionDescription of the function
KeywordsOptional keywords for the current function
UsagesModel elements, i.e., equations or functions, in which the function is used
Interface & Body SettingsLets you set the interface and body settings below
Interface SettingsSelect whether you want to define a free interface or load a previously defined interface
Body SettingsSelect whether you want to supply a specific formula or use an empty body (for now)
Interface SpecificationAdd all input and output variables for the function. The used symbols must be defined in the loaded notation
Body SpecificationShould you have selected “specific formula” in the body settings, you can supply the respective function here
Table 1: Elements of the function editor.

Workflow

Figure 2 illustrates the workflow to set up a function.

Figure 2: Workflow to set up a function.