%
% $Id: tropt.tex 19708 2010-10-29 18:04:21Z d3y133 $
%
\label{sec:tropt}

The TROPT module is one of three drivers (see Section \ref{sec:stepper}
for documentation on STEPPER and Section \ref{sec:driver} for documentation on DRIVER) 
to perform a geometry optimization
function on the molecule defined by input using the \verb+GEOMETRY+
directive (see Section \ref{sec:geom}).  Geometry optimization is
either an energy minimization or a transition state optimization.
The algorithm programmed in TROPT is a trust region quasi-newton optimization
and approximate energy Hessian updates.

TROPT is {\bf not} selected by default out of the two available modules to
perform geometry optimization.  In order to force use of TROPT (e.g.,
because a previous optimization used STEPPER or DRIVER) provide a TROPT input
block (below) --- even an empty block will force use of TROPT.

Optional input for this module is specified within the compound
directive,
\begin{verbatim}
  TROPT 
    (LOOSE || DEFAULT || TIGHT)
    GMAX <real value>
    GRMS <real value>
    XMAX <real value>
    XRMS <real value>

    OPTTOL <real opttol default 3e-4>

    EPREC <real eprec default 1e-7>

    TRUST <real trust default 0.3>

    CLEAR
    REDOAUTOZ

    INHESS <integer inhess default 0>

    (MODDIR || VARDIR) <integer dir default 0>
    (FIRSTNEG || NOFIRSTNEG)

    MAXITER <integer maxiter default 20>

    BSCALE <real BSCALE default 1.0>
    ASCALE <real ASCALE default 0.25>
    TSCALE <real TSCALE default 0.1>
    HSCALE <real HSCALE default 1.0>
   
    PRINT ...

    XYZ [<string xyz default $file_prefix$>]
    NOXYZ

  END
\end{verbatim}

\sloppy

\section{Convergence criteria}

\begin{verbatim}
    (LOOSE || DEFAULT || TIGHT)
    GMAX <real value>
    GRMS <real value>
    XMAX <real value>
    XRMS <real value>
    
    OPTTOL  <real value>
    
\end{verbatim}

The defaults may be used, or the directives \verb+LOOSE+,
\verb+DEFAULT+, or \verb+TIGHT+ specified to use standard sets of
values, or the individual criteria adjusted.  All criteria are in
atomic units.
\verb+GMAX+ and \verb+GRMS+ control the maximum and root mean square
gradient in the coordinates being used (Z-matrix, redundant internals,
or Cartesian).  \verb+XMAX+ and \verb+XRMS+ control the maximum and
root mean square of the Cartesian step. 

\begin{verbatim}
                  LOOSE    DEFAULT    TIGHT
         GMAX   0.0045d0   0.00045   0.000015   
         GRMS   0.0030d0   0.00030   0.00001
         XMAX   0.0054d0   0.00180   0.00006
         XRMS   0.0036d0   0.00120   0.00004
\end{verbatim}

Additionally the user may request a specific value for the tolerance with the keyword \verb+OPTTOL+ which will couple all the convergence criteria in the following way:

\begin{verbatim}
         GRMS   1.0*OPTTOL
         GMAX   1.5*OPTTOL
         XRMS   4.0*OPTTOL
         XMAX   6.0*OPTTOL
\end{verbatim}

Note that GMAX and GRMS used for convergence of geometry may significantly vary in 
different coordinate systems such as Z-matrix, redundant internals, or Cartesian. 
The coordinate system is defined in the input file (default is Z-matrix). 
Therefore the choice of coordinate system may slightly affect converged energy. 
Although in most cases XMAX and XRMS are last to converge which are always done 
in Cartesian coordinates, which insures convergence to the same geometry in 
different coordinate systems.


The old criterion may be recovered with the input
\begin{verbatim}
   gmax 0.0008; grms 1; xrms 1; xmax 1
\end{verbatim}

\section{Available precision}
\label{sec:tropt:eprec}

\begin{verbatim}
    EPREC <real eprec default 1e-7>
\end{verbatim}

In performing a trust region optimization the precision of the energy is coupled to the convergence criteria.
As mentioned above in most cases XMAX and XRMS are last to converge, thus, 
an accelerated converge is triggered in TROPT when GMAX and GRMS are already converged and the corresponding energy change with respect to the previous point is below the EPREC threshold, then, the structure is treated as optimized. This is used as an accelerated convergence criteria to avoid long tail in the optimization process. 
This will increase the speed of an optimization in most of the cases but it will 
be somehow cumbersome when dealing with flat energy surfaces, in this case a more tight EPREC value is recommended.
Note that the default EPREC for DFT calculations is 5e-6 instead of 1e-7.

\section{Controlling the step length}

\begin{verbatim}
    TRUST <real trust default 0.3>
\end{verbatim}

A dynamic trust radius (\verb+trust+) is used to control the step during
optimization processes both minimization and saddle-point searches.  
It defaults to 0.3 for minimizations and 0.1
for saddle-point searches.  

\section{Backstepping in TROPT}
If a step taken during the optimization is too large or in the wrong direction (e.g., the step causes the energy to go up for a minimization), the TROPT optimizer will automatically ``backstep'' and reduce the current value of the trust radius in order to avoid a permanent ``backsteping''.

\section{Maximum number of steps}

\begin{verbatim}
    MAXITER <integer maxiter default 20>
\end{verbatim}

By default at most 20 geometry optimization steps will be taken,
but this may be modified with this directive.

\section{Discard restart information}
\begin{verbatim}
    CLEAR
\end{verbatim}

By default TROPT reuses Hessian information from a previous
optimization, and, to facilitate a restart also stores which mode is
being followed for a saddle-point search.  This option deletes all
restart data.

\section{Regenerate internal coordinates}

\begin{verbatim}
    REDOAUTOZ
\end{verbatim}

Deletes Hessian data and regenerates internal coordinates at the
current geometry.  Useful if there has been a large change in the
geometry that has rendered the current set of coordinates invalid or
non-optimal.

\section{Initial Hessian}
\begin{verbatim}
    INHESS <integer inhess default 0>
\end{verbatim}

\begin{itemize}
\item  0 = Default ... use restart data if available, otherwise use diagonal guess.
\item  1 = Use diagonal initial guess.
\item  2 = Use restart data if available, otherwise transform
Cartesian Hessian from previous frequency calculation.
\end{itemize}


In addition, the diagonal elements of the initial Hessian for
internal coordinates may be scaled using separate factors for
bonds, angles and torsions with the following
\begin{verbatim}
    BSCALE <real bscale default 1.0>
    ASCALE <real ascale default 0.25>
    TSCALE <real tscale default 0.1>
\end{verbatim}
These values typically give a two-fold speedup over unit values, based
on about 100 test cases up to 15 atoms using 3-21g and 6-31g* SCF.
However, if doing many optimizations on physically similar systems it
may be worth fine tuning these parameters.

Finally, the entire Hessian from any source may be scaled
by a factor using the directive
\begin{verbatim}
    HSCALE <real hscale default 1.0>
\end{verbatim}
It might be of utility, for instance, when computing an initial
Hessian using SCF to start a large MP2 optimization.  The SCF
vibrational modes are expected to be stiffer than the MP2, so scaling
the initial Hessian by a number less than one might be beneficial.


\section{Mode or variable to follow to saddle point}

\begin{verbatim}
    (MODDIR || VARDIR) <integer dir default 0>
    (FIRSTNEG || NOFIRSTNEG)
\end{verbatim}

When searching for a transition state the program, by default,
will take an initial step uphill and then do mode following
using a fuzzy maximum overlap (the lowest eigen-mode with an
overlap with the previous search direction of 0.7 times the
maximum overlap is selected).  Once a negative eigen-value
is found, that mode is followed regardless of overlap.

The initial uphill step is appropriate if the gradient points roughly
in the direction of the saddle point, such as might be the case if a
constrained optimization was performed at the starting geometry.
Alternatively, the initial search direction may be chosen to be along
a specific internal variable (using the directive
\verb+VARDIR+) or along a specific eigen-mode (using \verb+MODDIR+).
Following a variable might be valuable if the initial gradient is
either very small or very large.  Note that the eigen-modes in the
optimizer have next-to-nothing to do with the output from a frequency
calculation.  You can examine the eigen-modes used by the optimizer
with

\begin{verbatim}
         tropt; print hvecs; end
\end{verbatim}

The selection of the first negative mode is usually a good choice if
the search is started in the vicinity of the transition state and the
initial search direction is satisfactory.  However, sometimes the
first negative mode might not be the one of interest (e.g., transverse
to the reaction direction).  If \verb+NOFIRSTNEG+ is specified, the
code will not take the first negative direction and will continue doing
mode-following until that mode goes negative.

\section{Optimization history as XYZ file}

\begin{verbatim}
    XYZ [<string xyz default $fileprefix>]
    NOXYZ
\end{verbatim}

The \verb+XYZ+ directive causes the geometry at each step 
to be output into file in the permanent directory in XYZ format. 
 The optional string will
prefix the filename.  The \verb+NOXYZ+ directive turns this off.

For example, the input
\begin{verbatim}
    tropt; xyz ; end
\end{verbatim}
will cause a trajectory file filename.xyz to be created
in the permanent directory.  

\section{Print options}

The UNIX command \verb+"egrep '^@' < output"+ will extract a pretty
table summarizing the optimization.

If you specify the NWChem input
\begin{verbatim}
      scf; print none; end
      tropt; print low; end
      task scf optimize
\end{verbatim}
you'll obtain a pleasantly terse output.

For more control, these options for the standard print directive are
recognized
\begin{itemize}
\item \verb+debug+   - prints a large amount of data.  Don't use in parallel.
\item \verb+high+    - print the search direction in internals
\item \verb+default+ - prints geometry for each major step (not during
                the line search), gradient in internals (before
                and after application of constraints)
\item \verb+low+     - prints convergence and energy information.  At 
                convergence prints final geometry, change in internals
                from initial geometry
\end{itemize}
and these specific print options
\begin{itemize}
\item      {\tt finish} (low)      - print geometry data at end of calculation
\item      {\tt bonds}  (default)  - print bonds at end of calculation
\item      {\tt angles} (default)  - print angles at end of calculation
\item      {\tt hvecs}  (never)    - print eigen-values/vectors of the Hessian
\item      {\tt searchdir} (high)  - print the search direction in internals
\item      `{\tt internal gradient}' (default) - print the gradient in internals
\item      {\tt sadmode} (default) - print the mode being followed to the saddle point
\end{itemize}

\fussy


