lammps/doc/minimize.html

237 lines
11 KiB
HTML

<HTML>
<CENTER><A HREF = "http://lammps.sandia.gov">LAMMPS WWW Site</A> - <A HREF = "Manual.html">LAMMPS Documentation</A> - <A HREF = "Section_commands.html#comm">LAMMPS Commands</A>
</CENTER>
<HR>
<H3>minimize command
</H3>
<P><B>Syntax:</B>
</P>
<PRE>minimize etol ftol maxiter maxeval
</PRE>
<UL><LI>etol = stopping tolerance for energy (unitless)
<LI>ftol = stopping tolerance for force (force units)
<LI>maxiter = max iterations of minimizer
<LI>maxeval = max number of force/energy evaluations
</UL>
<P><B>Examples:</B>
</P>
<PRE>minimize 1.0e-4 1.0e-6 100 1000
minimize 0.0 1.0e-8 1000 100000
</PRE>
<P><B>Description:</B>
</P>
<P>Perform an energy minimization of the system, by iteratively adjusting
atom coordinates. Iterations are terminated when one of the stopping
criteria is satisfied. At that point the configuration will hopefully
be in local potential energy minimum. More precisely, the
configuration should approximate a critical point for the objective
function (see below), which may or may not be a local minimum.
</P>
<P>The minimization algorithm used is set by the
<A HREF = "min_style.html">min_style</A> command. Other options are set by the
<A HREF = "min_modify.html">min_modify</A> command. Minimize commands can be
interspersed with <A HREF = "run.html">run</A> commands to alternate between
relaxation and dynamics. The minimizers bound the distance atoms move
in one iteration, so that you can relax systems with highly overlapped
atoms (large energies and forces) by pushing the atoms off of each
other.
</P>
<P>Alternate means of relaxing a system are to run dynamics with a small
or <A HREF = "fix_nve_limit.html">limited timestep</A>. Or dynamics can be run
using <A HREF = "fix_viscous.html">fix viscous</A> to impose a damping force that
slowly drains all kinetic energy from the system. The <A HREF = "pair_soft.html">pair_style
soft</A> potential can be used to un-overlap atoms while
running dynamics.
</P>
<P>A minimization involves an outer iteration loop which sets the search
direction along which atom coordinates are changed. An inner
iteration is then performed using a line search algorithm. The line
search typically evaluates forces and energies several times to set
new coordinates. Currently, a backtracking algorithm is used which
may not be optimal in terms of the number of force evaulations
performed, but appears to be more robust than previous line searches
we've tried. The backtracking method is described in Nocedal and
Wright's Numerical Optimization (Procedure 3.1 on p 41).
</P>
<P>The objective function being minimized is the total potential energy
of the system as a function of the N atom coordinates:
</P>
<CENTER><IMG SRC = "Eqs/min_energy.jpg">
</CENTER>
<P>where the first term is the sum of all non-bonded <A HREF = "pair_style.html">pairwise
interactions</A> including <A HREF = "kspace_style.html">long-range Coulombic
interactions</A>, the 2nd thru 5th terms are
<A HREF = "bond_style.html">bond</A>, <A HREF = "angle_style.html">angle</A>,
<A HREF = "dihedral_style.html">dihedral</A>, and <A HREF = "improper_style.html">improper</A>
interactions respectively, and the last term is energy due to
<A HREF = "fix.html">fixes</A> which can act as constraints or apply force to atoms,
such as thru interaction with a wall. See the discussion below about
how fix commands affect minimization.
</P>
<P>The starting point for the minimization is the current configuration
of the atoms.
</P>
<HR>
<P>The minimization procedure stops if any of several criteria are met:
</P>
<UL><LI>the change in energy between outer iterations is less than <I>etol</I>
<LI>the 2-norm (length) of the global force vector is less than the <I>ftol</I>
<LI>the line search fails because the step distance backtracks to 0.0
<LI>the number of outer iterations exceeds <I>maxiter</I>
<LI>the number of total force evaluations exceeds <I>maxeval</I>
</UL>
<P>For the first criterion, the specified energy tolerance <I>etol</I> is
unitless; it is met when the energy change between successive
iterations divided by the energy magnitude is less than or equal to
the tolerance. For example, a setting of 1.0e-4 for <I>etol</I> means an
energy tolerance of one part in 10^4.
</P>
<P>For the second criterion, the specified force tolerance <I>ftol</I> is in
force units, since it is the length of the global force vector for all
atoms, e.g. a vector of size 3N for N atoms. Since many of the
components will be near zero after minimization, you can think of
<I>ftol</I> as an upper bound on the final force on any component of any
atom. For example, a setting of 1.0e-4 for <I>ftol</I> means no x, y, or z
component of force on any atom will be larger than 1.0e-4 (in force
units) after minimization.
</P>
<P>Either or both of the <I>etol</I> and <I>ftol</I> values can be set to 0.0, in
which case some other criterion will terminate the minimization.
</P>
<P>During a minimization, the outer iteration count is treated as a
timestep. Output is triggered by this timestep, e.g. thermodynamic
output or dump and restart files.
</P>
<P>Following minimization, a statistical summary is printed that lists
which convergence criterion caused the minimizer to stop, as well as
information about the energy, force, final line search, and and
iteration counts. An example is as follows:
</P>
<PRE>Minimization stats:
Stopping criterion = max iterations
Energy initial, next-to-last, final =
-0.626828169302 -2.82642039062 -2.82643549739
Force two-norm initial, final = 2052.1 91.9642
Force max component initial, final = 346.048 9.78056
Final line search alpha, max atom move = 2.23899e-06 2.18986e-05
Iterations, force evaluations = 2000 12724
</PRE>
<P>The 3 energy values are for before and after the minimization and on
the next-to-last iteration. This is what the <I>etol</I> parameter checks.
</P>
<P>The two-norm force values are the length of the global force vector
before and after minimization. This is what the <I>ftol</I> parameter
checks.
</P>
<P>The max-component force values are the absolute value of the largest
component (x,y,z) in the global force vector.
</P>
<P>The alpha parameter for the line-search, when multiplied by the max
force component (on the last iteration), gives the max distance any
atom moved during the last iteration. Alpha will be 0.0 if the line
search could not reduce the energy. Even if alpha is non-zero, if the
"max atom move" distance is tiny compared to typical atom coordinates,
then it is possible the last iteration effectively caused no atom
movement and thus the evaluated energy did not change and the
minimizer terminated. Said another way, even with non-zero forces,
it's possible the effect of those forces is to move atoms a distance
less than machine precision, so that the energy cannot be further
reduced.
</P>
<P>The iterations and force evaluation values are what is checked by the
<I>maxiter</I> and <I>maxeval</I> parameters.
</P>
<HR>
<P>IMPORTANT NOTE: There are several force fields in LAMMPS which have
discontinuities or other approximations which may prevent you from
performing an energy minimization to high tolerances. For example,
you should use a <A HREF = "pair_style.html">pair style</A> that goes to 0.0 at the
cutoff distance when performing minimization (even if you later change
it when running dynamics). If you do not do this, the total energy of
the system will have discontinuities when the relative distance
between any pair of atoms changes from cutoff+epsilon to
cutoff-epsilon and the minimizer may behave poorly. Some of the
manybody potentials use splines and other internal cutoffs that
inherently have this problem. The <A HREF = "kspace_style.html">long-range Coulombic
styles</A> (PPPM, Ewald) are approximate to within the
user-specified tolerance, which means their energy and forces may not
agree to a higher precision than the Kspace-specified tolerance. In
all these cases, the minimizer may give up and stop before finding a
minimum to the specified energy or force tolerance.
</P>
<P>Note that a cutoff Lennard-Jones potential (and others) can be shifted
so that its energy is 0.0 at the cutoff via the
<A HREF = "pair_modify.html">pair_modify</A> command. See the doc pages for
inidividual <A HREF = "pair_style.html">pair styles</A> for details. Note that
Coulombic potentials always have a cutoff, unless versions with a
long-range component are used (e.g. <A HREF = "pair_lj.html">pair_style
lj/cut/coul/long</A>). The CHARMM potentials go to 0.0 at
the cutoff (e.g. <A HREF = "pair_charmm.html">pair_style lj/charmm/coul/charmm</A>),
as do the GROMACS potentials (e.g. <A HREF = "pair_gromacs.html">pair_style
lj/gromacs</A>).
</P>
<P>If a soft potential (<A HREF = "pair_soft.html">pair_style soft</A>) is used the
Astop value is used for the prefactor (no time dependence).
</P>
<P>The <A HREF = "fix_box_relax.html">fix box/relax</A> command can be used to apply an
external pressure to the simulation box and allow it to shrink/expand
during the minimization.
</P>
<P>Only a few other fixes (typically those that apply force constraints)
are invoked during minimization. See the doc pages for individual
<A HREF = "fix.html">fix</A> commands to see which ones are relevant.
</P>
<P>IMPORTANT NOTE: Some fixes which are invoked during minimization have
an associated potential energy. For that energy to be included in the
total potential energy of the system (the quantity being minimized),
you MUST enable the <A HREF = "fix_modify.html">fix_modify</A> <I>energy</I> option for
that fix. The doc pages for individual <A HREF = "fix.html">fix</A> commands
specify if this should be done.
</P>
<HR>
<P><B>Restrictions:</B>
</P>
<P>Features that are not yet implemented are listed here, in case someone
knows how they could be coded:
</P>
<P>It is an error to use <A HREF = "fix_shake.html">fix shake</A> with minimization
because it turns off bonds that should be included in the potential
energy of the system. The effect of a fix shake can be approximated
during a minimization by using stiff spring constants for the bonds
and/or angles that would normally be constrained by the SHAKE
algorithm.
</P>
<P><A HREF = "fix_rigid.html">Fix rigid</A> is also not supported by minimization. It
is not an error to have it defined, but the energy minimization will
not keep the defined body(s) rigid during the minimization. Note that
if bonds, angles, etc internal to a rigid body have been turned off
(e.g. via <A HREF = "neigh_modify.html">neigh_modify exclude</A>), they will not
contribute to the potential energy which is probably not what is
desired.
</P>
<P>Pair potentials that produce torque on a particle (e.g. <A HREF = "pair_gran.html">granular
potentials</A> or the <A HREF = "pair_gayberne.html">GayBerne
potential</A> for ellipsoidal particles) are not
relaxed by a minimization. More specifically, radial relaxations are
induced, but no rotations are induced by a minimization, so such a
system will not fully relax.
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "min_modify.html">min_modify</A>, <A HREF = "min_style.html">min_style</A>,
<A HREF = "run_style.html">run_style</A>
</P>
<P><B>Default:</B> none
</P>
</HTML>