Created
May 9, 2023 08:44
-
-
Save Roninkoi/b7acbc48b11c3dec37b31d490ca5e582 to your computer and use it in GitHub Desktop.
Extract last frame of LAMMPS xyz file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env python3 | |
| # Extract last frame from LAMMPS xyz dump file | |
| # inpath and write it to outpath | |
| inpath = "AgNWSiO2.xyz" | |
| outpath = "data.AgNWSiO2" | |
| df = open(inpath, "r") | |
| buf = [] | |
| i = 0 | |
| for l in df: | |
| # ITEM: TIME | |
| # ITEM: TIMESTEP | |
| if "ITEM: TIME" in l: | |
| buf.clear() | |
| print("Step:", i) | |
| i += 1 | |
| buf.append(l) | |
| df.close() | |
| df = open(outpath, "w") | |
| for l in buf: | |
| df.write(l) | |
| df.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment