Thanks for the prompt reply, Axel!
Assuming I want to extract the topology in a gather_atoms() fashion, in which variable is this info stored? Atom info is in lmp->atom->… but where can I find the bonds? Probably I need furthermore an nlocal counter for the number of bonds, since the number of nlocal does not match the number of local bonds. Maybe you know a function to which I can refer as a blueprint?
Since we're on the subject, how does the command extract_box() command work? I did several approaches but was not able to extract the periodicity or anything using this command.
Furthermore, thanks for the hints when changing the bond topology. I plan to use create_bonds or delete_bonds (or maybe fix bonds/create) directly from a LAMMPS input script to build new topology and avoid the problems you’ve mentioned. The python function should just identify atom IDs and store them in variables for later use.
On Fri, Apr 13, 2018 at 7:51 AM, Robert Meißner <robert.meissner@...33....4427...> wrote:
Dear LAMMPS Developers,FWIW, you can also launch the python interpreter in parallel (viapypar or mpi4py).
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:this just works by accident and not by construction. it looks to me,the straightforward way to address this would be to add a scalarcontext to compute bond/local (and other local computes) which thenallows to obtain the desired (and currently inaccessible) informationof the local array lengths.steve, do you agree? or am i overlooking something?
import numpy as np
bonds = np.array(,dtype=int).reshape(-1,3);
from lammps import lammps
lmp = lammps(ptr=lmpptr)
lmp.command("compute bonds all property/local btype batom1 batom2")
nbonds = lmp.extract_global("nbonds",0)
b = lmp.extract_compute("bonds",2,2)
for i in range(nbonds):
if b[i]: bonds = np.vstack([bonds,[b[i],b[i],b[i]]])
---what you see (in the source) is what you get. the philosophy is thatlibrary.cpp is deliberately incomplete and that only then functionsare added to library.cpp, when people have a demonstrated need thatcannot be satisfied differently.yours certainly fits the bill, however, i am not aware of any effortto make the topology information available.in general, please be very cautious when making changes to the bondtopology in LAMMPS. it is quite tricky to do so when running inparallel. for performance reasons, many parts of LAMMPS assume thatthe bond topology does not change, so data structures are initializedat the beginning of a run. so those need to be updated when changesare made, and in particularly updated consistently across all parallelranks. the (rather recently added) ability to access the pythoninterface from within a run and thus perform modifications, that werepreviously only possible outside a run, has opened the door to a lotof ways to make the internal state of LAMMPS inconsistent. if you areusing the very latest version of LAMMPS, multiple problematic classesof interface calls are now prohibited.axel.
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?
-- Dr. Axel Kohlmeyer akohlmey@...24... http://goo.gl/1wk0College of Science & Technology, Temple University, Philadelphia PA, USAInternational Centre for Theoretical Physics, Trieste. Italy.
Prof Dr.-Ing Robert Horst Meißner
Institute of Polymer and Composites
Tel.: +49 (0)40 42878 2580
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lammps-users mailing list