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.
hkland optionalhkildescribe the plane in the automatically conventionalized bulk cell.directionsfollows the order of the two lattice vectors insystem. Construction details are inmetadata.- 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
bulkand cut the requested Miller plane.millerrefers to the resulting conventional cell, which can use a different setting from the input. The input and conventional cells and angles are retained inmetadata. Three-index(h,k,l)and hexagonal four-index(h,k,i,l)notation are accepted.num_layerscounts repeats of the primitive plane cell along the surface normal.reference_atomselects 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_optionsacceptsdmaxandconnectors_overrideas inChemicalSystem.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_toleranceis 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.supercellis 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.
supercellhas the same matrix form as forChemicalSystem.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 withChemicalSystem.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.
- 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_changedreports whether conventionalization changed the input lattice setting.input_cell,conventional_cell, andprimitive_cellrecord those 3D lattice vectors in Å. Miller indices always refer toconventional_cell;requested_millerretains the original three- or four-index input andprimitive_milleris the plane used internally after primitive-cell conversion.slab_to_conventionalcontains 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.normalgives the reciprocal-space plane normal and its Cartesian direction.reference_atomindexes the chosen lower termination in the oriented primitive plane cell.layerscounts repeats along its third vector.cut_molecule_componentscounts 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_cellandperiodic_precursor_cellretain the 3D working lattice vectors; copies of those full systems are available onSurface.- bond_guess_connectors_override: tuple[tuple[int | str, int], ...]#
Immutable connector overrides passed to bond guessing.
- property bond_guess_options: dict[str, object]#
Copy of the options passed to
ChemicalSystem.guess_bonds().
- 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 Å.
- 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.
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.
hklare reciprocal-lattice (Miller) indices.cartesian_unitis the corresponding unit normal in the conventional cell’s Cartesian frame. A normal is generally not an integer direct-lattice[uvw]direction.
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.