Practical Guide · B

Converge Finite Size, Vacuum, and Image Interactions

Test the cell dimensions and boundary treatment that control periodic-image, concentration, slab-thickness, vacuum, and relaxation-volume errors.

Finite periodic models replace an isolated, dilute, semi-infinite, or macroscopic limit with a repeated cell. Begin by naming the intended limit and the residual interaction that the current model cannot yet exclude.

Open every structure in a trusted atomistic viewer before submission. Compare lateral repetitions, slab thickness, vacuum direction, relaxed depth, defect or adsorbate separation, constraints, and cell shape. Rotate the structures, measure the relevant distances, and confirm that a conversion or supercell operation changed only the controls declared by the protocol. A fixed-concentration or fixed-coverage route must preserve that quantity. A dilute or isolated-limit route intentionally changes concentration, coverage, or image separation while preserving the chemical and structural identity, normalization, state, and method branch. Visual inspection can expose a wrong model; it cannot establish finite-size convergence.

Next read the boundary-treatment section of the exact code manual and comparable Methods or Supporting Information. Decide whether the series holds one boundary method fixed or compares separate physical-method branches such as truncation, dipole correction, neutralization, or dielectric embedding. The method and input landscape and electronic-structure code landscape provide alternative starting points. The QE loop below is one demonstrated execution pattern, not a universal interface.

Prepare the size matrix

Before generating structures, write down the intended physical limit, target observable and units, predeclared tolerance, and independent size axes. Distinguish the controls intentionally varied toward that limit from the identity, normalization, state, boundary treatment, constraints, and method branch held fixed. Also name the required state and geometry checks, extraction rule, and stricter neighbours along every unresolved axis.

For a slab, lateral area, slab thickness, vacuum, and relaxation depth are separate axes. For a charged defect, shape, separation, dielectric treatment, correction, and relaxation volume can interact. Increasing vacuum alone does not test lateral concentration or electrostatic image error.

Name each input from its physical controls and run the prepared series with the actual code. A QE example is:

mkdir -p finite-size/runs
for input in finite-size/inputs/*.in; do
  test -f "$input"
  name=$(basename -- "$input" .in)
  run_dir="finite-size/runs/$name"
  test ! -e "$run_dir"
  mkdir -p "$run_dir"
  cp -- "$input" "$run_dir/$name.in"
  grep -Ei 'prefix|outdir|pseudo_dir' -- "$run_dir/$name.in"
  (
    cd "$run_dir"
    if pw.x -in "$name.in" > "$name.out" 2> "$name.err"; then
      pw_status=0
    else
      pw_status=$?
    fi
    printf '%s\n' "$pw_status" > "$name.exit-status"
    exit "$pw_status"
  ) || printf 'QE failed for %s; retain and inspect that run.\n' "$name" >&2
done

This loop is a protocol for the reader’s calculations, not execution evidence supplied by the synthetic companion.

Before launch, inspect the displayed prefix, outdir, and pseudo_dir for every copied input. Stage the exact tested-library pseudopotential files required by that input and create an isolated scratch path inside the run directory, or use reviewed absolute paths. Stop rather than letting a copied input inherit another run’s scratch or an unexplained potential directory.

Check and extract

For QE outputs, begin by separating termination and electronic solver evidence:

for run_dir in finite-size/runs/*; do
  name=$(basename -- "$run_dir")
  out="$run_dir/$name.out"
  err="$run_dir/$name.err"
  printf '\n%s\n' "$run_dir"
  cat -- "$run_dir/$name.exit-status"
  test "$(grep -cF 'Program PWSCF v.' -- "$out")" -eq 1
  test "$(grep -cF 'JOB DONE.' -- "$out")" -eq 1
  grep -E '^[[:space:]]+convergence has been achieved in[[:space:]]+[0-9]+ iterations[[:space:]]*$' -- "$out" | tail -n 1
  tail -n 40 -- "$out"
  tail -n 40 -- "$err"
  grep -Ei 'warning|error in routine|stopping|not converged|no convergence' \
    -- "$out" "$err" || true
done

The shell status, coherent banner, JOB DONE., stderr, and fatal-text scan constrain program completion. The convergence marker checks the reported electronic solver condition. tail exposes the final part of each file for manual inspection; none of these commands extracts or converges the target observable.

Use one parser for the reported energy difference, force, potential, work function, correction term, dipole probe, or other target. Preserve cell vectors, concentration, coverage, separation, relaxed geometry, charge state, and boundary method in the same table.

Decide against independent refinements

Open the retained structures beside the quantitative table and plot. Check that the compared rows still describe the intended physical object, then inspect the target along every independent size axis. Look for a plateau supported by stricter neighbours, anisotropy, false plateaus, geometry reconstruction, charge or magnetic-state changes, and results that remain sensitive at the edge of the series.

Accept a size only when the target lies inside its predeclared tolerance and remains there under a stricter change along every unresolved axis. A visually large vacuum is not evidence. A smooth three-point fit is not evidence that the assumed asymptotic law applies.

If different sizes relax to different structures, charge-localization states, magnetic states, or ordering patterns, stop treating them as one numerical series. Numerical convergence does not repair a changing physical model.

Optional synthetic replay

The companion is an optional arithmetic and decision-rule exercise after the real workflow is understood:

python3 examples/practical-guides/convergence_finite_size.py > finite-size-analysis.json
less finite-size-analysis.json

It analyses a hard-coded synthetic table with three lateral sizes and three vacuum lengths. It checks state labels, applies illustrative tolerances, rejects a false plateau, and requires stricter checks in both directions. It does not run DFT, inspect a real structure, or recommend a cell.

What this guide verifies

The companion verifies deterministic arithmetic on an illustrative lateral-size/vacuum matrix. It identifies one accepted synthetic region, independent lateral and vacuum confirmations, consistent state labels, and a false plateau.

It does not validate a real slab, defect, correction, vacuum thickness, dilute limit, extrapolation law, or DFT observable. Its selected synthetic point is not a parameter recommendation.

Official sources

Ways to work: Quantum ESPRESSOPython

Companion checked with: Python 3.12.

Reproducibility note

The companion material was checked with Python 3.12. It tests only the bounded software or analysis behaviour described here; it does not establish numerical convergence, model validity, or a material property.