# Calculate Lambda-2 Criterion

Problem:

How do I calculate the Lambda-2 criterion?

Solution:

Use a Tecplot Macro to automate the calculation.

Make sure Tecplot is aware of the variables representing your velocity field (Analyze->Field Variables menu).

The commands are as follow:

• Calculate the tensor of velocity gradients. This command can be obtained by recording the Analyze->Calculate Variables…->Velocity Gradient (tensor) action in Tecplot’s graphical user interface (GUI).
```\$!EXTENDEDCOMMAND
COMMANDPROCESSORID = 'CFDAnalyzer4'
COMMAND = 'Calculate Function=\'VELOCITYGRADIENT\' Normalization=\'None\' ValueLocation=\'Nodal\'
• Use the equations tool (Data->Alter->Specify Equations… menu) to define the symmetric (S) and anti-symmetric (Ω) components of ∇u . By definition: S(i,j) = (u(i,j)+u(j,i) )/2  and Ω(i,j) = (u(i,j)-u(j,i) )/2 :
```\$!ALTERDATA EQUATION = '{s11} = {dUdX}'
\$!ALTERDATA EQUATION = '{s12} = 0.5*({dUdY}+{dVdX})'
\$!ALTERDATA EQUATION = '{s13} = 0.5*({dUdZ}+{dWdX})'
\$!ALTERDATA EQUATION = '{s22} = {dVdY}'
\$!ALTERDATA EQUATION = '{s23} = 0.5*({dVdZ}+{dWdY})'
\$!ALTERDATA EQUATION = '{s33} = {dWdZ}'
\$!ALTERDATA EQUATION = '{Omga12} = 0.5*({dUdY}-{dVdX})'
\$!ALTERDATA EQUATION = '{Omga13} = 0.5*({dUdZ}-{dWdX})'
\$!ALTERDATA EQUATION = '{Omga23} = 0.5*({dVdZ}-{dWdY})'```
• Build the S2+Ω2 tensor using the equations tool:
```\$!ALTERDATA EQUATION = '{s2o2_11} = {s11}**2 + {s12}**2 + {s13}**2 - {Omga12}**2 - {Omga13}**2'
\$!ALTERDATA EQUATION = '{s2o2_12} = {s11}*{s12} + {s12}*{s22} + {s13}*{s23} - {Omga13}*{Omga23}'
\$!ALTERDATA EQUATION = '{s2o2_13} = {s11}*{s13} + {s12}*{s23} + {s13}*{s33} - {Omga12}*{Omga23}'
\$!ALTERDATA EQUATION = '{s2o2_22} = {s12}**2 + {s22}**2 + {s23}**2 - {Omga12}**2 - {Omga23}**2'
\$!ALTERDATA EQUATION = '{s2o2_23} = {s12}*{s13} + {s22}*{s23} + {s23}*{s33} - {Omga12}*{Omga13}'
\$!ALTERDATA EQUATION = '{s2o2_33} = {s13}**2 + {s23}**2 + {s33}**2 - {Omga13}**2 - {Omga23}**2'```
• Retrieve the variable numbers of the S2+Ω2 components, to be used for the calculation of the tensor eigenvalues:
```\$!GETVARNUMBYNAME |numVars2o2_11|
NAME = "s2o2_11"
\$!GETVARNUMBYNAME |numVars2o2_12|
NAME = "s2o2_12"
\$!GETVARNUMBYNAME |numVars2o2_13|
NAME = "s2o2_13"
\$!GETVARNUMBYNAME |numVars2o2_22|
NAME = "s2o2_22"
\$!GETVARNUMBYNAME |numVars2o2_23|
NAME = "s2o2_23"
\$!GETVARNUMBYNAME |numVars2o2_33|
NAME = "s2o2_33"```
• Calculate the eigenvectors and the eigenvalues of S2+Ω2 using the Tensor Tools (Tools->Tensor Eigensystem… menu):
```\$!EXTENDEDCOMMAND
COMMANDPROCESSORID = 'Tensor Eigensystem'
COMMAND = 'T11VarNum = |numVars2o2_11|, T12VarNum = |numVars2o2_12|, T13VarNum = |numVars2o2_13|,
T22VarNum = |numVars2o2_22|, T23VarNum = |numVars2o2_23|, T33VarNum = |numVars2o2_33|,
SortEgnV = TRUE, SaveEgnVect = TRUE '```

A set of new variables has been created: EgnVal(i)i={1,2,3} and EgnVec(ij)(i,j)={1,2,3}2. An iso-surface of Lambda-2 (EgnVal2) can be used to identify vortices.