[lammps-users] Enumerating bonds in PyLammps

Dear LAMMPS users,

Is there a way to access a list of all bonds in a system via some python API, be it lammps.py or PyLammps?

My goal is to define angle potential terms between these bonds, since it looks like there’s no automated way to do that (create_bonds many only creates bonds and angle terms must be added one by one, as I understand from the documentation)

For context:

I’m building a coarse-grained structure for graphene consisting in a triangular lattice with one particle/bead in the basis, with bonds and angles defined between first neighbors. I currently set up the lattice, add atoms via the create_atoms command and then run create_bonds many to. well, create many bonds.

The create_bonds many command correctly creates six bonds per particle, but no angles, which is expected, according to the docs. I made a Python script that reads the bonds from a data file and generates a sequence of appropriate create bonds single/angle commands. So in order to have a full system setup, for each lattice/supercell, I currently have to:

  1. set up the lattice and create_box
  2. create_atoms in that box
  3. create_bonds
  4. write_data to a file
  5. read this file with a python script to generate a list of angles
  6. include the file created by the python script.

I wish to avoid generating and reading/parsing the data file and creating/including the command file for each supercell.

Thanks form an unusually cloudy and rainy Natal,

I would not even try to do this from within LAMMPS. LAMMPS is good at doing the simulations and reading/storing the necessary topology data, but building (or modifying) a topology is tricky because everything has to be compatible with parallel processing and domain decomposed distributed data.

I don’t know of any python scripting based tool that can help (but given the rather simple nature of your system it should be rather straightforward to write something that does everything automatically from scratch in python). You could check of Pizza.py has the necessary functionality.

I wrote some scripts/tools that do the same thing in VMD (and then some) based on VMD’s Tcl scripting interface: https://sites.google.com/site/akohlmey/software/topotools
The package is bundled with VMD.

Thanks, Alex,

I already have a python script that generates the angles I need, based on the data file, I just wanted to be sure that I wasn’t missing something much easier.

For now I can keep using my script and saving the structures in a data file to be imported in the production runs.

For more complex systems I’ll certainly have a look at topotools.