Basics of Expression Editor
Rules and Options
Rule 1 — Expressions statements are separated by a space/tab/carriage return.
Rule 2 — An expression statement does not need to fit in a single line.
Rule 3 — Comments are added using the # symbol. Any text in the line after the # symbol, is not be used in the expression.
Example:
# Pump center coordinates
Pcx = 0
Pcy = 0
Pcz =0.01
* 
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 must be defined before you use it. Otherwise, an error message is returned when the program runs and will attempt to use it.
Example:
# the following are valid statements
a=1 b=2 c=3
d=4
# the following are invalid statements
b=5
b=7 # variable "b" redefined
Rule 5 — A variable, such as amp, cannot be redefined within the same section. The variable gives an error message when you click OK to try and save it.
Example :
#An expression for setting a sinusoidal pressure as a function of time
f = 50
one_atm = 101325
po = 4*one_atm
amp = 2*one_atm
high_p = po+amp*(0.5*sin(2*pi*f*time))
Rule 6 — Expressions are executed according to the order of each statement.
Rule 7 — Expressions operate on scalar and vector variables.
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 apply only to a single selected object or variable.
Rule 8 — Expressions in the Global Expressions box are executed before the expressions in the Local Expressions box.
Rule 9 — Variables defined in the Global Expressions box are used in Local Expressions.
Rule 10 — If a variable defined in the Local Expressions box has the same name as a variable in the Global Expressions box, then the variable in the Local Expressions box is used.
Variable Types
The Expression Editor operates on both Vectors and Scalars.
Scalars — A scalar is a single real number. The scalar is defined by equating it to an existing scalar or an expression which creates a scalar.
Example :
Scalar1 = 3
Scalar2 = heat.T # where heat.T is a predefined scalar quantity from the Heat module (the temperature )
Vectors — A vector is three (3) ordered numbers. The vector is defined using components inside a bracket [x,y,z]. A vector is also defined by equating it to an existing vector or an expression of vectors. Vectors are defined as :
[x,y,z] — A vector constant where each 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, and z scalar components of a vector are accessed by appending x, .y, and z respectively to the vector.
p.x p.y p.z — Way to access 3 scalar components of vector p.
Example:
Vector = [u, v, w] # Defines a vector with components u,v,w
Vector = flow.V # where flow.V is a predefined vector from the Flow module (the velocity vector)
Vector2 = [10, 20*u, 10+flow.V.z] + vel_old - 3*grid_vel
w = flow.V.z # Retrieves the z-component of flow.V (where flow.V is a predefined vector from the Flow module )
Units
Default units for the expressions and for the internal data retrieved from solver or module related variables are always SI or MKS. You can also choose non-SI units for user defined variables.
The default units of user defined input variables that pass from the Expression Editor to the solver though the Properties Panel are SI or MKS. To use different units for the variable, you type the unit in the appropriate unit label in the entry field.
Example:
When you specify the pressure boundary condition using a variable high_p defined in the Expression Editor, the unit for inlet pressure is Pa by default. You can change the unit manually to psi. A list of units is available in the Systems of Units menu.
* 
The predefined module variables maintain their Creo Flow Analysis default units in the Expression Editor.