I’ve been using ase in python scripts to read a number of files, including .extxyz, and it looks like the behavior for ase.io.read(…format=‘extxyz’) has changed, and I’m not sure where to find the key-value pairs from the header in the resulting Atoms object.
The headers in this file look like:
Lattice="13.3519 0.0 0.0 0.0 13.3519 0.0 0.0 0.0 13.3519" Properties=species:S:1:pos:R:3 name=C216Li24-15 energy=-1728.48358344 pbc="T T T"
Using ase-3.22.1, I can call atoms_object.info
and I get
{'name': 'C216Li24-15', 'energy': -1728.48358344}
But using ase-3.23.0, I get only
{'name': 'C216Li24-15'}
Is ‘energy’ being stored somewhere else, like in a calculator object?
Thanks!
It is being stored in a calculator object; try using atoms.get_potential_energy()
or looking at atoms.calc.results
.
This change in behaviour is to avoid ambiguity/conflict when equivalent information is placed on both the atoms and its Calculator.
Ah, thank you! I thought I had tried get_potential_energy, but that is indeed what I needed.
Hi! I came across a related issue with regards to xyz file. The headers in my xyz file look like:
Lattice="5.494219689819475 0.0 0.0 2.7471098449097373 4.758133825356323 0.0 0.0 0.0 27.21502897900848" Properties=species:S:1:pos:R:3:forces:R:3 energy=-136.82442956 pbc="T T T"
I tried using atoms = ase.io.extxyz.read_xyz(xyz_file)
and a generator object is created instead where I have no idea of how to acces attributes like the energy and atomic positions. Does anyone here have any advice on how should I proceed? Thanks!
What do you get if you call next()
on the generator?
Usually these functions are not used directly: ase.io.read(xyz_file, format='extxyz')
should return an Atoms.
Ahh I tried the function call you recommended, and I could access the potential energy and forces now. Thank you so much!!