"""A general shock tube problem for comparing the solver to an exactRiemann solution."""frompyro.utilimportmsgDEFAULT_INPUTS="inputs.sod.x"PROBLEM_PARAMS={"sod.direction":"x",# direction of the flow"sod.dens_left":1.0,"sod.dens_right":0.125,"sod.u_left":0.0,"sod.u_right":0.0,"sod.p_left":1.0,"sod.p_right":0.1}
[docs]definit_data(my_data,rp):""" initialize the sod problem """ifrp.get_param("driver.verbose"):msg.bold("initializing the sod problem...")# get the sod parametersdens_left=rp.get_param("sod.dens_left")dens_right=rp.get_param("sod.dens_right")u_left=rp.get_param("sod.u_left")u_right=rp.get_param("sod.u_right")p_left=rp.get_param("sod.p_left")p_right=rp.get_param("sod.p_right")# 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")# initialize the components, remember, that ener here is rho*eint# + 0.5*rho*v**2, where eint is the specific internal energy# (erg/g)xmin=rp.get_param("mesh.xmin")xmax=rp.get_param("mesh.xmax")ymin=rp.get_param("mesh.ymin")ymax=rp.get_param("mesh.ymax")gamma=rp.get_param("eos.gamma")direction=rp.get_param("sod.direction")xctr=0.5*(xmin+xmax)yctr=0.5*(ymin+ymax)myg=my_data.gridifdirection=="x":# leftidxl=myg.x2d<=xctrdens[idxl]=dens_leftxmom[idxl]=dens_left*u_leftymom[idxl]=0.0ener[idxl]=p_left/(gamma-1.0)+0.5*xmom[idxl]*u_left# rightidxr=myg.x2d>xctrdens[idxr]=dens_rightxmom[idxr]=dens_right*u_rightymom[idxr]=0.0ener[idxr]=p_right/(gamma-1.0)+0.5*xmom[idxr]*u_rightelse:# bottomidxb=myg.y2d<=yctrdens[idxb]=dens_leftxmom[idxb]=0.0ymom[idxb]=dens_left*u_leftener[idxb]=p_left/(gamma-1.0)+0.5*ymom[idxb]*u_left# topidxt=myg.y2d>yctrdens[idxt]=dens_rightxmom[idxt]=0.0ymom[idxt]=dens_right*u_rightener[idxt]=p_right/(gamma-1.0)+0.5*ymom[idxt]*u_right
[docs]deffinalize():""" print out any information to the user at the end of the run """print(""" The script analysis/sod_compare.py can be used to compare this output to the exact solution. Some sample exact solution data is present as analysis/sod-exact.out """)