"""Initialize a buoyant bubble in a hydrostatic atmosphere. This ismeant to be used to compare with the compressible solver bubbleproblem."""importnumpyfrompyro.utilimportmsgDEFAULT_INPUTS="inputs.bubble"PROBLEM_PARAMS={"bubble.dens_base":10.0,# density at the base of the atmosphere"bubble.scale_height":2.0,# scale height of the isothermal atmosphere"bubble.x_pert":2.0,"bubble.y_pert":2.0,"bubble.r_pert":0.25,"bubble.pert_amplitude_factor":5.0,"bubble.dens_cutoff":0.01}
[docs]definit_data(my_data,base,rp):""" initialize the bubble problem """ifrp.get_param("driver.verbose"):msg.bold("initializing the bubble problem...")# get the density and velocitiesdens=my_data.get_var("density")xvel=my_data.get_var("x-velocity")yvel=my_data.get_var("y-velocity")eint=my_data.get_var("eint")grav=rp.get_param("lm-atmosphere.grav")gamma=rp.get_param("eos.gamma")scale_height=rp.get_param("bubble.scale_height")dens_base=rp.get_param("bubble.dens_base")dens_cutoff=rp.get_param("bubble.dens_cutoff")x_pert=rp.get_param("bubble.x_pert")y_pert=rp.get_param("bubble.y_pert")r_pert=rp.get_param("bubble.r_pert")pert_amplitude_factor=rp.get_param("bubble.pert_amplitude_factor")# initialize the components -- we'll get a pressure too# but that is used only to initialize the base statexvel[:,:]=0.0yvel[:,:]=0.0dens[:,:]=dens_cutoff# set the density to be stratified in the y-directionmyg=my_data.gridpres=myg.scratch_array()j=myg.jloforjinrange(myg.jlo,myg.jhi+1):dens[:,j]=max(dens_base*numpy.exp(-myg.y[j]/scale_height),dens_cutoff)cs2=scale_height*abs(grav)# set the pressure (P = cs2*dens)pres=cs2*denseint[:,:]=pres/(gamma-1.0)/dens# boost the specific internal energy, keeping the pressure# constant, by dropping the densityr=numpy.sqrt((myg.x2d-x_pert)**2+(myg.y2d-y_pert)**2)idx=r<=r_perteint[idx]=eint[idx]*pert_amplitude_factordens[idx]=pres[idx]/(eint[idx]*(gamma-1.0))# do the base statebase["rho0"].d[:]=numpy.mean(dens,axis=0)base["p0"].d[:]=numpy.mean(pres,axis=0)# redo the pressure via HSEforjinrange(myg.jlo+1,myg.jhi):base["p0"].d[j]=base["p0"].d[j-1]+0.5*myg.dy*(base["rho0"].d[j]+base["rho0"].d[j-1])*grav
[docs]deffinalize():""" print out any information to the user at the end of the run """