I am implementing Lambda-2 criterion in Paraview 5.6.0 mounted on Linux. What it does is to provide a view of the presence of a vortex in a 3D flow by knowing when at least two of the eigenvalues of (||S||^2 + ||Omega||^2) are negative. Here, S and Omega are the symmetric and antisymmetric parts of the Velocity gradient tensor.
By following the instructions of some other posts where they dealt with this implementation, I have made the following:
- Gradient of unstructured data set. Inputting Velocity as Scalar Array and Compute Gradients
- Python calculator. Expression “eigenvalue(strain(Velocity)**2 + (Gradients - strain(Velocity))**2)”. Array name “Lambda”. This computes the three eigenvalues of the expression ||S||^2 + ||Omega||^2
- Calculator. “Lambda_Y”. Result Array Name “Lambda2”. Get the second eigenvalue of the previous result. Since the three eigenvalues are ordered such that Lambda1 >= Lambda2 >= Lambda3, if Lambda2 is negative, Lambda3 is negative too, so a vortex is found.
1- I am having some issues since the results that I obtain are not the expected ones. So I took one step back and I have been looking terms by terms what is happening there. I have realized that if I compute the Gradient of Unstructured Data Set to get the velocity gradient and I compute my means of a Python calculator “strain(Velocity)”, the tensor I am obtaining in both cases does not share the trace. Both of them should share the trace since strain(Velocity) = 1/2*(Gradient(Velocity) + transpose(Gradient(Velocity)), and it is not the case.
2- Also, I am evaluating if the issues comes from the eigenvalue calculation itself. To do so, I tried to simple compute the eigenvalues of the velocity gradient by means of the function eigenvalue(Gradients) as well as by means of numpy.linalg.eigvals(Gradients). Think this second version to compute should work better, however, it draws the following error (it does not recognize the Gradients tensor as a tensor):
Traceback (most recent call last):
File “”, line 4, in
File “/home/softs/softs/ParaView-5.6.0-MPI-Linux-64bit/lib/python2.7/site-packages/paraview/calculator.py”, line 192, in execute
retVal = compute(inputs, expression, ns=variables)
File “/home/softs/softs/ParaView-5.6.0-MPI-Linux-64bit/lib/python2.7/site-packages/paraview/calculator.py”, line 140, in compute
retVal = eval(expression, globals(), mylocals)
File “”, line 1, in
File “/home/softs/softs/ParaView-5.6.0-MPI-Linux-64bit/lib/python2.7/site-packages/numpy/linalg/linalg.py”, line 1021, in eigvals
File “/home/softs/softs/ParaView-5.6.0-MPI-Linux-64bit/lib/python2.7/site-packages/numpy/linalg/linalg.py”, line 204, in _assertRankAtLeast2
‘at least two-dimensional’ % a.ndim)
numpy.linalg.linalg.LinAlgError: 0-dimensional array given. Array must be at least two-dimensional
Thank you in advance,