"""Initialize the profile to a Gaussian. With a constantconductivity, an initial Gaussian profile remains Gaussian, with thepeak lowering and width increasing with time. This allows thisproblem to be used for verification."""importnumpyfrompyro.utilimportmsgDEFAULT_INPUTS="inputs.gaussian"PROBLEM_PARAMS={"gaussian.t_0":0.001,"gaussian.phi_0":1.0,"gaussian.phi_max":2.0}
[docs]defphi_analytic(dist,t,t_0,k,phi_1,phi_2):""" the analytic solution to the Gaussian diffusion problem """phi=(phi_2-phi_1)*(t_0/(t+t_0))* \
numpy.exp(-0.25*dist**2/(k*(t+t_0)))+phi_1returnphi
[docs]definit_data(my_data,rp):""" initialize the Gaussian diffusion problem """ifrp.get_param("driver.verbose"):msg.bold("initializing the Gaussian diffusion problem...")phi=my_data.get_var("phi")xmin=my_data.grid.xminxmax=my_data.grid.xmaxymin=my_data.grid.yminymax=my_data.grid.ymaxxctr=0.5*(xmin+xmax)yctr=0.5*(ymin+ymax)k=rp.get_param("diffusion.k")t_0=rp.get_param("gaussian.t_0")phi_max=rp.get_param("gaussian.phi_max")phi_0=rp.get_param("gaussian.phi_0")dist=numpy.sqrt((my_data.grid.x2d-xctr)**2+(my_data.grid.y2d-yctr)**2)phi[:,:]=phi_analytic(dist,0.0,t_0,k,phi_0,phi_max)# for later interpretation / analysis, store some auxiliary datamy_data.set_aux("k",k)my_data.set_aux("t_0",t_0)my_data.set_aux("phi_0",phi_0)my_data.set_aux("phi_max",phi_max)
[docs]deffinalize():""" print out any information to the user at the end of the run """ostr=""" The solution can be compared to the analytic solution with the script analysis/gauss_diffusion_compare.py """print(ostr)