When does one need to set `scales=domain.dealias`?

273 views
Skip to first unread message

Jack

unread,
Jun 5, 2021, 11:46:50 AM6/5/21
to Dedalus Users
Hello, 

When defining the 2D domain object for an IVP problem, one sets the dealias factor as 3/2 to deal with quadratic nonlinearity. After that, what is the correct scale to use for initial conditions and the forcing term in the grid space? 

Suppose one has

dealias = 3/2
x_basis = de.Fourier('x', Nx, interval=(0, Lx), dealias=dealias)
z_basis = de.Fourier('z', Nz, interval=(-Lz/2., Lz/2.), dealias=dealias)
domain  = de.Domain([x_basis, z_basis], grid_dtype=np.float64)

Should one define the forcing term by

I. 
x,z = domain.all_grids(scales=domain.dealias)
# Force
forceu = domain.new_field()
forcew = domain.new_field()
forceu.set_scales(scales=domain.dealias)
forcew.set_scales(scales=domain.dealias)
forceu['g'] = np.cos(2.*x) * np.cos(3.*z)
forcew['g'] = np.sin(x) * np.sin(4.*z)

or
II.
x,z = domain.all_grids()
forceu = domain.new_field()
forcew = domain.new_field()
forceu['g'] = np.cos(2.*x) * np.cos(3.*z)
forcew['g'] = np.sin(x) * np.sin(4.*z)

It seems that the code runs for both cases, but I am confused about which one should be used. Similarly for the initial conditions. 

In this line of the rayleigh benard example, the default scale 1 is used, while in this example,  scales=domain.dealias is used for setting the initial condition. When I change the scale in the rayleigh-benard example to scales=domain.dealias, I got some error message like `ValueError: operands could not be broadcast together with shapes (256,64) (1,96)`. 

I may misunderstand something. What is the correct way to set the scales? 



Thanks,
Jack


Keaton Burns

unread,
Jun 5, 2021, 11:54:03 AM6/5/21
to dedalu...@googlegroups.com
Hi Jack,

Typically it’s fine to set field values and initial conditions using scales=1.  If you’re doing a computation where determining the initial conditions involves evaluating other operators or solving other problems, as in that second example, then it may be more convenient to use the dealiased scales for everything.  But this is just because operators output fields with the dealiased scales by default (this is something we may change to reduce this confusion).  A fine alternative would be to take the result of the operator, change its scales back to 1, and then use it to set the initial conditions also with scales = 1.

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 view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/c0458565-fc33-4079-bca2-a2e7c86d3224n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages