Skip to content

stb-unitcell

Unit Cell Finder · menu code 4.7 · guide: 4.7 Unit Cell Finder

usage: stb-unitcell [-h] -f FILENAME [--mode {primitive,conventional,refined}]
                    [--symprec SYMPREC] [--angle-tolerance ANGLE_TOLERANCE]
                    [--ml-relax] [--ml-relax-cell] [--model {small,medium,large}]
                    [--custom-model PATH] [--custom-model-card JSON]
                    [--device {cpu,cuda}] [--view] [-o OUTPUT] [-v] [--no-intro]

Finds the primitive/conventional unit cell of a structure, or refines it.
Uses pymatgen's symmetry analyzer (spglib) to detect the crystal's true
unit cell, which may be much smaller than the literal input cell (e.g. a
4-atom conventional FCC cell reduces to a 1-atom primitive cell).

options:
  -h, --help            show this help message and exit
  -f FILENAME, --file FILENAME
                        Path to the input structure file (.fdf).
  --mode {primitive,conventional,refined}
                        primitive: smallest possible cell (default).
                        conventional: standardized, usually larger, cell.
                        refined: conventional cell with atomic positions snapped to the
                        detected symmetry -- cleans up numerical noise from relaxations or
                        hand-built/CIF structures without changing which atoms are present.
  --symprec SYMPREC     Symmetry precision (default: 0.01, pymatgen's own default, matches stb-symmetry). Also used as the tolerance for the before/after symmetry analysis below. Loosen further (e.g. 0.02-0.05) for a structure relaxed with a looser force tolerance -- a tighter value than the relaxation's own residual numerical noise can misdetect the true space group.
  --angle-tolerance ANGLE_TOLERANCE
                        Symmetry angle tolerance in degrees (default: 5.0, pymatgen's own default).
  --ml-relax            Pre-relax the reduced unit cell with a MACE potential (needs the optional 'ml' extra: pip install stb_suite[ml]) before writing it out -- positions only by default. Off by default.
  --ml-relax-cell       With --ml-relax, also relax the cell -- any vacuum-padded axis always stays exactly fixed. Only valid together with --ml-relax.
  --model {small,medium,large}
                        MACE-MP-0 foundation model size for --ml-relax (default: medium).
  --custom-model PATH   Path to a custom fine-tuned .model file for --ml-relax, instead of a MACE-MP-0 foundation size.
  --custom-model-card JSON
                        Model card of the --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 --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.
  --device {cpu,cuda}   Device to run the MACE model on (default: cpu).
  --view                Open an interactive 3D view (via ASE) comparing the input structure and the final reduced cell (page through frames in ase-gui) after writing the output file. Needs a display. Off by default.
  -o OUTPUT, --output OUTPUT
                        Output .fdf file name (default: unitcell.fdf).
  -v, --version         show program's version number and exit
  --no-intro            Do not show the introduction

Usage examples:
  stb-unitcell -f structure.fdf
  stb-unitcell -f structure.fdf --mode conventional -o conventional.fdf
  stb-unitcell -f structure.fdf --mode refined -o clean.fdf
  stb-unitcell -f structure.fdf --ml-relax --view

Notes:
  - This operates on the literal 3D periodic cell as given. For slabs/2D materials/nanotubes with a vacuum direction, spot-check that the vacuum axis wasn't reoriented before using the output.
  - The output's atom order and coordinate origin are NOT guaranteed to match the input, in any mode -- spglib rebuilds the cell from the detected symmetry operations from scratch, free to pick any symmetry-equivalent origin/ordering. For highly symmetric structures (e.g. a monoatomic FCC lattice) even tiny input noise can flip which equivalent origin it picks. This is expected: the crystal is the same, just relabeled.