def set_ic_rayleigh_benard_benchmark(model): noise = dedaLES.random_noise(model.domain) # Linear background + perturbations damped at walls zbottom, ztop = model.zbasis.interval a = model.problem.parameters['a'] Bz = model.problem.parameters['B0']/(ztop-zbottom) z = model.z pert = a * noise * (z - ztop) * (z - zbottom) model.set_fields(b=Bz*(z - pert))
""".format(surface_heat_flux, surface_buoyancy_flux, 1/initial_N, initial_dt, run_time, Lx, Ly, Lz, nx, ny, nz, turb_vel_scale, erosion_time_scale, kolmogorov_length_scale, Δx, Δy, Δz_min, Δz_max, closure_name) ) # Boundary conditions model.set_bc("no penetration", "top", "bottom") model.set_bc("free slip", "top", "bottom") model.set_tracer_gradient_bc("b", "top", gradient="surface_bz") #*tanh(t/tb)") model.set_tracer_gradient_bc("b", "bottom", gradient="initial_N2") model.build_solver(timestepper='SBDF3') # Initial condition noise = noise_amplitude * dedaLES.random_noise(model.domain) * model.z * (Lz - model.z) / Lz**2 initial_b = initial_N2*model.z model.set_fields( u = noise, v = noise, b = initial_b + np.sqrt(initial_N2) * noise #w = noise, ) model.stop_at(sim_time=run_time) dt_gizmo = dedaLES.TimeStepGizmo(model.solver, initial_dt=initial_dt, cadence=dt_cadence, max_change=1.5, safety=dt_safety) dt_gizmo.add_velocities(('u', 'v', 'w')) dt_gizmo.add_diffusivity('ν_sgs') dt_gizmo.add_diffusivity('κb_sgs')
model.set_tracer_gradient_bc('v', "bottom", gradient="-Vgz") model.set_tracer_gradient_bc("b", "top", gradient="bz_surf") model.set_tracer_gradient_bc("b", "bottom", gradient='bz_deep') model.build_solver(timestepper='CNAB2') # 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) # Add noise ... ? noise = dedaLES.random_noise(model.domain) b0 = b0 + b_noise * noise model.set_fields(b=b0, u=0, v=0, w=0) # CFL conditions CFL = flow_tools.CFL(model.solver, initial_dt=1e-2, cadence=1, max_change=1.5, max_dt=10, safety=0.5) CFL.add_velocities(('u', 'v+Vg', 'w')) #Analysis tasks snap = model.solver.evaluator.add_file_handler('snapshots', sim_dt=30) #snap.add_task("interp(b, z=0)", scales=1, name='b surface')
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, model.set_fields(u=noise, v=noise, w=noise, b=model.z / model.Lz - noise) model.stop_at(sim_time=100) # Analysis if closure is None: closure_name = 'DNS' else: closure_name = closure.__class__.__name__ simulation_name = "rayleigh_benard_snapshots_{:s}".format(closure_name) analysis = model.solver.evaluator.add_file_handler(simulation_name, iter=100, max_writes=100) analysis.add_system(model.solver.state, layout='g') stats = flow_tools.GlobalFlowProperty(model.solver, cadence=10) stats.add_property("sqrt(u*u + v*v + w*w) / ν", name="Re")
model = dns.DNS_3P_Box(nx=nx, ny=ny, nz=nz, Lx=Lx, Ly=Ly, Lz=Lz, ν=1.0, closure=closure) # model = channel_mod.ChannelMod_DNS(nx=nx, ny=ny, nz=nz, Lx=Lx, Ly=Ly, Lz=Lz, xleft=nx, yleft=ny, zbottom=nz, # nu=1.0, rho=1.0) model.build_solver() # Random initial condition. Re_k = u k / ν => u ~ ν * Re_k / k Re = 1000.0 # Re at grid scale u0 = Re / nx model.u['g'] = u0 * dedaLES.random_noise(model.domain, seed=23) model.v['g'] = u0 * dedaLES.random_noise(model.domain, seed=42) model.u['g'] = model.u['g'] - np.mean(model.u['g']) model.v['g'] = model.v['g'] - np.mean(model.v['g']) # Diagnose w from continuity ux = model.domain.new_field() vy = model.domain.new_field() wz = model.domain.new_field() model.u.differentiate('x', out=ux) model.v.differentiate('y', out=vy) model.w.differentiate('z', out=wz) wz['g'] = -ux['g'] - vy['g'] wz.integrate('z', out=model.w)
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) spinup_model.stop_at(sim_time=spinup_time) # Make CFL spinup_CFL = flow_tools.CFL(spinup_model.solver, initial_dt=dt0, cadence=10, max_change=1.5, safety=0.5) spinup_CFL.add_velocities(('u', 'v', 'w')) # Flow properties: Reynolds number and three Nusselt numbers