xnn.common.data.ase_io.atoms_to_structure#
- xnn.common.data.ase_io.atoms_to_structure(atoms, energy_key='energy', forces_key='forces', stress_key='stress')[source]#
Convert one ASE
Atomsobject to an xnn structure dict.Geometry (positions, atomic numbers, cell, pbc) is always extracted; positions are taken as-is (the neighbor-list builder handles unwrapped coordinates). Targets are added when available: with the default key names, first from the attached calculator (
get_potential_energy/get_forces/get_stress), then fromatoms.info["energy"]/atoms.arrays["forces"]/atoms.info["stress"]. A non-default key selects that entry ofinfo/arraysinstead (e.g. MACE-conventionREF_energy/REF_forces/REF_stress). Stress is converted to a full(3, 3)matrix.- Parameters:
- Returns:
Structure dict with keys
"pos","atomic_numbers","cell"(Nonefor non-periodic frames),"pbc", and optionally"energy","forces","stress"and"total_charge"(fromatoms.info["total_charge"]oratoms.info["charge"]).- Return type: