Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

strain rate

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 :: velocity field gradient 
Python :: python create empty list with size 10 
Python :: get channel name by channel id discord py 
Python :: uncompress zip file in pythonanywhere 
Python :: import variables fron another file 
Python :: difference between iglob() and glob() functions in python 
Python :: __len__ in python 
Python :: pandas iloc stack overflow 
Python :: jupyterlab collapsing cells 
Python :: Python NumPy atleast_1d Function Example when inputs are in high dimension 
Python :: jupyter extension 4 
Python :: python text file contains 
Python :: smile detection 
Python :: Python NumPy require Function Example with requirements attribute 
Python :: add a new field to a Hosted Feature Layer 
Python :: Python NumPy dsplit Function 
Python :: mypy run on single file 
Python :: modles en django 
Python :: how to run string like normal code in python 
Python :: NumPy right_shift Code When inputs and bit shift are an arrays 
Python :: python code to scan paper table to excel 
Python :: mock connection sqlalchemy 
Python :: Demonstration of Python range() 
Python :: parameter name in string 
Python :: python regex exclude letters 
Python :: dimensions of dataset in python 
Python :: how to add start menu in python 
Python :: singke line expresions python 
Python :: shere point file uploading to doc repository python 
Python :: ring open another file 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =