ase_io#
- irmsd.interfaces.ase_io._ENERGY_UNITS_KEY = 'energy_units'#
Info key (case-insensitive) carrying an explicit energy-unit declaration.
- irmsd.interfaces.ase_io._HARTREE_UNIT_ALIASES = frozenset({'a.u.', 'atomic', 'au', 'e_h', 'eh', 'ha', 'hartree', 'hartrees'})#
Values (case-insensitive) marking an energy as already in Hartree.
- irmsd.interfaces.ase_io._ase_energy_to_hartree(atoms) float | None[source]#
Energy of atoms in Hartree; eV unless an
energy_units=Hartreemarker says otherwise.
- irmsd.interfaces.ase_io._declared_hartree(info) bool[source]#
True if
infocarriesenergy_units=Hartree(as our extxyz writers emit).
- irmsd.interfaces.ase_io._hartree_to_ev(energy: float | None) float | None[source]#
Hartree to eV, passing None through.
- irmsd.interfaces.ase_io._strip_energy_units(info: dict) dict[source]#
Copy of
infowithoutenergy_units; avoids double conversion on round-trip.
- irmsd.interfaces.ase_io.ase_to_molecule(atoms: ase.Atoms) Molecule[source]#
- irmsd.interfaces.ase_io.ase_to_molecule(atoms: Sequence['ase.Atoms']) list[Molecule]
Convert ASE Atoms (single or sequence) to irmsd.core.Molecule.
Triggers no calculator evaluation and does not modify the input. Energies are converted from eV to Hartree unless
infodeclaresenergy_units=Hartree; the marker is dropped from the result’sinfo. A per-atomcanonical_idarray is carried over asMolecule.ids.- Parameters:
atoms (
ase.AtomsorSequence[ase.Atoms])- Returns:
A list, in input order, if atoms is a sequence.
- Return type:
Moleculeorlist[Molecule]- Raises:
RuntimeError – If ASE is not installed.
TypeError – If the input is neither an ASE Atoms instance nor a sequence of them.
- irmsd.interfaces.ase_io.cregen_ase(atoms_list: Sequence['ase.Atoms'], rthr: float = 0.125, ethr: float = 8e-05, bthr: float = 0.01, printlvl: int = 0, ewin: float | None = None) List['ase.Atoms'][source]#
ASE wrapper for
cregen().- Parameters:
atoms_list (
Sequence[ase.Atoms]) – List or tuple; all structures must have the same atom count.rthr (
float) – Distance threshold in Angstrom.ethr (
float) – Energy threshold for pre-sorting, in Hartree.bthr (
float) – Relative threshold for comparing rotational constants.printlvl (
int, optional) – Verbosity level.ewin (
floatorNone) – Energy window above the lowest structure, in Hartree.
- Returns:
Rebuilt from the sorted Molecules.
- Return type:
list[ase.Atoms]
- irmsd.interfaces.ase_io.delta_irmsd_list_ase(atoms_list: Sequence['ase.Atoms'], iinversion: int = 0, allcanon: bool = True, printlvl: int = 0) Tuple[np.ndarray, List['ase.Atoms']][source]#
ASE wrapper for
delta_irmsd_list_molecule.- Parameters:
- Returns:
delta (
np.ndarray) – Float array from the backend; seedelta_irmsd_list.new_atoms_list (
list[ase.Atoms]) – Rebuilt from the transformed Molecules.
- irmsd.interfaces.ase_io.get_axis_ase(atoms) tuple[ndarray, ndarray, ndarray][source]#
Principal-axis data via Molecule.get_axis().
- Parameters:
atoms (
ase.Atoms)- Returns:
rot_constants_MHz, avg_momentum_au, rotation_matrix
- Return type:
tuple[np.ndarray,np.ndarray,np.ndarray]
- irmsd.interfaces.ase_io.get_canonical_ase(atoms, wbo: ndarray | None = None, invtype: str = 'apsp+', heavy: bool = False) ndarray[source]#
Canonical ranks / invariants via Molecule.get_canonical().
- Parameters:
- Return type:
np.ndarray- Raises:
RuntimeError – If ASE is not installed.
TypeError – If atoms is not an ASE Atoms instance.
- irmsd.interfaces.ase_io.get_cn_ase(atoms) ndarray[source]#
Coordination numbers via Molecule.get_cn(), shape (N,).
- Parameters:
atoms (
ase.Atoms)
- irmsd.interfaces.ase_io.get_energies_from_atoms_list(atoms_list: Sequence['ase.Atoms']) np.ndarray[source]#
Energies of atoms_list in Hartree, shape (N,); 0.0 where none is available.
Units follow
_ase_energy_to_hartree().
- irmsd.interfaces.ase_io.get_energy_ase(atoms)[source]#
Return the energy already stored on an ASE Atoms object, or None.
Looks in
atoms.info["energy"], then the calculator’sresults(“energy”, “free_energy”, “enthalpy”), thenget_potential_energy()only if that needs no new calculation. The value is in ASE units (eV).- Parameters:
atoms (
ase.Atoms)- Return type:
- Raises:
RuntimeError – If ASE is not installed.
TypeError – If atoms is not an ASE Atoms object.
- irmsd.interfaces.ase_io.get_irmsd_ase(atoms1, atoms2, iinversion: int = 0) Tuple[float, 'ase.Atoms', 'ase.Atoms'][source]#
ASE wrapper for
get_irmsd_molecule.- Parameters:
atoms1 (
ase.Atoms)atoms2 (
ase.Atoms)iinversion (
int, optional) – 0 = ‘auto’, 1 = ‘on’, 2 = ‘off’.
- Returns:
irmsd (
float) – In Angstrom.new_atoms1, new_atoms2 (
ase.Atoms) – New objects for the transformed structures.
- Raises:
RuntimeError – If ASE is not installed.
TypeError – If inputs are not ASE Atoms.
- irmsd.interfaces.ase_io.get_point_group_ase(atoms, **settings) str | None[source]#
Schoenflies point group via Molecule.get_point_group().
- Parameters:
atoms (
ase.Atoms)**settings – Analyzer settings (threshold, primary_threshold, max_axis_order, max_opt_cycles, max_atoms), see
irmsd.get_point_group().
- Returns:
None if the analysis was skipped.
- Return type:
- irmsd.interfaces.ase_io.get_rmsd_ase(atoms1, atoms2, mask=None) Tuple[float, 'ase.Atoms', np.ndarray][source]#
ASE wrapper for
get_rmsd_molecule.- Parameters:
atoms1 (
ase.Atoms) – Reference structure.atoms2 (
ase.Atoms) – Structure aligned onto atoms1.mask (
array-likeofbool, optional) – Atoms of the first structure that enter the RMSD.
- Returns:
rmsd (
float) – In Angstrom.new_atoms2 (
ase.Atoms) – New object with coordinates aligned to atoms1.rotation_matrix (
np.ndarray) – 3x3 rotation used for the alignment.
- Raises:
RuntimeError – If ASE is not installed.
TypeError – If inputs are not ASE Atoms.
- irmsd.interfaces.ase_io.molecule_to_ase(molecules: Molecule) ase.Atoms[source]#
- irmsd.interfaces.ase_io.molecule_to_ase(molecules: Sequence[Molecule]) list['ase.Atoms']
Convert Molecule(s) to ASE Atoms without attaching a calculator.
The Hartree energy is written to
info["energy"]in eV unlessinfoalready has anenergyentry; anyenergy_unitsmarker is dropped.Molecule.idsbecomes a per-atomcanonical_idarray. The returned objects do not share state with the input.- Parameters:
molecules (
MoleculeorSequence[Molecule])- Returns:
A list, in input order, if molecules is a sequence.
- Return type:
ase.Atomsorlist[ase.Atoms]- Raises:
RuntimeError – If ASE is not installed.
TypeError – If the input is neither a Molecule nor a sequence of Molecules.
- irmsd.interfaces.ase_io.prune_ase(atoms_list: Sequence['ase.Atoms'], rthr: float, iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, ethr: float | None = None, ewin: float | None = None) List['ase.Atoms'][source]#
ASE wrapper for
prune().- Parameters:
atoms_list (
Sequence[ase.Atoms]) – List or tuple; all structures must have the same atom count.rthr (
float) – Distance threshold for the sorter.iinversion (
int, optional) – 0 = ‘auto’, 1 = ‘on’, 2 = ‘off’.allcanon (
bool, optional) – Canonicalization flag.printlvl (
int, optional) – Verbosity level.ethr (
floatorNone) – Energy threshold for pre-sorting, in Hartree.ewin (
floatorNone) – Energy window above the lowest structure, in Hartree.
- Returns:
Rebuilt from the sorted Molecules.
- Return type:
list[ase.Atoms]
- irmsd.interfaces.ase_io.sorter_irmsd_ase(atoms_list: Sequence['ase.Atoms'], rthr: float = 0.125, iinversion: int = 0, allcanon: bool = True, printlvl: int = 0, ethr: float | None = None, ewin: float | None = None) Tuple[np.ndarray, List['ase.Atoms']][source]#
ASE wrapper for
sorter_irmsd_molecule.- Parameters:
atoms_list (
Sequence[ase.Atoms]) – List or tuple; all structures must have the same atom count.rthr (
float) – Distance threshold for the sorter.iinversion (
int, optional) – 0 = ‘auto’, 1 = ‘on’, 2 = ‘off’.allcanon (
bool, optional) – Canonicalization flag.printlvl (
int, optional) – Verbosity level.ethr (
floatorNone) – Energy threshold for pre-sorting, in Hartree.ewin (
floatorNone) – Energy window above the lowest structure, in Hartree.
- Returns:
groups (
np.ndarray) – Integer group index per structure.new_atoms_list (
list[ase.Atoms]) – Rebuilt from the sorted Molecules.