\(\renewcommand{\AA}{\text{Å}}\)

# fix command

## Syntax

```
fix ID group-ID style args
```

ID = user-assigned name for the fix

group-ID = ID of the group of atoms to apply the fix to

style = one of a long list of possible style names (see below)

args = arguments used by a particular style

## Examples

```
fix 1 all nve
fix 3 all nvt temp 300.0 300.0 0.01
fix mine top setforce 0.0 NULL 0.0
```

## Description

Set a fix that will be applied to a group of atoms. In LAMMPS, a “fix” is any operation that is applied to the system during timestepping or minimization. Examples include updating of atom positions and velocities due to time integration, controlling temperature, applying constraint forces to atoms, enforcing boundary conditions, computing diagnostics, etc. There are hundreds of fixes defined in LAMMPS and new ones can be added; see the Modify page for details.

Fixes perform their operations at different stages of the timestep. If two or more fixes operate at the same stage of the timestep, they are invoked in the order they were specified in the input script.

The ID of a fix can only contain alphanumeric characters and underscores.

Fixes can be deleted with the unfix command.

Note

The unfix command is the only way to turn off a fix; simply specifying a new fix with a similar style will not turn off the first one. This is especially important to realize for integration fixes. For example, using a fix nve command for a second run after using a fix nvt command for the first run will not cancel out the NVT time integration invoked by the “fix nvt” command. Thus, two time integrators would be in place!

If you specify a new fix with the same ID and style as an existing fix, the old fix is deleted and the new one is created (presumably with new settings). This is the same as if an “unfix” command were first performed on the old fix, except that the new fix is kept in the same order relative to the existing fixes as the old one originally was. Note that this operation also wipes out any additional changes made to the old fix via the fix_modify command.

The fix modify command allows settings for some fixes to be reset. See the page for individual fixes for details.

Some fixes store an internal “state” which is written to binary restart files via the restart or write_restart commands. This allows the fix to continue on with its calculations in a restarted simulation. See the read_restart command for info on how to re-specify a fix in an input script that reads a restart file. See the doc pages for individual fixes for info on which ones can be restarted.

Some fixes calculate and store any of four *styles* of quantities:
global, per-atom, local, or per-grid.

A global quantity is one or more system-wide values, e.g. the energy of a wall interacting with particles. A per-atom quantity is one or more values per atom, e.g. the original coordinates of each atom at time 0. Per-atom values are set to 0.0 for atoms not in the specified fix group. Local quantities are calculated by each processor based on the atoms it owns, but there may be zero or more per atom, e.g. values for each bond. Per-grid quantities are calculated on a regular 2d or 3d grid which overlays a 2d or 3d simulation domain. The grid points and the data they store are distributed across processors; each processor owns the grid points which fall within its subdomain.

As a general rule of thumb, fixes that produce per-atom quantities
have the word “atom” at the end of their style, e.g. *ave/atom*.
Fixes that produce local quantities have the word “local” at the end
of their style, e.g. *store/local*. Fixes that produce per-grid
quantities have the word “grid” at the end of their style,
e.g. *ave/grid*.

Global, per-atom, local, and per-grid quantities can also be of three
*kinds*: a single scalar value (global only), a vector of values, or a
2d array of values. For per-atom, local, and per-grid quantities, a
“vector” means a single value for each atom, each local entity
(e.g. bond), or grid cell. Likewise an “array”, means multiple values
for each atom, each local entity, or each grid cell.

Note that a single fix can produce any combination of global, per-atom, local, or per-grid values. Likewise it can produce any combination of scalar, vector, or array output for each style. The exception is that for per-atom, local, and per-grid output, either a vector or array can be produced, but not both. The doc page for each fix explains the values it produces, if any.

When a fix output is accessed by another input script command it is referenced via the following bracket notation, where ID is the ID of the fix:

f_ID |
entire scalar, vector, or array |

f_ID[I] |
one element of vector, one column of array |

f_ID[I][J] |
one element of array |

In other words, using one bracket reduces the dimension of the quantity once (vector \(\to\) scalar, array \(\to\) vector). Using two brackets reduces the dimension twice (array \(\to\) scalar). Thus, for example, a command that uses global scalar fix values as input can also process elements of a vector or array. Depending on the command, this can either be done directly using the syntax in the table, or by first defining a variable of the appropriate style to store the quantity, then using the variable as an input to the command.

Note that commands and variables which take fix outputs as input typically do not allow for all styles and kinds of data (e.g., a command may require global but not per-atom values, or it may require a vector of values, not a scalar). This means there is typically no ambiguity about referring to a fix output as c_ID even if it produces, for example, both a scalar and vector. The doc pages for various commands explain the details, including how any ambiguities are resolved.

In LAMMPS, the values generated by a fix can be used in several ways:

Global values can be output via the thermo_style custom or fix ave/time command. Alternatively, the values can be referenced in an equal-style variable command.

Per-atom values can be output via the dump custom command, or they can be time-averaged via the fix ave/atom command or reduced by the compute reduce command. Alternatively, per-atom values can be referenced in an atom-style variable.

Local values can be reduced by the compute reduce command or histogrammed by the fix ave/histo command. They can also be output by the dump local command.

See the Howto output page for a summary of various LAMMPS output options, many of which involve fixes.

The results of fixes that calculate global quantities can be either “intensive” or “extensive” values. Intensive means the value is independent of the number of atoms in the simulation (e.g., temperature). Extensive means the value scales with the number of atoms in the simulation (e.g., total rotational kinetic energy). Thermodynamic output will normalize extensive values by the number of atoms in the system, depending on the “thermo_modify norm” setting. It will not normalize intensive values. If a fix value is accessed in another way (e.g., by a variable), you may want to know whether it is an intensive or extensive value. See the page for individual fix styles for further info.

Each fix style has its own page that describes its arguments and what it does, as listed below. Here is an alphabetical list of fix styles available in LAMMPS. They are also listed in more compact form on the Commands fix doc page.

There are also additional accelerated fix styles included in the LAMMPS distribution for faster performance on CPUs, GPUs, and KNLs. The individual style names on the Commands fix doc page are followed by one or more of (g,i,k,o,t) to indicate which accelerated styles exist.

accelerate/cos - apply cosine-shaped acceleration to atoms

acks2/reaxff - apply ACKS2 charge equilibration

adapt - change a simulation parameter over time

adapt/fep - enhanced version of fix adapt

addforce - add a force to each atom

add/heat - add a heat flux to each atom

addtorque - add a torque to a group of atoms

alchemy - perform an “alchemical transformation” between two partitions

amoeba/bitorsion - torsion/torsion terms in AMOEBA force field

amoeba/pitorsion - 6-body terms in AMOEBA force field

append/atoms - append atoms to a running simulation

atc - initiates a coupled MD/FE simulation

atom/swap - Monte Carlo atom type swapping

ave/atom - compute per-atom time-averaged quantities

ave/chunk - compute per-chunk time-averaged quantities

ave/correlate - compute/output time correlations

ave/correlate/long - alternative to ave/correlate that allows efficient calculation over long time windows

ave/grid - compute per-grid time-averaged quantities

ave/histo - compute/output time-averaged histograms

ave/histo/weight - weighted version of fix ave/histo

ave/time - compute/output global time-averaged quantities

aveforce - add an averaged force to each atom

balance - perform dynamic load-balancing

brownian - overdamped translational brownian motion

brownian/asphere - overdamped translational and rotational brownian motion for ellipsoids

brownian/sphere - overdamped translational and rotational brownian motion for spheres

bocs - NPT style time integration with pressure correction

bond/break - break bonds on the fly

bond/create - create bonds on the fly

bond/create/angle - create bonds on the fly with angle constraints

bond/react - apply topology changes to model reactions

bond/swap - Monte Carlo bond swapping

box/relax - relax box size during energy minimization

charge/regulation - Monte Carlo sampling of charge regulation

cmap - CMAP torsion/torsion terms in CHARMM force field

colvars - interface to the collective variables “Colvars” library

controller - apply control loop feedback mechanism

damping/cundall - Cundall non-viscous damping for granular simulations

deform - change the simulation box size/shape

deform/pressure - change the simulation box size/shape with additional loading conditions

deposit - add new atoms above a surface

dpd/energy - constant energy dissipative particle dynamics

drag - drag atoms towards a defined coordinate

drude - part of Drude oscillator polarization model

drude/transform/direct - part of Drude oscillator polarization model

drude/transform/inverse - part of Drude oscillator polarization model

dt/reset - reset the timestep based on velocity, forces

edpd/source - add heat source to eDPD simulations

efield - impose electric field on system

efield/tip4p - impose electric field on system with TIP4P molecules

ehex - enhanced heat exchange algorithm

electrode/conp - impose electric potential

electrode/conq - impose total electric charge

electrode/thermo - apply thermo-potentiostat

electron/stopping - electronic stopping power as a friction force

electron/stopping/fit - electronic stopping power as a friction force

enforce2d - zero out

*z*-dimension velocity and forceeos/cv - applies a mesoparticle equation of state to relate the particle internal energy to the particle internal temperature

eos/table - applies a tabulated mesoparticle equation of state to relate the particle internal energy to the particle internal temperature

eos/table/rx - applies a tabulated mesoparticle equation of state to relate the concentration-dependent particle internal energy to the particle internal temperature

evaporate - remove atoms from simulation periodically

external - callback to an external driver program

ffl - apply a Fast-Forward Langevin equation thermostat

filter/corotate - implement corotation filter to allow larger timesteps with r-RESPA

flow/gauss - Gaussian dynamics for constant mass flux

freeze - freeze atoms in a granular simulation

gcmc - grand canonical insertions/deletions

gld - generalized Langevin dynamics integrator

gle - generalized Langevin equation thermostat

gravity - add gravity to atoms in a granular simulation

grem - implements the generalized replica exchange method

halt - terminate a dynamics run or minimization

heat - add/subtract momentum-conserving heat

heat/flow - plain time integration of heat flow with per-atom temperature updates

hyper/global - global hyperdynamics

hyper/local - local hyperdynamics

imd - implements the “Interactive MD” (IMD) protocol

indent - impose force due to an indenter

ipi - enable LAMMPS to run as a client for i-PI path-integral simulations

langevin - Langevin temperature control

langevin/drude - Langevin temperature control of Drude oscillators

langevin/eff - Langevin temperature control for the electron force field model

langevin/spin - Langevin temperature control for a spin or spin-lattice system

lb/fluid - lattice-Boltzmann fluid on a uniform mesh

lb/momentum - fix momentum replacement for use with a lattice-Boltzmann fluid

lb/viscous - fix viscous replacement for use with a lattice-Boltzmann fluid

lineforce - constrain atoms to move in a line

manifoldforce - restrain atoms to a manifold during minimization

mdi/qm - LAMMPS operates as a client for a quantum code via the MolSSI Driver Interface (MDI)

mdi/qmmm - LAMMPS operates as client for QM/MM simulation with a quantum code via the MolSSI Driver Interface (MDI)

meso/move - move mesoscopic SPH/SDPD particles in a prescribed fashion

mol/swap - Monte Carlo atom type swapping with a molecule

momentum - zero the linear and/or angular momentum of a group of atoms

momentum/chunk - zero the linear and/or angular momentum of a chunk of atoms

move - move atoms in a prescribed fashion

msst - multi-scale shock technique (MSST) integration

mvv/dpd - DPD using the modified velocity-Verlet integration algorithm

mvv/edpd - constant energy DPD using the modified velocity-Verlet algorithm

mvv/tdpd - constant temperature DPD using the modified velocity-Verlet algorithm

neb - nudged elastic band (NEB) spring forces

neb/spin - nudged elastic band (NEB) spring forces for spins

nonaffine/displacement - calculate nonaffine displacement of atoms

nph - constant NPH time integration via Nose/Hoover

nph/asphere - NPH for aspherical particles

nph/body - NPH for body particles

nph/eff - NPH for nuclei and electrons in the electron force field model

nph/sphere - NPH for spherical particles

nphug - constant-stress Hugoniostat integration

npt - constant NPT time integration via Nose/Hoover

npt/asphere - NPT for aspherical particles

npt/body - NPT for body particles

npt/cauchy - NPT with Cauchy stress

npt/eff - NPT for nuclei and electrons in the electron force field model

npt/sphere - NPT for spherical particles

npt/uef - NPT style time integration with diagonal flow

numdiff - numerically approximate atomic forces using finite energy differences

numdiff/virial - numerically approximate virial stress tensor using finite energy differences

nve - constant NVE time integration

nve/asphere - NVE for aspherical particles

nve/asphere/noforce - NVE for aspherical particles without forces

nve/awpmd - NVE for the Antisymmetrized Wave Packet Molecular Dynamics model

nve/body - NVE for body particles

nve/dot - rigid body constant energy time integrator for coarse grain models

nve/dotc/langevin - Langevin style rigid body time integrator for coarse grain models

nve/eff - NVE for nuclei and electrons in the electron force field model

nve/limit - NVE with limited step length

nve/line - NVE for line segments

nve/manifold/rattle - NVE time integration for atoms constrained to a curved surface (manifold)

nve/noforce - NVE without forces (update positions only)

nve/sphere - NVE for spherical particles

nve/bpm/sphere - NVE for spherical particles used in the BPM package

nve/spin - NVE for a spin or spin-lattice system

nve/tri - NVE for triangles

nvk - constant kinetic energy time integration

nvt - NVT time integration via Nose/Hoover

nvt/asphere - NVT for aspherical particles

nvt/body - NVT for body particles

nvt/eff - NVE for nuclei and electrons in the electron force field model

nvt/manifold/rattle - NVT time integration for atoms constrained to a curved surface (manifold)

nvt/sllod - NVT for NEMD with SLLOD equations

nvt/sllod/eff - NVT for NEMD with SLLOD equations for the electron force field model

nvt/sphere - NVT for spherical particles

nvt/uef - NVT style time integration with diagonal flow

oneway - constrain particles on move in one direction

orient/bcc - add grain boundary migration force for BCC

orient/fcc - add grain boundary migration force for FCC

orient/eco - add generalized grain boundary migration force

pafi - constrained force averages on hyper-planes to compute free energies (PAFI)

pair - access per-atom info from pair styles

phonon - calculate dynamical matrix from MD simulations

pimd/langevin - Feynman path-integral molecular dynamics with stochastic thermostat

pimd/nvt - Feynman path-integral molecular dynamics with Nose-Hoover thermostat

planeforce - constrain atoms to move in a plane

plumed - wrapper on PLUMED free energy library

poems - constrain clusters of atoms to move as coupled rigid bodies

polarize/bem/gmres - compute induced charges at the interface between impermeable media with different dielectric constants with generalized minimum residual (GMRES)

polarize/bem/icc - compute induced charges at the interface between impermeable media with different dielectric constants with the successive over-relaxation algorithm

polarize/functional - compute induced charges at the interface between impermeable media with different dielectric constants with the energy variational approach

pour - pour new atoms/molecules into a granular simulation domain

precession/spin - apply a precession torque to each magnetic spin

press/berendsen - pressure control by Berendsen barostat

press/langevin - pressure control by Langevin barostat

print - print text and variables during a simulation

propel/self - model self-propelled particles

property/atom - add customized per-atom values

python/invoke - call a Python function during a simulation

python/move - move particles using a Python function during a simulation run

qbmsst - quantum bath multi-scale shock technique time integrator

qeq/comb - charge equilibration for COMB potential

qeq/dynamic - charge equilibration via dynamic method

qeq/fire - charge equilibration via FIRE minimizer

qeq/point - charge equilibration via point method

qeq/reaxff - charge equilibration for ReaxFF potential

qeq/shielded - charge equilibration via shielded method

qeq/slater - charge equilibration via Slater method

qmmm - functionality to enable a quantum mechanics/molecular mechanics coupling

qtb - implement quantum thermal bath scheme

rattle - RATTLE constraints on bonds and/or angles

reaxff/bonds - write out ReaxFF bond information

reaxff/species - write out ReaxFF molecule information

recenter - constrain the center-of-mass position of a group of atoms

restrain - constrain a bond, angle, dihedral

rheo - integrator for the RHEO package

rheo/thermal - thermal integrator for the RHEO package

rheo/oxidation - create oxidation bonds for the RHEO package

rheo/pressure - pressure calculation for the RHEO package

rheo/viscosity - viscosity calculation for the RHEO package

rhok - add bias potential for long-range ordered systems

rigid - constrain one or more clusters of atoms to move as a rigid body with NVE integration

rigid/meso - constrain clusters of mesoscopic SPH/SDPD particles to move as a rigid body

rigid/nph - constrain one or more clusters of atoms to move as a rigid body with NPH integration

rigid/nph/small - constrain many small clusters of atoms to move as a rigid body with NPH integration

rigid/npt - constrain one or more clusters of atoms to move as a rigid body with NPT integration

rigid/npt/small - constrain many small clusters of atoms to move as a rigid body with NPT integration

rigid/nve - constrain one or more clusters of atoms to move as a rigid body with alternate NVE integration

rigid/nve/small - constrain many small clusters of atoms to move as a rigid body with alternate NVE integration

rigid/nvt - constrain one or more clusters of atoms to move as a rigid body with NVT integration

rigid/nvt/small - constrain many small clusters of atoms to move as a rigid body with NVT integration

rigid/small - constrain many small clusters of atoms to move as a rigid body with NVE integration

rx - solve reaction kinetic ODEs for a defined reaction set

saed/vtk - time-average the intensities from compute saed

setforce - set the force on each atom

setforce/spin - set magnetic precession vectors on each atom

sgcmc - fix for hybrid semi-grand canonical MD/MC simulations

shake - SHAKE constraints on bonds and/or angles

shardlow - integration of DPD equations of motion using the Shardlow splitting

smd - applied a steered MD force to a group

smd/adjust_dt - calculate a new stable time increment for use with SMD integrators

smd/integrate_tlsph - explicit time integration with total Lagrangian SPH pair style

smd/integrate_ulsph - explicit time integration with updated Lagrangian SPH pair style

smd/move_tri_surf - update position and velocity near rigid surfaces using SPH integrators

smd/setvel - sets each velocity component, ignoring forces, for Smooth Mach Dynamics

smd/wall_surface - create a rigid wall with a triangulated surface for use in Smooth Mach Dynamics

sph - time integration for SPH/DPDE particles

sph/stationary - update energy and density but not position or velocity in Smooth Particle Hydrodynamics

spring - apply harmonic spring force to group of atoms

spring/chunk - apply harmonic spring force to each chunk of atoms

spring/rg - spring on radius of gyration of group of atoms

spring/self - spring from each atom to its origin

srd - stochastic rotation dynamics (SRD)

store/force - store force on each atom

store/state - store attributes for each atom

tdpd/source - add external concentration source

temp/berendsen - temperature control by Berendsen thermostat

temp/csld - canonical sampling thermostat with Langevin dynamics

temp/csvr - canonical sampling thermostat with Hamiltonian dynamics

temp/rescale - temperature control by velocity rescaling

temp/rescale/eff - temperature control by velocity rescaling in the electron force field model

tfmc - perform force-bias Monte Carlo with time-stamped method

tgnvt/drude - NVT time integration for Drude polarizable model via temperature-grouped Nose-Hoover

tgnpt/drude - NPT time integration for Drude polarizable model via temperature-grouped Nose-Hoover

thermal/conductivity - Mueller-Plathe kinetic energy exchange for thermal conductivity calculation

ti/spring - perform thermodynamic integration between a solid and an Einstein crystal

tmd - guide a group of atoms to a new configuration

ttm - two-temperature model for electronic/atomic coupling (replicated grid)

ttm/grid - two-temperature model for electronic/atomic coupling (distributed grid)

ttm/mod - enhanced two-temperature model with additional options

tune/kspace - auto-tune \(k\)-space parameters

vector - accumulate a global vector every

*N*timestepsviscosity - Mueller-Plathe momentum exchange for viscosity calculation

viscous - viscous damping for granular simulations

viscous/sphere - viscous damping on angular velocity for granular simulations

wall/body/polygon - time integration for body particles of style rounded/polygon

wall/body/polyhedron - time integration for body particles of style rounded/polyhedron

wall/colloid - Lennard-Jones wall interacting with finite-size particles

wall/ees - wall for ellipsoidal particles

wall/flow - flow boundary conditions

wall/gran - frictional wall(s) for granular simulations

wall/gran/region - fix wall/region equivalent for use with granular particles

wall/harmonic - harmonic spring wall

wall/lj1043 - Lennard-Jones 10–4–3 wall

wall/lj126 - Lennard-Jones 12–6 wall

wall/lj93 - Lennard-Jones 9–3 wall

wall/lepton - Custom Lepton expression wall

wall/morse - Morse potential wall

wall/piston - moving reflective piston wall

wall/reflect - reflecting wall(s)

wall/reflect/stochastic - reflecting wall(s) with finite temperature

wall/region - use region surface as wall

wall/region/ees - use region surface as wall for ellipsoidal particles

wall/srd - slip/no-slip wall for SRD particles

wall/table - Tabulated potential wall wall

widom - Widom insertions of atoms or molecules

## Restrictions

Some fix styles are part of specific packages. They are only enabled if LAMMPS was built with that package. See the Build package page for more info. The doc pages for individual fixes tell if it is part of a package.

## Default

none