Re: [lammps-users] Has anyone used LAMMPS to do this or does anyone have any suggestions?

Hi Axel and LAMMPS users,

Thanks so much for the valuable clue long time ago. I just gained a bit of cplus knowledge and went back to this project. Please let me ask more specifically.

During a verlet run within a “pair” function “compute_force()”, I would like to calculate the pressure (i.e. P=sum(fpair*dx)/Voronoi volume per atom), also I would like to call the Voronoi face area each neighbour pair for further use. The belows are what I have done:

=========for Voronoi volume and Question 1 ===========

In the pair calculation, I added the ptr for the Voronoi calculation:

Compute *Voronoi_info;

Char id_voro[]=”voroinfo”;

Int icompute=modify->find_compute(id_voro);


Then further call it through:


Double **voro=Voronoi_info->array_atom;

In input file I just add: compute voroinfo all Voronoi/atom

Until here results show it is all good;

Question 1:

Since, as you said, the “compute_***.h” actually happens after a verlet run(normally when output dump needed), also I indeed feel the simulation is slowed down. So in this way, if here I manually call it during a verlet run, will it actually be called twice? If so, it do severely slow down the simulation, may I ask in which file I can skip off the extra calculation of voronoi?

============for Voronoi face area per pair and Question 2======================

In the “compute.h” I added the container:

std::vector<std::vector> v_face_areas;//to store voro face area of each neighbour pair

std::vector<std::vector> v_neighbors;//to store id of neighbours of each target atom

std::vectorid_target;//to store id of each target atom

Then in the compute_voronoi_atom.cpp;

In function loopCells():


In function processCell():



During the pair calculation;

I call the container using the ptr (mentioned in the voro volume part) as below:

#include “compute.h” and I think they are all in namespace LAMMPS_NS




Question 2:

However, segmentation fault happens here, it shows the address not mapped, which means the ptr seems not work. Could you please provide some suggestions on how this Voronoi information (in “compute_voronoi_atom.cpp”, neigh and narea) can be stored and called outside the Voronoi compute? Or is there anything I can improve for the may I am on?

Many thanks

Best Regards,


sorry, but I didn’t write the voronoi compute or the voronoi library, so I cannot comment on that.
It also physically pains me to see how you are trying to modify the code which looks like operating on a chronometer watch with a sledgehammer.

the only useful comment I can give is that you can check for the “invoked_peratom” property in the voronoi compute.
it will be set to the current timestep when you invoke its compute_peratom() function and thus if it is the same value than update->ntimestep it has already been called for the same timestep.

I cannot debug segfaults from remote. that is what debuggers are for. there is a short discussion of how to track down a segfault to the origin in the LAMMPS manual.


Hi Axel,

Thanks for the suggestions, I will check out the debugging tool and the Voronoi compute parameter.

I feel, up to now, the chronometer is strong enough, hope I am not destroying it.

Very appreciate for the clue and quick response.

Best Regards,