-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVorticity.py
More file actions
31 lines (23 loc) · 733 Bytes
/
Vorticity.py
File metadata and controls
31 lines (23 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
def Vorticity(u, v, dx, dy):
"""Calculates the Vorticity
Params:
-------
x, y 2D arrays of float, x and y direction points
u, v 2D arrays of float, u and v velocity vectors
Returns:
-------
Vorticity 2D array of float, curl of the velocity field
"""
dV = np.empty_like(v, dtype=float)
dU = np.empty_like(u, dtype=float)
dV = np.gradient(v)
dU = np.gradient(u)
V_gradient = dV[1]/dx
U_gradient = dU[0]/dy
Vorticity = V_gradient - U_gradient
Vorticity[-1,:] = Vorticity[0,:]
Vorticity[:,-1] = Vorticity[:,0]
Vorticity[-2,:] = Vorticity[-1,:]
Vorticity[:,-2] = Vorticity[:,-1]
return Vorticity