Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radau quadrature for SDC #666

Merged
merged 113 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
58a368f
implement MOL/SDC PLM reflecting BCs
zingale Aug 19, 2019
79d7a44
implement an okay_to_burn() function
zingale Aug 19, 2019
e578f06
first pass at implementing limits on burning for SDC
zingale Aug 19, 2019
2c0e732
a multilevel inputs file
zingale Aug 19, 2019
014703a
Merge branch 'development' into xrb_sdc
zingale Aug 20, 2019
bc8e95c
first pass at fixing the flux registers for SDC
zingale Aug 20, 2019
31806bb
Merge branch 'development' into xrb_sdc
zingale Aug 21, 2019
b3b34bc
add plm_well_balanced
zingale Aug 22, 2019
974b26b
add first part of the Kappeli well-balanced scheme
zingale Aug 22, 2019
b259236
we are not using these custom BCs -- we use reflect now for 4th order
zingale Aug 22, 2019
e48d5c5
we don't use this anymore
zingale Aug 22, 2019
2fe8fbc
finish first pass at well-balanced. It kinda works, but not as good …
zingale Aug 22, 2019
17e5576
fix p0 in well-balanced
zingale Aug 23, 2019
285f734
implement 1-d X BCs
zingale Aug 23, 2019
4fa3ed7
add a +X HSE BC
zingale Aug 23, 2019
bdb75de
add 2nd order MC slope option
zingale Aug 23, 2019
d3a7ba3
fix comment
zingale Aug 23, 2019
80792a1
some 2nd order model support for well balancing
zingale Aug 23, 2019
edea55f
add well balanced test
zingale Aug 23, 2019
c49786a
fix the 2nd order model
zingale Aug 23, 2019
97fea33
set plm_iorder
zingale Aug 24, 2019
880a295
a simple plotting routine
zingale Aug 24, 2019
63c56f4
remove unneeded parameter
zingale Aug 24, 2019
3866e0b
a uniform grid SDC inputs
zingale Aug 25, 2019
37051cc
implement well-balancing for the other directions
zingale Aug 26, 2019
6658bcb
+Y HSE BC for testing purposes
zingale Aug 26, 2019
d2e0102
a well-balanced test in 2-d
zingale Aug 26, 2019
1c400f0
switch the 2-d well-balanced test to r-z
zingale Aug 26, 2019
28c1d49
a small uniform grid test
zingale Aug 27, 2019
802448a
update
zingale Aug 28, 2019
5024913
sdc probin
zingale Aug 28, 2019
362a9f9
Merge branch 'development' into xrb_sdc
zingale Aug 29, 2019
7ebf1aa
Merge branch 'development' into xrb_sdc
zingale Aug 30, 2019
f8a1b04
Merge branch 'development' into xrb_sdc
zingale Sep 2, 2019
e8cbf85
update changes
zingale Sep 2, 2019
fb320ea
return to capture change in plm_iorder default
zingale Sep 2, 2019
88637c9
fix compilation with old SDC
zingale Sep 2, 2019
662bc42
Merge branch 'development' into xrb_sdc
zingale Sep 3, 2019
34b259c
update changes
zingale Sep 3, 2019
db8a354
Merge branch 'development' into xrb_sdc
zingale Sep 3, 2019
6d4ed70
Merge branch 'xrb_sdc' of github.com:AMReX-Astro/Castro into xrb_sdc
zingale Sep 3, 2019
9fc51eb
new sdc_quadature parameter
zingale Sep 4, 2019
f51e1b8
Merge branch 'xrb_sdc' into sdc_radau
zingale Sep 4, 2019
741b666
add an sdc_quadrature parameter to optionally enable Radau
zingale Sep 4, 2019
f681c8f
add sdc_quadrature to Fortran
zingale Sep 4, 2019
a062254
define dt_m more generally
zingale Sep 5, 2019
b0db99c
some more straightening out of dt vs dt_m
zingale Sep 5, 2019
95fa608
some work for pure hydro Radau SDC
zingale Sep 5, 2019
c4ce552
compute the Radau integrals for reaction
zingale Sep 5, 2019
683afe5
finish first pass at implementing Radau
zingale Sep 5, 2019
9d9c142
Merge branch 'sdc_radau' of github.com:AMReX-Astro/Castro into sdc_radau
zingale Sep 6, 2019
2420b38
fix interface
zingale Sep 6, 2019
649af19
Merge branch 'development' into sdc_radau
zingale Sep 7, 2019
2af55c0
Merge branch 'development' into sdc_radau
zingale Sep 12, 2019
6b8d0d9
Merge branch 'development' into xrb_sdc
zingale Sep 12, 2019
6ad506f
Merge branch 'development' into xrb_sdc
zingale Sep 13, 2019
eecc806
Merge branch 'development' into sdc_radau
zingale Sep 13, 2019
3e76585
Merge branch 'xrb_sdc' into sdc_radau
zingale Sep 13, 2019
aada5fa
a test inputs file for SDC 2
zingale Sep 13, 2019
6a9a815
more meaningful SDC progress messages
zingale Sep 13, 2019
84c1951
add some debugging output for when Newton fails
zingale Sep 13, 2019
9b22c1f
remove unused function + add species normalization to f_sdc_jac
zingale Sep 13, 2019
8c2a46b
more normalization work
zingale Sep 14, 2019
82d8c94
fix a comment
zingale Sep 15, 2019
d0938d0
use small_x in the normalization of species
zingale Sep 15, 2019
4bfb92d
sync up a bit with the regression version
zingale Sep 15, 2019
4a2b4b8
fix merge issue
zingale Sep 15, 2019
4abeb7b
Merge branch 'development' into xrb_sdc
zingale Sep 15, 2019
9a7e4e4
Merge branch 'development' into sdc_radau
zingale Sep 15, 2019
6f4f5bd
Merge branch 'development' into sdc_radau
zingale Sep 16, 2019
8bdff09
fix names
zingale Sep 16, 2019
279c3eb
remove mpi
zingale Sep 16, 2019
c2cab60
fix number of steps
zingale Sep 16, 2019
e1f4523
Merge branch 'development' into sdc_radau
zingale Sep 16, 2019
eb79538
fix quadrature values
zingale Sep 17, 2019
631e542
check quadrature value
zingale Sep 17, 2019
e17e02c
Merge branch 'development' into sdc_radau
zingale Sep 17, 2019
cf6aeee
fix merge conflicts
zingale Sep 17, 2019
a43e53e
use amrex::Print()
zingale Sep 17, 2019
2944b61
Merge branch 'development' into xrb_sdc
zingale Sep 18, 2019
01cbb10
revert the overloading of plm_iorder
zingale Sep 18, 2019
455510f
update notes on plm_iorder
zingale Sep 18, 2019
ff67ee4
use constrained_layout
zingale Sep 18, 2019
2ed6d88
Merge branch 'sdc_radau' of github.com:AMReX-Astro/Castro into sdc_radau
zingale Sep 18, 2019
e2fd1a0
add SDC-2
zingale Sep 18, 2019
4c2610a
some tweaks to the inputs
zingale Sep 18, 2019
3a46724
fix dir names
zingale Sep 19, 2019
d028989
Merge branch 'development' into sdc_radau
zingale Sep 19, 2019
7fd8983
add a plot that groups integrators
zingale Sep 19, 2019
2d6c837
some robustness to the plot script
zingale Sep 20, 2019
1ea1ad4
Merge branch 'development' into xrb_sdc
zingale Sep 20, 2019
02b7267
Merge branch 'development' into sdc_radau
zingale Sep 20, 2019
9c520a5
Merge branch 'xrb_sdc' into sdc_radau
zingale Sep 20, 2019
4f34c4d
Merge branch 'sdc_radau' of github.com:AMReX-Astro/Castro into sdc_radau
zingale Sep 20, 2019
98203fc
undo commit
zingale Sep 20, 2019
03b963e
Merge branch 'development' into xrb_sdc
zingale Sep 22, 2019
4a8ba95
Merge branch 'development' into sdc_radau
zingale Sep 22, 2019
c123f71
remove MethodOfLines
zingale Sep 23, 2019
f13dcd2
move if test out of loop
zingale Sep 23, 2019
f790a3c
Merge branch 'xrb_sdc' into sdc_radau
zingale Sep 23, 2019
2365a90
Merge branch 'development' into sdc_radau
zingale Sep 23, 2019
764596a
Merge branch 'development' into sdc_radau
zingale Sep 23, 2019
792d5c9
Merge branch 'development' into sdc_radau
zingale Sep 24, 2019
d8cf9b3
Merge branch 'sdc_radau' of github.com:AMReX-Astro/Castro into sdc_radau
zingale Sep 24, 2019
571f1f0
fill U_old
zingale Sep 24, 2019
95af67e
Merge branch 'development' into sdc_radau
zingale Sep 24, 2019
a919557
change precision of weights
zingale Sep 24, 2019
e409093
Merge branch 'sdc_radau' of github.com:AMReX-Astro/Castro into sdc_radau
zingale Sep 24, 2019
022d2e1
fix merge issue
zingale Sep 24, 2019
7cf535f
Merge branch 'development' into sdc_radau
zingale Sep 25, 2019
fd3ed9a
Merge branch 'development' into sdc_radau
zingale Sep 27, 2019
c6a4795
Merge branch 'development' into sdc_radau
zingale Oct 6, 2019
a309313
Merge branch 'development' into sdc_radau
zingale Oct 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions Exec/science/Detonation/inputs-det-x.sdc2
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 15000
stop_time = 0.2

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 0 0 0
geometry.coord_sys = 0 # 0 => cart, 1 => RZ 2=>spherical
geometry.prob_lo = 0 0 0
geometry.prob_hi = 4.e4 2500 2500
amr.n_cell = 512 16 16


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

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

castro.time_integration_method = 2
castro.sdc_order = 2
castro.sdc_quadrature = 0
#castro.sdc_extra = 1

castro.sdc_solve_for_rhoe = 1

castro.sdc_solver = 1
castro.sdc_solver_tol_dens = 1.e-5
castro.sdc_solver_tol_spec = 1.e-5
castro.sdc_solver_tol_ener = 1.e-5
castro.sdc_use_analytic_jac = 1

castro.ppm_type = 0

castro.use_flattening = 1

castro.small_temp = 1.e7

castro.riemann_solver = 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.05 # scale back initial timestep
castro.dt_cutoff = 5.e-20 # level 0 timestep below which we halt
castro.dtnuc_e = 0.25

# 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 = 4 # 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.check_file = det_x_chk # root name of checkpoint file
amr.check_int = 300 # number of timesteps between checkpoints

# PLOTFILES
amr.plot_file = det_x_plt # root name of plotfile
amr.plot_per = 1.e-7
amr.derive_plot_vars = ALL

#PROBIN FILENAME
amr.probin_file = probin-det-x
4 changes: 2 additions & 2 deletions Exec/science/Detonation/sdc_tests/inputs.1d.sdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 40000
stop_time = 0.2
max_step = 400000
stop_time = 3.e-6

# PROBLEM SIZE & GEOMETRY
geometry.is_periodic = 0 0 0
Expand Down
80 changes: 68 additions & 12 deletions Exec/science/Detonation/sdc_tests/make_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ def get_velocity(self):
def get_data(self, n=-1):
"""get the temperature and energy generation rate from the nth
plotfile (starting to count at 0)."""

return Profile(os.path.join(self.name, self.files[n]))

try:
return Profile(os.path.join(self.name, self.files[n]))
except IndexError:
return None

if __name__ == "__main__":

Expand All @@ -153,9 +154,15 @@ def get_data(self, n=-1):
runs.sort()
print(runs)

# make a plot of the profiles for different CFLs and different resolutions
nzones = set([q.nzones for q in runs])
integrators = set([q.integrator for q in runs])
nzones = list(set([q.nzones for q in runs]))
nzones.sort()
integrators = list(set([q.integrator for q in runs]))
integrators.sort()
cfls = list(set([q.cfl for q in runs]))
cfls.sort()

# make a plot of the profiles for different CFLs with the same
# integrator and resolutions

idx = 5
for nz in nzones:
Expand All @@ -165,17 +172,19 @@ def get_data(self, n=-1):
if len(dset) == 0:
continue

fig = plt.figure(1)
fig.clear()
fig, axes = plt.subplots(ncols=1, nrows=3, constrained_layout=True, squeeze=True)

fig.set_size_inches(7.0, 9.0)

ax_T = fig.add_subplot(311)
ax_e = fig.add_subplot(312)
ax_he = fig.add_subplot(313)
ax_T = axes[0]
ax_e = axes[1]
ax_he = axes[2]

for q in dset:
pf = q.get_data(idx)
if not pf:
continue

print("working on {}, time = {}".format(q.name, pf.time))

ax_T.plot(pf.x, pf.T, label="CFL = {}".format(q.cfl))
Expand All @@ -198,5 +207,52 @@ def get_data(self, n=-1):

fig.suptitle("{}, number of zones = {}".format(intg, nz))

fig.tight_layout()
fig.savefig("det_cfl_compare_{}_nz{}.png".format(intg.replace(" ", "_"), nz))
plt.close()

# make a plot of the profiles for different integrators with the same CFLs and resolutions

idx = 5
for nz in nzones:
for c in cfls:
dset = [q for q in runs if q.cfl == c and q.nzones == nz]
dset.sort(key=lambda q: q.integrator)
if len(dset) == 0:
continue

fig, axes = plt.subplots(ncols=1, nrows=3, constrained_layout=True, squeeze=True)

fig.set_size_inches(7.0, 9.0)

ax_T = axes[0]
ax_e = axes[1]
ax_he = axes[2]

for q in dset:
pf = q.get_data(idx)
if not pf:
continue
print("working on {}, time = {}".format(q.name, pf.time))

ax_T.plot(pf.x, pf.T, label="{}".format(q.integrator))
ax_e.plot(pf.x, pf.enuc)
ax_he.plot(pf.x, pf.rho_he4)

ax_T.legend(frameon=False)

ax_T.set_ylabel(r"$T$ (K)")
ax_e.set_ylabel(r"$H_\mathrm{nuc}$ (erg/g/s)")
ax_he.set_ylabel(r"$\rho X({}^4\mathrm{He})$ (g/cm${}^3$)")
ax_he.set_xlabel("x (cm)")

ax_T.set_xlim(5000, 15000)
ax_e.set_xlim(5000, 15000)
ax_he.set_xlim(5000, 15000)

ax_e.set_yscale("log")
ax_he.set_yscale("log")

fig.suptitle("number of zones = {}, CFL = {}".format(nz, c))

fig.savefig("det_integrator_compare_cfl{}_nz{}.png".format(c, nz))
plt.close()
2 changes: 2 additions & 0 deletions Exec/science/Detonation/sdc_tests/probin.sdc
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@
! rtol_enuc = 1.e-8
call_eos_in_rhs = T
do_constant_volume_burn = T

small_x = 1.e-10
/
84 changes: 82 additions & 2 deletions Exec/science/Detonation/sdc_tests/setup_runs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stop_time=3.e-6"
RUNPARAMS="
castro.time_integration_method=2
castro.sdc_order=4
castro.sdc_quadrature=1
castro.sdc_quadrature=0
castro.limit_fourth_order=1
castro.use_reconstructed_gamma1=1
castro.sdc_solve_for_rhoe=1
Expand Down Expand Up @@ -59,14 +59,54 @@ do
done


#=============================================================================
# Lobatto SDC-2
#=============================================================================

RUNPARAMS="
castro.time_integration_method=2
castro.sdc_order=2
castro.sdc_quadrature=0
castro.limit_fourth_order=1
castro.use_reconstructed_gamma1=1
castro.sdc_solve_for_rhoe=1
castro.sdc_solver_tol_dens=1.e-8
castro.sdc_solver_tol_spec=1.e-8
castro.sdc_solver_tol_ener=1.e-8
castro.sdc_solver=2"

for c in ${CFL}
do

for nz in ${NZONES}
do
rdir=det_z${nz}_c${c}_lobatto_sdc2
if [ ! -d ${rdir} ]; then
mkdir ${rdir}
fi

cd ${rdir}
for nf in ${NEEDED_FILES}
do
if [ ! -f ${nf} ]; then
cp ../${nf} .
fi
done

nohup ${CASTRO_EXEC} inputs.1d.sdc amr.plot_file=${rdir}_plt ${GLOBAL_RUNPARAMS} ${RUNPARAMS} castro.cfl=${c} amr.n_cell=${nz} >& out &
cd ..
done
done


#=============================================================================
# Radau SDC-4
#=============================================================================

RUNPARAMS="
castro.time_integration_method=2
castro.sdc_order=4
castro.sdc_quadrature=2
castro.sdc_quadrature=1
castro.limit_fourth_order=1
castro.use_reconstructed_gamma1=1
castro.sdc_solve_for_rhoe=1
Expand Down Expand Up @@ -99,6 +139,46 @@ do
done


#=============================================================================
# Radau SDC-2
#=============================================================================

RUNPARAMS="
castro.time_integration_method=2
castro.sdc_order=2
castro.sdc_quadrature=1
castro.limit_fourth_order=1
castro.use_reconstructed_gamma1=1
castro.sdc_solve_for_rhoe=1
castro.sdc_solver_tol_dens=1.e-8
castro.sdc_solver_tol_spec=1.e-8
castro.sdc_solver_tol_ener=1.e-8
castro.sdc_solver=2"

for c in ${CFL}
do

for nz in ${NZONES}
do
rdir=det_z${nz}_c${c}_radau_sdc2
if [ ! -d ${rdir} ]; then
mkdir ${rdir}
fi

cd ${rdir}
for nf in ${NEEDED_FILES}
do
if [ ! -f ${nf} ]; then
cp ../${nf} .
fi
done

nohup ${CASTRO_EXEC} inputs.1d.sdc amr.plot_file=${rdir}_plt ${GLOBAL_RUNPARAMS} ${RUNPARAMS} castro.cfl=${c} amr.n_cell=${nz} >& out &
cd ..
done
done



#=============================================================================
# Strang CTU
Expand Down
1 change: 1 addition & 0 deletions Source/driver/Castro_advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ Castro::initialize_advance(Real time, Real dt, int amr_iteration, int amr_ncycle

MultiFab& S_old = get_old_data(State_Type);
k_new.resize(SDC_NODES);

k_new[0].reset(new MultiFab(S_old, amrex::make_alias, 0, NUM_STATE));
for (int n = 1; n < SDC_NODES; ++n) {
k_new[n].reset(new MultiFab(grids, dmap, NUM_STATE, 0));
Expand Down
11 changes: 7 additions & 4 deletions Source/driver/Castro_advance_sdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ Castro::do_advance_sdc (Real time,


// the next chunk of code constructs the advective term for the
// current node, m. First we get the sources, then convert to
// primitive, then get the source term from the MOL driver. Note,
// for m = 0, we only have to do all of this the first iteration,
// since that state never changes
// current node, m. First we get the sources, then full hydro
// source term from the MOL driver. Note, for m = 0, we only have
// to do all of this the first iteration, since that state never
// changes
if (!(sdc_iteration > 0 && m == 0) &&
!(sdc_iteration == sdc_order+sdc_extra-1 && m == SDC_NODES-1)) {

Expand Down Expand Up @@ -205,6 +205,9 @@ Castro::do_advance_sdc (Real time,
// this if we are on the final node (since there is nothing to
// update to
if (m < SDC_NODES-1) {

amrex::Print() << "... doing the SDC update, iteration = " << sdc_iteration << " from node " << m << " to " << m+1 << std::endl;

do_sdc_update(m, m+1, dt); //(dt_sdc[m+1] - dt_sdc[m])*dt);

// we now have a new value of k_new[m+1], do a clean_state on it
Expand Down
Loading