Last active
April 10, 2019 14:06
-
-
Save pastewka/6b316dd8ecb4c21f73fd625c8c3671c7 to your computer and use it in GitHub Desktop.
Convert LAMMPS data files into NetCDF trajectory
This file contains 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
import glob | |
import os | |
from ase.io import NetCDFTrajectory, read | |
fns = glob.glob('/work/ws/nemo/fr_rj1011-18.07.03-GAP_low_density-0/18.10.15-aC_GAP-quasistatic-bond_breaking_B/quasistatic-2.7_B_*.lammps') | |
nc = NetCDFTrajectory('quasistatic_2.7.nc', 'w') | |
fns = sorted(fns, key=lambda x: int(os.path.basename(x).replace('quasistatic-2.7_B_', '').replace('.lammps', ''))) | |
for fn in fns: | |
print(fn) | |
a = read(fn, format='lammps-data', style='atomic') | |
nc.write(a, arrays=['id', 'travel']) | |
nc.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment