Boundary conditions and general forcing functions

985 views
Skip to first unread message

Giulio Meille

unread,
Feb 17, 2016, 8:20:38 PM2/17/16
to Dedalus Users
Hi,

I am a beginner in Dedalus attempting to write my first script (please bear with these questions...) simulating the 2D shallow water equations with no slip BC. 

First, a very basic question about BCs:

To specify BCs, we generally use the myproblem.add_bc("right/left(myfield = x)) formalism. However, in a  multidimensional problem, the formalism does not seem to specify along which basis the boundary condition is being applied. Am I correct in assuming that the BC is being applied along the "interesting" Chebyshev direction? How might I apply no slip BCs along the entire perimeter of my domain if I am (hopefully correctly) working with Fourier in my x-basis and Chebyshev in my y-basis? From my understanding, it seems to me that the Dedalus BC formalism is such that 'll only be able to apply BCs on the endpoints of my x-basis and not my y-basis.

General Forcing functions Question:

I am trying to add a specific type of general forcing function to my dynamical equations and am trying to understand Daniel Lecoanet's explanation and modify it to suit my needs. 


I want to be able to specify my forcing function as a a scalar at each gridpoint and at each timestep of the simulation. That is, the forcing function at each timestep should be represented by an array (representing the gridpoints) of prespecified numerical scalars, and then the dynamical equations should then be modified at each gridpoint to include the forcing term specified in the array at that gridpoint. Hopefully that makes sense... Is there an "easy" way to do this using Dan Lecoanet's instructions?

Thanks so much,

Giulio 

Keaton Burns

unread,
Feb 18, 2016, 6:30:28 PM2/18/16
to Dedalus Users
Hi Giulio,

The current version of Dedalus only supports up to one Chebyshev dimension in a problem, and the Chebyshev basis is the only one for which boundary conditions can be explicitly specified, so this is why there’s only “left” and “right” and no further distinction for which dimension the BC is being applied to.

In the multidimensional case, the other dimensions must either be Fourier or Sin/Cos series, and the corresponding boundary conditions are those implicitly tied to each of those bases. That is, a Fourier representation is for fields that are periodic in a given direction, a sine series is used for fields with odd parity around the endpoints, and a cosine series is used for fields with an even parity around the endpoints.

So the Sin/Cos basis allows you to do multidimensional problems with boundaries, but only if the boundary conditions are equations match up so that each field has definite parity in the Sin/Cos dimensions. Typically, without rotation, things work out so that you can do stress-free boundary conditions in the Sin/Cos direction using this setup, but not no-slip. Doing no-slip all the way around generally requires multiple Chebyshev basis, which is currently under development.

For forcing, if you can analytically write your forcing function as a function of say (x, y, z, t), then you can just write it in on the RHS of the relevant equation, e.g. “LHS = cos(x-t)”. If it’s more complicated than that, yes it’s probably easiest to use the GeneralFunction operator (see link below), which lets you write an arbitrary function specifying the local data of your forcing term, using the local data grids (as you do for initial conditions) and solver.sim_time, if necessary. See:

https://bitbucket.org/dedalus-project/dedalus/src/5278f1abfe16f578963c4e9ca8ac04c395c3a1f7/dedalus/core/operators.py?at=default&fileviewer=file-view-default#operators.py-165

Hope that helps, and definitely keep e-mailing if anything is still unclear.

Best,
-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 post to this group, send email to dedalu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/f6e2268b-73b3-449e-8561-68ae24a7889a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Giulio Meille

unread,
Feb 19, 2016, 2:59:39 AM2/19/16
to Dedalus Users
Thank you Keaton, that was very illuminating. Unfortunately it doesn't seem I will be able to use Dedalus for my specific problem, but I do have a few follow-up question about bases for future problems.

As you mentioned, the sin/cos basis is appropriate along a given dimension when there is definite parity. I don't see how this is ever going to be the case for nonlinear dynamical equations with coupling between fields such as the advective terms of the Navier-Stokes Eq. Nonlinearities would generally destroy parity and as you mentioned perhaps even linear coupling. Can we only look at these types of IVP in 2D if we want to simulate with periodic boundary conditions along our Fourier dimension?

I'm also a bit confused about in what sense problems need to be decoupled between modes along the N-1 non-Chebyshev bases for the linearized differential equations. Let's say I linearize my dynamical equations and have some linear coupling terms of the fields between these equations. This is fine, right? - when we say that the modes are uncoupled we mean uncoupled between mode number, not uncoupled between fields. Is the proper way to determine whether the non-Chebyshev dimensions are uncoupled literally to substitute in general forms of the modes and see if there is coupling between different mode numbers?

Thanks again,

Giulio

Keaton Burns

unread,
Feb 19, 2016, 4:22:25 PM2/19/16
to Dedalus Users
Hi Giulio,

The quadratic nonlinearities in the advective terms modify the parity in well-defined ways, the issue is whether the resulting parities match the parities of the other terms in the equations, as well as the BC’s.

Let’s take a look at incompressible hydro in a 2D domain, Sin/Cos in x and Chebyshev in y. At the sidewalls, u should have odd parity (-1) due to impenetrability, while for stress-free boundary conditions, v should have even parity (+1). The parity of the partial derivatives are then:

dx(u): +1
dy(u): -1
dx(v): -1
dy(v): +1

The parity of the advective terms are then:

u*dx(u): (-1)*(+1) = -1
v*dy(u): (+1)*(-1) = -1
u*dx(v): (-1)*(-1) = +1
v*dy(v): (+1)*(+1) = +1

So the parity of (u*dx(u) + v*dy(u)) matches the parity of u, and the parity of (u*dx(v) + v*dy(v)) matches the parity of v. You can work out that the parities of all the other terms match, too, if you take the pressure p to have even parity (+1). For no-slip boundary conditions, v would also have parity (-1), and you can work out that then the parities of the relevant advective terms don’t match up.

For your second question, yes, coupling between the fields is fine, you just cannot have linear coupling between different modes in the non-Chebyshev dimensions. You can tell from the form of the linear operators whether they should couple different Fourier (or Sin/Cos) modes. Differential operators don’t couple Fourier modes, but e.g. interpolation along the Fourier direction or multiplication by an x-dependent non-constant coefficient would couple them.

Best,
-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 post to this group, send email to dedalu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/91a3db79-edfe-4bea-9d8b-01504c2b4bfe%40googlegroups.com.

Daniel Lecoanet

unread,
Feb 19, 2016, 5:33:55 PM2/19/16
to dedalus-users
Just to follow up... I know Anna Lieb (who has posted on this group) successfully solved 2D shallow water using Dedalus.  So its definitely possible to do that problem in Dedalus.

Daniel

Reply all
Reply to author
Forward
0 new messages