-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaylor_Green_Analytical_Solution.py
More file actions
40 lines (29 loc) · 1.28 KB
/
Taylor_Green_Analytical_Solution.py
File metadata and controls
40 lines (29 loc) · 1.28 KB
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
32
33
34
35
36
37
38
39
40
import numpy as np
def Analytical_Solution(u_exact, v_exact, p_exact, xu, yu, xv, yv, xp, yp, T, Nx, Ny):
'''Calculates the analytical solution of Taylor Green Vortex at time T.
Params:
-------
u_exact, v_exact, p_exact 2D array of float, exact solution grids
xu, yu 2D array of float, u velocity grid points
xv, yv 2D array of float, v velocity grid points
xp, yp 2D array of float, pressure grid points
T float, solution Time
Returns:
--------
u, v 2D array of float, analytical u and v at T
p 2D array of float, analytical p at T
'''
u = np.empty_like(u_exact, dtype=float)
v = np.empty_like(v_exact, dtype=float)
p = np.empty_like(p_exact, dtype=float)
for i in range(0,Ny+2):
for j in range(0,Nx+3):
u[i,j] = -np.exp(-2.0*T)*np.cos(xu[j])*np.sin(yu[i])
for i in range(0,Ny+3):
for j in range(0,Nx+2):
v[i,j] = np.exp(-2.0*T)*np.sin(xv[j])*np.cos(yv[i])
for i in range(0,Ny):
for j in range(0,Nx):
p[i,j] = -0.25*np.exp(-4.0*T)*(np.cos(2.0*xp[j]) +\
np.cos(2.0*yp[i]))
return u, v, p