[lammps-users] dumping a local pairwise quantitiy

Dear all,

I’m using a custom written LAMMPS pair-style which calculates a quantity (history dependent max force felt at each contact point) at a local contact level. I would like to access that value for every contact similar to DIST, FX, FY etc from compute pair local and dump it using dump local like I currently do to obtain contact forces. If I have to modify lammps to get this desired result, must I only alter these two files or must I modify more files? Is there also a place I can refer how to modify dump local or compute pair local as I didn’t see many regarding this on the archive.


to make this kind of functionality work you must have a “single()” method in your custom pair style to compute all properties and for the number additional properties outside of pairwise force and energy, you have to set the “single_extra” member variable and allocate a suitably sized block of memory for the “svector” pointer.
please see the pair styles in the GRANULAR package for examples.

this is too specific a functionality to have it globally documented or discussed. to learn about these things, you must read the source code.


Thanks Axel. Yes, I see that in the single() method in my pair style, the pertinent quantity which I would like to access (which for my case deltamax) is calculated there. As for svector, I see that:
svector[0] = fs1;
svector[1] = fs2;
svector[2] = fs3;
svector[3] = fs;

I also see that in compute pair local, calls on single here:
if (flag) {
if (singleflag)
eng = pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair);
else eng = fpair = 0.0;

if (nvalues == 1) ptr = &vector[m];
else ptr = array[m];

for (n = 0; n < nvalues; n++) {
switch (pstyle[n]) {
case DIST:
ptr[n] = sqrt(rsq);
case ENG:
ptr[n] = eng;
case FORCE:
ptr[n] = sqrt(rsq)fpair;
case FX:
ptr[n] = delx
case FY:
ptr[n] = delyfpair;
case FZ:
ptr[n] = delz
case PN:
ptr[n] = pair->svector[pindex[n]];

I am guessing if I can add another element to svector which for my case is svector[4]=deltamax and add a case say “case delta max:” to compute pair local as shown above, I can access what I want?

My apologies I am not familiar with C++ and am still learning.

Sorry for the rudimentary question.


please re-read what I already told you carefully and also read the documentation for compute pair local and some of the granular pair styles.

no changes to compute pair/local should be necessary.

this has very little to do with knowing C++ and is mostly a question of common sense and knowing how something should behave (i.e. what the LAMMPS manual says) and then how it is implemented. for the latter I already gave you all necessary information.


Dear Axel,

I appreciate your help. Thanks to you I was able to get this to work.