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_cellfor 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_strainbounds every absolute principal stretch minus one, in each layer.topkeeps the bottom fixed;bottomkeeps the top fixed.bothinterpolates the aligned cells withstrain_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.
separationis the positive gap between facing atomic z extents.registryshifts the top by fractional common-cell coordinates. Default output is 2D periodic; positivevacuumcreates 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 == mand zigzag tubes havem == 0length – number of axial repeat units, defaults to
1bond – bond length in the unrolled sheet in Angstrom, defaults to
1.42symbol – chemical symbol used for all atoms, defaults to
Cperiodicity – number of periodic directions, either
1for an isolated periodic tube or3for a three-dimensional periodic cell, defaults to1periodic_direction – Cartesian direction of the tube axis, either
x,y, orz, defaults tox; must bexwhenperiodicity == 1vacuum – nominal gap between periodic images perpendicular to the tube axis in Angstrom, used only when
periodicity == 3, defaults to8.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
periodicityis not1or3,periodic_directionis notx,y, orz, orperiodicity == 1andperiodic_directionis notx