How to choose `batch_duration`
This page answers how large the physical time represented by one batch may be. A single run cannot establish a safe value. The basic method is to compare fixed widths at 1/2, 1, and 2 times a reference value and find a range that does not change the result at the same physical time.
After reading this page, you can run a fixed-width comparison and decide whether to retain that width or use adaptive
cached_kneq0 progression.
sim.tol_relis a monitoring and output value. The current implementation does not use it for early stopping; the run continues to the accepted batch count set bysim.batch_count.
Choose the path first
Section titled “Choose the path first”| Goal | Path |
|---|---|
| Check time-width sensitivity for a general case | Compare fixed widths at 1/2, 1, and 2 times |
Bound the local-potential change of one cached_kneq0 batch | Use max_nonzero_mode_potential_step |
| Check overall stability or global accuracy including | Run a fixed-width comparison; adaptive progression alone is insufficient |
sim.batch_duration is the physical time of one batch and the time width over which surface charge is updated.
When sim.batch_duration_step is used, the resolved width is
The two keys are mutually exclusive. sim.dt is the particle-push time step, while batch_duration controls how long
surface-charge changes are accumulated before they are applied.
boundary_inflow, plane_source, reservoir_face, photo_raycast, and
surface_charge_closure="fixed_current" require a positive resolved batch_duration.
See the Input parameter reference for the complete input contract.
Compare fixed widths
Section titled “Compare fixed widths”Hold the comparison conditions fixed
Section titled “Hold the comparison conditions fixed”- Set
write_files=trueandhistory_stride > 0to savesummary.txtandcharge_history.csv. - Keep the mesh, particle distributions, RNG seed, OpenMP thread count, and MPI rank count fixed.
- Give each run a separate
output.dir. - Change
batch_counttogether with the width so that the runs are compared near the samesimulated_time_s.
For a reference width and reference batch count , use:
| Run | batch_duration | batch_count | output.dir |
|---|---|---|---|
| half | outputs/batch-half | ||
| reference | outputs/batch-reference | ||
| double | outputs/batch-double |
Choose an even . For example, with s and , the half, reference, and double settings are
(5.0e-8, 200), (1.0e-7, 100), and (2.0e-7, 50), respectively.
These numbers demonstrate the edit and are not recommended physical defaults.
When using batch_duration_step, keep dt fixed and scale the step value by the same factors of 1/2, 1, and 2.
Create and run the configurations
Section titled “Create and run the configurations”Copy the original configuration three times, then change only the corresponding [sim] and [output] values from the
table above.
cp beach.toml batch-half.tomlcp beach.toml batch-reference.tomlcp beach.toml batch-double.tomlValidate the inputs, then run them locally or on a compute node.
beachx lint batch-half.tomlbeachx lint batch-reference.tomlbeachx lint batch-double.toml
beach batch-half.tomlbeach batch-reference.tomlbeach batch-double.tomlSee Run a simulation for choosing an execution environment.
Check the expected outputs
Section titled “Check the expected outputs”Each run needs summary.txt, charges.csv, and charge_history.csv.
Check the completed batch count and physical end time with:
for output_dir in outputs/batch-half outputs/batch-reference outputs/batch-double; do beachx inspect "$output_dir" grep -E '^(batches|last_rel_change|simulated_time_s)=' "$output_dir/summary.txt"doneThe expected state is:
- All three runs complete with exit code
0. batchesequalssim.batch_countin each configuration.simulated_time_sreaches the same physical end time in all three runs.- The
batchcolumn incharge_history.csvcan be converted with each run’s width to compare element charge at corresponding physical times.
Successful completion does not establish numerical stability or a steady state. last_rel_change is also a diagnostic
for comparing history and final state, not a stopping condition.
Choose the width
Section titled “Choose the width”Compare the final surface-charge distribution, total charge, local-potential range, absorbed/escaped counts, and history oscillation. Define “agreement” from the accuracy required for the study’s quantities of interest before comparing runs.
| Observation | Decision |
|---|---|
| Half and reference agree within the chosen tolerance | The reference is a practical candidate; retain half as the validation baseline |
| The reference or double run oscillates or diverges | Lower batch_duration |
| Final charge changes systematically with width | Repeat the comparison at smaller widths |
| Monte Carlo noise obscures the history | Adjust w_particle or target_macro_particles_per_batch first |
| Change continues at the end | Increase batch_count by the same factor in all compared runs, extending their common physical end time |
This is a step-size sensitivity check, not Richardson extrapolation. It assumes neither a power law for the error nor a
particular convergence order. batch_duration theory explains why.
Use adaptive progression
Section titled “Use adaptive k≠0k\ne0k=0 progression”Cases where it applies
Section titled “Cases where it applies”This path is an advanced option for an existing periodic2 case and requires all of the following:
[periodic2].nonzero_mode_backend = "cached_kneq0"- a positive
sim.batch_duration, or asim.batch_duration_stepthat resolves to a positive value - time-scaled
boundary_inflow,plane_source,reservoir_face, orphoto_raycast target_macro_particles_per_batch, rather than fixedw_particle, for reservoir inflow andplane_source
A volume_seed with positive npcls_per_step cannot be used on this path.
Set the limit and run
Section titled “Set the limit and run”Copy the original periodic2 configuration, then change the corresponding existing values under [periodic2] and
[output] in adaptive.toml.
cp beach.toml adaptive.toml[periodic2]nonzero_mode_backend = "cached_kneq0"max_nonzero_mode_potential_step = 1.0e-2 # V
[output]dir = "outputs/adaptive"1.0e-2 V is an input example. Set it from the acceptable local-potential change, then compare it with a run at half the
limit.
beachx lint adaptive.tomlbeach adaptive.tomlbeachx inspect outputs/adaptiveLet be the resolved sim.batch_duration. For every accepted batch, BEACH tests
. It evaluates the potential change produced by the candidate charge at every panel
centroid and accepts the first width whose maximum absolute value does not exceed the limit.
Check the expected outputs
Section titled “Check the expected outputs”grep -E '^(batches|simulated_time_s|periodic2_max_nonzero_mode_potential_step_V|adaptive_nonzero_mode_rejected_trials|adaptive_nonzero_mode_last_batch_duration_s|adaptive_nonzero_mode_last_potential_step_V|adaptive_nonzero_mode_omp_threads)=' \ outputs/adaptive/summary.txtadaptive_nonzero_mode_last_batch_duration_sis the last accepted width.adaptive_nonzero_mode_last_potential_step_Vis the last accepted potential change and does not exceed the configured limit.adaptive_nonzero_mode_rejected_trials=0is valid. The field is the cumulative number of halvings needed to satisfy the limit.simulated_time_saccumulates accepted widths and is not generally equal tobatch_count * batch_duration.
A rejected retry restores the RNG and macro-particle residuals and does not update statistics, history, or the charge ledger. The run stops if one batch still exceeds the limit after 24 halvings. In that case, examine the field model, particle statistics, and charge change as well as reducing the maximum width.
Decide whether to retain the limit
Section titled “Decide whether to retain the limit”- Create a run with half the
max_nonzero_mode_potential_step. - Compare surface charge, local-potential range, total charge, and particle statistics near the same
simulated_time_s. - If they agree within the chosen tolerance, retain the larger limit as a practical candidate.
- For a fixed-width control, omit the key or set it to
0.
max_nonzero_mode_potential_step is a local-potential trust bound for freezing the field within a batch.
It does not guarantee local truncation error, an order of global accuracy, or stability of the update. Adaptive
progression therefore still requires a fixed-width or limit-halving sensitivity check.
For target-count reservoirs and fixed-rays_per_batch photo sources, halving the trial width also halves macro-particle
charge. A limit-halving comparison therefore includes both time-discretization and Monte Carlo variance changes. Use the
same RNG seed and report charge-distribution norms together with particle statistics.
Rejected retries within one run use a fixed OpenMP team size. A restart may use a different team size, so check numerical agreement of charge distributions and accepted widths rather than bitwise identity across the restart.
Related documents
Section titled “Related documents”batch_durationtheory — fixed points, linear stability, and applicability limits- Input parameter reference — key types and complete constraints
- Boundary-reservoir inflow and velocity sampling — particle count and weight
- Output Format Reference — adaptive receipts
- Validate Results — numerical convergence and physical validity
- BEACH computational cycle — update order with a frozen field within each batch