Accessing Interatomic distances from python via lammps python library

Hi LAMMPS Users:
I am trying to develop an analysis project which runs lammps simulations from a python code via python library.
Is there anyway to access already calculated interatomic distances from python side as a pointer similar to coordinates with command:
lammps.extract_atom(“x”,3).
If not is it possible to implement? I am trying to avoid additional overhead to calculate already calculated distances at the python side.

Regards.

Hi LAMMPS Users:
I am trying to develop an analysis project which runs lammps simulations
from a python code via python library.

Is there anyway to access already calculated interatomic distances from
python side as a pointer similar to coordinates with command:
lammps.extract_atom(“x”,3).

no. this information is not stored.

If not is it possible to implement? I am trying to avoid additional overhead
to calculate already calculated distances at the python side.

what you are asking does not make much sense. you are not considering
the overhead of storing and retrieving this information, which is
large, since the associated storage would be double that of the
neighbor lists, which is among the largest consumer of memory.

if you worry about performance this much, you should not implement
your analysis in python but as a compute style in c++ and then only
make the processed data available through the python interface. in the
compute, you can request a neighbor list, which already has
pre-selected all likely atoms to look at for computing the distances,
and for as long you can deal with the squared distance, the cost for
re-computing it is moderate (3 multiplies and 2 adds).

axel.

Hi,
Thanks for the advise.I am trying to access the neighbor list with :

input script:
compute pairs all pair/local natom1 natom2

From the python side I use:

pairs=lmp.extract_compute(“pairs”,1,2)

I receive Null Pointer access error.
Since I am not an expert in C++ I am trying to avoid modifying C++ code as much as possible.
The reason for this is I am trying to record bond breaking/formation events and get a statistics out of it.
Cheers.

Hi,
Thanks for the advise.
I am trying to access the neighbor list with :

input script:
compute pairs all pair/local natom1 natom2

From the python side I use:

pairs=lmp.extract_compute(“pairs”,1,2)

I receive Null Pointer access error.
Since I am not an expert in C++ I am trying to avoid modifying C++ code as
much as possible.

then you should not do what you are asking about.

The reason for this is I am trying to record bond breaking/formation events
and get a statistics out of it.

that information is readily available through fix reax/c/species and
fix reax/c/bonds and you can very easily do your statistical analysis
by parsing the output of those commands in post-processing. this is an
approach that makes sense.

what you seem to be trying makes no sense, you will have to re-do a
lot of work that those fixes have already included and you'll do this
at python speed, i.e. 100x slower than C++ code, and yet you have
provided no explanation why post-processing would be inadequate.

besides, if you are willing to go through such great pains to avoid
having to program c++, it will be the lesser evil to spend some time
*learning* c++ and then have that skill available in your toolchest
for future issues as well.

axel.

The pair/local compute stores “local” data.

So in your extract_compute() call you want style=2

(see the library.cpp doc info on lammps_extract_compute()

which is the 2nd arg (you have 1).

That’s likely why you’re getting a NULL returned.

Steve