Builder API#

The scm.structures.builder package groups structure builders by task. Import functions and classes from the relevant module:

  • Adsorption Finder identifies adsorption sites on slabs and generates adsorbate structures.

  • Polymer builder joins monomers into chains, periodic polymers, or cells containing multiple chains.

Other builders#

The package also provides tools for matching two periodic layers and constructing nanotubes.

class InterfaceMatch(bottom_matrix: tuple[tuple[int, int], tuple[int, int]], top_matrix: tuple[tuple[int, int], tuple[int, int]], common_cell: tuple[tuple[float, float], tuple[float, float]], bottom_transform: tuple[tuple[float, float], tuple[float, float]], top_transform: tuple[tuple[float, float], tuple[float, float]], bottom_cell: tuple[tuple[float, float], tuple[float, float]], top_cell: tuple[tuple[float, float], tuple[float, float]], bottom_atom_count: int, top_atom_count: int, search_angle: float, strain_weight: float)#

Immutable lattice correspondence in each input’s standardized plane frame.

matrix @ input_cell @ transform == common_cell for each layer. Transforms include rotation; strain properties remove rigid rotation by polar decomposition. Reference cells and counts allow compatible inputs to be checked at build time; they do not identify chemical composition.

find_interface_matches(bottom: ChemicalSystem, top: ChemicalSystem, *, angles: Sequence[float] = (0.0,), max_index: int = 3, max_atoms: int = 500, max_strain: float = 0.02, strain_mode: Literal['top', 'bottom', 'both'] = 'top', strain_weight: float = 0.5) → list[InterfaceMatch]#

Find small common in-plane cells, sorted by atom count then strain.

Enumerate top lattice vectors with coefficients in [-max_index, max_index], rotate them by each angle, and round their bottom fractional coordinates to integers. Pair independent vectors to form candidate cells. This inexpensive nearest-in-fractional-coordinates search can miss matches in skew cells. Equivalent bases are not symmetry-reduced.

max_strain bounds every absolute principal stretch minus one, in each layer. top keeps the bottom fixed; bottom keeps the top fixed. both interpolates the aligned cells with strain_weight (0 keeps bottom fixed, 1 keeps top fixed). This is not elastic-energy minimization. Angles are relative to frames with each layer’s first vector along x. Three-dimensional inputs must be prepared slabs, contiguous across z: their third lattice vector is ignored. Inputs are never modified.

build_interface(bottom: ChemicalSystem, top: ChemicalSystem, match: InterfaceMatch, *, separation: float = 3.3, registry: tuple[float, float] = (0.0, 0.0), vacuum: float | None = None) → ChemicalSystem#

Build a match, preserving layer thickness and leaving inputs unchanged.

Output is aligned to the xy plane. separation is the positive gap between facing atomic z extents. registry shifts the top by fractional common-cell coordinates. Default output is 2D periodic; positive vacuum creates a 3D cell with that total empty gap between periodic images of the stack. Atoms are mapped to fractional coordinates in [0, 1) along the periodic directions. No relaxation or registry optimization is performed.

nanotube(n: int, m: int, length: int = 1, bond: float = 1.42, symbol: str = 'C', periodicity: Literal[1, 3] = 1, periodic_direction: Literal['x', 'y', 'z'] = 'x', vacuum: float = 8.0) → ChemicalSystem#

Build a periodic single-walled nanotube as a ChemicalSystem.

Parameters:
  • n – first chiral index in the standardized (n, m) nanotube notation

  • m – second chiral index; armchair tubes have n == m and zigzag tubes have m == 0

  • length – number of axial repeat units, defaults to 1

  • bond – bond length in the unrolled sheet in Angstrom, defaults to 1.42

  • symbol – chemical symbol used for all atoms, defaults to C

  • periodicity – number of periodic directions, either 1 for an isolated periodic tube or 3 for a three-dimensional periodic cell, defaults to 1

  • periodic_direction – Cartesian direction of the tube axis, either x, y, or z, defaults to x; must be x when periodicity == 1

  • vacuum – nominal gap between periodic images perpendicular to the tube axis in Angstrom, used only when periodicity == 3, defaults to 8.0

Returns:

chemical system with one axial lattice vector for one-dimensional periodicity, or three orthogonal lattice vectors for three-dimensional periodicity

Raises:

ValueError – if periodicity is not 1 or 3, periodic_direction is not x, y, or z, or periodicity == 1 and periodic_direction is not x