Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

vorticity

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 :: bulet in jupyter notebook 
Python :: python create empty list with size 
Python :: python adding an item 
Python :: to iterate across information on same nest 
Python :: drop columns delta table 
Python :: generate pycryptodome salt 
Python :: python new set 
Python :: python subprocess call with no environment variable 
Python :: Python NumPy squeeze function Syntax 
Python :: Python NumPy transpose Function Example in one line of code 
Python :: run all pycharm jupyter notebook 
Python :: manipulate sns legend 
Python :: how to convrete .npz file to txt file in python 
Python :: Python NumPy concatenate Function Example when axis equal to 0 
Python :: seaborn log heatmap 
Python :: Python NumPy hsplit Function 
Python :: How to obtain a jpeg resolution in python 
Python :: how to fetch limited rows in pandas dataframe using sqlalchemy 
Python :: funcs_and_args for loop python 
Python :: NumPy packbits Syntax 
Python :: ttk.frame 
Python :: ExpressionalRebel 
Python :: call a Python range() using range(stop) 
Python :: cv2 recize 
Python :: send by email in odoo 14 
Python :: selsearch 
Python :: django insert data into database without form 
Python :: Creating 2-dimesional array 
Python :: python without creating pyc 
Python :: ring get the type a given path (file or directory) 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =