Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
en:simulation:benutzerdefinierte_funktionen [2026/01/10 21:21] – [Manage a User-defined Function] neelesten:simulation:benutzerdefinierte_funktionen [2026/01/10 21:29] (aktuell) – [User-defined Function] neelest
Zeile 1: Zeile 1:
 ====== User-defined Function ====== ====== User-defined Function ======
- 
-  *[[en:Simulation:Benutzerdefinierte Funktionen: Benutzerdefinierte Funktion]] 
-  *[[en:Simulation:Benutzerdefinierte Funktionen: Bearbeiten benutzerdefinierter Funktionen]] 
-  *[[en:Simulation:Benutzerdefinierte Funktionen:Definition benutzerdefinierter Funktionen]] 
  
 Besides the above described build-in calculations, SIGMA offers the user to define his own functions to be calculated. These user defined functions are defined in a purpose build mini-language. The results calculated by such user defined functions are treated as any other result and can be viewed in diagrams or as result list. Besides the above described build-in calculations, SIGMA offers the user to define his own functions to be calculated. These user defined functions are defined in a purpose build mini-language. The results calculated by such user defined functions are treated as any other result and can be viewed in diagrams or as result list.
Zeile 40: Zeile 36:
 ==== Operator Precedence ==== ==== Operator Precedence ====
  
-The operators *” and /” have precedence over +” and -+  * The operators * and / have precedence over + and -. 
- +  The power operator ^ has higher binding strength than the other operators. 
-The power operator ^” has higher binding strength than the other operators. +  Functions have the greatest binding strength. 
- +  Parenthesizes expressions are evaluated first.
-Functions have the greatest binding strength. +
- +
-Parenthesizes expressions are evaluated first.+
  
 ==== Associativity ==== ==== Associativity ====
Zeile 65: Zeile 58:
 A logical expression represents a single logical value( as ”true” or ”false”). In such an expression comparison operators as well as the logical operators and and or may be used. A logical expression represents a single logical value( as ”true” or ”false”). In such an expression comparison operators as well as the logical operators and and or may be used.
  
-Comparison operators compare two (values of) mathematical expressions and return a logical value, which can be further combined by the two defined logical operators. The six comparison operators defined are: Less(<), less-or-equal(<=), equal(==), greater-or-equal(>=), greater(>) and unequal(!=).+Comparison operators compare two (values of) mathematical expressions and return a logical value, which can be further combined by the two defined logical operators. The six comparison operators defined are: Less(<), less-or-equal ( < = ), equal ( == ), greater-or-equal ( >= ), greater (>) and unequal ( != ).
  
 Logical expressions can neither be parenthesized nor their values stored in variables and retrieved later. The use of logical expressions is limited to conditional statements, which are explained in the section Statements. Logical expressions can neither be parenthesized nor their values stored in variables and retrieved later. The use of logical expressions is limited to conditional statements, which are explained in the section Statements.
Zeile 78: Zeile 71:
 ===== Statements ===== ===== Statements =====
  
-The above described expression (mathematic and logical) is an inherent part of statements and cannot be used on their ownThe user defined functions distinguish between four different statements. Each statement covers only single line in the language.+The expressions described above cannot stand alone, but can only be used in conjunction with instructionsFour different instructions are used for user-defined functions. Each instruction begins on new line and must be completed at the end of a line.
  
 ==== Assignments ==== ==== Assignments ====
  
-An assignment binds the value of a mathematical expression to a variable. Therefore, on the left hand side of the assignment sign (=) is the variable and on the right hand side a mathematical expression. The syntax is as follows:+An assignment binds the value of a mathematical expression to a variable. Therefore, on the left hand side of the assignment sign ( = ) is the variable and on the right hand side a mathematical expression. The syntax is as follows:
  
-''<Identifier> `=´ <mathematical expression>''+''<Identifier> = <mathematical expression>''
  
-By using an assignment with an unknown identifier, a variable is created and initialized with the value of the given mathematical expression. The variable can be used later in mathematical expression to retrieve their value. +By using an assignment with an unknown identifier, a variable is created and initialized with the value of the given mathematical expression. The variable can be used later in mathematical expression to retrieve their value. The identifier has always to start with a letter, but numerals may be contained in the variable identifier. The value of logical expression cannot be bound to variables!
- +
-The identifier has always to start with a letter, but numerals may be contained in the variable identifier. +
- +
-The value of logical expression cannot be bound to variables!+
  
 In the following a few examples to assignments: In the following a few examples to assignments:
Zeile 105: 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:
  
-''`return´ <mathematical expression>''+''return <mathematical expression>''
  
 === Conditional Statement === === Conditional Statement ===
Zeile 111: Zeile 100:
 An ''if-then-else'' statement evaluates a statement dependent on a given condition. This condition is expressed as a logical expression following the keyword if. If the condition holds, the statement following the then-keyword is evaluated, and otherwise the else denoted statement. The else-case is optional. If no else is given, simply the then denoted statement is not evaluated. The syntax is as follows: An ''if-then-else'' statement evaluates a statement dependent on a given condition. This condition is expressed as a logical expression following the keyword if. If the condition holds, the statement following the then-keyword is evaluated, and otherwise the else denoted statement. The else-case is optional. If no else is given, simply the then denoted statement is not evaluated. The syntax is as follows:
  
-''`if´ <logical expression> `then´ <statement>`else´ <statement> ]''+''if <logical expression> then <statement>else <statement> ]''
  
 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 126: 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 //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:
- +
-''`begin´''+
  
 +''begin''
               <statement 1>               <statement 1>
- 
                  ...                  ...
- 
               <statement n>               <statement n>
- +''end''
-`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 173: 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 192: 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.