Hello,
I’m using the following command to read a Xdatcar file from an NPT simulation, which contains variable lattice. I’m not sure why the argument constant_lattice=False doesn’t create a 2D array of variable lattice. I only see the lattice of the 1st frame repeated throughout the snapshots.
from pymatgen.core.trajectory import Trajectory
trj = Trajectory.from_file(‘XDATCAR’, constant_lattice=False)
The second question I had is:
Can Pymatgen handle RDF from 2 atom indices? E.g. I see the following code get_rdf_figure (isite , normalized=True , figsize=None , step_function=None )
where, isite seems to only consider self interaction RDF? Or can isite be [atom_N, atom_M] in the unit cell?
The trajectory object should read variable lattice… are you sure the XDATCAR is right?
As for RDF, pymatgen doesn’t have good support for such things at the moment. What MP has is a separate code called MPMorph which contains more MD-focused tools like RDFs. MPMorph is not fully developed, but you can pull it from github, and it can read RDFs from pymatgen structure objects.
I can confirm that XDATCAR is correctly written. My structure contains around 500 atoms with 7 different elements and 6000 snapshots (100ish MB). Is any of this causing an issue?
Are you still having an issue with this? I’m looking into it now and the Trajectory class seems to be handling variable lattices correctly. I’m wondering if the XDATCAR assumes constant lattice. I don’t have access to an XDATCAR from an NPT run and don’t know the exact formatting. Can you try the following and let me know if the output is as expected?
Alternatively, can you supply me with the XDATCAR file you are trying to read? I only need the first 10 or so frames. You can edit the file and delete the extra snapshots.
I created a manual script to parse that information. The command you sent prints out the same lattice constant. I unfortunately can’t send the frames due to proprietary structures. I’ll see if I can reproduce that error with a different run and post the output back.
Thanks for getting back to me. Looks like my suspicious were correct. Pymatgen’s Xdatcar parser does not properly handle variable lattice during MD simulations. If you can get me the output of the different run, that would be great!
In the meantime, you should be able to work around this by taking the structures from the ‘vasprun.xml’ rather than the ‘XDATCAR’.
from pymatgen.core.trajectory import Trajectory
trj = Trajectory.from_file(‘vasprun.xml’, constant_lattice=False)
Thanks for the file. I looked into this a bit more and it appears to have been fixed a few days after our first correspondence. If you update pymatgen v2022.0.7 or later, the parsing of the Xdatcar to create trajectories should behave as expected.