def init_rayleigh_benard_benchmark(nx=64, ny=64, nz=16, closure=None): Lx, Ly, Lz = 25.0, 25.0, 1.0 # Domain # Parameters Pr = 1.0 # Prandtl number f = 0.0 # Coriolis parameter κ = 1.0 # Thermal diffusivity ε = 0.8 # Perturbation above criticality a = 1e-3 # Noise amplitude for initial condition # Constants Ra_critical = 1707.762 Ra = Ra_critical + ε ν = Pr*κ # Viscosity Bz = -Ra*Pr # Unstable buoyancy gradient # Construct model model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx, ny=ny, nz=nz, f=f, ν=ν, κ=κ, B0=Bz*Lz, a=a, closure=closure) model.set_bc("nopenetration", "top", "bottom") model.set_bc("freeslip", "top", "bottom") model.problem.add_bc("right(b) = B0") model.problem.add_bc("left(b) = 0") return model
import dedaLES from dedaLES import mpiprint # Basics mpiprint('') # 1. DNS of Navier-Stokes dns_model = dedaLES.NavierStokesTriplyPeriodicFlow(nx=4, ny=4, nz=4, ν=1) dns_model.build_solver() mpiprint("\nDNS Navier-Stokes model built!\n") # 2. LES of Navier-Stokes les_model = dedaLES.NavierStokesTriplyPeriodicFlow( nx=4, ny=4, nz=4, ν=1, closure=dedaLES.ConstantSmagorinsky()) les_model.build_solver() mpiprint("\nLES Navier-Stokes model built!\n") # 2. Boussinesq in a channel bouss_model = dedaLES.BoussinesqChannelFlow(nx=4, ny=4, nz=4, ν=1, κ=0.1) for bc in ["no penetration", "no slip", "no flux"]: bouss_model.set_bc(bc, "top", "bottom") bouss_model.build_solver() mpiprint("\nBoussinesq model built!\n")
#dt_safety = params['dt_safety'] stats_cadence = 100 averages_cadence = 10 analysis_cadence = 100 run_time = day max_writes = 100 if debug: nx = ny = nz = 8 dt_cadence = np.inf initial_dt = 1e-16 run_time = 10*initial_dt stats_cadence = analysis_cadence = averages_cadence = 1 # Construct model model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx, ny=ny, nz=nz, ν=ν, κ=κ, closure=closure, case=int(case), surface_buoyancy_flux=surface_buoyancy_flux, surface_bz=surface_bz, initial_N2=initial_N2) Δx = Lx/nx Δy = Ly/ny Δz_min, Δz_max = dedaLES.grid_stats(model, 2) Δmin = min(Δx, Δy, Δz_min) logger.info("""\n *** Convection into a linearly stratified fluid *** Simulation info --------------- surface heat_flux : {:.2e} W m⁻² surface buoyancy flux : {:.2e} m² s⁻³
CFL_cadence = 10 stats_cadence = 100 analysis_cadence = 100 run_time = 2*hour max_writes = 1000 if debug: nx = ny = nz = 8 CFL_cadence = np.inf initial_dt = 1e-16 run_time = 10*initial_dt stats_cadence = analysis_cadence = 1 # Construct model closure = None model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx, ny=ny, nz=nz, ν=ν, κ=κ, closure=closure, surface_flux=surface_flux, surface_bz=surface_bz, initial_N2=initial_N2) Δx = Lx/nx Δy = Ly/ny Δz_min, Δz_max = dedaLES.grid_stats(model, 2) logger.info("""\n *** Convection into a linearly stratified fluid *** Simulation info --------------- Q : {:.2e} m C s⁻¹ surface buoyancy flux : {:.2e} m² s⁻³ 1/N : {:.2e} s initial dt : {:.2e} s
Ra = 1e5 # Rayleigh number. Ra = Δb*L^3 / ν*κ = Δb*L^3*Pr / ν^2 Pr = 0.7 # Prandtl number a = 1e-1 # Noise amplitude for initial condition Δb = 1.0 # Buoyancy difference # Calculated parameters ν = np.sqrt(Pr / Ra) # Viscosity. ν = sqrt(Pr/Ra) with Lz=Δb=1 κ = ν / Pr # Thermal diffusivity # Construct model closure = None #dedaLES.AnisotropicMinimumDissipation() #dedaLES.ConstantSmagorinsky() model = dedaLES.BoussinesqChannelFlow(Lx=1, Ly=1, Lz=6, nx=64, ny=64, nz=32, ν=ν, κ=κ, Δb=1, closure=closure) model.set_bc("no penetration", "top", "bottom") model.set_bc("no slip", "top", "bottom") model.problem.add_bc("right(b) = 0") model.problem.add_bc("left(b) = Δb") model.build_solver() # Set initial condition: unstable buoyancy grad + random perturbations noise = a * dedaLES.random_noise( model.domain) * model.z * (model.Lz - model.z) / model.Lz**2,
nx = ny = 128 # Horizontal resolution nz = 34 # Vertical resolution Lx = Ly = 3840.0 # Domain horizontal extent [m] Lz = 1020 # Domain vertical extent [m] a = 1e-2 # Non-dimensional initial noise amplitude dt = 90.0 # Timestep # Calculated parameters bz_surf = Q*α*g / (cP*ρ0*κ) # Unstable surface buoyancy gradient [s⁻²] b_init = (Lz-h0)*bz_deep # Initial buoyancy at bottom of domain b_noise = a*b_init # Noise amplitude for initial buoyancy condition # Construct model closure = dedaLES.ConstantSmagorinsky() model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx, ny=ny, nz=nz, ν=ν, κ=κ, zbottom=-Lz bz_deep=bz_deep, bz_surf=bz_surf, tb=day/2, closure=closure, H=Lz) # Boundary conditions model.set_bc("no penetration", "top", "bottom") model.set_bc("free slip", "top", "bottom") model.set_tracer_gradient_bc("b", "top", gradient="bz_surf") #*tanh(t/tb)") model.set_tracer_gradient_bc("b", "bottom", gradient="bz_deep") model.build_solver() # Initial condition def smoothstep(z, d): return 0.5*(1 + np.tanh(z/d)) b0 = bz_deep * (model.z + h0) * smoothstep(-model.z-h0, d)
from dedalus.extras import flow_tools import dedaLES logger = logging.getLogger(__name__) a = 10.0 dt = 1e-4 nx = nz = 32 ny = 4 closure = dedaLES.AnisotropicMinimumDissipation() #closure = dedaLES.ConstantSmagorinsky() #closure = None model = dedaLES.BoussinesqChannelFlow(nx=nx, ny=ny, nz=nz, ν=1, κ=1, closure=closure) model.set_bc("no penetration", "top", "bottom") model.set_bc("no slip", "top", "bottom") model.set_bc("no flux", "top", "bottom") model.build_solver() # Initial condition fields = {} for field in ['u', 'v', 'w', 'b']: noise = dedaLES.random_noise(model.domain) pert = a * noise * model.z * (1 - model.z) fields[field] = pert
closure: {}\n\n""".format(Ra, nx, nz, closure_name)) ## ## Spinup! ## nx_spinup = int(nx / spinup_coarsening_factor) ny_spinup = int(ny / spinup_coarsening_factor) nz_spinup = int(nz / spinup_coarsening_factor) spinup_model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx_spinup, ny=ny_spinup, nz=nz_spinup, ν=ν, κ=κ, Δb=Δb, closure=closure, Ra=Ra) set_rayleigh_benard_bcs(spinup_model) spinup_model.build_solver(timestepper='SBDF3') # Set initial condition: unstable buoyancy grad + random perturbations noise = a * dedaLES.random_noise( spinup_model.domain) * spinup_model.z * (Lz - spinup_model.z) / Lz**2, spinup_model.set_fields(u=noise, v=noise, w=noise, b=spinup_model.z / Lz - noise)
# Parameters Pr = 1.0 # Prandtl number f = 0.0 # Coriolis parameter κ = 1.0 # Thermal diffusivity ε = 0.8 # Perturbation above criticality a = 1e-3 # Noise amplitude for initial condition # Constants Ra_critical = 1707.762 Ra = Ra_critical + ε ν = Pr*κ # Viscosity Bz = -Ra*Pr # Unstable buoyancy gradient # Construct model model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx, ny=ny, nz=nz, ν=ν, κ=κ, B0=Bz*Lz, closure=dedaLES.ConstantSmagorinsky()) model.set_bc("nopenetration", "top", "bottom") model.set_bc("freeslip", "top", "bottom") model.problem.add_bc("right(b) = B0") model.problem.add_bc("left(b) = 0") model.build_solver() # Random perturbations, initialized globally for same results in parallel noise = dedaLES.random_noise(model.domain) # Linear background + perturbations damped at walls z = model.z pert = a * noise * z * (Lz - z)
Δb = 1.0 # Buoyancy difference # Calculated parameters ν = np.sqrt(Δb * Pr * Lz**3 / Ra) # Viscosity. ν = sqrt(Pr/Ra) with Lz=Δb=1 κ = ν / Pr # Thermal diffusivity # Construct model #closure = dedaLES.AnisotropicMinimumDissipation() #closure = dedaLES.ConstantSmagorinsky() closure = None model = dedaLES.BoussinesqChannelFlow(Lx=Lx, Ly=Ly, Lz=Lz, nx=nx, ny=ny, nz=nz, ν=ν, κ=κ, Δb=Δb, closure=closure, nu=ν, V=Lx * Ly * Lz) model.set_bc("no penetration", "top", "bottom") model.set_bc("no slip", "top", "bottom") model.problem.add_bc("right(b) = 0") model.problem.add_bc("left(b) = Δb") model.problem.substitutions[ 'ε'] = "ν*(ux*ux + uy*uy + uz*uz + vx*vx + vy*vy + vz*vz + wx*wx + wy*wy + wz*wz)" model.build_solver()