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 dozens of fixes defined in LAMMPS and new ones can be added; see this section for a discussion.

Fixes perform their operations at different stages of the timestep. If 2 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 doc 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 one of three styles of quantities: global, per-atom, or local, which can be used by other commands or output as described below. 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 displacement vector for each atom since 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 atoms.

Note that a single fix may produces either global or per-atom or local quantities (or none at all), but never more than one of these.

Global, per-atom, and local quantities each come in three kinds: a single scalar value, a vector of values, or a 2d array of values. The doc page for each fix describes the style and kind of values it produces, e.g. a per-atom vector. Some fixes produce more than one kind of a single style, e.g. a global scalar and a global vector.

When a fix quantity is accessed, as in many of the output commands discussed below, it can be 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 -> scalar, array -> vector). Using two brackets reduces the dimension twice (array -> scalar). Thus a command that uses scalar fix values as input can also process elements of a vector or array.

Note that commands and variables which use fix quantities typically do not allow for all kinds, e.g. a command may require a vector of values, not a scalar. This means there is no ambiguity about referring to a fix quantity as f_ID even if it produces, for example, both a scalar and vector. The doc pages for various commands explain the details.


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

See this howto section 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 doc page for individual fixes for further info.


Each fix style has its own documentation page which describes its arguments and what it does, as listed below. Here is an alphabetic list of fix styles available in LAMMPS. They are also given in more compact form in the Fix section of this page.

There are also additional fix styles (not listed here) submitted by users which are included in the LAMMPS distribution. The list of these with links to the individual styles are given in the fix section of this page.

  • adapt - change a simulation parameter over time
  • addforce - add a force to each atom
  • append/atoms - append atoms to a running simulation
  • atom/swap - Monte Carlo atom type swapping
  • aveforce - add an averaged force to each atom
  • ave/atom - compute per-atom time-averaged quantities
  • ave/chunk - compute per-chunk time-averaged quantities
  • ave/correlate - compute/output time correlations
  • ave/histo - compute/output time-averaged histograms
  • ave/time - compute/output global time-averaged quantities
  • balance - perform dynamic load-balancing
  • bond/break - break bonds on the fly
  • bond/create - create bonds on the fly
  • bond/swap - Monte Carlo bond swapping
  • box/relax - relax box size during energy minimization
  • deform - change the simulation box size/shape
  • deposit - add new atoms above a surface
  • drag - drag atoms towards a defined coordinate
  • dt/reset - reset the timestep based on velocity, forces
  • efield - impose electric field on system
  • ehex - ehanced heat exchange algorithm
  • enforce2d - zero out z-dimension velocity and force
  • evaporate - remove atoms from simulation periodically
  • external - callback to an external driver program
  • freeze - freeze atoms in a granular simulation
  • gcmc - grand canonical insertions/deletions
  • gld - generalized Langevin dynamics integrator
  • gravity - add gravity to atoms in a granular simulation
  • halt - terminate a dynamics run or minimization
  • heat - add/subtract momentum-conserving heat
  • indent - impose force due to an indenter
  • latte - wrapper on LATTE density-functional tight-binding code
  • langevin - Langevin temperature control
  • lineforce - constrain atoms to move in a line
  • momentum - zero the linear and/or angular momentum of a group of atoms
  • move - move atoms in a prescribed fashion
  • msst - multi-scale shock technique (MSST) integration
  • neb - nudged elastic band (NEB) spring forces
  • nph - constant NPH time integration via Nose/Hoover
  • nphug - constant-stress Hugoniostat integration
  • nph/asphere - NPH for aspherical particles
  • nph/body - NPH for body particles
  • nph/sphere - NPH for spherical particles
  • npt - constant NPT time integration via Nose/Hoover
  • npt/asphere - NPT for aspherical particles
  • npt/body - NPT for body particles
  • npt/sphere - NPT for spherical particles
  • nve - constant NVE time integration
  • nve/asphere - NVE for aspherical particles
  • nve/asphere/noforce - NVE for aspherical particles without forces”
  • nve/body - NVE for body particles
  • nve/limit - NVE with limited step length
  • nve/line - NVE for line segments
  • nve/noforce - NVE without forces (v only)
  • nve/sphere - NVE for spherical particles
  • nve/tri - NVE for triangles
  • nvt - constant NVT time integration via Nose/Hoover
  • nvt/asphere - NVT for aspherical particles
  • nvt/body - NVT for body particles
  • nvt/sllod - NVT for NEMD with SLLOD equations
  • nvt/sphere - NVT for spherical particles
  • 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
  • planeforce - constrain atoms to move in a plane
  • poems - constrain clusters of atoms to move as coupled rigid bodies
  • pour - pour new atoms/molecules into a granular simulation domain
  • press/berendsen - pressure control by Berendsen barostat
  • print - print text and variables during a simulation
  • property/atom - add customized per-atom values
  • 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/shielded - charge equilibration via shielded method qeq/slater - charge equilibration via Slater method rattle - RATTLE constraints on bonds and/or angles
  • reax/bonds - write out ReaxFF bond information recenter - constrain the center-of-mass position of a group of atoms
  • restrain - constrain a bond, angle, dihedral
  • rigid - constrain one or more clusters of atoms to move as a rigid body with NVE integration
  • rigid/nph - constrain one or more 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/nve - constrain one or more 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/small - constrain many small clusters of atoms to move as a rigid body with NVE integration
  • rigid/small/nph - constrain many small clusters of atoms to move as a rigid body with NPH integration
  • rigid/small/npt - constrain many small clusters of atoms to move as a rigid body with NPT integration
  • rigid/small/nve - constrain many small clusters of atoms to move as a rigid body with alternate NVE integration
  • rigid/small/nvt - constrain many small clusters of atoms to move as a rigid body with NVT integration
  • setforce - set the force on each atom
  • shake - SHAKE constraints on bonds and/or angles
  • 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
  • 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
  • tfmc - perform force-bias Monte Carlo with time-stamped method
  • thermal/conductivity - Muller-Plathe kinetic energy exchange for thermal conductivity calculation
  • tmd - guide a group of atoms to a new configuration
  • ttm - two-temperature model for electronic/atomic coupling
  • tune/kspace - auto-tune KSpace parameters
  • vector - accumulate a global vector every N timesteps
  • viscosity - Muller-Plathe momentum exchange for viscosity calculation
  • viscous - viscous damping for granular simulations
  • wall/colloid - Lennard-Jones wall interacting with finite-size particles
  • wall/gran - frictional wall(s) for granular simulations
  • 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/piston - moving reflective piston wall
  • wall/reflect - reflecting wall(s)
  • wall/region - use region surface as wall
  • wall/srd - slip/no-slip wall for SRD particles

Restrictions

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