diff --git a/Exec/unit_tests/diffusion_test/GNUmakefile b/Exec/unit_tests/diffusion_test/GNUmakefile index 5c088c4db9..75ad382b0a 100644 --- a/Exec/unit_tests/diffusion_test/GNUmakefile +++ b/Exec/unit_tests/diffusion_test/GNUmakefile @@ -5,7 +5,7 @@ DEBUG = FALSE DIM = 2 -COMP = gnu +COMP = gnu USE_MPI = TRUE USE_OMP = FALSE diff --git a/Exec/unit_tests/diffusion_test/README.md b/Exec/unit_tests/diffusion_test/README.md index 7c8fdf0dd4..0d26264dec 100644 --- a/Exec/unit_tests/diffusion_test/README.md +++ b/Exec/unit_tests/diffusion_test/README.md @@ -40,17 +40,17 @@ analyic solution) at the end of the simulation. This can be used for convergence testing. -## 1-d spherical with AMR +## 2-d axisymmetric with AMR This uses the 2nd order accurate predictor-corrector formulation of diffusion that is used with the CTU hydrodynamics solver. A test of -the diffusion in 1-d spherical coordinates, with 2 levels of -refinement can be run as: +the diffusion in 2-d cylindrical axisymmetric coordinates, +with 2 levels of refinement can be run as: ``` -./Castro2d.gnu.ex inputs.2d.sph -./Castro2d.gnu.ex inputs.2d.sph amr.n_cell=128 256 -./Castro2d.gnu.ex inputs.2d.sph amr.n_cell=256 512 +./Castro2d.gnu.ex inputs.2d.axisymmetric amr.n_cell=64 128 +./Castro2d.gnu.ex inputs.2d.axisymmetric amr.n_cell=128 256 +./Castro2d.gnu.ex inputs.2d.axisymmetric amr.n_cell=256 512 ``` At the end, each run will report the norm of the error against the @@ -58,9 +58,9 @@ analytic solution, giving: ``` base resolution L-inf error -64 0.0003707056645 -128 9.414571162e-05 -256 2.437072009e-05 + (64 , 128) 0.0003707056645 + (128, 256) 9.414571162e-05 + (256, 512) 2.437072009e-05 ``` @@ -137,15 +137,15 @@ Warning: BoxArray lengths are not the same at level 0 \begin{center} \begin{tabular}{|cccc|} \hline Variable & $e_{4h \rightarrow 2h}$ & Order & $e_{2h \rightarrow h}$\\ -\hline -density& 0.000000e+00 & ------------ &0.000000e+00 \\ -xmom& 0.000000e+00 & ------------ &0.000000e+00 \\ -ymom& 0.000000e+00 & ------------ &0.000000e+00 \\ -zmom& 0.000000e+00 & ------------ &0.000000e+00 \\ -rho_E& 3.479414e-04 & 2.012958966 & 8.620750e-05 \\ -rho_e& 3.479414e-04 & 2.012958966 & 8.620750e-05 \\ -Temp& 3.479414e-04 & 2.012958966 & 8.620750e-05 \\ -rho_X& 0.000000e+00 & ------------ &0.000000e+00 \\ +\hline +density& 0.000000e+00 & ------------ &0.000000e+00 \\ +xmom& 0.000000e+00 & ------------ &0.000000e+00 \\ +ymom& 0.000000e+00 & ------------ &0.000000e+00 \\ +zmom& 0.000000e+00 & ------------ &0.000000e+00 \\ +rho_E& 3.479414e-04 & 2.012958966 & 8.620750e-05 \\ +rho_e& 3.479414e-04 & 2.012958966 & 8.620750e-05 \\ +Temp& 3.479414e-04 & 2.012958966 & 8.620750e-05 \\ +rho_X& 0.000000e+00 & ------------ &0.000000e+00 \\ ``` (some bits were edited out) @@ -190,16 +190,16 @@ Warning: BoxArray lengths are not the same at level 0 \begin{center} \begin{tabular}{|cccc|} \hline Variable & $e_{4h \rightarrow 2h}$ & Order & $e_{2h \rightarrow h}$\\ -\hline -density& 0.000000e+00 & ------------ &0.000000e+00 \\ -xmom& 0.000000e+00 & ------------ &0.000000e+00 \\ -ymom& 0.000000e+00 & ------------ &0.000000e+00 \\ -zmom& 0.000000e+00 & ------------ &0.000000e+00 \\ -rho_E& 1.111626e-05 & 3.948910124 & 7.198104e-07 \\ -rho_e& 1.111626e-05 & 3.948910124 & 7.198104e-07 \\ -Temp& 1.063477e-05 & 3.952987539 & 6.866892e-07 \\ -rho_X& 0.000000e+00 & ------------ &0.000000e+00 \\ -pressure& 7.410837e-06 & 3.948910124 & 4.798736e-07 \\ +\hline +density& 0.000000e+00 & ------------ &0.000000e+00 \\ +xmom& 0.000000e+00 & ------------ &0.000000e+00 \\ +ymom& 0.000000e+00 & ------------ &0.000000e+00 \\ +zmom& 0.000000e+00 & ------------ &0.000000e+00 \\ +rho_E& 1.111626e-05 & 3.948910124 & 7.198104e-07 \\ +rho_e& 1.111626e-05 & 3.948910124 & 7.198104e-07 \\ +Temp& 1.063477e-05 & 3.952987539 & 6.866892e-07 \\ +rho_X& 0.000000e+00 & ------------ &0.000000e+00 \\ +pressure& 7.410837e-06 & 3.948910124 & 4.798736e-07 \\ ``` e.g. we see fourth-order convergence in the temperature @@ -241,18 +241,14 @@ Warning: BoxArray lengths are not the same at level 0 \begin{center} \begin{tabular}{|cccc|} \hline Variable & $e_{4h \rightarrow 2h}$ & Order & $e_{2h \rightarrow h}$\\ -\hline -density& 0.000000e+00 & ------------ &0.000000e+00 \\ -xmom& 0.000000e+00 & ------------ &0.000000e+00 \\ -ymom& 0.000000e+00 & ------------ &0.000000e+00 \\ -zmom& 0.000000e+00 & ------------ &0.000000e+00 \\ -rho_E& 1.902161e-06 & 3.957610923 & 1.224299e-07 \\ -rho_e& 1.902161e-06 & 3.957610923 & 1.224299e-07 \\ -Temp& 1.770452e-06 & 3.966033724 & 1.132894e-07 \\ +\hline +density& 0.000000e+00 & ------------ &0.000000e+00 \\ +xmom& 0.000000e+00 & ------------ &0.000000e+00 \\ +ymom& 0.000000e+00 & ------------ &0.000000e+00 \\ +zmom& 0.000000e+00 & ------------ &0.000000e+00 \\ +rho_E& 1.902161e-06 & 3.957610923 & 1.224299e-07 \\ +rho_e& 1.902161e-06 & 3.957610923 & 1.224299e-07 \\ +Temp& 1.770452e-06 & 3.966033724 & 1.132894e-07 \\ ``` e.g. we see fourth-order convergence in the temperature - - - - diff --git a/Exec/unit_tests/diffusion_test/analysis/profiles.py b/Exec/unit_tests/diffusion_test/analysis/profiles.py index 6d596e580b..1ffc653ad7 100755 --- a/Exec/unit_tests/diffusion_test/analysis/profiles.py +++ b/Exec/unit_tests/diffusion_test/analysis/profiles.py @@ -12,6 +12,8 @@ import matplotlib.pyplot as plt import yt +from yt.frontends.boxlib.api import CastroDataset + ## Define RGBA to HEX def rgba_to_hex(rgba): @@ -22,15 +24,22 @@ def rgba_to_hex(rgba): def get_T_profile(plotfile): - ds = yt.load(plotfile) + ds = CastroDataset(plotfile) time = float(ds.current_time) ad = ds.all_data() # Sort the ray values by 'x' so there are no discontinuities # in the line plot - srt = np.argsort(ad['x']) - x_coord = np.array(ad['x'][srt]) + + coords = {"cartesian":"x", + "cylindrical":"z", + "spherical":"r"} + + coord = coords[ds.geometry] + + srt = np.argsort(ad[coord]) + x_coord = np.array(ad[coord][srt]) temp = np.array(ad['Temp'][srt]) return time, x_coord, temp diff --git a/Exec/unit_tests/diffusion_test/analysis/slice_grid.py b/Exec/unit_tests/diffusion_test/analysis/slice_grid.py old mode 100644 new mode 100755 index 0262dea2c0..3d957c7a81 --- a/Exec/unit_tests/diffusion_test/analysis/slice_grid.py +++ b/Exec/unit_tests/diffusion_test/analysis/slice_grid.py @@ -1,14 +1,28 @@ +#!/usr/bin/env python3 + +import sys import yt +from yt.frontends.boxlib.api import CastroDataset + +""" +Give a temperature slice plot for 2d plot file +""" + +fname = sys.argv[1] +ds = CastroDataset(fname) -ds = yt.load("diffuse_plt00147") +slice_dirs = {"cylindrical":"theta", + "spherical":"phi"} +slice_dir = slice_dirs[ds.geometry] -slc = yt.SlicePlot(ds, "theta", "Temp") -slc.annotate_grids() -slc.set_figure_size(16) +slc = yt.SlicePlot(ds, slice_dir, "Temp") +if ds.geometry == "cylindrical": + slc.annotate_grids() +slc.set_figure_size(12) slc.set_buff_size(1600) -slc.set_font_size(64) +slc.set_font_size(24) slc.set_cmap("Temp", "plasma_r") slc.set_log("Temp", False) slc.set_axes_unit("cm") -slc.save("diffusion_temp_amr.pdf") +slc.save("diffusion_temp.png") diff --git a/Exec/unit_tests/diffusion_test/inputs.2d.axisymmetric b/Exec/unit_tests/diffusion_test/inputs.2d.axisymmetric new file mode 100644 index 0000000000..5a90e2e6cc --- /dev/null +++ b/Exec/unit_tests/diffusion_test/inputs.2d.axisymmetric @@ -0,0 +1,70 @@ +# ------------------ INPUTS TO MAIN PROGRAM ------------------- +max_step = 50000 +stop_time = 0.001 + +# PROBLEM SIZE & GEOMETRY +geometry.is_periodic = 0 0 +geometry.coord_sys = 1 # 1 = RZ +geometry.prob_lo = 0.0 0.0 +geometry.prob_hi = 0.5 1.0 +amr.n_cell = 64 128 + +# >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<< +# 0 = Interior 3 = Symmetry +# 1 = Inflow 4 = SlipWall +# 2 = Outflow 5 = NoSlipWall +# >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<< +castro.lo_bc = 3 2 +castro.hi_bc = 2 2 + +# WHICH PHYSICS +castro.do_hydro = 0 +castro.diffuse_temp = 1 +castro.do_react = 0 + +# TIME STEP CONTROL + +castro.cfl = 0.5 # cfl number for hyperbolic system +castro.init_shrink = 0.1 # scale back initial timestep +castro.change_max = 1.1 # maximum increase in dt over successive steps + +# DIAGNOSTICS & VERBOSITY +castro.sum_interval = 1 # timesteps between computing mass +castro.v = 1 # verbosity in Castro.cpp +amr.v = 1 # verbosity in Amr.cpp +#amr.grid_log = grdlog # name of grid logging file + +# REFINEMENT / REGRIDDING +amr.max_level = 1 # maximum level number allowed +amr.ref_ratio = 2 2 2 2 # refinement ratio +amr.regrid_int = 2 # how often to regrid +amr.blocking_factor = 8 # block factor in grid generation +amr.max_grid_size = 32 + +amr.refinement_indicators = temperr tempgrad + +amr.refine.temperr.value_greater = 1.1 +amr.refine.temperr.field_name = Temp +amr.refine.temperr.max_level = 3 + +amr.refine.tempgrad.gradient = 0.1 +amr.refine.tempgrad.field_name = Temp +amr.refine.tempgrad.max_level = 3 + +# CHECKPOINT FILES +amr.check_file = diffuse_chk # root name of checkpoint file +amr.check_int = 1000 # number of timesteps between checkpoints + +# PLOTFILES +amr.plot_file = diffuse_plt +amr.plot_int = 10 +amr.derive_plot_vars=ALL + +# PROBLEM PARAMETERS +problem.diff_coeff = 1.0 + +# CONDUCTIVITY +conductivity.const_conductivity = 10.0 + +# EOS +eos.eos_assume_neutral = 1 diff --git a/Exec/unit_tests/diffusion_test/inputs.2d.sph b/Exec/unit_tests/diffusion_test/inputs.2d.sph index 5a90e2e6cc..b324d434f7 100644 --- a/Exec/unit_tests/diffusion_test/inputs.2d.sph +++ b/Exec/unit_tests/diffusion_test/inputs.2d.sph @@ -4,20 +4,22 @@ stop_time = 0.001 # PROBLEM SIZE & GEOMETRY geometry.is_periodic = 0 0 -geometry.coord_sys = 1 # 1 = RZ -geometry.prob_lo = 0.0 0.0 -geometry.prob_hi = 0.5 1.0 -amr.n_cell = 64 128 +geometry.coord_sys = 2 # 2 = SPHERICAL +geometry.prob_lo = 0.00001 0.0 +geometry.prob_hi = 1.0 3.141592653589793238 +amr.n_cell = 64 64 + +castro.allow_non_unit_aspect_zones = 1 # >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<< # 0 = Interior 3 = Symmetry # 1 = Inflow 4 = SlipWall # 2 = Outflow 5 = NoSlipWall # >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<< -castro.lo_bc = 3 2 -castro.hi_bc = 2 2 +castro.lo_bc = 3 3 +castro.hi_bc = 2 3 -# WHICH PHYSICS +# WHICH PHYSICS castro.do_hydro = 0 castro.diffuse_temp = 1 castro.do_react = 0 @@ -35,7 +37,7 @@ amr.v = 1 # verbosity in Amr.cpp #amr.grid_log = grdlog # name of grid logging file # REFINEMENT / REGRIDDING -amr.max_level = 1 # maximum level number allowed +amr.max_level = 0 # maximum level number allowed amr.ref_ratio = 2 2 2 2 # refinement ratio amr.regrid_int = 2 # how often to regrid amr.blocking_factor = 8 # block factor in grid generation diff --git a/Exec/unit_tests/diffusion_test/prob_util.H b/Exec/unit_tests/diffusion_test/prob_util.H index bc00c38b4f..db2a798522 100644 --- a/Exec/unit_tests/diffusion_test/prob_util.H +++ b/Exec/unit_tests/diffusion_test/prob_util.H @@ -5,7 +5,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE Real analytic(const Real* r, const Real time, const int coord_type) { Real exponent; - if (AMREX_SPACEDIM == 1 && coord_type == 2) { + if (coord_type == 2) { // Handle spherical coordinates exponent = 3.0_rt / 2.0_rt; } else if (AMREX_SPACEDIM == 2 && coord_type == 1) { @@ -16,8 +16,12 @@ Real analytic(const Real* r, const Real time, const int coord_type) { } Real dist2 = 0.0; - for (int d = 0; d < AMREX_SPACEDIM; d++) { - dist2 += r[d] * r[d]; + if (coord_type == 2) { + dist2 = r[0]*r[0]; + } else { + for (int d = 0; d < AMREX_SPACEDIM; d++) { + dist2 += r[d] * r[d]; + } } Real temp = problem::T1 + (problem::T2 - problem::T1) *