Skip to content

stb-stackingfault

Stage 1 - Prep of the 5.10 2D Stacking Fault (Gamma-Surface) workflow · menu code 5.10.1

usage: stb-stackingfault [-h] -l1 LAYER1 -l2 LAYER2 -c CALC [-p PSEUDO_DIR]
                         [-a MAX_AREA] [-s MAX_STRAIN] [-id MATCH_ID] [-g GAP]
                         [--vacuum VACUUM] [-sm {top,bottom,sym}] [-t TWIST] [--d3]
                         [--no-d3] [--mode {1,2,3}] [--relax-z-steps RELAX_Z_STEPS]
                         [--scan {surface,x,y,xy}] [-n SCAN_POINTS] [-nx GRID_NX]
                         [-ny GRID_NY] [--ml-prerelax-layers] [--ml-preview]
                         [--ml-model {small,medium,large}] [--ml-custom-model PATH]
                         [--ml-custom-model-card JSON] [--ml-device {cpu,cuda}]
                         [--ml-fmax ML_FMAX] [-O OUTPUT_DIR] [-v] [--no-intro]

Prepares SIESTA folders for a 2D stacking-fault (generalized stacking fault energy / gamma-surface) study: rigidly slides one layer of a bilayer across a 2D grid of lateral offsets and writes one SIESTA folder per grid point -- a plain single-point by default, or a real/ML-assisted z-only relaxation, see --mode.

options:
  -h, --help            show this help message and exit
  -l1 LAYER1, --layer1 LAYER1
                        Bottom monolayer .fdf (stays fixed).
  -l2 LAYER2, --layer2 LAYER2
                        Top monolayer .fdf (rigidly slid across the grid). Pass the same file as --layer1 for a material sliding against itself.
  -c CALC, --calc CALC  calc.fdf template (kgrid, basis, XC, %include structure.fdf, etc.) -- copied into every shift_II_JJ/ folder; single-point SCF enforcement (and the optional --d3 dispersion correction) is added via a config_extra.fdf %include, not embedded inline.
  -p PSEUDO_DIR, --pseudo-dir PSEUDO_DIR
                        Pseudopotentials source (optional): a bundled bank or a folder path.
  -a MAX_AREA, --max_area MAX_AREA
                        Maximum ZSL commensurate-supercell area, Ang^2 (default: 150.0, same as stb-2Dstacking).
  -s MAX_STRAIN, --max_strain MAX_STRAIN
                        Maximum allowed ZSL match strain fraction (default: 0.05).
  -id MATCH_ID, --match_id MATCH_ID
                        Which ZSL match to use, 0-based, best (lowest strain) first (default: 0).
  -g GAP, --gap GAP     Interlayer gap in Ang (default: 3.2, same as stb-2Dstacking). Under --mode 3 (default) this is the FIXED value used across the whole grid -- a rigid-shift protocol, standard in the literature (see the [INFO] closest-contact line in the report for how close high-energy registries got at this fixed distance). Under --mode 1/2 this is only the STARTING guess -- SIESTA (mode 1) or MACE-MP-0 (mode 2) relaxes it per grid point from here.
  --vacuum VACUUM       Target vacuum space in Ang. Inherits --layer1's by default.
  -sm {top,bottom,sym}, --strain_mode {top,bottom,sym}
                        Strain distribution mode for the ZSL match (default: top).
  -t TWIST, --twist TWIST
                        Twist angle of layer 2 in degrees (default: 0.0), FIXED for the whole grid -- a different twist is a different physical system, not swept here.
  --d3                  Force the Grimme DFT-D3 dispersion correction (via config_extra.fdf) in every generated calc.fdf -- physically relevant here since the interlayer binding swept across the grid is a van-der-Waals-dominated interaction that plain GGA misses (same correction stb-adsorb/stb-neb force by default elsewhere in the suite). ON by default. Applies in every --mode.
  --no-d3               Disable the DFT-D3 dispersion correction (not recommended for this workflow -- see --d3).
  --mode {1,2,3}        Interlayer-gap strategy, per grid point (default: 1):
                          1 = SIESTA relaxes z for real: writes one restricted CG relaxation per grid point (x,y frozen for every atom, only z free -- see build_z_relax_block/--relax-z-steps). Most accurate (same level of theory as the reported energy), most expensive (a real relaxation, not one SCF, per point).
                          2 = MACE-MP-0 relaxes z first (same x,y-frozen/z-free definition as mode 1, cheap ML engine), THEN writes a plain single-point SIESTA folder at the resulting geometry -- middle ground between cost and accuracy. Needs the optional 'ml' extra.
                          3 = fixed --gap, plain single-point SIESTA, no relaxation of any kind (today's behavior, the cheapest of the three).
  --relax-z-steps RELAX_Z_STEPS
                        With --mode 1: MD.Steps for the restricted SIESTA z-relaxation (default: 200). Ignored in modes 2/3.
  --scan {surface,x,y,xy}
                        Sweep shape (default: surface):
                          surface = full 2D grid (-nx x -ny points), the gamma-surface -- output is the pm3d map/heatmap already documented above.
                          x       = 1D sweep along shift_x only (shift_y fixed at 0) -- -n points, output is a line plot (E vs. distance along x).
                          y       = 1D sweep along shift_y only (shift_x fixed at 0) -- -n points, output is a line plot (E vs. distance along y).
                          xy      = 1D sweep along the diagonal shift_x == shift_y -- -n points, output is a line plot (E vs. distance along the diagonal).
                        -nx/-ny only apply to 'surface'; -n/--scan-points only applies to 'x'/'y'/'xy'.
  -n SCAN_POINTS, --scan-points SCAN_POINTS
                        With --scan x/y/xy: number of points along the 1D sweep (default: 15). Ignored under --scan surface (see -nx/-ny instead).
  -nx GRID_NX, --grid-nx GRID_NX
                        With --scan surface: grid resolution along shift_x, this many lateral shifts covering [0, 1) (default: 6 on a hexagonal lattice, so that the grid contains the AB/BA registries at shifts 1/3 and 2/3 -- use a multiple of 3 there --, 7 otherwise). Independent of --grid-ny -- an anisotropic lattice (a != b, e.g. a rectangular or low-symmetry 2D cell) often warrants a different sampling density per axis rather than forcing a square grid. Ignored under --scan x/y/xy (see -n/--scan-points instead).
  -ny GRID_NY, --grid-ny GRID_NY
                        With --scan surface: grid resolution along shift_y (default: as -nx). See --grid-nx. Ignored under --scan x/y/xy.
  --ml-prerelax-layers  Relax each monolayer's positions (cell fixed) with MACE-MP-0 before stacking -- a cheap safety net when you're not fully certain --layer1/--layer2 are already at equilibrium. Needs the optional 'ml' extra.
  --ml-preview          Evaluate the whole grid's single-point energy on MACE-MP-0 (fast, no SIESTA) and write stackingfault_ml_preview.png -- a quick sanity check of the gamma-surface's shape before committing to the full Nx x Ny DFT single-points. Written alongside the normal SIESTA folders, not instead of them. Needs the optional 'ml' extra.
  --ml-model {small,medium,large}
                        MACE-MP-0 model size (default: medium). Ignored if --ml-custom-model is given.
  --ml-custom-model PATH
                        Use a custom MACE model file instead of the MACE-MP-0 foundation potential -- e.g. one fine-tuned on your own SIESTA data via stb-mlffAnalysis. Overrides --ml-model.
  --ml-custom-model-card JSON
                        Model card of the --ml-custom-model file: the mlff_model_card.json that stb-mlffAnalysis wrote next to it (training data, level of theory, accuracy, energy scale). Required with --ml-custom-model -- the card is checked against the model file and used to warn when a structure is outside what the model was trained on.
  --ml-device {cpu,cuda}
  --ml-fmax ML_FMAX     Force convergence for --ml-prerelax-layers and --mode 2's z-only MACE relaxation (default: 0.05).
  -O OUTPUT_DIR, --output-dir OUTPUT_DIR
                        Root directory (default: current directory) -- everything lives under its 'sf_run/' subfolder: every 'shift_II_JJ/' grid folder under 'sf_run/positions/' and the manifest directly under 'sf_run/' (the report and its references file go to the current folder) -- same self-contained-run-folder convention as stb-adsorb's 'sites/' and stb-neb's 'neb_run/'.
  -v, --version         show program's version number and exit
  --no-intro            Do not show the introduction

Usage examples:
  stb-stackingfault -l1 graphene.fdf -l2 graphene.fdf -c calc.fdf -nx 7 -ny 7
  stb-stackingfault -l1 graphene.fdf -l2 hbn.fdf -c calc.fdf -nx 9 -ny 5 -g 3.4
  stb-stackingfault -l1 graphene.fdf -l2 graphene.fdf -c calc.fdf --scan x -n 15

Pass the SAME file for -l1/-l2 for the canonical use case (a material sliding against itself, e.g. graphite ABA vs. ABC stacking) -- already the precedented 'identical layers' case for stb-2Dstacking's own ZSL match. Different files study an interlayer/heterostructure sliding energy landscape instead.

-nx/-ny may differ (an asymmetric grid) -- useful for an anisotropic 2D lattice where one in-plane direction needs finer sampling than the other (--scan surface only).

--scan x/y/xy trade the full 2D gamma-surface for a cheaper 1D line through it (along shift_x, shift_y, or the shift_x=shift_y diagonal) -- useful for a quick high-symmetry-line profile before committing to the full surface.