Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

vortex identification

def Lambda2(macroscopic_velocities, negative_cutoff = 0):
  """Use vortex detection algorithm "Lambda2" to get which nodes in your velocity field are inside a vortex.
  """
  # First define the gradients of the velocity field: Δu
  _gradients = np.gradient(macroscopic_velocities, 
                           axis = (0, 1, 2))
  gradients = np.einsum('dD...-> ...dD', 
                        np.array(_gradients))

  # Get the strain rate tensor: S = (Δu + Δuᵀ)/2
  transposed_gradients = np.einsum('...dD -> ...Dd', 
                                   gradients)
  strain_rate = (gradients + transposed_gradients)/2

  # Get the vorticity tensor: Ω = (Δu - Δuᵀ)/2
  vorticity = (gradients - transposed_gradients)/2 

  # Get the eigenvalues (λ) of S² + Ω². Use np.eigh to get ordered eigenvalues. 
  S2_O2 = strain_rate**2 + vorticity**2
  eigen_values, errors = np.linalg.eigh(S2_O2)

  # Select the locations where λ₂ < the negative cutoff. 
  # Negative cutoff must be 0 or less.
  in_vortex = (eigen_values < negative_cutoff)[..., 1]
  return in_vortex
Comment

PREVIOUS NEXT
Code Example
Python :: conditional_escape 
Python :: Use xarray to open a ncdf file 
Python :: python multi dimensional dict 
Python :: *9c0xxbz] 
Python :: convert float array to integer 
Python :: cartopy indicate lat lon 
Python :: list update python 
Python :: Find element with class name in requests-html python 
Python :: Python NumPy squeeze function Example with axis=1 
Python :: Python NumPy ndarray.T Example 
Python :: else 
Python :: pypi autopep8 
Python :: Python NumPy asarray Function Example Tuple to an array 
Python :: Python NumPy stack Function Syntax 
Python :: how to change text in heatmap matplotlib 
Python :: emit data to specific client socketio python 
Python :: codeforces problem 580A 
Python :: python model feature importance 
Python :: track keyboard press pynput 
Python :: NumPy packbits Code Packed array along axis 1 
Python :: Termfastapi get ip 
Python :: dictionary display 
Python :: Python range Incrementing with the range using a positive step 
Python :: python forward declaration 
Python :: print(i) 
Python :: How to allow discord bot to respond to webhook. Python. Discord.py 
Python :: DOWNLOAD ANALYZE_DXP.PY 
Python :: dict python inpmenttion 
Python :: python static 
Python :: ring convert between Numbers and Bytes 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =