\documentclass[a4paper,11pt]{article}
%\usepackage{times}
\usepackage{graphicx}
\usepackage[body={16cm,24.5cm}]{geometry}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ae,aecompl} 
%\input{m-pictex.tex}
%\usepackage{m-ch-en}
\usepackage{amsmath,amssymb}
%\usepackage{slashbox}
%\usepackage{psfrag}
%\usepackage{multirow}
%\usepackage{amscd}
%\usepackage{empheq}
%\usepackage{yhmath}
%\usepackage{array}
\usepackage{fancyhdr}
%\usepackage{braket}
\usepackage{marvosym}
%\usepackage{xr}


\DeclareGraphicsExtensions{.eps,.ps}
\graphicspath{{.}{../}}

\renewcommand{\arraystretch}{1.2}
\setcounter{tocdepth}{2}
\makeatletter
\@addtoreset{section}{part}
\makeatother

\lhead[]{}
\rhead[]{}
\cfoot{}
\title{Opt'n Path mini-help}
\author{P. Fleurat-Lessard, P. Dayal \\
Laboratoire de Chimie de l'ENS Lyon, 46 all\'ee d'Italie, F-69364 Lyon
Cedex 7}
\date{March 2013}

\def\Path{\texttt{Opt'n Path}}
\begin{document}
\maketitle

\section{Introduction}
\Path{} is a program that can optimize a reaction path between two
  structures. The algorithm to optimize the path is close to the string
  method. The originality of this program lies in the coordinate set it
 can use to generate and optimize the path.

This program is an independant program that calls standard electronic
  structure codes to get the energies and forces it needs to optimize
  the reaction path. For now, it is coupled to Gaussian, MOPAC,
  Vasp, Turbomole and Siesta.

\section{Installation}
We suppose here that you will install \Path{} into a directory called
\texttt{optnpath}. First, create the directory: 
\begin{verbatim}
 mkdir optnpath
 cd optnpath
 mv ../optnpath_x.yy.tgz .
\end{verbatim}
Uncompress the archive:
\begin{verbatim}
 gunzip optnpath_x.yy.tgz
 tar -xvf Optnpath.tar
\end{verbatim}
You should now have this \texttt{Mini\_help.pdf} file and 4 directories (doc, src, utils, examples).

\section{Compilation}
Go to the directory  in which you have uncompressed the files.
Change to the \texttt{src} directory. 
Edit the \texttt{Makefile} to change the \texttt{Machine} description
according to the compiler you want to use. Main choices are:
gfortran, g95, ifort, pgf, xlf and pathscale for now. You might also
have to check that the locations of 
the libraries are ok.
Type \texttt{make}. You should now have a file called
\texttt{Path.exe} in this directory, as well as two utilities called
\texttt{xyz2scan} and \texttt{xyz2path} located in the \texttt{utils}
directories. You should copy all these executables to your
\texttt{~/bin} directory (or any place from which they can be executed).

\section{Use}
\subsection{Path calculation}
 To call \Path{}, you can type:
\verb=Path.exe Input_file Output_file=
The input file \texttt{Input\_file} is based on a namelist and looks like:
\begin{verbatim}
 &path
 nat=3, ! Number of atoms
 ngeomi=3, ! Number of initial geometries 
 ngeomf=12, !Number of geometries along the path
 OptReac=.T., ! Do you want to optimize the reactants ?
 OptProd=.T., ! Optimize the products
 coord='zmat', ! We use Z-matrix coordinates
 maxcyc=31, ! Max number of iterations 
 IReparam=2,! re-distribution of points along the path every 2 iterations
 ISpline=50, ! Start using spline interpolation at iteration 50
 Hinv=.T. , ! Use inverse of the Hessian internally (default: T)
 MW=T, ! Works in Mass Weighted coordiante (default T)
 PathName='Path_HCN_zmat_test', ! Name of the file used for path outputs
 prog='gaussian',! we use G03 to get energy and gradients
 SMax=0.1 ! Displacement cannot exceed 0.1 atomic units (or mass weighted at. unit)
 /
  3
 Energy :      0.04937364
 H     0.0000     0.0000     0.0340
 C     0.0000     0.0000     1.1030
 N     0.0000     0.0000     2.2631
  3
 Energy :      0.04937364
 H     0.0000     1.1000     1.1030
 C     0.0000     0.0000     1.1030
 N     0.0000     0.0000     2.2631
3
 CNH
H 0.000000    0.000000    3.3
C 0.000000    0.000000    1.1
N 0.000000    0.000000    2.26
%chk=Test
#P  AM1 FORCE

 HCN est bien 

0,1
H 0.000000    0.000000    0.000000
C 0.000000    0.000000    1.000
N 0.000000    0.000000    3.00

\end{verbatim}

\subsubsection{Compulsory variables are:}
\begin{description}
\item[NGeomi:] Number of geometries defining the Initial path 
\item[NGeomf:] Number of geometries defining the Final path 
\item[Nat:] Number of atoms 
\end{description}

          
\subsubsection{Other options:}
\begin{description}
\item[Input:] String that indicates the type of the input geometries.
          Accepted values are: Cart (or Xmol or Xyz), Vasp, Turbomole or Siesta.
\item[Prog:] string that indicates the program that will be used for energy and gradient calculations. 
               Accepted values are: Gaussian, Mopac, Vasp, Turbomole, Siesta or Ext. \\
\begin{itemize}
\item   In case of a Gaussian calculations, input must be set to Cart. 
                One example of a gaussian input should be added at the end of the 
                input file.See example file \texttt{Test\_HCN\_zmat\_g03.path}. \\
\item       In the case of a VASP calculation, if input is set to Cart, then 
              the preamble of a VASP calculation s\item \texttt{Mopac}: Examples  using sequential call
  to MOPAC2009 to calculate the energies and forces along the path.
hould be added at the end of 
              the input file. See example file \texttt{Test\_VASP\_cart.path}. 
              In the case of a VASP calculation, one should also give value of the  
              \texttt{RunMode} variable .
\item  In the case of a SIESTA calculation, an example of a Siesta input file
     should be added at the end of the input file. See \texttt{Test\_Siesta.path}.
\end{itemize}

\item[RunMode:] When running on a multi-processor machine, this indicates
  wether \Path{} should calculate the energy and gradient of the whole path in parallel
              or not. User has two options. One is to calculate the energy and
              gradient of each point sequentially. This is usefull when
              running on one (or two) processors. In this case,
              \texttt{RunMode} should be put to \texttt{SERIAL}.When running
              in parallel with 8 or more processors, one can use VASP to
              calculate simultaneously the energies and gradients for all
              points, as in a normal NEB calculation. In this case,
              \texttt{RunMode} must be set to \texttt{PARA}. 
 \emph{For now, this is usefull only for VASP.} \\

\item[ProgExe:] Name (with full path) of the executable to be used to get
  energies and gradients. For example, if VASP is used in parallel, one might
  have something like: \\ 
\verb!ProgExe='/usr/local/mpich/bin/mpirun -machinefile machine -np 8 ~/bin/VASP_46'!.
Another option that I use, is to put \verb!ProgExe='./run_vasp'! and I put every option needed to run VASP
into the \texttt{run\_vasp} file. 
\item[EReac:] (REAL) By default, \Path{} does not compute the energy of the reactants
 and products. This thus indicates the reactants energy to \Path{} to have better plots
 at the end.
\item[EProd:] (REAL) By default, \Path{} does not compute the energy of the reactants
 and products. This thus indicates the products energy to \Path{} to have better plots.
\item[PathName:] Prefix used to save the path. Default is Path 
\item[Poscar:] string that will be used as the prefix for the different  
           POSCAR files in a VASP calculations. Usefull only if PathOnly=.TRUE., 
           not used for internal calculations. 
\item[CalcName:] Prefix for the files used for the energy and gradient calculations
\item[ISuffix:] Suffix for the input file used for energy and gradient calculations. 
The full inputfile name will thus be \textit{CalcName}.\textit{ISuffix}.
\item[OSuffix:] Suffix for the output file used for energy and gradient calculations.
 The full outputfile name will thus be \textit{CalcName}.\textit{OSuffix}.
\item[IGeomRef:] Index of the geometry used to construct the internal coordinates. 
         Valid only for Coord=Zmat, Hybrid or Mixed.
\item[Fact:] REAL used to define if two atoms are linked. 
         If $d(A,B) \leq fact*(rcov(A)+rcov(B))$, then A and B are considered Linked. 
\item[debugFile:] Name of the file that indicates which subroutine should print debug info. 
\item[Coord:] System of coordinates to use. Possible choices are: 
\begin{itemize}
\item CART (or Xyz): works in cartesian 
\item Zmat: works in internal coordinates (Zmat) 
\item Mixed: frozen atoms, as well as atoms defined by the  
          'cart' array(see below) are describe in CARTESIAN, whereas the 
          others are described in Zmat  
\item  Baker: use of Baker coordinates, also called delocalized internal coordinates 
\item Hybrid: geometries are described in zmat, but the gradient are used in cartesian 
\end{itemize}
\item[Step\_method:] method to compute the step for optimizing a geometry; choices are:  
\begin{itemize}
\item RFO: Rational function optimization 
\item GDIIS: Geometry optimization using direct inversion in the iterative supspace 
\end{itemize}
\item[HUpdate:] method to update the hessian. By default, it is Murtagh-Sargent 
         Except for geometry optimization where it is BFGS. 
\item[MaxCyc:] maximum number of iterations for the path optimization 
\item[Smax:] Maximum length of a step during path optimization 
\item[SThresh:] Step Threshold to consider that the path is stationary 
\item[GThresh:] Gradient Threshold to consider that the path is stationary, only orthogonal part is taken 
\item[FTan:] We moving the path, this gives the proportion of the displacement tangent to the path 
         that is kept. FTan=1. corresponds to the full displacement,  
         whereas FTan=0. gives a displacement orthogonal to the path. 
\item[IReparam:] The path is not reparameterised at each iteration. This gives the 
frequency of reparameterization.  
\item[IReparamT:] When the path is not reparameterised at each iteration, this gives the 
frequency of reparameterization of the \emph{tangents}.
\item[ISpline:] By default, a linear interpolation is used to generate the path. 
            This option indicates the first step where spline interpolation is used. 
\item[BoxTol:]  Real between 0. and 1. When doing periodic calculations, 
        it might happen that an atom moves out of the unit cell.
        Path detects this by comparing the displacement to boxtol:
        if an atom moves by more than Boxtol, then it is moved back into the unit cell. Default value: 0.5.
\item[FrozTol:]  (Real) This indicates the threshold to determine wether an atom moves between two images. Default is 1e-4.
\item[OptGeom:] This INTEGER indicates the index of the geometry you want to optimize. 
If \texttt{OptGeom} is set, then \Path{} performs a geometry optimization instead of a path interpolation.
\item[GeomFile:]  Name of the file to print the geometries and their energy
      during a geometry optimization. If this variable is not given
      then nothing is printed.
\item[AnaFile:]  Name of the file to print the values of the geometrical parameters
that are monitored if \texttt{AnaGeom=.TRUE.}. Default is \textit{PathName}.dat
\item[GplotFile:]  Name of the \texttt{gnuplot} file to plot the evolution of the geometrical parameters that are monitored if \texttt{AnaGeom=.TRUE.}. Default is \textit{PathName}.gplot
%% Not described here: NMaxPtPath, NGintMax (too technical ?)
\end{description}
           
\subsubsection{Arrays:}
\begin{description}
\item[Rcov:] Array containing the covalent radii of the first 86 elements. 
         You can modify it using, \verb!rcov(6)=0.8!. 
\item[Mass:] Array containing the atomic mass of the first 86 elements. 
\item[AtTypes:] Name of the different atoms used in a VASP calculations. 
          If not given, Path will read the POTCAR file. 
\end{description}
           
\subsubsection{Flags:}
\begin{description}
\item[MW:]  Flag. True if one wants to work in Mass Weighted coordinates. Default=.TRUE. 
\item[Renum:] Flag. True if one wants to reoder the atoms in the
  initial order. default is .TRUE. unless for \texttt{Coord} equals \texttt{CART}.
\item[OptProd:] True if one wants to optimize the geometry of the products. 
\item[OptReac:] True if one wants to optimize the geometry of the reactants. 
\item[CalcEProd:] if TRUE the product energy will be
  computed. Default is FALSE. Not Compatible with \texttt{RunMode=Para}. 
\item[CalcEReac:] if TRUE the reactants energy will be
  computed. Default is FALSE. Not Compatible with \texttt{RunMode=Para}. 
\item[PathOnly:] TRUE if one wants to generate the initial path, and stops.  
\item[Align:] If .FALSE., successive geometries along the path are not aligned on each other before path interpolation. Default is .TRUE. if there are 4 atoms or more.
\item[Hinv:] if True, then Hessian inversed is used. 
\item[IniHup:] if True, then Hessian inverse is extrapolated
  using the initial path calculations.  
\item[HupNeighbour:]  if True, then Hessian inverse is
  extrapolated using the neighbouring points of the path.  
\item[FFrozen:] True if one wants to freeze the positions of some atoms.  
                If True, a \verb!&frozenlist! namelist containing the
                list of frozen atoms must be given.  
                 If VASP is used, and frozen is not given 
        here, the program will use the F flags of the input geometry 
\item[FCart:]  True if one wants to describe some atoms using cartesian coordinates.  
               *** Only used in 'mixed' calculations. *** 
             If True, a \verb!&cartlist! namelist containing the list of cart atoms must be given. 
             By default, only frozen atoms are described in cartesian coordinates. 
        
\item[Autocart:] True if you want to let the program choosing the cartesian atoms. 
\item[VMD:] TRUE if you want to use VMD to look at the Path. Used only for VASP for now.
\item[WriteVASP:] TRUE if you want to print the images coordinates in POSCAR files.
See also the POSCAR option. This can be used only if prog or input=VASP.
\item[AnaGeom:] If TRUE, Opt'n Path will create a file .dat for geometries analysis.
        If True, Opt'n Path will look for the AnaList namelist after the Path Namelist.
\item[DynMaxStep:] if TRUE, the maximum allowed step is updated at each step, for each geometry.
        If energy goes up, $Smax=Smax*0.8$, if not $Smax=Smax*1.2$. 
       It is ensured that the dynamical Smax is within $[0.5*SMax_0,2*Smax_0]$.
\end{description}

\subsubsection{Additional namelists:}
\begin{description}
\item[\&cartlist list= \ldots{} \&end] This gives the list of atoms that are described using cartesian coordinates. Read only if \texttt{FCart=.TRUE.}. To indicate an atom range, from 1 to 5 for example, one can put 1 -5 in the list. For example: \\
\texttt{\&cartlist list = 1 2 6 12 -20 \&end} \\
will described atoms 1, 2, 6, 12, 13, 14, 15, 16, 17, 18, 19 and 20 in cartesian.
\item[\&Frozenlist list= \ldots{}  \&end] This gives the list of atoms that are frozen during optimization. Read only if \texttt{FFrozen=.TRUE.}. To indicate an atom range, from 1 to 5 for example, one can put 1 -5 in the list. 
\item[\&Analist nb= \ldots{} \&end] list of variables for geometry analysis. If present and if AnaGeom=T then
     Opt'n Path will read it and print the values of the variable in a .dat file
    If AnaGeom is T but Analist is not given, then Path.dat just contains the energy. 
Analist contains the number of variables to monitor: Nb, and is followed by the description
of the variables among:
b(ond) At1 At2
a(ngle) At1 At2 At3
d(ihedral) At1 At2 At3 At4
c NbAt At1 At2 At3 At4 At5... to create a center of mass. The centers of mass are added
at the end of the real atoms of the system.
\end{description}

\subsection{Examples}
More to come...      have a look at the files provided in the
\texttt{examples} directory. In particular, you will find there three
directories containing easy-to-use examples. That is, each directory contains
all the files you need to launch the application. For now, you have working
examples for:
\begin{enumerate}
\item \texttt{Gaussian}: Examples  using sequential call
  to Gaussian to calculate the energies and forces along the path. 
\item \texttt{VASP}: Examples  using 
  to VASP to calculate the energies and forces along the path.
As VASP can perform NEB calculations, Path can use it in two ways:
Serial or Parallel. 
\begin{itemize}
\item[Serial] 
In the Serial mode, Path uses Vasp to compute the energy and forces of
each image separately (as it does for Gaussian for example). 
Therefore, the INCAR file should not contain any references to the
number of images (no IMAGES command!). 

\item[Parallel]
In the Parallel mode, Path uses VASP to compute at once the energies
and forces for all the images (as VASP does for a NEB calculation). 
Therefore, the INCAR file MUST contain the IMAGES command.
More, the directories 00, 01, ... should exist.

\item[Home or Scratch ?]
On our local cluster, it is adviced to perform the calculations on the
/scratch directory that is local rather than on the /home that is
mounted  via NFS and is thus slow. 
However, when doing so, we sometimes had troubles with VASP, and
discovered that all files should be copied on the /scratch of all
machines. 
Therefore, the scripts are a bit tricky.
In case your computer center is similar to ours, we provide 2 SGE
scripts: 
\begin{itemize}
\item[run\_Path\_SGE\_home] performs the VASP calculations in the /home
directory 
\item[run\_Path\_SGE\_scratch] creates the directories, copies the
  files and performs the VASP calculations in the local /scratch
  directories.
\end{itemize}
\end{itemize}
\item \texttt{Mopac}: Examples  using sequential call
  to MOPAC to calculate the energies and forces along the path.
\item \texttt{Siesta}: Examples  using sequential call
  to Siesta to calculate the energies and forces along the path.
\item \texttt{Test}: Examples  using the analytical HCN potential
  energy surface to calculate the energies and forces along the path.
As this is fast, we also provide other Analysis tools.
See README files in the Cart and Zmat subdirectories.
\end{enumerate}

\subsection{Path analysis}
In order to analyse the path evolution, we provide some utilities, in
the \texttt{utils} directory. \texttt{xyz2scan} and \texttt{xyz2path}
have to be compiled. For this, go to either the \texttt{src} or the
\texttt{utils} directory and type \texttt{make utils}.
Here is a brief description of these utilities.

\begin{itemize}
\item \texttt{AnaPath} and/or \texttt{AnaPathref} \\
These scripts analyse a calculated path. They use \texttt{xyz2path} to
convert the cartesian coordinates saved by \Path{} into a data file
(called PathName.datl) that be plotted using the gnuplot files that are
also created. They all plot the path energy  but in different ways:
\begin{itemize}
\item[PathName\_l.gplot] plots the energy of the first iteration (the
  initial path) together with the energy of the following iterations,
  but one at a time.
\item[PathName\_l2.gplot]  plots the energy of the path for all
  iterations, with respect to the
curvilinear distance along the path.
\item[PathName\_l3.gplot]  plots the energy of the path for all
  iterations, with respect to the index of the images.
\end{itemize}
\item \texttt{xyz2path} and \texttt{xyz2scan} convert a bunch of
  cartesian coordinates into 
  a data file. They are very similar: the only difference is the way
  they print their results. For \texttt{xyz2scan} the analyses are
  indiced using the geometry number whereas \texttt{xyz2path} computes
  the mass weighted distance between two geometries and uses this
  distance to index the results. \\
They both use a file called 'list' to perform the analysis,  which has
the following structure:  each line contains the type of the value you
want to follow, it can be:
\begin{itemize}
\item[b]  for a Bond distance
\item[a] for an angle
\item[d] for a dihedral
\item[c] to create a center of mass
\end{itemize}
This descriptor is followed by the number of the atoms involved.  The
exception, is the \texttt{c} command that is followed by the number of
atoms used to define this center of mass, and then the index of the atoms.
A typical file can be:
\begin{verbatim}
 b  1  2
 b 2  3
 a 1 2 3
 c  2 1 2   <- create a new atom located at the middle of the 1-2 bond.
\end{verbatim}

The cartesian geometries have to follow the XMol format. If the
comment line contains \texttt{E=} then \texttt{xyz2scan} and
\texttt{xyz2path} will read the following number and take it as the
image energy.
\end{itemize}

\end{document}
