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.
Glossary
SHAKE Algorithm

What is the SHAKE Algorithm?
A foundational numerical method for enforcing rigid bond constraints in molecular dynamics simulations, enabling larger integration time steps.
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.
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.
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.
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.
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.
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.
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.
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.
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.
| Feature | SHAKE | RATTLE | LINCS |
|---|---|---|---|
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) |
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core algorithms and concepts that underpin constrained molecular dynamics simulations, forming the computational toolkit alongside the SHAKE algorithm.
Verlet Integration
The foundational symplectic integrator for Newton's equations of motion. The Velocity Verlet variant calculates positions and velocities at the same time step, providing excellent energy conservation. SHAKE operates directly on the positions generated by this integrator, resetting bond lengths before the velocity update.
- Standard time step: 1-2 fs without constraints
- Error per step: O(Δt⁴) for positions
- Symplectic nature preserves phase space volume
Lagrange Multipliers
The mathematical formalism underlying holonomic constraint enforcement. SHAKE iteratively solves for the undetermined multipliers that represent the constraint forces required to maintain fixed bond lengths. Each multiplier corresponds to the magnitude of the force acting along a specific rigid bond vector.
- Converts constrained dynamics to an unconstrained optimization problem
- RATTLE extends this to velocity constraints for kinetic energy consistency
- Direct matrix inversion is avoided via iterative Gauss-Seidel relaxation
LINCS Algorithm
A non-iterative constraint solver that resets bonds in a single pass using a power series expansion of the inverse constraint matrix. Significantly faster than SHAKE for large molecules and parallelizes efficiently on GPUs. The default constraint algorithm in GROMACS for bonds involving hydrogen atoms.
- Expansion order: typically 4-8 terms
- Handles bond-angle coupling via matrix inversion
- Preferred for GPU-accelerated MD due to deterministic execution time
SETTLE Algorithm
An analytical constraint solver specifically for rigid water models (TIP3P, SPC/E). Solves the constraint equations exactly without iteration by treating the water molecule as a rigid triangle. Vastly more efficient than applying SHAKE to each water bond and angle individually.
- Constrains two O-H bonds and one H-O-H angle simultaneously
- Closed-form solution using quaternion rotation
- Essential for simulations where water constitutes >80% of atoms

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us