############################## CASTRO INPUTS ###############################################

# Name of the probin file
amr.probin_file = probin_test_wdmerger_retry

############################################################################################
# Geometry
############################################################################################

# Non-periodic boundary conditions
geometry.is_periodic = 0 0

# Cartesian coordinate system
geometry.coord_sys = 1

# Lower boundary limits in physical space
geometry.prob_lo = 0.0e0 -5.12e9

# Upper boundary limits in physical space
geometry.prob_hi = 5.12e9 5.12e9

# System center of mass
castro.center = 0.0e0 0.0e0

############################################################################################
# Boundary conditions
# 0 = Interior           3 = Symmetry
# 1 = Inflow             4 = SlipWall
# 2 = Outflow            5 = NoSlipWall
############################################################################################

# Boundary conditions on lo x, y, and z edges
castro.lo_bc = 3 2

# Boundary conditions on hi x, y, and z edges
castro.hi_bc = 2 2

############################################################################################ 
# Timestepping
############################################################################################

# Maximum coarse timestep
max_step = 1

# Whether to use our custom stopping criteria
castro.use_stopping_criterion = 1

# CFL number for hyperbolic system
castro.cfl = 0.5

# Fixed level 0 timestep; unused if < 0
castro.fixed_dt = -1.0

# Scale back initial timestep by this factor
castro.init_shrink = 1.0

# Factor by which dt is allowed to change each timestep
castro.change_max = 1.05

# If we regrid on Level 0, compute a new timestep afterward
amr.compute_new_dt_on_regrid = 1

# Use a retry if an advance violated our stability criteria
castro.use_retry = 1

############################################################################################ 
# Resolution, gridding and AMR
############################################################################################

# Number of cells on the coarse grid
amr.n_cell = 128 256

# Maximum level number allowed
amr.max_level = 2

# Refinement ratio
amr.ref_ratio = 4 4

# How many coarse timesteps between regridding
amr.regrid_int = 2

# Number of buffer cells in error estimation
amr.n_error_buf = 2 2

# Maximum grid size at each level
amr.max_grid_size = 32 32 48 64 64

# Grid sizes must be a multiple of blocking factor
amr.blocking_factor = 32 8 8 16 32

# What constitutes an efficient grid
amr.grid_eff = 0.9

# Order of reconstruction for interpolation
castro.state_interp_order = 0

# Limiting on state data interpolation (preserve linear combinations)
castro.lin_limit_state_interp = 1

############################################################################################
# Physics to include
############################################################################################

# Whether or not to do hydrodynamics
castro.do_hydro = 1

# Whether or not to do gravity
castro.do_grav = 1

# Whether or not to do reactions
castro.do_react = 0

# Whether or not to apply the sponge
castro.do_sponge = 0

# Whether or not to apply external source terms
castro.add_ext_src = 0
castro.ext_src_implicit = 1

# Whether or not to include the rotation source term
castro.do_rotation = 0

############################################################################################
# PPM/Hydro options
############################################################################################

# Piecewise parabolic with the original limiters (0 is piecewise linear; 2 is new limiters)
castro.ppm_type = 1

# Use the EOS in calculation of the edge states going into the Riemann solver
castro.ppm_temp_fix = 0

# Which Riemann solver to use.
# 0 = Colella, Glaz, and Ferguson (cheaper, less accurate)
# 1 = Colella and Glaz 1985 (more expensive, more accurate)
# 2 = HLL
castro.riemann_solver = 0

# For the CG Riemann solver, we need to tell the solver not to quit when 
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1

# Whether to use the hybrid advection technique that conserves angular momentum
castro.hybrid_hydro = 0

# Reset (rho*e) if it goes negative in the transverse terms
castro.transverse_reset_rhoe = 1

# Reset rho if it goes negative in the transverse terms
castro.transverse_reset_density = 1

# Explicitly limit fluxes to avoid hitting a negative density
castro.limit_fluxes_on_small_dens = 0

############################################################################################
# Thermodynamics
############################################################################################

# Minimum allowable temperature (K)
castro.small_temp = 1.0e5

# Minimum allowable density (g / cm**3)
castro.small_dens = 1.e-5

# Threshold for when to use the internal energy in calculating pressure
castro.dual_energy_eta1 = 1.0e-3

# Threshold for when to use (E - K) in updating internal energy
castro.dual_energy_eta2 = 1.0e-4

# Use Coulomb corrections in Helmholtz EOS
eos.use_eos_coulomb = 1

# Keep EOS inputs constant after EOS evaluation
eos.eos_input_is_constant = 1

############################################################################################
# Reactions/Network
############################################################################################

# Limit timestep based on nuclear burning considerations (changes in internal energy)
castro.dtnuc_e = 1.e200

# Limit timestep based on nuclear burning considerations (changes in species)
castro.dtnuc_X = 1.e200

# Which method to use for estimating de/dt and dX/dt
castro.dtnuc_mode = 1

# Minimum temperature for allowing nuclear burning
castro.react_T_min = 1.0e8

# Maximum temperature for allowing nuclear burning
castro.react_T_max = 1.0e12

# Minimum density for allowing nuclear burning
castro.react_rho_min = 1.0e6

# Maximum density for allowing nuclear burning
castro.react_rho_max = 1.0e12

# Smallest allowable mass fraction
network.small_x = 1.0e-12

# Burn at constant volume
integrator.do_constant_volume_burn = 1

# Evaluate the RHS during the burn
integrator.call_eos_in_rhs = 1

# Integration tolerances
integrator.rtol_spec = 1.0e-10
integrator.atol_spec = 1.0e-10

integrator.rtol_temp = 1.0e-6
integrator.atol_temp = 1.0e-6

integrator.rtol_enuc = 1.0e-6
integrator.atol_enuc = 1.0e-6

# Do not abort or retry on a failed burn (Castro will handle this)
integrator.retry_burn = 1

# Renormalize abundances during the burn
integrator.renormalize_abundances = 1

############################################################################################
# Gravity
############################################################################################

# Full self-gravity with the Poisson equation
gravity.gravity_type = PoissonGrav

# Multipole expansion includes terms up to r**(-max_multipole_order)
gravity.max_multipole_order = 6

# Relative tolerance for multigrid solver for phi solves
gravity.abs_tol = 1.e-10

# Turn off sync solve for gravity after refluxing
gravity.no_sync = 0

############################################################################################
# Rotation
############################################################################################

# Rotational period of the rotating reference frame
castro.rotational_period = 100.0

# Whether to evolve state variables in the inertial or rotating frame
castro.state_in_rotating_frame = 1

############################################################################################
# Load balancing
############################################################################################

# Choice of load balancing strategy to use
DistributionMapping.strategy = KNAPSACK

# Efficiency demanded from the knapsack algorithm
DistributionMapping.efficiency = 0.9

############################################################################################
# Diagnostics and I/O
############################################################################################

# Calculate and print the center of mass at each time step
castro.show_center_of_mass = 1

# Timesteps between computing and printing volume averaged diagnostic quantities
castro.sum_interval = 1

# Simulation time between computing and printing volume averaged diagnostic quantities
castro.sum_per = -1.0

# Whether or not to output plotfiles
amr.plot_files_output = 1

# Whether or not to output checkpoints
amr.checkpoint_files_output = 1

# Root name of checkpoint files
amr.check_file = chk

# We want to store the 'old' state data in checkpoints
castro.dump_old = 1

# Simulation time between checkpoints
amr.check_per = 1.0

# Number of timesteps between checkpoints
amr.check_int = -1

# Root name of plot files
amr.plot_file = plt

# Simulation time between plotfiles
amr.plot_per = 0.1

# Number of timesteps between plotfiles
amr.plot_int = -1

# Root name of small plot files
amr.small_plot_file = smallplt

# Simulation time between small plotfiles
amr.small_plot_per = 0.05

# Number of timesteps between small plotfiles
amr.small_plot_int = -1

# Do not write plotfiles when we dump checkpoints
amr.write_plotfile_with_checkpoint = 0

# How often to check whether the run script asked for a checkpoint dump
amr.message_int = 1

# Control verbosity in Amr.cpp
amr.v = 1

# Control verbosity in Castro.cpp
castro.v = 1

# Control verbosity in Gravity.cpp
gravity.v = 1

# Control verbosity in the multigrid solver
mg.v = 0

# State variables to add to plot files
amr.plot_vars = ALL

# Derived variables to add to plot files
amr.derive_plot_vars = pressure x_velocity y_velocity z_velocity soundspeed

# State variables to add to small plot files
amr.small_plot_vars = density Temp

# Name of the diagnostic sum output files
amr.data_log = grid_diag.out star_diag.out species_diag.out amr_diag.out primary_diag.out secondary_diag.out extrema_diag.out

# Used a forced fixed dt that is known to be larger
# than the safe hydrodynamic timestep given the above
# CFL value. This guarantees that we will retry on
# all levels, at least in the first timestep.
castro.fixed_dt = 0.08