Skip to content

Commit

Permalink
add a resolution to the nse_test convergence (#2693)
Browse files Browse the repository at this point in the history
allow for 3 different convergence orders
  • Loading branch information
zingale authored Jan 1, 2024
1 parent e8756a5 commit 961b6b6
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ problem.u0=1.e8
problem.v0=1.e8
"

mpiexec -n 8 ${EXEC} inputs.32 ${RUNPARAMS} >& /dev/null
mpiexec -n 8 ${EXEC} inputs.64 ${RUNPARAMS} >& /dev/null
mpiexec -n 8 ${EXEC} inputs.128 ${RUNPARAMS} >& /dev/null

RichardsonConvergenceTest2d.gnu.ex coarFile=nse_test_32_plt00080 mediFile=nse_test_64_plt00160 fineFile=nse_test_128_plt00320 >& nse_convergence_simple_sdc_vlo.out

mpiexec -n 8 ${EXEC} inputs.256 ${RUNPARAMS} >& /dev/null

RichardsonConvergenceTest2d.gnu.ex coarFile=nse_test_64_plt00125 mediFile=nse_test_128_plt00250 fineFile=nse_test_256_plt00500 >& nse_convergence_simple_sdc_lo.out
RichardsonConvergenceTest2d.gnu.ex coarFile=nse_test_64_plt00160 mediFile=nse_test_128_plt00320 fineFile=nse_test_256_plt00640 >& nse_convergence_simple_sdc_lo.out

mpiexec -n 8 ${EXEC} inputs.512 ${RUNPARAMS} >& /dev/null

RichardsonConvergenceTest2d.gnu.ex coarFile=nse_test_128_plt00250 mediFile=nse_test_256_plt00500 fineFile=nse_test_512_plt01000 >& nse_convergence_simple_sdc_hi.out
RichardsonConvergenceTest2d.gnu.ex coarFile=nse_test_128_plt00320 mediFile=nse_test_256_plt00640 fineFile=nse_test_512_plt01280 >& nse_convergence_simple_sdc_hi.out


132 changes: 89 additions & 43 deletions Exec/reacting_tests/nse_test/create_pretty_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ def sci_not(num):
return r"${:5.3f} \times 10^{{{}}}$".format(round(mant, 3), exp)

class Variable():
def __init__(self, name, lo, o1, med, o2, hi):
def __init__(self, name, lo, o1, med, o2, hi, o3=None, vhi=None):
self.name = name
self.lo = float(lo)
self.o1 = float(o1)
self.med = float(med)
self.o2 = float(o2)
self.hi = float(hi)
if o3 is not None:
self.o3 = float(o3)
else:
self.o3 = None
if vhi is not None:
self.vhi = float(vhi)
else:
self.vhi = None

def get_table_line(self, pretty_name=None, simple=False):
if pretty_name is not None:
Expand All @@ -29,69 +37,103 @@ def get_table_line(self, pretty_name=None, simple=False):
name = self.name

if simple:
_str = r" {:27} {:14.10g} {:5.3f} {:14.10g} {:5.3f} {:14.10g}"
return _str.format(name, self.lo, round(self.o1, 3), self.med, round(self.o2, 3), self.hi)
if self.o3 is None:
return rf" {name:27} {self.lo:14.10g} {round(self.o1, 3):5.3f} {self.med:14.10g} {round(self.o2, 3):5.3f} {self.hi:14.10g}"
else:
return rf" {name:27} {self.lo:14.10g} {round(self.o1, 3):5.3f} {self.med:14.10g} {round(self.o2, 3):5.3f} {self.hi:14.10g} {round(self.o3, 3):5.3f} {self.vhi:14.10g}"

else:
_str = r" {:27} & {:23} & {:5.3f} & {:23} & {:5.3f} & {:23} \\"
return _str.format(name, sci_not(self.lo), round(self.o1, 3), sci_not(self.med), round(self.o2, 3), sci_not(self.hi))
if self.o3 is None:
return rf" {name:27} & {sci_not(self.lo):23} & {round(self.o1, 3):5.3f} & {sci_not(self.med):23} & {round(self.o2, 3):5.3f} & {sci_not(self.hi):23} \\"
else:
return rf" {name:27} & {sci_not(self.lo):23} & {round(self.o1, 3):5.3f} & {sci_not(self.med):23} & {round(self.o2, 3):5.3f} & {sci_not(self.hi):23} & {round(self.o3, 3):5.3f} & {sci_not(self.vhi):23} \\"

class ConvergenceData():
class ConvergenceData2():
def __init__(self):
self.data = []

def add_variable(self, name, lo, order1, med, order2, hi):
self.data.append(Variable(name, lo, order1, med, order2, hi))

def read_convergence(file_lo, file_hi):
class ConvergenceData3():
def __init__(self):
self.data = []

def add_variable(self, name, lo, order1, med, order2, hi, order3, vhi):
self.data.append(Variable(name, lo, order1, med, order2, hi, order3, vhi))

def read_convergence(file_lo, file_hi, file_vhi):

# we'll wait until we find the L1 data

lines_lo = []
found_l1 = False
with open(file_lo, "r") as flo:
for line in flo:
if "L1 norm" in line:
found_l1 = True
continue
if not found_l1:
continue
# value data lines have 4 columns
if len(line.split()) == 4:
lines_lo.append(line.strip())

lines_hi = []
found_l1 = False
with open(file_hi, "r") as fhi:
for line in fhi:
if "L1 norm" in line:
found_l1 = True
continue
if not found_l1:
lines_vhi = []

fdata = [(lines_lo, file_lo), (lines_hi, file_hi)]
if file_vhi is not None:
fdata.append((lines_vhi, file_vhi))

for lines, filec in fdata:
found_l1 = False
with open(filec, "r") as fc:
for line in fc:
if "L1 norm" in line:
found_l1 = True
continue
if not found_l1:
continue
# value data lines have 4 columns
if len(line.split()) == 4:
lines.append(line.strip())

if file_vhi is None:

cd = ConvergenceData2()

for llo, lhi in zip(lines_lo, lines_hi):

vlo, elo, o1, emed1 = llo.split()
vhi, emed2, o2, ehi = lhi.split()

if "---" in o1 or "---" in o2:
print("skipping {}".format(vlo))
continue
# value data lines have 4 columns
if len(line.split()) == 4:
lines_hi.append(line.strip())

cd = ConvergenceData()
if vlo != vhi:
sys.exit("error: variable mismatch")

if emed1.strip() != emed2.strip():
print(emed1, emed2)
sys.exit("error: error mismatch")

cd.add_variable(vlo, elo, o1, emed1, o2, ehi)

for llo, lhi in zip(lines_lo, lines_hi):
else:

vlo, elo, o1, emed1 = llo.split()
vhi, emed2, o2, ehi = lhi.split()
cd = ConvergenceData3()

if "---" in o1 or "---" in o2:
print("skipping {}".format(vlo))
continue
for llo, lhi, lvhi in zip(lines_lo, lines_hi, lines_vhi):

vlo, elo, o1, emed1 = llo.split()
vhi, emed2, o2, ehi1 = lhi.split()
vvhi, ehi2, o3, evhi = lvhi.split()

if "---" in o1 or "---" in o2 or "---" in o3:
print("skipping {}".format(vlo))
continue

if vlo != vhi:
sys.exit("error: variable mismatch")
if vlo != vhi or vlo != vvhi:
sys.exit("error: variable mismatch")

if emed1.strip() != emed2.strip():
print(emed1, emed2)
sys.exit("error: error mismatch")
if emed1.strip() != emed2.strip() or ehi1.strip() != ehi2.strip():
print(emed1, emed2, ehi1, ehi2)
print(llo)
print(lhi)
print(lvhi)
sys.exit("error: error mismatch")

cd.add_variable(vlo, elo, o1, emed1, o2, ehi)
cd.add_variable(vlo, elo, o1, emed1, o2, ehi1, o3, evhi)

return cd

Expand All @@ -103,6 +145,8 @@ def read_convergence(file_lo, file_hi):
help="name of the low resolution convergence output file")
parser.add_argument("hifile", type=str, nargs=1,
help="name of the high resolution convergence output file")
parser.add_argument("veryhifile", type=str, nargs="?", default=None,
help="(optional) name of the very high resolution convergence output file")

args = parser.parse_args()

Expand All @@ -129,8 +173,10 @@ def read_convergence(file_lo, file_hi):
# sdc4
file_lo = args.lofile[0]
file_hi = args.hifile[0]
file_vhi = args.veryhifile
print(file_vhi)

sdc4 = read_convergence(file_lo, file_hi)
sdc4 = read_convergence(file_lo, file_hi, file_vhi)

for v in sdc4.data:
if v.name in good_vars.keys():
Expand Down
2 changes: 1 addition & 1 deletion Exec/reacting_tests/nse_test/inputs.128
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 15000
stop_time = 0.025
stop_time = 0.032

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 1 1 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/reacting_tests/nse_test/inputs.256
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 15000
stop_time = 0.025
stop_time = 0.032

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 1 1 1
Expand Down
74 changes: 74 additions & 0 deletions Exec/reacting_tests/nse_test/inputs.32
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 15000
stop_time = 0.032

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 1 1 1
geometry.coord_sys = 0 # 0 => cart, 1 => RZ 2=>spherical
geometry.prob_lo = 0 0 0
geometry.prob_hi = 2.e7 2.e7 2.e7
amr.n_cell = 32 32 32


# >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<<
# 0 = Interior 3 = Symmetry
# 1 = Inflow 4 = SlipWall
# 2 = Outflow 5 = NoSlipWall
# >>>>>>>>>>>>> BC FLAGS <<<<<<<<<<<<<<<<
castro.lo_bc = 0 0 0
castro.hi_bc = 0 0 0

# WHICH PHYSICS
castro.do_hydro = 1
castro.do_react = 1

castro.ppm_type = 1
castro.ppm_temp_fix = 0

castro.use_flattening = 1

castro.riemann_solver = 0

castro.small_temp = 1.e7

# TIME STEP CONTROL
castro.cfl = 0.8 # cfl number for hyperbolic system
castro.init_shrink = 1.0 # scale back initial timestep
castro.change_max = 1.1 # scale back initial timestep
castro.fixed_dt = 4.e-4

# 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 = 0 # maximum level number allowed
amr.ref_ratio = 2 2 2 2 # refinement ratio
amr.regrid_int = 2 2 2 2 # how often to regrid
amr.blocking_factor = 8 # block factor in grid generation
amr.max_grid_size = 64
amr.n_error_buf = 2 2 2 2 # number of buffer cells in error est

# CHECKPOINT FILES
amr.checkpoint_files_output = 0
amr.check_file = nse_test_32_chk # root name of checkpoint file
amr.check_int = 300 # number of timesteps between checkpoints

# PLOTFILES
amr.plot_file = nse_test_32_plt # root name of plotfile
amr.plot_per = 0.24
amr.derive_plot_vars = ALL

# problem initialization

problem.T0 = 5.e9
problem.dT_fact = 0.2
problem.rho0 = 1.e9
problem.L_pert = 2.e7
problem.nse_tol = 1.e2

# microphysics

network.nse_table_interp_linear = 0
2 changes: 1 addition & 1 deletion Exec/reacting_tests/nse_test/inputs.512
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 15000
stop_time = 0.025
stop_time = 0.032

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 1 1 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/reacting_tests/nse_test/inputs.64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 15000
stop_time = 0.025
stop_time = 0.032

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 1 1 1
Expand Down

0 comments on commit 961b6b6

Please sign in to comment.