[lammps-users] update the frame of reference in granular model

Dear All,

I have a problem to understand the source code of “src/GRANULAR/pair_granular.cpp” (version lammps-29Oct20). The fragment of the source code is copied below:

// rotate and update displacements / force.
// see e.g. eq. 17 of Luding, Gran. Matter 2008, v10,p235
if (historyupdate) {
rsht = history[0]*nx + history[1]*ny + history[2]nz;
if (tangential_model[itype][jtype] == TANGENTIAL_MINDLIN_FORCE ||
tangential_model[itype][jtype] ==
frameupdate = fabs(rsht) < EPSILON
frameupdate = fabs(rsht)k_tangential < EPSILONFscrit;
if (frameupdate)

According to the comment, this fragment is used to account for changes in the frame of reference of the contacting pair of particles during contact, to make sure that history is perpendicular to (nx,ny,nz). The quantity “rsht” is the dot product of history and (nx,ny,nz). Why the condition is the condition is “<”? If the dot product rhst is 0 (means history is perpendicular to the position vector), we needn’t to adjust the tangential displacement.


This is far too specific for me to answer, you better discuss this with the author of this section of code or the author/maintainer of the granular pair style. Both are cc’d on this e-mail.


Dear Deng,

Thank you for your careful examination, I think you are right, and it should be a superior sign: >.

I made the updates in this PR https://github.com/lammps/lammps/pull/2196. The former implementation had a < sign to determine when there is NO update because rsht is too small (l. 434), followed by an update if rsht>0 (l. 435 there was an issue with this second step as you can read from the PR discussions).

I got rid of the faulty rsht>0 line but as you point out, I also got rid of the proper logic in the process, which is to update when the angle is big, not small. If Dan Bolintineanu confirms, you could submit a PR to make that change.

Thanks again for spotting this.
Jibril B. Coulibaly

Dear Deng, Jibril,

Yes, good catch, I agree with Jibril, the sign should be > in both cases. Also true for rolling history slightly farther down in the PairGranular::compute code. Please feel free to make a PR, or let one of us know and we can do so.


Dan Bolintineanu


I would appreciate it if you could make the changes and e-mail a diff/patch file to me. I already have a suitable branch with collected small changes and fixes, where I can add these easily. i think that would be the most efficient way to resolve this.



Sure thing, see attached.



pair_granular_cpp_patch (1.22 KB)

thanks for the quick turnaround.
this change will be included in the next patch release (within 2-3 weeks I hope).