Periodic boundary condition in EVP (D3)

125 views
Skip to first unread message

Ziyan Zhu

unread,
Jun 3, 2022, 7:02:29 PM6/3/22
to Dedalus Users
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 

Daniel Lecoanet

unread,
Jun 7, 2022, 10:14:51 AM6/7/22
to Dedalus Users
Hi Zoe,

If you want to run a periodic simulation, I would recommend that you use a Fourier basis.

Daniel

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/5c6bd53d-2454-4ddf-aa26-b9a6f3e31579n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages