I am trying to perform a simple shear simulation.
I want to reduced the maximum tilt value from the current 0.5 to <max_tilt_factor> smaller than 0.5. To do so I am changing th source code.
I do believe I am using an older version of lammps (the one in liggghts) but the logic still applies.
So far the changes I have done (knowing I shear in the xy direction) are the following:
in
‘’’
FixDeform::end_of_step()
‘’’
change the if condition for flipping by decreasing 0.5 to the new threshold, e.g. 0.1
‘’’
if (triclinic && flipflag) {
double xprd = set[0].hi_target - set[0].lo_target;
double yprd = set[1].hi_target - set[1].lo_target;
double xprdinv = 1.0 / xprd;
double yprdinv = 1.0 / yprd;
if(
e.g. set[5].tilt_targetxprdinv < -0.1 ||
set[5].tilt_targetxprdinv > 0.1)
‘’’
in the same function I reduce the flip, by two times the maximum allowed
‘’’
if (domain->xperiodic) {
if (set[5].tilt_flipxprdinv < -0.5) {
set[5].tilt_flip += 0.2xprd;
flipxy = 1;
}
if (set[5].tilt_flipxprdinv > 0.1) {
set[5].tilt_flip -= 0.2xprd;
flipxy = -1;
}
‘’’
in the same function when it checks for too high values of tilt I changed the condition on how the value should be multiple of current dimensions to
‘’’
// tilt_target can be large positive or large negative value
// add/subtract box lengths until tilt_target is closest to current value
int idenom = 0;
if (i == 5) idenom = 0;
else if (i == 4) idenom = 0;
else if (i == 3) idenom = 1;
double denom = set[idenom].hi_target - set[idenom].lo_target;
if (i==5) denom *= 0.2;
‘’’
where the last if condition makes the tilt jump the desired amount.
Finally
‘’’
void Domain::image_flip(int m, int n, int p)
{
tagint *image = atom->image;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
int xbox = (image[i] & IMGMASK) - IMGMAX;
int ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
int zbox = (image[i] >> IMG2BITS) - IMGMAX;
ybox -= pzbox;
xbox -= 0.2mybox + nzbox;
image[i] = ((tagint) (xbox + IMGMAX) & IMGMASK) |
(((tagint) (ybox + IMGMAX) & IMGMASK) << IMGBITS) |
(((tagint) (zbox + IMGMAX) & IMGMASK) << IMG2BITS);
}
}
‘’’
I added a 0.2 factor for the image flags.
Now the code correctly tilts the box less, but the stress rises sharply after
the tilt, and particles behave errroneously.
What might be the cause of this?
Sorry, but LIGGGHTS was forked from LAMMPS a very long time ago and the code bases have diverged significantly. If you want serious help, you have to ask in the LIGGGHTS forum, not here.
It makes sense in the case there are other flows generated in the gradient direction.
The tilt of the box makes the domain different from the classic Lees-Edwards boundary conditions. Furthermore I observe a circulation in my particles only when the box tilt is close to zero.
I know LIGGGHTS was forked a long time ago, but the community there is smaller (and I think they made a commercial software now so they are less interested in open source developments).
I still think the issue lies in basic logic of LAMMPS code, but anyway I will try to ask the LIGGGHTS community.
It is not possible to run a continuous sheared molecular dynamics simulation with “simple” periodic boundaries that restricts the possible tilt factors to a subrange meaningfully smaller than [-0.5, 0.5), since “flipping” a box from tilt (for example) 0.3 results in a new box of -0.7.
You can translate that range, but you can’t shrink it.
The “classic” picture of Lees-Edwards boundary conditions does show orthogonal “boxes”. But those boxes have to be offset relative to each other, and thus the underlying periodicity is still triclinic, not orthogonal.
Thank you for your replies I think now I have a clear picture.
Thank you.
After looking a bit more into it, I realized the code inherently assumes a tilt change of 1' since it then updates (by an integer) the image flag of the particles that are remapped back into the box. The update of the flag corresponds to a full crossing of the boundary (i.e. what happens with the standard PBCs during non-flipping time steps) only if the tilt goes from the maximum value ato another value1-a` .
Therefore reducing the tilt would require to change the logic of the image flags in LAMMPS which is hardwired and works best for most of the possible situations.
My next step is simply keeping the original code, but changing the simulation box in a way the L_x >> L_y , so that even when the tilt is 0.5 the physical angle remains small.
I am considering it, but there are feature not yet implemented to my knowledge (such as superquadrics).
Yes, there are granular features that are only in LIGGGHTS and there are granular features that are only in LAMMPS. The first gap is narrowing while the second is growing.