RayleighBenard3D#

class RayleighBenard3D(Prandtl=1, Rayleigh=1000000.0, nx=64, ny=64, nz=32, BCs=None, dealiasing=1.5, comm=None, Lz=1, Lx=4, Ly=4, useGPU=False, **kwargs)[source]#

Bases: GenericSpectralLinear

3D Rayleigh-Benard convection, FFT in x and y and ultraspherical in z, IMEX with the nonlinear advection explicit.

Rayleigh-Benard Convection is a variation of incompressible Navier-Stokes.

The equations we solve are

u_x + v_y + w_z = 0 T_t - kappa (T_xx + T_yy + T_zz) = -uT_x - vT_y - wT_z u_t - nu (u_xx + u_yy + u_zz) + p_x = -uu_x - vu_y - wu_z v_t - nu (v_xx + v_yy + v_zz) + p_y = -uv_x - vv_y - wv_z w_t - nu (w_xx + w_yy + w_zz) + p_z - T = -uw_x - vw_y - ww_z

with u and v the horizontal velocities (in x and y), w the vertical velocity (in z), T the temperature, p the pressure, indices denoting derivatives, kappa=(Rayleigh * Prandtl)**(-1/2) and nu = (Rayleigh / Prandtl)**(-1/2). Everything on the left hand side, that is the viscous part, the pressure gradient and the buoyancy due to temperature are treated implicitly, while the non-linear convection part on the right hand side is integrated explicitly.

The domain, vertical boundary conditions and pressure gauge are

Omega = [0, Lx) x [0, Ly] x (0, Lz) T(z=+1) = 0 T(z=-1) = Lz u(z=+-1) = v(z=+-1) = w(z=+-1) = 0 integral over p = 0

The spectral discretization uses FFT horizontally, implying periodic BCs, and an ultraspherical method vertically to facilitate the Dirichlet BCs.

Parameters:
  • Prandtl (float) – Prandtl number

  • Rayleigh (float) – Rayleigh number

  • nx (int) – Horizontal resolution

  • nz (int) – Vertical resolution

  • BCs (dict) – Can specify boundary conditions here

  • dealiasing (float) – Dealiasing factor for evaluating the non-linear part

  • comm (mpi4py.Intracomm) – Space communicator

compute_Nusselt_numbers(u)[source]#

Compute the various versions of the Nusselt number. This reflects the type of heat transport. If the Nusselt number is equal to one, it indicates heat transport due to conduction. If it is larger, advection is present. Computing the Nusselt number at various places can be used to check the code.

Parameters:

u – The solution you want to compute the Nusselt numbers of

Returns:

dict –

Nusselt number averaged over the entire volume and horizontally averaged at the top and bottom as well

as computed from thermal and kinetic dissipation.

dtype_f#

alias of imex_mesh

dtype_u#

alias of mesh

eval_f(u, *args, **kwargs)[source]#

Evaluate the right hand side, split into an implicit and an explicit part.

The implicit part is -L u, i.e. diffusion, pressure gradient, buoyancy and, in the pressure line, the negative divergence, converted back to the Chebychev-T basis. The explicit part is the advection -(u d/dx + v d/dy + w d/dz) of u, v, w and T, computed in physical space on a grid padded by the dealiasing factor.

Parameters:
  • u (dtype_u) – Solution, in spectral space if spectral_space is set, else in physical space

  • *args – Not used, the right hand side does not depend on time

  • **kwargs – Not used, the right hand side does not depend on time

Returns:

dtype_f – The right hand side, in the same space as u

get_frequency_spectrum(u)[source]#

Compute the frequency spectrum of the velocities in x and y direction in the horizontal plane for every point in z. If the problem is well resolved, the coefficients will decay quickly with the wave number, and the reverse indicates that the resolution is too low.

The returned spectrum has three dimensions. The first is for component (i.e. u or v), the second is for every point in z and the third is the energy in every wave number.

Parameters:

u – The solution you want to compute the spectrum of

Returns:

RayleighBenard3D.xp.ndarray – wave numbers RayleighBenard3D.xp.ndarray: spectrum

get_vertical_profiles(u, components)[source]#

Compute horizontally averaged vertical profiles from the horizontal mean mode of each component, transformed to physical space in z and broadcast from rank 0, which holds the mean mode.

Parameters:
  • u (dtype_u) – Solution, in spectral space if spectral_space is set, else in physical space

  • components (list of str) – Names of the components you want the profiles of

Returns:

dict – Profile along z for each component, as xp.ndarray

u_exact(t=0, noise_level=0.001, seed=99)[source]#

Initial conditions, which are only available at t=0 and for Lz=1. Velocities and temperature are linear in z between their boundary values, the pressure is zero, and the temperature is perturbed with seeded uniformly distributed noise, multiplied by noise_level and z (z - Lz), which vanishes at both plates. The vertical velocity w has to have equal boundary values, since a linear w is not divergence free.

Parameters:
  • t (float) – Time, has to be 0

  • noise_level (float) – Amplitude of the noise

  • seed (int) – Seed for the random number generator

Returns:

dtype_u – Initial conditions, in spectral space if spectral_space is set, else in physical space