Crystal#

class de_ebsd.crystal.Crystal(a, b, c, alpha, beta, gamma, space_group, sites, origin=2)[source]#

Bases: object

A crystal defined by its lattice, space group, and asymmetric unit.

Prefer the from_parameters() constructor:

crystal = Crystal.from_parameters(
    a=0.5431, space_group=227, atoms=[("Si", (0.125, 0.125, 0.125))]
)
Parameters:
a, b, c

Lattice parameters in nm.

alpha, beta, gamma

Lattice angles in degrees.

space_group

International space-group number (1-230).

sites

The asymmetric unit as a sequence of AtomSite.

origin

Origin choice for the 24 centrosymmetric space groups that the International Tables list with two origins (e.g. Fd-3m). The default, 2, places the origin on an inversion center (the modern standard used by EMsoft and kikuchipy reference data); pass 1 for the tabulated diffpy setting. The choice-2 operators are derived by conjugating the tabulated operators with the smallest inversion-center shift; this is verified for the cubic two-origin groups – for other two-origin groups, confirm the convention against the International Tables.

Methods

allowed_by_centering

Boolean mask of reflections allowed by the lattice centering.

d_spacing

Interplanar spacing d in nm for Miller indices hkl.

explore

Explore STEM orientations using geometric lines and kinematic spots.

from_cif

Create a crystal from a CIF file.

from_parameters

Create a crystal from lattice parameters and a simple atom list.

g_cartesian

Reciprocal-lattice vectors in the Cartesian crystal frame (nm^-1).

g_length

Length |g| in nm^-1 for Miller indices hkl of shape (..., 3).

overview

Compose phase metadata with native crystal and master figures.

show

Display the expanded crystal structure as a native 3-D figure.

Attributes

centering

Lattice centering symbol (first letter of the space-group symbol).

density

Mass density in g/cm^3 from the unit-cell contents and volume.

direct_metric

Direct metric tensor g_ij in nm^2.

direct_structure_matrix

Columns are the basis vectors a, b, c in the Cartesian crystal frame (nm).

has_two_origins

Whether this space group is one the Tables list with two origin choices.

mean_atomic_number

Composition- (number-) averaged atomic number, sum(n_i Z_i) / sum(n_i).

mean_atomic_weight

Composition- (number-) averaged atomic weight in g/mol.

multiplicities

Number of equivalent atoms per asymmetric-unit site.

positions

Expanded orbit (n_m, 3) of fractional positions, one array per site.

reciprocal_metric

Reciprocal metric tensor g*_ij in nm^-2.

reciprocal_structure_matrix

Columns are the reciprocal basis vectors a*, b*, c* in the Cartesian frame (nm^-1).

volume

Unit-cell volume in nm^3.

allowed_by_centering(hkl)[source]#

Boolean mask of reflections allowed by the lattice centering.

Mirrors EMsoft IsGAllowed: only centering absences are tested; glide/screw absences follow automatically from |U_g| = 0.

property centering#

Lattice centering symbol (first letter of the space-group symbol).

d_spacing(hkl)[source]#

Interplanar spacing d in nm for Miller indices hkl.

property density#

Mass density in g/cm^3 from the unit-cell contents and volume.

property direct_metric#

Direct metric tensor g_ij in nm^2.

property direct_structure_matrix#

Columns are the basis vectors a, b, c in the Cartesian crystal frame (nm).

explore(*, energy_kev=200.0, dmin=0.1, **kwargs)[source]#

Explore STEM orientations using geometric lines and kinematic spots.

Returns a CrystalExplorer with a shared projection, band sphere, and crystal view. Beam energy is in keV and the minimum lattice spacing dmin in nm. Further keyword arguments are passed to the explorer. No master-pattern simulation is run.

Display the result in Jupyter for interactive controls, or mount its native figure in an application with a live Python bridge.

classmethod from_cif(path, origin=None, debye_waller=0.005)[source]#

Create a crystal from a CIF file.

Reads only the asymmetric unit; the symmetry expansion is this class’s own job, so passing the expanded cell that diffpy.structure.loadStructure returns would double-count every atom.

CIF lengths are Angstrom and are converted to nm. An U_iso column becomes the Debye-Waller factor as B = 8 pi^2 U_iso, converted to nm^2; sites without one (or with U_iso <= 0) fall back to debye_waller. Ionic _atom_site_type_symbol entries are reduced to the element ("Si4+" -> "Si"), since the scattering tables are per element.

Parameters:
path

Path to the CIF file. Only its first data block is read.

origin

Origin choice for the two-origin space groups. None (default) reads _space_group_IT_coordinate_system_code from the file and falls back to 2 – the modern standard used by EMsoft and kikuchipy. Getting this wrong silently produces a plausible but incorrect master pattern, so pass it explicitly when the file does not record it and the group has two origins (has_two_origins).

debye_waller

Fallback isotropic B in nm^2 for sites with no usable U_iso.

Returns:
Crystal
classmethod from_parameters(a, b=None, c=None, alpha=90.0, beta=90.0, gamma=90.0, space_group=1, atoms=(), debye_waller=0.005)[source]#

Create a crystal from lattice parameters and a simple atom list.

atoms entries may be AtomSite objects or plain tuples (element, (x, y, z)) / (element, (x, y, z), occupancy); tuples get the shared debye_waller default.

g_cartesian(hkl)[source]#

Reciprocal-lattice vectors in the Cartesian crystal frame (nm^-1).

g_length(hkl)[source]#

Length |g| in nm^-1 for Miller indices hkl of shape (…, 3).

property has_two_origins#

Whether this space group is one the Tables list with two origin choices.

When True, origin changes the atom positions and therefore the master pattern, so a CIF that does not record its choice is ambiguous.

property mean_atomic_number#

Composition- (number-) averaged atomic number, sum(n_i Z_i) / sum(n_i).

property mean_atomic_weight#

Composition- (number-) averaged atomic weight in g/mol.

property multiplicities#

Number of equivalent atoms per asymmetric-unit site.

overview(master_pattern=None, name=None, *, texture_height=128, n_grid=96)[source]#

Compose phase metadata with native crystal and master figures.

The returned PhaseOverview displays in a notebook and gives SpyDE named figures to mount with its existing anyplotlib bridge. It never serializes a figure into another widget.

property positions#

Expanded orbit (n_m, 3) of fractional positions, one array per site.

property reciprocal_metric#

Reciprocal metric tensor g*_ij in nm^-2.

property reciprocal_structure_matrix#

Columns are the reciprocal basis vectors a*, b*, c* in the Cartesian frame (nm^-1).

show(title=None)[source]#

Display the expanded crystal structure as a native 3-D figure.

property volume#

Unit-cell volume in nm^3.