Surfaces#

Surface.from_bulk converts a bulk ChemicalSystem to its conventional cell, builds a two-dimensional slab, and records the bulk crystal directions parallel to its lattice vectors. Pass the surface plane as three-index miller=(h, k, l) or, for hexagonal axes, four-index miller=(h, k, i, l). The plane labels are available as surface.hkl and, where applicable, surface.hkil.

surface.directions is ordered like surface.system.lattice.vectors. Each CrystalDirection has a three-index uvw and, for hexagonal axes, a four-index uvtw. Its string representation uses the preferred notation. These labels give orientation; measure the corresponding vector in surface.system for its length.

surface.metadata.convention_changed reports whether the input lattice setting changed during conventionalization. Other construction details and exact bulk translation coefficients are retained in the frozen SurfaceMetadata record. make_supercell((nx, ny)) repeats the two surface vectors, while make_supercell_trafo(supercell) combines them using a two-by-two integer matrix. Like the corresponding ChemicalSystem methods, each takes one sequence or NumPy array argument. Both return a new Surface with updated crystal directions.

For termination selection, reference_atom="auto" compares cuts using bonds in the periodic bulk. bond_strategy="auto" currently guesses bonds; "provided" uses bonds supplied on the input bulk. molecule_cut="auto" currently restores finite molecules across a cut; "avoid" rejects cuts through them, and "allow" permits fragments. See Surface.from_bulk for these options. To prepare a three-dimensional calculation cell, use with_vacuum_gap on surface.system.

from scm.structures import Surface

surface = Surface.from_bulk(copper_bulk, miller=(0, 0, 1), num_layers=4)
print(surface.hkl, surface.directions)
larger_surface = surface.make_supercell((2, 3))
class Surface(system: ChemicalSystem, metadata: SurfaceMetadata, _oriented_bulk: ChemicalSystem, _periodic_precursor: ChemicalSystem)#

A 2D slab and its bulk crystal plane and in-plane direction labels.

hkl and optional hkil describe the plane in the automatically conventionalized bulk cell. directions follows the order of the two lattice vectors in system. Construction details are in metadata.

classmethod from_bulk(bulk: ChemicalSystem, miller: Sequence[int], num_layers: int, *, reference_atom: int | Literal['auto'] = 'auto', symmetry_tolerance: float = 0.1, bond_strategy: Literal['auto', 'guess', 'provided'] = 'auto', bond_guess_options: Mapping[str, object] | None = None, molecule_cut: Literal['auto', 'restore', 'avoid', 'allow'] = 'auto') → Surface#

Conventionalize bulk and cut the requested Miller plane.

miller refers to the resulting conventional cell, which can use a different setting from the input. The input and conventional cells and angles are retained in metadata. Three-index (h,k,l) and hexagonal four-index (h,k,i,l) notation are accepted.

num_layers counts repeats of the primitive plane cell along the surface normal. reference_atom selects the lower termination by index in the oriented primitive cell. "auto" compares bulk bond coordination after each possible cut. bond_strategy="auto" currently resolves to "guess"; "provided" uses bonds on the input bulk. bond_guess_options accepts dmax and connectors_override as in ChemicalSystem.guess_bonds() when bonds are guessed. molecule_cut="auto" currently resolves to "restore": finite molecules can cross the cut and are unwrapped. "avoid" requires a cut with no crossed finite molecule, while "allow" leaves molecular fragments at the faces. Internal molecular bonds contribute to the termination score only with "allow". The score favors the highest minimum retained coordination for each element, then the smallest spread and fewest broken bonds. This geometric bond score is not a surface energy. Finite molecules are handled in the repeated 3D cell before the normal direction becomes nonperiodic. When restored, they may extend beyond the nominal layer boundaries. Infinite bonded networks remain periodic; their bonds can be cut at the slab faces. Among equivalent signs for the in-plane basis, the first nonzero conventional-cell coefficient of the first slab vector is positive. symmetry_tolerance is passed to ChemicalSystem’s conventional and primitive cell conversion methods. The completed slab is mapped into its in-plane cell; if atoms touch an in-plane boundary, all atoms are translated together to give at least 0.1 Å clearance where the cell geometry permits it. This does not change the periodic structure.

make_supercell(supercell: Sequence[int] | ndarray) → Surface#

Repeat the slab along its two lattice vectors, as in ChemicalSystem.make_supercell.

supercell is a pair of positive integer repeat counts, such as (2, 3). A list or NumPy array is accepted too.

make_supercell_trafo(supercell: Sequence[Sequence[int]] | ndarray) → Surface#

Combine slab vectors with a positive-determinant 2×2 integer matrix.

supercell has the same matrix form as for ChemicalSystem.make_supercell_trafo. Matrix rows give the coefficients of the new vectors in the old basis. The result retains exact conventional-bulk directions and maps atoms into the new cell with ChemicalSystem.map_atoms(0).

property directions: tuple[CrystalDirection, CrystalDirection]#

Bulk directions parallel to the two slab lattice vectors, in order.

property hkil: tuple[int, int, int, int] | None#

Four-index Miller–Bravais plane for hexagonal axes, if applicable.

property hkl: tuple[int, int, int]#

Three-index Miller plane in the conventional bulk cell.

metadata: SurfaceMetadata#

Immutable construction details, including whether the convention changed.

system: ChemicalSystem#

Prepared two-dimensional ChemicalSystem.

class SurfaceMetadata(hkl: tuple[int, int, int], slab_to_conventional: tuple[tuple[Fraction, Fraction, Fraction], tuple[Fraction, Fraction, Fraction]], input_cell: tuple[tuple[float, float, float], ...], conventional_cell: tuple[tuple[float, float, float], ...], primitive_cell: tuple[tuple[float, float, float], ...], primitive_miller: tuple[int, int, int], reference_atom: int, layers: int, requested_miller: tuple[int, ...], cut_molecule_components: int, bond_strategy_requested: Literal['auto', 'guess', 'provided'], molecule_cut_requested: Literal['auto', 'restore', 'avoid', 'allow'], bond_strategy_used: Literal['guess', 'provided'], molecule_cut_used: Literal['restore', 'avoid', 'allow'], bond_guess_dmax: float | None, bond_guess_connectors_override: tuple[tuple[int | str, int], ...], oriented_bulk_cell: tuple[tuple[float, float, float], ...], periodic_precursor_cell: tuple[tuple[float, float, float], ...])#

Immutable construction details for a Surface.

convention_changed reports whether conventionalization changed the input lattice setting. input_cell, conventional_cell, and primitive_cell record those 3D lattice vectors in Å. Miller indices always refer to conventional_cell; requested_miller retains the original three- or four-index input and primitive_miller is the plane used internally after primitive-cell conversion.

slab_to_conventional contains the exact, possibly fractional bulk coefficients of the two surface lattice vectors. Reduced [uvw] labels lose their lengths, so these coefficients are needed when surface vectors are combined in a supercell. normal gives the reciprocal-space plane normal and its Cartesian direction.

reference_atom indexes the chosen lower termination in the oriented primitive plane cell. layers counts repeats along its third vector. cut_molecule_components counts finite molecular components crossed by the cut per surface cell. The requested and resolved bond and molecule policies record how the slab was prepared. oriented_bulk_cell and periodic_precursor_cell retain the 3D working lattice vectors; copies of those full systems are available on Surface.

to_dict() → dict[str, object]#

Return JSON-friendly construction provenance.

bond_guess_connectors_override: tuple[tuple[int | str, int], ...]#

Immutable connector overrides passed to bond guessing.

bond_guess_dmax: float | None#

Maximum bond distance passed to bond guessing, if any.

property bond_guess_options: dict[str, object]#

Copy of the options passed to ChemicalSystem.guess_bonds().

bond_strategy_requested: Literal['auto', 'guess', 'provided']#

Requested bond policy.

bond_strategy_used: Literal['guess', 'provided']#

Resolved bond policy used to prepare the slab.

property convention_changed: bool#

Whether conventionalization changed the input cell vectors.

conventional_cell: tuple[tuple[float, float, float], ...]#

Conventional bulk lattice vectors in Å.

cut_molecule_components: int#

Finite molecules crossed by the selected cut per surface cell.

hkl: tuple[int, int, int]#

Plane indices in the conventional bulk cell.

input_cell: tuple[tuple[float, float, float], ...]#

Input bulk lattice vectors in Å.

layers: int#

Number of repeats normal to the primitive plane cell.

molecule_cut_requested: Literal['auto', 'restore', 'avoid', 'allow']#

Requested molecule-cut policy.

molecule_cut_used: Literal['restore', 'avoid', 'allow']#

Resolved molecule-cut policy used to prepare the slab.

property normal: CrystalPlaneNormal#

Miller plane normal in reciprocal and conventional Cartesian coordinates.

oriented_bulk_cell: tuple[tuple[float, float, float], ...]#

Oriented 3D plane-cell lattice vectors in Å.

periodic_precursor_cell: tuple[tuple[float, float, float], ...]#

Repeated 3D precursor lattice vectors in Å.

primitive_cell: tuple[tuple[float, float, float], ...]#

Primitive bulk lattice vectors in Å.

primitive_miller: tuple[int, int, int]#

Plane indices after primitive-cell conversion.

reference_atom: int#

Atom defining the selected lower termination in the oriented cell.

requested_miller: tuple[int, ...]#

Original three- or four-index Miller argument.

slab_to_conventional: tuple[tuple[Fraction, Fraction, Fraction], tuple[Fraction, Fraction, Fraction]]#

Exact bulk coefficients of the two slab lattice vectors.

class CrystalDirection(uvw: tuple[int, int, int], uvtw: tuple[int, int, int, int] | None = None)#

Reduced bulk direction parallel to one surface lattice vector.

property indices: tuple[int, ...]#

Preferred direction label: four indices for hexagonal cells, three otherwise.

uvtw: tuple[int, int, int, int] | None = None#

Four-index [uvtw] label in a hexagonal setting; otherwise None.

uvw: tuple[int, int, int]#

Reduced integer crystal direction.

uvw is a reduced integer direction in the conventional direct lattice. uvtw is its four-index label when hexagonal axes are used.

class CrystalPlaneNormal(hkl: tuple[int, int, int], cartesian_unit: tuple[float, float, float], hkil: tuple[int, int, int, int] | None = None)#

Surface-plane normal expressed in the conventional bulk cell.

hkl are reciprocal-lattice (Miller) indices. cartesian_unit is the corresponding unit normal in the conventional cell’s Cartesian frame. A normal is generally not an integer direct-lattice [uvw] direction.

hkil: tuple[int, int, int, int] | None = None#

Four-index (hkil) plane label in a hexagonal setting; otherwise None.

SurfaceMetadata.normal is the reciprocal-space normal to the surface plane. In a low-symmetry cell its Cartesian direction need not coincide with an integer direct-lattice [uvw] direction.

For worked examples, see cubic surfaces, other crystal systems, and crystal directions.