Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

velocity field gradient

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 :: pandas sample weights example 
Python :: how to plot a single centroid 
Python :: mk270 suits for programming reddit 
Python :: Sequential Execution EC2 
Python :: convert a float array to an integer 
Python :: install python 3.10 pip 
Python :: linux show output 
Python :: find a paragraph in requests-html 
Python :: Python NumPy broadcast_to() Function Syntax 
Python :: Python NumPy rollaxis Function Syntax 
Python :: os.path.join not working 
Python :: youtube-dl python not found 
Python :: Python NumPy asanyarray Function Syntax 
Python :: Python NumPy block Function Syntax 
Python :: inverrt heatmap cmap 
Python :: fpdf latin-1 
Python :: python __sub__ 
Python :: sorting a specific row python 
Python :: print number upto 2 decimal places in f string python 
Python :: NumPy unpackbits Syntax 
Python :: free konta mc 
Python :: adjugate of 3x3 matrix in python 
Python :: Concatenation of two range() functions 
Python :: for loop for calendar day selection using selenium python 
Python :: print banner in python 
Python :: heatmap colorbar label 
Python :: string exercise 
Python :: Django, limit queryset without slicing 
Python :: linkedin bot python 
Python :: ring get the windows new line string 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =