Inferensys

Glossary

SHAKE Algorithm

A numerical constraint algorithm that resets the positions of atoms involved in rigid bonds after each integration step, allowing for a larger simulation time step by freezing the fastest vibrational degrees of freedom.
Enterprise integration architect reviewing API connections on laptop, diagram showing systems connecting, modern office setup.
CONSTRAINT DYNAMICS

What is the SHAKE Algorithm?

A foundational numerical method for enforcing rigid bond constraints in molecular dynamics simulations, enabling larger integration time steps.

The SHAKE algorithm is a numerical procedure that resets the positions of atoms involved in rigid bonds after each integration step in a molecular dynamics (MD) simulation. By applying holonomic constraints to fix bond lengths, it eliminates the fastest vibrational degrees of freedom, typically hydrogen stretching, which would otherwise require an impractically small time step to integrate accurately.

SHAKE operates iteratively using Lagrange multipliers to calculate the constraint forces needed to maintain fixed interatomic distances. It processes each constraint sequentially, cycling through all rigid bonds until the change in atomic positions converges below a specified tolerance. This allows simulations to use a 2 femtosecond time step rather than the 0.5 femtosecond step required without constraints, effectively doubling computational throughput for biomolecular systems.

CONSTRAINT ALGORITHM

Key Characteristics of SHAKE

The SHAKE algorithm is a foundational numerical procedure in molecular dynamics that enforces rigid bond constraints, enabling significantly larger integration time steps by freezing the highest-frequency vibrational motions.

01

Iterative Constraint Satisfaction

SHAKE operates by iteratively resetting atomic positions after an unconstrained integration step. It applies a correction vector along each constrained bond to satisfy a fixed distance criterion. The algorithm loops through all constraints until all bond lengths converge to within a specified tolerance, typically 10⁻⁴ Å. This iterative Gauss-Seidel approach is simple but can struggle with highly interconnected constraint networks, such as those involving three-center bonds or ring systems.

02

Freezing Fast Degrees of Freedom

The primary purpose of SHAKE is to eliminate the fastest vibrational modes from a simulation, specifically bonds involving hydrogen atoms (e.g., O-H, N-H, C-H). These bonds vibrate with a period of ~10 fs, which would otherwise dictate a maximum time step of ~1 fs. By constraining them, the integration time step can be safely increased to 2 fs in atomistic simulations, effectively doubling computational throughput without sacrificing accuracy for slower, more relevant conformational dynamics.

03

RATTLE: The Velocity-Space Extension

SHAKE only corrects atomic positions, leaving velocities unconstrained. RATTLE is the complementary algorithm that applies a second set of constraints to the velocities, ensuring they are orthogonal to the bond direction. This is essential for generating correct kinetic energy distributions and is required for proper NVT and NPT ensemble sampling. Most modern MD engines implement both SHAKE (for positions) and RATTLE (for velocities) as a unified constraint solver.

04

SETTLE: Analytical Water Rigidity

For the specific case of rigid water models like TIP3P or SPC, the iterative SHAKE procedure is computationally wasteful. SETTLE provides an exact, analytical solution to reset the positions and velocities of a three-site water molecule in a single step. By solving the constraint equations directly from the molecular geometry, SETTLE eliminates iteration overhead and is the standard method for maintaining water rigidity in virtually all biomolecular simulations.

05

LINCS: Non-Iterative Linear Constraints

The LINCS (LINear Constraint Solver) algorithm is a non-iterative alternative to SHAKE that resets bonds in a single step using a matrix inversion. After an unconstrained update, LINCS projects the new bond lengths back onto the constraint manifold using a power-series expansion of the inverse constraint coupling matrix. It is significantly faster than SHAKE for large, interconnected constraint networks and is the default constraint algorithm in the GROMACS simulation package.

06

Tolerance and Convergence Failure

SHAKE's iterative nature means it can fail to converge if the constraint network is over-specified or if atoms move too far in a single step. A relative tolerance (typically 10⁻⁴) defines when a bond is considered constrained. If the maximum number of iterations is exceeded, the time step is often rejected and retried with a smaller step. This is a common source of simulation crashes, particularly during energy minimization or when using hydrogen mass repartitioning schemes with aggressive time steps.

CONSTRAINT ALGORITHM COMPARISON

SHAKE vs. RATTLE vs. LINCS

Comparison of the three primary constraint algorithms used in molecular dynamics to freeze high-frequency bond vibrations, enabling larger integration time steps.

FeatureSHAKERATTLELINCS

Integration Scheme

Verlet (positions only)

Velocity Verlet (positions and velocities)

Leap-frog or Velocity Verlet

Constrained Degrees of Freedom

Bond lengths

Bond lengths and velocities

Bond lengths and angles

Iterative Solver

Matrix Inversion Method

Parallelization Efficiency

Low (serial constraints)

Low (serial constraints)

High (linear scaling)

Suitable for Large Biomolecules

Handles Angle Constraints

Typical Implementation

GROMACS (legacy), AMBER

AMBER, CHARMM

GROMACS (default)

Computational Cost Scaling

O(N^2) worst-case

O(N^2) worst-case

O(N)

CONSTRAINT ALGORITHMS

Frequently Asked Questions

Explore the core mechanics and practical applications of the SHAKE algorithm, a foundational constraint method that enables efficient molecular dynamics simulations by freezing high-frequency bond vibrations.

The SHAKE algorithm is an iterative constraint method used in molecular dynamics simulations to reset the positions of atoms involved in rigid bonds after each integration step. It works by applying a corrective force along the bond vector to satisfy a fixed distance constraint, effectively freezing the fastest vibrational degrees of freedom, such as the stretching of bonds involving hydrogen atoms. This allows the simulation to use a larger time step (typically 2 femtoseconds instead of 0.5-1 fs) without sacrificing numerical stability. The algorithm iterates through all constrained bonds until the deviation from the target bond length falls below a specified tolerance, solving a set of coupled constraint equations using a Gauss-Seidel iterative approach. By eliminating the need to explicitly integrate these high-frequency motions, SHAKE dramatically accelerates the sampling of conformational space in biomolecular systems.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.