atompack.ase_bridge

ASE conversion helpers for atompack.

Functions

to_ase(molecule, *[, attach_calc, calc_mode, ...])

Convert an atompack molecule to ase.Atoms.

to_ase_batch(source[, indices, attach_calc, ...])

Convert many atompack molecules to ASE Atoms efficiently.

from_ase(atoms[, energy, forces, charges, velocities, ...])

Convert one ASE Atoms object to an atompack Molecule.

add_ase_batch(db, atoms_list, *[, copy_info, ...])

Write many ASE Atoms objects efficiently, preserving supported metadata.

Module Contents

atompack.ase_bridge.to_ase(molecule, *, attach_calc=True, calc_mode='singlepoint', copy_info=True, copy_arrays=True)[source]

Convert an atompack molecule to ase.Atoms.

The conversion reads directly from the molecule getters, so it works for both owned and view-backed molecules without going through molecule.atoms(). That keeps the path compatible with lazy SOA-backed molecules, although ASE object creation still requires Python/NumPy allocations.

Mapping rules:

  • positions and atomic_numbers always become the ASE geometry.

  • cell and pbc are copied when present.

  • velocities are attached with atoms.set_velocities(...).

  • energy, forces, stress, and charges are attached through an ASE calculator when attach_calc=True. calc_mode="singlepoint" preserves ASE’s snapshot semantics, while calc_mode="nocopy" is faster but does not snapshot the atoms state.

  • Custom properties shaped like per-atom arrays are stored in atoms.arrays when copy_arrays=True.

  • Remaining custom properties are stored in atoms.info when copy_info=True.

Parameters

moleculeatompack.Molecule

Molecule to convert.

attach_calcbool, default=True

Attach supported builtin results through an ASE calculator.

calc_mode{“singlepoint”, “nocopy”, “none”}, default=”singlepoint”

Calculator attachment mode. "singlepoint" uses ASE’s standard snapshotting calculator, "nocopy" skips the internal atoms copy for higher throughput, and "none" suppresses calculator attachment.

copy_infobool, default=True

Copy non-array custom properties into atoms.info.

copy_arraysbool, default=True

Copy per-atom custom arrays into atoms.arrays.

Returns

ase.Atoms

Converted ASE object.

atompack.ase_bridge.to_ase_batch(source, indices=None, *, attach_calc=True, calc_mode='singlepoint', copy_info=True, copy_arrays=True)[source]

Convert many atompack molecules to ASE Atoms efficiently.

atompack.ase_bridge.from_ase(atoms, energy=None, forces=None, charges=None, velocities=None, cell=None, stress=None, copy_info=True, copy_arrays=True, info=None)[source]

Convert one ASE Atoms object to an atompack Molecule.

Custom values from atoms.info, atoms.arrays, calculator results, and explicit info= overrides are stored as molecule-scope properties. Array shape is not used to infer atom-property scope during ingestion.

atompack.ase_bridge.add_ase_batch(db, atoms_list, *, copy_info=True, copy_arrays=True, info=None, batch_size=512)[source]

Write many ASE Atoms objects efficiently, preserving supported metadata.