Hello,
I am a bit confused about how to impose periodic boundary conditions in Dedalus 3.
I am interested in solving the spectrum of shallow water equations with a periodic boundary. I could get D2 and D3 to match with a no-slip boundary condition but not with periodic boundary conditions. Below is my working setup for the no-slip boundary condition. I would like to impose the fields u and v to be periodic. From the documentation and examples, it seems like the periodic boundary condition is implemented through 'integ(u) = 0' but I am having trouble applying it to my specific case. Any help is greatly appreciated!
# Global parameters
Ny = 51 # number of points in y direction
Ly = 10*np.pi # width the domain
kmax = np.pi # horizontal wave number extrema
kx_global = np.linspace(-kmax,kmax,100)
ky = 0.0
N = 1
def problem_builder(kx):
# Create bases and domain
ycoord = d3.Coordinate('y')
dist = d3.Distributor(ycoord, dtype=np.complex128)
ybasis = d3.Chebyshev(ycoord, size=Ny, bounds=(-Ly/2, Ly/2))
y = dist.local_grids(ybasis) # grid
# Fields
u = dist.Field(name='u', bases=ybasis)
v = dist.Field(name='v', bases=ybasis)
h = dist.Field(name='h', bases=ybasis)
tau_1 = dist.Field(name='tau_1')
tau_2 = dist.Field(name='tau_2')
omega = dist.Field(name='omega')
# Substitution
dy = lambda A: d3.Differentiate(A, ycoord)
dx = lambda A: 1j*kx*A
dt = lambda A: -1j*omega*A
lift_basis = ybasis.derivative_basis(1)
lift = lambda A: d3.Lift(A, lift_basis, -1)
ky = 1
# define non-constant coefficients
f = dist.Field(bases=ybasis)
f['g'] = np.sin(2*np.pi*y[0]/Ly)
problem = d3.EVP([u, v, h, tau_1, tau_2], eigenvalue=omega, namespace=locals())
problem.add_equation("dt(u) + dx(h) - f * v = 0")
problem.add_equation("dt(v) + dy(h) + f * u + lift(tau_1) = 0")
problem.add_equation("dt(h) + dx(u) + dy(v) + lift(tau_2) = 0")
# # no-slip boundary condition
problem.add_equation("v(y='left') = 0")
problem.add_equation("v(y='right') = 0")
solver = problem.build_solver()
return solver, ybasis, dist
Best,
Zoe