Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| en:simulation:benutzerdefinierte_funktionen [2026/01/10 21:26] – [Assignments] neelest | en:simulation:benutzerdefinierte_funktionen [2026/01/10 21:29] (aktuell) – [User-defined Function] neelest | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== User-defined Function ====== | ====== User-defined Function ====== | ||
| - | |||
| - | *[[en: | ||
| - | *[[en: | ||
| - | *[[en: | ||
| Besides the above described build-in calculations, | Besides the above described build-in calculations, | ||
| Zeile 98: | Zeile 94: | ||
| A return statement determines the return-value of the user defined function. The evaluation of the function stops and the function is exited with the given return-value. The syntax is as follows: | A return statement determines the return-value of the user defined function. The evaluation of the function stops and the function is exited with the given return-value. The syntax is as follows: | ||
| - | '' | + | '' |
| === Conditional Statement === | === Conditional Statement === | ||
| Zeile 104: | Zeile 100: | ||
| An '' | An '' | ||
| - | '' | + | '' |
| As a simple example the determination of the maximum of two values is shown below: | As a simple example the determination of the maximum of two values is shown below: | ||
| Zeile 119: | Zeile 115: | ||
| ==== Grouping Statements ==== | ==== Grouping Statements ==== | ||
| - | The keywords begin and end parenthesize a sequence of statements. This group of statements can be evaluated as a single statement, for example in a conditional statement, where one of cases needs more than one single statement to work properly. The syntax is as follows: | + | The keywords |
| - | + | ||
| - | '' | + | |
| + | '' | ||
| < | < | ||
| - | |||
| ... | ... | ||
| - | |||
| < | < | ||
| - | + | '' | |
| - | `end´'' | + | |
| ===== Further Information for Use of User-defined Functions ===== | ===== Further Information for Use of User-defined Functions ===== | ||
| - | ===== Importance of Lines ===== | + | ==== Importance of Lines ==== |
| By defining user defined functions each statement, except the if-then-else statement, which consists of more than one line, has always to cover a single line. Due to that there is no special end-marker (like ”;”) for statements, the end of line terminates a single statement. As expressions are an inherent part of statements they are also terminated by the end of line. | By defining user defined functions each statement, except the if-then-else statement, which consists of more than one line, has always to cover a single line. Due to that there is no special end-marker (like ”;”) for statements, the end of line terminates a single statement. As expressions are an inherent part of statements they are also terminated by the end of line. | ||
| - | ===== Variables | + | ==== Variables ==== |
| Only mathematical values can be bound to variables. There are no variables for storing and retrieving logical values. Variables don’t have to be declared, like in other languages. By using an unknown identifier a variable is created, that can further be used. If the first use of an unknown identifier on the left hand side of an assignment, the variable is initialized with the given value. If the first occurrence of an identifier is an expression, the variable will be created, but their value is invalid. | Only mathematical values can be bound to variables. There are no variables for storing and retrieving logical values. Variables don’t have to be declared, like in other languages. By using an unknown identifier a variable is created, that can further be used. If the first use of an unknown identifier on the left hand side of an assignment, the variable is initialized with the given value. If the first occurrence of an identifier is an expression, the variable will be created, but their value is invalid. | ||
| - | ===== Predefined Variables | + | ==== Predefined Variables ==== |
| Any user defined function is evaluated by SIGMA for a single grid point in the calculation core. Some data at these grid points like geometry data, data of the used material, process parameters and results can be accessed by user defined function through the use of predefined variables, which are created and initialized by SIGMA. There are 144 of such predefined variables which can be easily used in user defined functions (see figure). | Any user defined function is evaluated by SIGMA for a single grid point in the calculation core. Some data at these grid points like geometry data, data of the used material, process parameters and results can be accessed by user defined function through the use of predefined variables, which are created and initialized by SIGMA. There are 144 of such predefined variables which can be easily used in user defined functions (see figure). | ||
| - | ===== Operators | + | ==== Operators ==== |
| In the following table all useable operators are listed. Operators with higher precedence listed before operators with lower precedence. | In the following table all useable operators are listed. Operators with higher precedence listed before operators with lower precedence. | ||
| Zeile 166: | Zeile 158: | ||
| - | ===== Build-in Functions | + | ==== Build-in Functions ==== |
| Fourteen build-in functions may be used in mathematical expressions. Each of them takes a single parameter, which is directly following the identifier of the function. Such functions have higher binding strength than the power-operator. The following table lists all these build-in functions. | Fourteen build-in functions may be used in mathematical expressions. Each of them takes a single parameter, which is directly following the identifier of the function. Such functions have higher binding strength than the power-operator. The following table lists all these build-in functions. | ||
| Zeile 185: | Zeile 177: | ||
| | Square root| sqrt | Computes the sqaure root of the parameter | | | Square root| sqrt | Computes the sqaure root of the parameter | | ||
| - | ===== Evaluation of User-defined Functions | + | ==== Evaluation of User-defined Functions ==== |
| A user-defined function is evaluated for each grid point. It therefore delivers exactly one function value for each grid point. All the values together can afterwards be graphically depicted in a user-defined diagram. As described above predefined variables can be used in the function to represent specific values for this grid point. The user-defined functions are only used after the standard calculations and do not influence them. | A user-defined function is evaluated for each grid point. It therefore delivers exactly one function value for each grid point. All the values together can afterwards be graphically depicted in a user-defined diagram. As described above predefined variables can be used in the function to represent specific values for this grid point. The user-defined functions are only used after the standard calculations and do not influence them. | ||
| - | ===== Invalid Values | + | ==== Invalid Values ==== |
| Not all predefined variables have a valid value bound to them, as the predefined variables are the same for each grid point, but not all data is defined for each grid point. For instance the number of discs (of a kneading block) is a predefined variable but their value is only defined for grid points that represent a location at the screw where a kneading block is located. In all other cases the value of such a predefined variable is invalid. Also some operators are not defined for all operands (Division by zero). Because of that, a special value denoting not defined values exists for user defined functions. This value is bound to the predefined variable invalid. Operators taking an invalid value as one of their parameters, return themselves the invalid value as result. This invalid value is also a valid return value for the user defined function, in that case no result is shown for the according grid point. | Not all predefined variables have a valid value bound to them, as the predefined variables are the same for each grid point, but not all data is defined for each grid point. For instance the number of discs (of a kneading block) is a predefined variable but their value is only defined for grid points that represent a location at the screw where a kneading block is located. In all other cases the value of such a predefined variable is invalid. Also some operators are not defined for all operands (Division by zero). Because of that, a special value denoting not defined values exists for user defined functions. This value is bound to the predefined variable invalid. Operators taking an invalid value as one of their parameters, return themselves the invalid value as result. This invalid value is also a valid return value for the user defined function, in that case no result is shown for the according grid point. | ||