# alternatives to fix spring + rigid body for friction simulation

Hi all,

I’m working on friction simulations using a rigid tip attached (by spring) to a moving bob. I’m aware that fix spring doesn’t work with rigid bodies; the rigid tip gets confused when the bob moves across the periodic boundary.

One possible workaround is to give the sample a velocity and drag it against the tip (rather than the other way around), but I’d like to avoid assigning a velocity to the sample, since this complicates thermodynamic and phonon calculations. But is there any alternative?

Instead of making the tip a rigid body, you might try
using fix aveforce 0 0 0 and see if that does what you
want. The tip should then move as one entity but
still respond to external forces (e.g. from fix spring).
Hopefully fix spring would then work across PBC as well.

Steve

Thanks. I decided to modify fix_spring.cpp instead:

242 dx = xcm2[0] - xcm[0] - xc;
243 dy = xcm2[1] - xcm[1] - yc;
244 dz = xcm2[2] - xcm[2] - zc;
245 if (!xflag) dx = 0.0;
246 if (!yflag) dy = 0.0;
247 if (!zflag) dz = 0.0;
248
249 // MODIFIED TO WORKAROUND RIGID BUG
250 while ( dx > 0.5domain->xprd ) dx -= domain->xprd;
251 while ( dx < -0.5
domain->xprd ) dx += domain->xprd;
252 while ( dy > 0.5domain->yprd ) dy -= domain->yprd;
253 while ( dy < -0.5
domain->yprd ) dy += domain->yprd;
254 while ( dz > 0.5domain->zprd ) dz -= domain->zprd;
255 while ( dz < -0.5
domain->zprd ) dz += domain->zprd;
256 // END WORKAROUND
257 r = sqrt(dxdx + dydy + dz*dz);
258 r = MAX(r,SMALL);
259 dr = r - r0;

Thank you