Interfaces#
Use find_interfaces() to compare two
Surface objects. Each candidate reports
pairs of bulk crystal directions that become parallel in the constructed
interface. The returned BuiltInterface
contains the full ChemicalSystem and serializable
provenance metadata. Its interface_atoms(distance) method selects atoms
near the gap midpoint for visualization; use the complete system for
calculations.
from scm.structures import Surface, find_interfaces
bottom = Surface.from_bulk(copper_bulk, miller=(1, 1, 1), num_layers=4)
top = Surface.from_bulk(brucite_bulk, miller=(0, 0, 0, 1), num_layers=3)
matches = find_interfaces(bottom, top, max_strain=0.04, strain_mode="both")
interface = matches.best().build(separation=3.0, vacuum=12.0)
for pair in interface.parallel_directions:
print(pair.bottom, "||", pair.top)
closeup = interface.interface_atoms(distance=4.0)
- find_interfaces(bottom: Surface, top: Surface, *, angles: Sequence[float] | None = None, angle_tolerance: float = 1.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, max_area: float | None = None, max_vector_length: float | None = None, min_vector_angle: float = 0.0) InterfaceSearchResult#
Search two surfaces, keeping crystal directions attached to every match.
Every pair of integer supercells within
max_indexandmax_atomsis checked. Relative rotation is solved from each pair. Optionalanglesfilter the resulting standardized-frame rotations withinangle_tolerancedegrees. Withoutangles, all rotations are allowed. The reported direction pairs are exact in the conventional bulk bases; their Cartesian vectors become parallel after the chosen match is built.
- class InterfaceSearchResult(candidates: tuple[InterfaceCandidate, ...])#
Ranked matches; the first is the smallest allowed cell with a good shape.
Iterate over
candidatesor usebest()for the first choice.pareto()shows the atom-count versus strain alternatives.- best() InterfaceCandidate#
Return the first ranked match, or raise if the search found none.
- pareto() tuple[InterfaceCandidate, ...]#
Matches not beaten in both atom count and maximum principal strain.
- class InterfaceCandidate(bottom: Surface, top: Surface, match: InterfaceMatch)#
A geometric match bound to the two bulk-derived surfaces it connects.
matchcontains the supercell matrices, common cell, transforms, and principal strains.bottomandtopretain the bulk directions.- build(*, separation: float = 3.3, registry: tuple[float, float] = (0.0, 0.0), vacuum: float | None = None) BuiltInterface#
Stack the two surfaces and retain their direction provenance.
separationis the gap in Å between the facing atomic planes.registryshifts the top by fractional common-cell vectors.vacuumadds a third lattice vector and this much empty space between periodic stack images; omit it for a 2D periodic interface. The atoms are not relaxed.
- property frame_rotation_degrees: float#
Rotation between standardized input frames, not necessarily atomic twist.
- property parallel_directions: tuple[ParallelDirections, ParallelDirections]#
Corresponding crystal translations along both common-cell axes.
- class BuiltInterface(system: ChemicalSystem, candidate: InterfaceCandidate, separation: float, registry: tuple[float, float], vacuum: float | None)#
The ChemicalSystem and the provenance needed to interpret it.
- interface_atoms(distance: float) ChemicalSystem#
Return atoms within
distanceÅ of the interface gap midpoint.The subset retains the interface lattice and atom attributes. It is intended for visualization;
ChemicalSystem.extract_atomsresets total charge and removes bonds to omitted atoms.
- property metadata: dict[str, object]#
Serializable surface, direction, match, and stacking provenance.
- property parallel_directions: tuple[ParallelDirections, ParallelDirections]#
Two pairs of bulk directions spanning the common interface cell.
- system: ChemicalSystem#
Complete interface ChemicalSystem.
BuiltInterface.system is the complete interface ChemicalSystem.
- class ParallelDirections(bottom: CrystalDirection, top: CrystalDirection, final_length: float)#
One pair of bulk translations made parallel in the final interface.
bottomandtoprefer to their respective conventional bulk cells.final_lengthis their shared length in Å after the match’s rotation and strain have been applied.- bottom: CrystalDirection#
Translation in the bottom conventional bulk cell.
- top: CrystalDirection#
Corresponding translation in the top conventional bulk cell.
ParallelDirections.bottom and top are the corresponding translations
in the two conventional bulk cells. final_length is their shared length
after matching, in ångströms.
Lower-level interface builder#
The lower-level builder can match and stack two prepared periodic layers.
For a workflow starting from bulk crystals, use
find_interfaces().
- 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.