中文 English
You are here: Expression Editor > Basics of Expression Editor

13.2 Basics of Expression Editor

The following concepts explain how to use the Expression Editor:

13.2.1 Rules and Options

This section lists the rules for the Expression Editor.

Rule 1: Expressions statements are separated by a space/tab/carriage return.

Rule 2: An expression statement does not need to be fit in a single line.

Rule 3: Comments can be added using the # mark. Any text in the line after “#” will not be used in the expression.

´ Note:  For user defined variable for 3D Display/Plot, special formatted comments are used to redefine display/ plot name with unit.

Rule 4: A user defined variable has to be defined before it can be used. (Otherwise an error message will be returned when the program is running and attempts to use it.)

Rule 5: A variable (e.g. “amp” below) cannot be redefined within the same section and will give an error message when trying to save it (i.e. click OK ).

Rule 6: The expressions are executed according to the order of each statement.

Rule 7: Expressions can operate on both variable types-Scalars and Vectors.

 

13.2.2 Global and Local Expressions

The Expression Editor has two sections for entering expressions: Global and Local. A Global Expression is available everywhere, while Local expressions can only be applied to a single selected object/variable.

Rule 8: Global Expressions are executed before Local Expressions.

Rule 9: Variables defined in the Global Expressions can be used inLocal Expressions.

Rule 10: If a variable defined in a Local Expressions has the same name as a variable in the Global Expressions, the Local one will be used.

 

13.2.3 Variable Types

The Expression Editor can operate on both Vectors and Scalars.

Scalars

A Scalar is a single real number. It can be defined by equating it to an existing scalar or an expression which creates a scalar.

Vectors

A Vector is three (3) ordered numbers. It can be defined using components inside a bracket [x,y,z]. It can also be defined by equating it to an existing vector or an expression of vectors.

Definition:

[x,y,z]: a vector constant where each of x,y,z can be a number or an expression of numbers.

p = q: defines "p" as a vector if "q" is a vector constant, or a vector variable, or an expression of vectors.

The x, y, & z scalar components of a vector can be accessed by appending “.x”, “.y” & “.z” respectively to the vector.

p.x p.y p.z : way to access 3 scalar components of vector p.

 

13.2.4 Units

  • The default units for the expressions are SI (MKS). The default units for the internal data retrieved from solver (e.g. module related variables) are always SI (MKS). User can also choose Non-SI units for user defined variables.
  • The default units of user defined input variables, passed from the Expression Editor to the solver via the Properties Panel, are SI (MKS). If the user uses different units for the variable, user should choose the correct unit by typing in the appropriate unit label in the entry field as shown in Figure 13.4.
 

Note: The predefined module variables maintain their Simerics Default Units within Expression Editor.

 

Figure 13.4 - Example-Change of units

 

Copyright © 2023 Simerics Inc.,