Calculate Data from Expressions
Use the Calculate tool to create new field quantities using a python expression. The new fields can be derived from existing fields or be completely independent of other results in the dataset.
There are some important characteristics of the Calculate tool that need to be understood to use it effectively. When a new function is created, it is not immediately evaluated. Rather, the expression syntax is parsed and checked for validity. If an expression contains invalid functions or variables it will not be accepted by the calculate context and the text will revert back to the previous state. Once the expression is validated, it is added to the global variable list within the session of HyperMesh CFD. It is not until that expression is selected to use for contouring, streamline tracing, or generating an isosurface that it is evaluated. When the expression is evaluated, it is evaluated on a local basis. For example, you create an expression for total pressure:
pTot = 0.5*density*velocity**2 + pressure
If you then choose to color a slice plane by pTot, it is calculated based on the local coordinates and results variables available on that slice plane. No information from the parent volume dataset is accessed. This is done to minimize memory overhead of the derived variables and to improve performance. However, if your expression includes gradients of quantities, it is important to note that the gradients will not be calculated on a global level. Rather, they will be evaluated using the data on the surface. In the case of a slice plane, this means that the gradients will not be accurate in the plane normal direction. This “calculate on demand” approach also has some implications for querying the fields prior to use. A number of features in the user interface rely on the ability to query the function range. One example is the range setting of the colormap. For preexisting variables, the range is populated based on a query of the range of the scalar. Since derived fields are not computed a priori, the range inputs will not be populated with proper values.

From the Post ribbon, click the Calculate tool.
The Derived Data Calculator dialog opens.
 Click to add a variable.

Define the name and expression.
 Define the name without spaces so that it can be utilized in further expression definitions.
 If using an existing variable with a space in its names, like “wall shear stress”, replace the spaces with “_”.
 Expressions are defined in python syntax.
Tip: Click / to import or export defined expressions. CFD_Formulas.zip contains an example CSV file with a list of standard functions you can utilize.Tip: Click to automatically load predefined expressions for common aerodynamic coefficients and other derived fields. A complete list of the fields in given in the table below.The output of each expression produces new results at each node of the geometry that it is operating on. Results fields are stored as numpy arrays and can be operated on using standard numpy operations. For example, the xcomponent of the velocity array can be accessed with slicing by using the following syntax:
X_{Vel} = velocity[:,0]
Alternatively, the predefined field for the x component of the velocity could be directly referred to in an expression as follows:
X_{VelSquared} = (x velocity)*(x velocity)
The expression shown above is not acceptable python syntax due to the space in the “x velocity” string. To overcome this, each expression is parsed prior to evaluation to convert the variable names to a valid python expression.
Function/Variable  Description  Example  

Name  Expression  
gradient()  Calculates the gradient of a field  gradVel  gradient(velocity) 
mag()  Calculates the magnitude of an array  velMag  mag(velocity) 
strain()  Calculates the strain of a vector  velStrain  strain(velocity) 
eigenvalue()  Calculates the eigenvalue of an array  lambda2  eigenvalue(velStrain**2.0 + (gradVelvelStrain)**2.0) 
cross()  Calculates the cross product of two vectors  powellParameter  cross(vorticity,velocity) 
curl()  Calculates the curl of a vector  vorticity  curl(velocity) 
divergence()  Calculates the divergence of an array  divVel  divergence(velocity) 
make_vector()  Creates a vector from three scalar fields  velocity_xy  make_vector(velocity[:,0],velocity[:,1],velocity[:,2]*0.0) 
Some functions above return vector and tensor quantities. At the current time, HyperMesh CFD has no way to know a priori what the return dimension of a given function will be. As such, results may be unpredictable for complex expressions. The expression validation also becomes more complex as nested functions are used. It is best to use multiple fields to build up complex expressions. For example, to compute the Qcriterion, first compute the gradient of the velocity, then sum the gradients in a separate expression to evaluate Q:
Name  Expression 

gradVel  gradient(velocity) 
Q_criterion  0.5*( gradVel[:,0,0]*gradVel[:,0,0] + gradVel[:,1,0]*gradVel[:,0,1] + gradVel[:,2,0]*gradVel[:,0,2] + gradVel[:,0,1]*gradVel[:,1,0] + gradVel[:,1,1]*gradVel[:,1,1] + gradVel[:,2,1]*gradVel[:,1,2] + gradVel[:,0,2]*gradVel[:,2,0] + gradVel[:,1,2]*gradVel[:,2,1] + gradVel[:,2,2]*gradVel[:,2,2] ) 
Field  SI Units 

pressure_inf  Pa 
velocity_magnitude_inf  m/s 
density_inf  kg/m^3 
velocity_magnitude  m/s 
pressure_static  Pa 
pressure_dynamic  Pa 
pressure_dynamic_inf  Pa 
pressure_coefficient  Nondimensional 
total_pressure  Pa 
total_pressure_coefficient  Nondimensional 
total_pressure_inf  Pa 
velocity_magnitude_coefficient  Nondimensional 
shear_stress_magnitude  N/m^2 
skin_friction_coefficient  Nondimensional 
velocity_xy  m/s (Vector) 
velocity_xz  m/s (Vector) 
velocity_yz  m/s (Vector) 
velocity_gradient  1/sec (Tensor) 
velocity_strain  Nondimensional (Vector) 
Q_criterion  1/sec^2 
lambda2  1/sec^2 
lambda2_magnitude  1/sec^2 
lambda2_x  1/sec^2 
lambda2_y  1/sec^2 
lambda2_z  1/sec^2 
vorticity  1/sec (Vector) 
vorticity_magnitude  1/sec 
vorticity_x  1/sec 
vorticity_y  1/sec 
vorticity_z  1/sec 
powell  m/sec^2 (Vector) 
powell_magnitude  m/sec^2 
powell_x  m/sec^2 
powell_y  m/sec^2 
powell_z  m/sec^2 
xCrd  m 
yCrd  m 
zCrd  m 
surface_normal_x  Nondimensional 
surface_normal_y  Nondimensional 
surface_normal_z  Nondimensional 
pressure_stress_x  N/m^2 
pressure_stress_y  N/m^2 
pressure_stress_z  N/m^2 
x_total  N/m^2 
y_total  N/m^2 
z_total  N/m^2 