[docs]definit_data(my_data,rp):""" initialize the rt problem """# see the random number generatorrng=np.random.default_rng(12345)ifrp.get_param("driver.verbose"):msg.bold("initializing the rt problem...")# get the density, momenta, and energy as separate variablesdens=my_data.get_var("density")xmom=my_data.get_var("x-momentum")ymom=my_data.get_var("y-momentum")ener=my_data.get_var("energy")gamma=rp.get_param("eos.gamma")grav=rp.get_param("compressible.grav")dens1=rp.get_param("rt_multimode.dens1")dens2=rp.get_param("rt_multimode.dens2")p0=rp.get_param("rt_multimode.p0")amp=rp.get_param("rt_multimode.amp")sigma=rp.get_param("rt_multimode.sigma")nmodes=rp.get_param("rt_multimode.nmodes")# initialize the components, remember, that ener here is# rho*eint + 0.5*rho*v**2, where eint is the specific# internal energy (erg/g)xmom[:,:]=0.0ymom[:,:]=0.0dens[:,:]=0.0# set the density to be stratified in the y-directionmyg=my_data.gridycenter=0.5*(myg.ymin+myg.ymax)p=myg.scratch_array()j=myg.jlowhilej<=myg.jhi:ifmyg.y[j]<ycenter:dens[:,j]=dens1p[:,j]=p0+dens1*grav*myg.y[j]else:dens[:,j]=dens2p[:,j]=p0+dens1*grav*ycenter+dens2*grav*(myg.y[j]-ycenter)j+=1# add multiple modes to the vertical velocityL=myg.xmax-myg.xminforkinrange(1,nmodes+1):phase=rng.random()*2*np.pimode_amp=amp*rng.random()ymom[:,:]+=(mode_amp*np.cos(2.0*np.pi*k*myg.x2d/L+phase)*np.exp(-(myg.y2d-ycenter)**2/sigma**2))ymom/=nmodesymom*=dens# set the energy (P = cs2*dens)ener[:,:]=p[:,:]/(gamma-1.0)+ \
0.5*(xmom[:,:]**2+ymom[:,:]**2)/dens[:,:]
[docs]deffinalize():""" print out any information to the user at the end of the run """