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","dipole"(fromatoms.info["dipole"]oratoms.info["dipole_moment"]),"polarizability"(fromatoms.info["polarizability"]),"total_charge"(fromatoms.info["total_charge"]oratoms.info["charge"]),"charges"(fromatoms.arrays["charges"], reference partial charges),"fragment_charges"(fromatoms.arrays["fragment_charges"], the net charge of each atom’s fragment),"spin_multiplicity"(fromatoms.info["spin_multiplicity"]oratoms.info["multiplicity"]), the loss weights"weight","energy_weight","force_weight"and"stress_weight"(from the same keys ofatoms.info) and"atom_force_weight"(fromatoms.arrays["atom_force_weight"]).- Return type: