How to Rotate a Periodic Model?
Published:
This is a note of the mechanical model of plant cell wall in my work.
How to rotate a model with periodicity?
Geometric Relations

Assume the left figure is the minimal periodic unit of the material. After rotation, we obtain the model on the right. To satisfy periodic boundary conditions, suppose there are $ n $ periods in the $d_x$ direction and $m$ periods in the $d_y$ direction. The following relations must hold: $ l_x=md_y \sin\theta $ $ l_y=md_y \cos\theta
$ $ nd_x=\frac{l_x}{\cos\theta} $ This gives: $tan\theta=\frac{n}{m}\frac{d_x}{d_y}$
At the same time, volume conservation must be satisfied: $ d_x d_y m n=l_x l_y $
The final solution is: $ \sin\theta \cos\theta=\tan\theta $ Only when $\theta=k\pi $ does this hold, meaning that except for rotations that are multiples of 180 degrees, no rotated system remains periodic — the lattice constants must inevitably become mismatched. Since the lattice constants cannot satisfy the rotation requirement, how should we proceed to minimize the tolerance?
Numerical Approximation

Assume the initial lattice ratio $d_y/d_x=8/3$. The blue line is the volume tolerance after rotation, the yellow line is the lateral bond length tolerance, and the red line is the total tolerance.
We modify equation (1) by introducing a tolerance $\Delta\varphi$ to describe the volume change rate and $\gamma$ to describe the lateral bond length change ($\Delta\varphi$ near 0, $\gamma$ near 1): $ l_x=md_y \sin\theta $ $ l_y=md_y \cos\theta $
$ nd_x*\gamma=\frac{l_x}{\cos\theta} $
$ nmd_xd_y*(1+\Delta\varphi)=l_xl_y $
Define the error function $etol=(\Delta\varphi)^2+(\gamma-1)^2$, and finally obtain the error and the lattice ratio as functions of the angle.
$ etol=\sqrt{(\lambda tol)^2+(\Delta \varphi tol)^2}=\sqrt{\left(\lambda p \tan \left( \theta\right)-1\right)^2+\left(\lambda p \sin ^2\left( \theta\right) \tan \left( \theta\right)\right)^2} $ The minimum of the error function can be solved analytically: $ etol_{,p}=0 $ $ p=\frac{\cot\theta}{\lambda(1+\sin^4\theta)} $ $ \lambda tol=\frac{1}{1+\sin^4\theta}-1 $ $ e\Delta\varphi=\frac{\sin^2\theta}{1+\sin^4\theta} $ $ etol=\frac{\sin^2\theta}{\sqrt{1+\sin^4\theta}} $ The optimal lattice ratio before and after rotation is:

It can be seen that to control the tolerance to within approximately 10%, the orientation angle is limited to 0~20 degrees.
Example
The coarse-grained model cell of the S2 layer satisfies $p=m/n=d_y/d_x=8/3$. For different $m,n$, the orientation angle $\theta$ can take different values.
| n | m | p | $ \theta $ | $l_x $ | $l_y $ |
|---|---|---|---|---|---|
| 10 | 21 | 2.1248 | 10 | 87.5187 | 496.343 |
| 1 | 1 | 1.0164 | 20 | 8.20848 | 22.5526 |
| 16 | 10 | 0.611312 | 30 | 120 | 207.846 |
| 21 | 10 | 0.483251 | 35 | 137.658 | 196.596 |
Rotating a periodic model requires using a tilted box!
