Step function parameters

160 views
Skip to first unread message

Ziyan Zhu

unread,
Oct 9, 2020, 4:32:22 PM10/9/20
to Dedalus Users
Hello, 

I am a new user of Dedalus. I am wondering if Dedalus can solve an eigenvalue problem or a boundary value problem with a step function parameter. For example, in the following code, instead of 'problem.substitutions['f'] = "1.0" ', I would like to substitute f with a step function of the form of 
f = 0.5 for f < 0
f = 1 for f > 0. 
Is something like this possible? 

Thanks in advance, 
Zoe 

Ny = 51 # number of points in y direction
Ly = 5*np.pi #  width the domain
kmax = np.pi # horizontal wave number extrema
kx_global = np.linspace(-kmax,kmax,100)

# Create bases and domain
y_basis = de.Chebyshev('y', Ny, interval=(-Ly/2, Ly/2)) 
domain = de.Domain([y_basis], grid_dtype=np.complex128, comm=MPI.COMM_SELF) # build a physical domain 

# EVP -> setting up eigenvalue problem 
problem = de.EVP(domain, variables=['u','v','h'], eigenvalue='omega')
# Dirichlet preconditioning that sparifies Dirchlet boundary (interpolation at the Chebyshev interval endpoints)
# Only necessary for Dirichlet boundary condition 
problem.meta[:]['y']['dirichlet'] = True

problem.parameters['Ly'] = Ly
problem.parameters['kx'] = 1 # why do we take kx = 1 but later change kx? 
problem.parameters['pi'] = np.pi

# Use substitutions for x and t derivatives
problem.substitutions['dx(A)'] = "1j*kx*A"
problem.substitutions['dt(A)'] = "-1j*omega*A"
problem.substitutions['w'] = "dx(u) + dy(v)"

problem.substitutions['f'] = "1.0"

problem.add_equation("dt(u) + dx(h) - f * v = 0")
problem.add_equation("dt(v) + dy(h) + f * u = 0")
problem.add_equation("dt(h) + w = 0")

problem.add_bc("left(v) = 0")
problem.add_bc("right(v) = 0")




Keaton Burns

unread,
Oct 9, 2020, 5:05:59 PM10/9/20
to dedalu...@googlegroups.com
Hi Zoe,

First, you could try creating a field for f, setting it to a parametrically smoothed-out step function like tanh or erf, and passing that field into the problem as an NCC parameter.

You could also try using a compound Chebyshev basis, which is two Chebyshev segments stacked next to each other.  Then you could actually make a discontinuous NCC field for f, and pass that in.

-Keaton
--
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/b7c7f442-094f-4224-b755-c0a76b05253dn%40googlegroups.com.

Ziyan Zhu

unread,
Oct 14, 2020, 1:48:24 AM10/14/20
to Dedalus Users
Many thanks for your prompt help, Keaton! 

Best,
Zoe 
Reply all
Reply to author
Forward
0 new messages