Skip to content

Add support for writing bond information in Lammps data files

Pablo Piaggi requested to merge PabloPiaggi/ase:lammpsdata-bonds into master

This PR adds support for writing bond information in Lammps data files with style = 'full'.

The code assumes that the bond information is kept in arrays['bonds'] in the same format in which it is read by read_lammps_data. As a matter of fact, the following code preserves the bond information:

import ase.io
atoms=ase.io.read("ase/test/testdata/lammpsdata_input.data",format='lammps-data',atom_style="full")
ase.io.write("out.lammps-data",atoms,atom_style='full')

I added a new boolean optional argument 'bonds' to the method write_lammps_data, to choose whether to write bond information or not. The default is currently set to True. This is because lammps and ovito follow the same convention: if bond information is present and atom_style = 'full' then bond information is relevant and thus is written. The default can be changed to False to improve backward compatibility at the expense of less intuitive behavior.

Checklist

Edited by Pablo Piaggi

Merge request reports