Question regarding box deform angle limit

GROMACS version: 2020.6
GROMACS modification: No
I have used the deform function in Gromacs-2020.6. However, when the deform was bigger than 30 degrees, the box was changed to another direction. I attached the images here. ( The image is the frame, where the deform angle is bigger than 30)

In this situation, if I want to continue the shear deformation in this direction, what should I do ??

Appreciating your precious suggestion in advance!


My understanding is that Gromacs utilizes what’s called modular invariance to reset the box and prevent it to deform too much. Basically, if the initial box were cubic with side length L and were deformed in a off diagonal direction with speed u, at time t such that t=L/(2u) you would see the box ‘jumping’ as your image shows.

For liquid that’s preferable, since they react to deformation rates and you would keep like to keep shearing indefinitely. For solids (I don’t know what your systems is but it is too ordered to be a liquid)… I think there is no workaround: modular invariance is hardcoded in Gromacs, anyone correct me if I am wrong.

If you want, you can try and edit BoxDeformation::apply in src/gromacs/mdlib/boxdeformation.cpp, removing the for loop that does the reset:

/* We correct the off-diagonal elements,
     * which can grow indefinitely during shearing,
     * so the shifts do not get messed up.
    for (int i = 1; i < DIM; i++)
        for (int j = i - 1; j >= 0; j--)
            while (updatedBox[i][j] - box[i][j] > 0.5 * updatedBox[j][j])
                rvec_dec(updatedBox[i], updatedBox[j]);
            while (updatedBox[i][j] - box[i][j] < -0.5 * updatedBox[j][j])
                rvec_inc(updatedBox[i], updatedBox[j]);

But I cannot predict the side effects :-|

Thank your very much, I will do some tests.


Hello Pellegrino

If I want to increase the deformation angle, for example, up to 60 degrees, what should I do to change this code?



I don’t think the checked criterion is on the deformation angle itself, but rather on the deformation tensor (that is: you would probably reach a different max angle if your simulation box were taller or shorter).

Nevertheless, I tried to removed that for loop and my run crashed, so I don’t think there is a easy fix.

Thanks for your reply.
Would you mind paraphrasing the details regarding the deformation tensor in the boxdefromation.cpp file? I am still confused.

Appreciating in advance