# Set up the exact solution
# Use SDF grid
grid = sdf.grid
# Misc parameters
c0 = 1
m = 8
A = 0.25
rho = 1
# Functions required
def x1(x, y, A):
return x - A*np.sin(x)*np.cosh(y)
def y1(x, y, A):
return y - A*np.cos(x)*np.sinh(y)
def f1(x, y, A):
return 1 - A*np.cos(x)*np.cosh(y)
def f2(x, y, A):
return A*np.sin(x)*np.sinh(y)
def c(x, y, A, c0):
term1 = (1-A*np.cos(x)*np.cosh(y))**2
term2 = (A*np.sin(x)*np.sinh(y))**2
return c0*(term1 + term2)**-0.5
def alpha(m, c0):
return c0*np.sqrt(m**2+(np.pi/2)**2)
def u(t, x, y, c0, m, A):
x1_vals = x1(x, y, A)
y1_vals = y1(x, y, A)
alp = alpha(m, c0)
return np.cos(m*x1_vals-alp*t)*np.cos(np.pi*y1_vals/2)
def u2(t, x, y, c0, m, A):
x1_vals = x1(x, y, A)
y1_vals = y1(x, y, A)
alp = alpha(m, c0)
return np.sin(m*x1_vals-alp*t)*np.sin(np.pi*y1_vals/2)
def vx(t, x, y, c0, m, A):
f1_vals = f1(x, y, A)
f2_vals = f2(x, y, A)
u_vals = u(t, x, y, c0, m, A)
u2_vals = u2(t, x, y, c0, m, A)
alp = alpha(m, c0)
term1 = -m*f1_vals*u_vals
term2 = np.pi*f2_vals*u2_vals/2
return (term1 + term2)/alp
def vy(t, x, y, c0, m, A):
f1_vals = f1(x, y, A)
f2_vals = f2(x, y, A)
u_vals = u(t, x, y, c0, m, A)
u2_vals = u2(t, x, y, c0, m, A)
alp = alpha(m, c0)
term1 = m*f2_vals*u_vals
term2 = np.pi*f1_vals*u2_vals/2
return (term1 + term2)/alp
xvals = np.linspace(0, 2*np.pi, grid.shape[0]-8) # Trim off the edges where we will have bcs
yvals = np.linspace(-3*np.pi/4, 0, grid.shape[1]-4) # -3pi/4
xmsh, ymsh = np.meshgrid(xvals, yvals, indexing='ij')