Source code for pyro.compressible_fv4.problems.hse
"""Initialize an isothermal hydrostatic atmosphere. It should remainstatic. This is a test of our treatment of the gravitational sourceterm."""importnumpyasnpfrompyro.utilimportmsgDEFAULT_INPUTS="inputs.hse"PROBLEM_PARAMS={"hse.dens0":1.0,"hse.h":1.0}
[docs]definit_data(my_data,rp):""" initialize the HSE problem """ifrp.get_param("driver.verbose"):msg.bold("initializing the HSE 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")dens0=rp.get_param("hse.dens0")print("dens0 = ",dens0)H=rp.get_param("hse.h")# isothermal sound speed (squared)cs2=H*abs(grav)# 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.gridp=myg.scratch_array()forjinrange(myg.jlo,myg.jhi+1):dens[:,j]=dens0*np.exp(-myg.y[j]/H)ifj==myg.jlo:p[:,j]=dens[:,j]*cs2else:p[:,j]=p[:,j-1]+0.5*myg.dy*(dens[:,j]+dens[:,j-1])*grav# set the energyener[:,:]=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 """