-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality to read ASE *.traj file in Trajectory class method from_file() #3422
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a test for this. Could you upload an ASE traj file and read it in tests/core/test_trajectory.py
?
…ile tests/files/LiMnO2_test_relax.traj.
Signed-off-by: Jingyang Wang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments.
pymatgen/core/trajectory.py
Outdated
constant_lattice=constant_lattice, | ||
**kwargs, | ||
) | ||
if not is_mol: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should do if is_mol
(return from_molecules) and then else
(return from_structures). Makes more sense to start with a positive logic statement rather than a negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @exenGT, almost ready to go! 👍
tests/core/test_trajectory.py
Outdated
@@ -471,3 +471,7 @@ def test_xdatcar_write(self): | |||
written_traj = Trajectory.from_file("traj_test_XDATCAR") | |||
self._check_traj_equality(self.traj, written_traj) | |||
os.remove("traj_test_XDATCAR") | |||
|
|||
def test_read_file(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best match the method name in the test name: i.e. test_from_file
. Also, maybe check the traj length and composition of the 1st frame for extra safety.
Signed-off-by: Janosh Riebesell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is failing due to file not found. Also, could you compress tests/files/LiMnO2_chgnet_relax.traj
?
3c23114
to
36e289c
Compare
…from_file() (materialsproject#3422) * Add functionality to read ASE *.traj files in Trajectory.from_file(). * fix Trajectory.from_file turning abs path into file name --------- Signed-off-by: Jingyang Wang <[email protected]> Signed-off-by: Janosh Riebesell <[email protected]> Co-authored-by: Janosh Riebesell <[email protected]>
Summary:
Add functionality to read ASE *.traj file in Trajectory class method from_file(), located in core/trajectory.py.
Purpose:
As ASE *.traj file is a standard format for generating and storing relaxation / MD trajectories, it would be nice to have a method which can read a Pymatgen Trajectory instance from an ASE *.traj file.