httk.io.cif.expand_asu

Functions

pos_key(v, grid_den[, tol])

Hashable key for a position after snapping.

find_adjacent_key_wrap(k, pos_map, grid_dens)

Look for k in pos_map; if missing, check the 26 neighbors

apply_op_frac(R, t, f)

Apply a (fractional) symmetry operation and wrap to [0,1).

species_to_numbers(species)

asu_data_to_numbers_by_labels(asu_data)

Optional helper mirroring your magnetic 'separate_noneq_atoms' behavior:

expand_asu(→ tuple[Any, Ellipsis])

Generalized ASU expansion.

apply_op_moment(R, time_flag, m, lattice, spin_basis)

mag_asu_data_to_numbers(mag_asu_data)

Numbering that separates non-equivalent atoms (labels), mapping each label to a unique id,

cif_to_struct(fs, *[, separate_noneq_atoms, tol])

Read a CIF file, expand the asymmetric unit, and return the result.

expand_mag_asu(fs, *[, separate_noneq_atoms, ...])

Read an mCIF file, expand the asymmetric unit, and return the result.

Module Contents

httk.io.cif.expand_asu.pos_key(v, grid_den, tol=1e-08)[source]

Hashable key for a position after snapping.

httk.io.cif.expand_asu.find_adjacent_key_wrap(k, pos_map, grid_dens)[source]

Look for k in pos_map; if missing, check the 26 neighbors (Chebyshev distance 1) with periodic boundaries. Return (found_key or None).

httk.io.cif.expand_asu.apply_op_frac(R, t, f)[source]

Apply a (fractional) symmetry operation and wrap to [0,1). Works with int-like R and float-like t/f.

httk.io.cif.expand_asu.species_to_numbers(species)[source]
httk.io.cif.expand_asu.asu_data_to_numbers_by_labels(asu_data)[source]

Optional helper mirroring your magnetic ‘separate_noneq_atoms’ behavior: give each distinct label a unique number (even if same element symbol).

httk.io.cif.expand_asu.expand_asu(positions_frac, species, ops, *, grid_dens=16384, tol=1e-06, moments=None, apply_op_moment_fn: collections.abc.Callable[Ellipsis, Any] | None = None, spin_basis=None, basis=None, mag_grid_dens=16384) tuple[Any, Ellipsis][source]

Generalized ASU expansion.

For a non-magnetic expansion:

positions_full, species_full = expand_asu(pos, species, ops)

For a magnetic expansion:

positions_full, species_full, moments_full, mom_classes, symops_classes = expand_asu(
    pos, species, ops, moments=moments, apply_op_moment_fn=apply_op_moment,
    spin_basis=spin_basis, basis=basis, mag_grid_dens=mag_grid_dens)

For non-magnetic input ops are (R, t); for magnetic input they are (R, t, time_flag). Duplicate positions are removed using snapped position keys with neighbour wrap-around.

httk.io.cif.expand_asu.apply_op_moment(R, time_flag, m, lattice, spin_basis)[source]
httk.io.cif.expand_asu.mag_asu_data_to_numbers(mag_asu_data)[source]

Numbering that separates non-equivalent atoms (labels), mapping each label to a unique id, while still storing element symbol as numbers_to_species[id]. This is the corrected intent of your original helper.

httk.io.cif.expand_asu.cif_to_struct(fs, *, separate_noneq_atoms=False, tol=1e-06)[source]

Read a CIF file, expand the asymmetric unit, and return the result.

fs is a filename or file-like object (anything accepted by the read_cif layer). When separate_noneq_atoms is true, unique numbers are assigned by CIF label (even for the same element); otherwise numbers are assigned by element symbol. tol controls the expansion consistency tolerance. Returns a dict with the expanded structure data.

httk.io.cif.expand_asu.expand_mag_asu(fs, *, separate_noneq_atoms=False, error_on_nonmag=True, tol=1e-06, mag_grid_dens=16384)[source]

Read an mCIF file, expand the asymmetric unit, and return the result.

fs is a filename or file-like object (anything accepted by the read_cif stack). When separate_noneq_atoms is true, unique numbers are assigned by CIF label (even for the same element symbol); otherwise numbers are assigned by element symbol. When error_on_nonmag is true, an error is raised if no magnetic moments can be extracted. tol is the expansion consistency tolerance and mag_grid_dens is the density used when snapping magnetization directions and classes. Returns a dict with the expanded magnetic structure data.