how to add equation and boundary for poisson equation, which has non-constant parameters

203 views
Skip to first unread message

ruirui wang

unread,
Jul 29, 2020, 11:46:58 AM7/29/20
to Dedalus Users
Hello!
   I want to solve a poisson equation (N*dx(dx(w))+dz(dz(w))=F),  which has non-constant parameters . this parameters, such as N and F, change both with x axis and z axis. How should I set my equation and boundary . When I set my basis in x and z axis as 'Chebyshev',  left and right  boundary are set as  'w=0', it will be wrong and tell me : ' Boundary condition must be constant along 'x''.
   the following is my code:
# Create bases and domain
x_basis = de.Chebyshev('x', int(nx), interval=(x_in, x_out))
z_basis = de.Chebyshev('z',int(nz), interval=(z_in, z_out))
domain = de.Domain([x_basis, z_basis],grid_dtype=np.float64)


problem.add_equation("N2*dx(wx) +dz(wz) = F")
problem.add_equation("wx - dx(w) = 0")
problem.add_equation("wz - dz(w) = 0")
problem.add_bc("left(w)-right(w)= 0", condition="(nx != 0)and (ny != 0)")
problem.add_bc("right(wz) = 0", condition="(nx != 0)and (ny != 0)")
 

Thank you for your reply


                                                                                                                                                       

Daniel Lecoanet

unread,
Jul 29, 2020, 12:01:26 PM7/29/20
to dedalu...@googlegroups.com
Hi,

Currently in Dedalus you can only use a single Chebyshev direction.

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/3fbf550a-c3b7-4eca-888e-92d0b831b305o%40googlegroups.com.

ruirui wang

unread,
Jul 29, 2020, 12:23:44 PM7/29/20
to Dedalus Users
Thank you for your reply .  Olny one direction can use Chebyshev, which means non-constant coefficients (NCCs) only change in one direction ,right?  But when I have a parameter which change not only in one direction,  whether Dedalus can solve this equation?

在 2020年7月30日星期四 UTC+8上午12:01:26,Daniel Lecoanet写道:
Hi,

Currently in Dedalus you can only use a single Chebyshev direction.

Daniel

On Wed, Jul 29, 2020 at 11:47 AM ruirui wang <ruiru...@gmail.com> wrote:
Hello!
   I want to solve a poisson equation (N*dx(dx(w))+dz(dz(w))=F),  which has non-constant parameters . this parameters, such as N and F, change both with x axis and z axis. How should I set my equation and boundary . When I set my basis in x and z axis as 'Chebyshev',  left and right  boundary are set as  'w=0', it will be wrong and tell me : ' Boundary condition must be constant along 'x''.
   the following is my code:
# Create bases and domain
x_basis = de.Chebyshev('x', int(nx), interval=(x_in, x_out))
z_basis = de.Chebyshev('z',int(nz), interval=(z_in, z_out))
domain = de.Domain([x_basis, z_basis],grid_dtype=np.float64)


problem.add_equation("N2*dx(wx) +dz(wz) = F")
problem.add_equation("wx - dx(w) = 0")
problem.add_equation("wz - dz(w) = 0")
problem.add_bc("left(w)-right(w)= 0", condition="(nx != 0)and (ny != 0)")
problem.add_bc("right(wz) = 0", condition="(nx != 0)and (ny != 0)")
 

Thank you for your reply


                                                                                                                                                       

--
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 dedalu...@googlegroups.com.

Evan Henry Anders

unread,
Jul 29, 2020, 2:53:49 PM7/29/20
to dedalus-users
Hi,

Yes, Dedalus can solve equations on two-dimensional spaces, with parameters which vary in both directions. But Dedalus can only handle one Chebyshev derivative, and non-constant coefficients can only vary in the chebyshev direction.

It's a bit unclear what you're trying to do. Do F and N2 need to evolve in time? Or do they just need to vary in space? Either way, I *think* you could make a few changes to your code like this:

# Create bases and domain
x_basis = de.Fourier('x', int(nx), interval=(x_in, x_out)) #Make this fourier

z_basis = de.Chebyshev('z',int(nz), interval=(z_in, z_out))
domain = de.Domain([x_basis, z_basis],grid_dtype=np.float64) 

F = domain.new_field()
N2 = domain.new_field()
problem.parameters['F'] = F
problem.parameters['N2'] = N2 
 
problem.add_equation("dz(wz) = F - N2*dx(wx)") #N2 is now a field which can vary in x- and z- directions

problem.add_equation("wz - dz(w) = 0")

Where here, F and N2 are both Dedalus fields that you can fill with whatever you want (and you could change them as you time evolve the system). On top of these equations, you would need to add boundary conditions in the chebyshev direction (where left() puts those conditions at z_in, and right() puts them at z_out). 

But, if this doesn't work, or if you *need* two Chebyshev bases with NCCs in both the x- and z- direction, then Dedalus doesn't have that functionality, unfortunately.

Best,
Evan

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/d3798f60-bd11-4d4b-adc3-b0ed3bf0fe77o%40googlegroups.com.

Keaton Burns

unread,
Jul 30, 2020, 12:30:09 PM7/30/20
to dedalu...@googlegroups.com
Hi,

To clarify a little, Evan’s answer is correct for initial value problems, where you can move linear terms with x-dependent NCCs to the RHS to be explicitly integrated.  But for the LBVP you’re trying to solve, that won’t work with a single solve since the RHS is just being statically evaluated using whatever the state fields happen to be.

Instead, you can try splitting N2 into its horizontal mean and perturbations and writing the equations something like

N_mean*dx(wx) + dz(wz) = F - N_pert*dx(wx)

Then solving the LBVP multiple times will produce a simple iterative scheme like

(N_mean dx dx + dz dz) w_{n+1} = F - N_pert dx dx w_{n}

which should converge quickly if the perturbations are small compared to the mean.

Best,
-Keaton

ruirui wang

unread,
Aug 14, 2020, 1:11:31 AM8/14/20
to Dedalus Users
Sorry!It's a long time.  
This is a good idea!   But there is wrong when the dependent variable is on the RHS . This is the error: "dedalus.tools.exceptions. UnsupportedEquationError: RHS must be independent of ['w', 'wz']" 
How do I add equation for dedalus? Thank you very much!

Keaton Burns

unread,
Aug 14, 2020, 10:07:42 AM8/14/20
to dedalu...@googlegroups.com
You can circumvent this by just creating some dummy variables for representing each problem variable on the RHS, and manually updating them to match the problem variables between each solve.

ruirui wang

unread,
Aug 22, 2020, 12:34:21 AM8/22/20
to Dedalus Users
It works! Thank you!
Reply all
Reply to author
Forward
0 new messages