LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
[lammps-users] Accessing number of bonds in python operated LAMMPS or length of internal LAMMPS data array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lammps-users] Accessing number of bonds in python operated LAMMPS or length of internal LAMMPS data array


From: Robert Meißner <robert.meissner@...4427...>
Date: Fri, 13 Apr 2018 13:51:41 +0200

Dear LAMMPS Developers,

since I'm facing the same problem right now, has there been any progress achieved on this matter? I want to extract the bond topology to create/delete some distinct bonds by identifying atoms from their bonded neighbors. If I'm running LAMMPS from python (thus in serial) the following code will give me something which works:

---

import numpy as np

bonds = np.array([],dtype=int).reshape(-1,3);

def bond_topology(lmpptr):
  from lammps import lammps
  lmp = lammps(ptr=lmpptr)
 
  global bonds
 
  lmp.command("compute bonds all property/local btype batom1 batom2")
  lmp.command("run 0")
  nbonds = lmp.extract_global("nbonds",0)
  b = lmp.extract_compute("bonds",2,2)

  for i in range(nbonds):
    if b[i][0]: bonds = np.vstack([bonds,[b[i][0],b[i][1],b[i][2]]])
  lmp.command("uncompute bonds")

---

However, when running python from LAMMPS obviously every MPI proc starts his own python interpreter and has only his local bond topology making this code fragment pretty useless since I need the full topology. Maybe someone has already made a routine like lmp.gather_bonds(...) or something similar to get the topology from python?


Best

Robert



-- 
Prof Dr.-Ing Robert Horst Meißner

Institute of Polymer and Composites
Denickestr. 15
D-21073 Hamburg
Tel.:  +49 (0)40 42878 2580
E-mail: robert.meissner@...4427...
Homepage: www.tuhh.de/alt/kvweb