Skip to content

Suggestion for read and transform trajectory  #10

@JianxingHuang

Description

@JianxingHuang

It takes quite a long time to read and transfrom the 'trajectory.xyz' file. I would suggest to use the method provided by pymatgen/ase, which is faster. The code example is shown below:

from ase.io import read, write  
import numpy as np
from pymatgen.io.ase import AseAtomsAdaptor
from ase import Atoms
from pymatgen.io.lammps.outputs import parse_lammps_dumps
confs = parse_lammps_dumps('trajectory.xyz') # this is a generator
symbols = ['La'] *24 +['Zr'] * 16 + ['O'] *96 + ['Li']*56
ats = [Atoms(symbols=symbols, positions=conf.data.values[:, :3],
             cell=conf.box.to_lattice().matrix, pbc=True) for conf in confs]
write('LLZO.xyz', ats)
ats = read('LLZO.xyz', ':100')

Besides, I suggest to rename the 'trajectory.xyz' as 'dump.trajectory'. For it is more like a lammps-dump output rather than '.xyz' type file. Because '.xyz' hints the user to use ase.io.read to load the data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions