root / src / Path.f90 @ 3
Historique | Voir | Annoter | Télécharger (89,33 ko)
| 1 | 1 | pfleura2 | ! This programs generates and optimizes a reaction path |
|---|---|---|---|
| 2 | 1 | pfleura2 | ! between at least two endpoints. |
| 3 | 1 | pfleura2 | ! |
| 4 | 1 | pfleura2 | ! It uses NAMELIST for input, see below ! |
| 5 | 1 | pfleura2 | ! |
| 6 | 1 | pfleura2 | ! v3.0 |
| 7 | 1 | pfleura2 | ! First version entirely in Fortran. |
| 8 | 1 | pfleura2 | ! It uses routines from Cart (path creation and parameterisation) |
| 9 | 1 | pfleura2 | ! and from IRC06, especially routines for point optimization. |
| 10 | 1 | pfleura2 | ! |
| 11 | 1 | pfleura2 | ! TO DO: |
| 12 | 1 | pfleura2 | ! 1) Possibility to read and/or calculate some hessian structures |
| 13 | 1 | pfleura2 | ! 2) Use of internal coordinate to estimate the hessian for stable |
| 14 | 1 | pfleura2 | ! species in a much better way... |
| 15 | 1 | pfleura2 | ! |
| 16 | 1 | pfleura2 | !!!!!!!!!!!!!!! |
| 17 | 1 | pfleura2 | ! v3.1 |
| 18 | 1 | pfleura2 | ! The Hessian update includes neighbour points. |
| 19 | 1 | pfleura2 | ! |
| 20 | 1 | pfleura2 | ! v3.2 |
| 21 | 1 | pfleura2 | ! We add the option Hinv that uses the BFGS update of the Hessian inverse |
| 22 | 1 | pfleura2 | ! |
| 23 | 1 | pfleura2 | ! v3.3 |
| 24 | 1 | pfleura2 | ! We add the full option for ZMAT coordinates, where all is done using |
| 25 | 1 | pfleura2 | ! internal coordinates. |
| 26 | 1 | pfleura2 | ! v3.31 |
| 27 | 1 | pfleura2 | ! The step size is controlled using the step norm and not the maximum step |
| 28 | 1 | pfleura2 | ! component. |
| 29 | 1 | pfleura2 | ! v3.5 |
| 30 | 1 | pfleura2 | ! Big modifications of Calc_zmat_const_frag in order to be able |
| 31 | 1 | pfleura2 | ! to treat VASP geometries. |
| 32 | 1 | pfleura2 | ! For now, only XYZ geometries are read and written. VASP interface |
| 33 | 1 | pfleura2 | ! has to be written. |
| 34 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 35 | 1 | pfleura2 | ! v3.6 |
| 36 | 1 | pfleura2 | ! Some minor modif in Calc_zmat_const_frag to have nicer programming |
| 37 | 1 | pfleura2 | ! and a new mode added: Coord=MIXED where part of the system |
| 38 | 1 | pfleura2 | ! is extrapolated in cartesian coordinates and the rest of it in zmat. |
| 39 | 1 | pfleura2 | ! it might be Useful for VASP, or when lots of atoms are frozen |
| 40 | 1 | pfleura2 | ! by default, when Coord=MIXED, all frozen atoms are described in cartesian |
| 41 | 1 | pfleura2 | ! coordinates. |
| 42 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 43 | 1 | pfleura2 | ! v3.61 |
| 44 | 1 | pfleura2 | ! We move further and further to VASP program. New variables added to the 'path' namelist: |
| 45 | 1 | pfleura2 | ! input: what is the program used for the geometries ? |
| 46 | 1 | pfleura2 | ! Possible values: xyz (or cart) for Xmol format; VASP. Xyz should be used for Gaussian |
| 47 | 1 | pfleura2 | ! prog: what is the program used for the calculations ? |
| 48 | 1 | pfleura2 | ! Possible values for now: gaussian, vasp. |
| 49 | 1 | pfleura2 | ! For now (02/2007), when prog='vasp' is used, only the initial path is created. |
| 50 | 1 | pfleura2 | ! That means that we have only added input/output subroutines :-) |
| 51 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 52 | 1 | pfleura2 | ! v3.7 |
| 53 | 1 | pfleura2 | ! We try to improve the optimization steps. For that, we first modify many routines |
| 54 | 1 | pfleura2 | ! so that the new step is calculated in the 'free' degrees of freedom, as it is done |
| 55 | 1 | pfleura2 | ! in IRC07/ADF for example. That will allow us to impose constraints in an easier way. |
| 56 | 1 | pfleura2 | ! |
| 57 | 1 | pfleura2 | ! v3.701 |
| 58 | 1 | pfleura2 | ! Add a new option for the initial extrapolation of the Hessian |
| 59 | 1 | pfleura2 | ! |
| 60 | 1 | pfleura2 | !v3.71 |
| 61 | 1 | pfleura2 | ! The optimization step has been improved... but the vfree part has not yet been included. |
| 62 | 1 | pfleura2 | ! This has still to be done :-) |
| 63 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 64 | 1 | pfleura2 | ! v3.8 |
| 65 | 1 | pfleura2 | ! I have included part of the vfree procedure: for now freemv returns the Id |
| 66 | 1 | pfleura2 | ! matrix, that is used to project out the tangent vector. |
| 67 | 1 | pfleura2 | ! This improves the optimization a lot, but I will have to implement |
| 68 | 1 | pfleura2 | ! a real freemw subroutine to have constraints there ! |
| 69 | 1 | pfleura2 | ! v3.81 Technical version |
| 70 | 1 | pfleura2 | ! I have added a new program 'Ext'. When this one is used, Path creates a Ext.in file, |
| 71 | 1 | pfleura2 | ! calls Ext.exe file to get a Ext.out file that contains the Energy and the gradient. |
| 72 | 1 | pfleura2 | ! Format: |
| 73 | 1 | pfleura2 | ! Ext.in : Xmol format. The second line (comment in Xmol) contains the COORD name. |
| 74 | 1 | pfleura2 | ! Ext.out: Energy on firt line (1X,D25.15), then gradient in CARTESIAN coordinates |
| 75 | 1 | pfleura2 | ! (3(1X,D25.15)) format. Natoms lines. |
| 76 | 1 | pfleura2 | ! TO DO: Gradient could be given in COORD format, ie cartesian for COORD=CART, XYZ or HYBRID |
| 77 | 1 | pfleura2 | ! ZMAT for CORD=ZMAT (in that case, 6 zeros are there at the begining !) |
| 78 | 1 | pfleura2 | ! For MIXED, it is equivalent to CART :-) |
| 79 | 1 | pfleura2 | ! v3.811 |
| 80 | 1 | pfleura2 | ! I have added a prog="TEST" option, where egradient calls egrad_test subroutine. |
| 81 | 1 | pfleura2 | ! It then calculates the energy and gradient as it wants and it returns the cartesian |
| 82 | 1 | pfleura2 | ! gradient. The purpose is to have an analytical approximation of the PES of the system |
| 83 | 1 | pfleura2 | ! under study to gain some time in testing the program. This is not documented :-) |
| 84 | 1 | pfleura2 | ! |
| 85 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 86 | 1 | pfleura2 | ! v3.9 |
| 87 | 1 | pfleura2 | ! In order to be fully interfaced with VASP, I have to change the architecture |
| 88 | 1 | pfleura2 | ! of the program. In particular, with VASP, one can use a Para8+NEB routine |
| 89 | 1 | pfleura2 | ! of VASP to calculate energy+forces for all points of the path. |
| 90 | 1 | pfleura2 | ! v3.91 |
| 91 | 1 | pfleura2 | ! One small modification: in the cart list, one can freeze a whole sequence by |
| 92 | 1 | pfleura2 | ! entering a negative number for the last atom of the sequence |
| 93 | 1 | pfleura2 | ! for example : cart=1 -160 165 -170 will define atoms from 1 to 160 and from |
| 94 | 1 | pfleura2 | ! 165 to 170 (included) as cartesian atoms. |
| 95 | 1 | pfleura2 | ! Of course, Same applies to Frozen |
| 96 | 1 | pfleura2 | ! v3.92 / v3.93 |
| 97 | 1 | pfleura2 | ! Slight modifications. One noticeable: when using Vasp, the program analyses the |
| 98 | 1 | pfleura2 | ! displacements to suggest which atoms could be described in CART. |
| 99 | 1 | pfleura2 | ! v3.94 |
| 100 | 1 | pfleura2 | ! VaspMode=Para now implemented. One needs to be careful in defining 'ProgExe'. |
| 101 | 1 | pfleura2 | ! In particular, one must put the mpirun command in ProgExe !!! There is NO test. |
| 102 | 1 | pfleura2 | ! v3.95 |
| 103 | 1 | pfleura2 | ! When using internal coordinates (zmat, hybrid or mixes), Path calculates the number |
| 104 | 1 | pfleura2 | ! of fragments for each geometry. The reference one (ie the one used to compute the internal |
| 105 | 1 | pfleura2 | ! coordinates) is now the one with the least fragments. |
| 106 | 1 | pfleura2 | ! user can also choose one geometry by specifying IGeomRef in the Path namelis. |
| 107 | 1 | pfleura2 | ! v3.96 |
| 108 | 1 | pfleura2 | ! I have added a test for the geometry step: it does not allow valence angle to |
| 109 | 1 | pfleura2 | ! be negative or bigger than 180. I hope that this might help geometry optimization |
| 110 | 1 | pfleura2 | ! when dealing with nearly linear molecules. |
| 111 | 1 | pfleura2 | ! v3.961 |
| 112 | 1 | pfleura2 | ! The options cart and frozen are now LOGICAL: |
| 113 | 1 | pfleura2 | ! Fcart=T indicates that a &cartlist namelist should be read ! |
| 114 | 1 | pfleura2 | ! Ffrozen=T indicates that a &frozenlist namelist should be read ! |
| 115 | 1 | pfleura2 | ! TO DO: Autocart=T indicates that the atoms described in cartesian coordiantes should |
| 116 | 1 | pfleura2 | ! be found automatically |
| 117 | 1 | pfleura2 | ! v3.97 |
| 118 | 1 | pfleura2 | ! Baker has been implemented by P. Dayal: we are interpolating Xint for now. |
| 119 | 1 | pfleura2 | ! TO do: interpolate Umat ? |
| 120 | 1 | pfleura2 | ! ----- |
| 121 | 1 | pfleura2 | ! v3.971 |
| 122 | 1 | pfleura2 | ! AutoCart=T is being implemented. Goal: having a 'black box' version for Vasp users. |
| 123 | 1 | pfleura2 | ! Vmd: True if user wants to watch the path using VMD. Only used for VASP for now. |
| 124 | 1 | pfleura2 | !------------ |
| 125 | 1 | pfleura2 | ! v3.98 |
| 126 | 1 | pfleura2 | ! Calc_zmat has been replaced by Calc_zmat_frag which is more robust. |
| 127 | 1 | pfleura2 | ! Still missing: linear molecules and some tests. |
| 128 | 1 | pfleura2 | ! |
| 129 | 1 | pfleura2 | ! v3.981 |
| 130 | 1 | pfleura2 | ! * Added a non document flag in .valid file that switch on the numerical |
| 131 | 1 | pfleura2 | ! calculation of the hessian instead of the update. |
| 132 | 1 | pfleura2 | ! * Added HesUpd variable in the namelist. Default value is MS for path |
| 133 | 1 | pfleura2 | ! optimization because it does not imposes a positive hessian, and BFGS |
| 134 | 1 | pfleura2 | ! for geometry optimization |
| 135 | 1 | pfleura2 | ! v 4.0 |
| 136 | 1 | pfleura2 | ! * This version has been made public within the CARTE project. |
| 137 | 1 | pfleura2 | ! * Added: |
| 138 | 1 | pfleura2 | ! - Step_method to choose the optimization method: RFO or Diis |
| 139 | 1 | pfleura2 | ! - DynMaxStep: if TRUE, the maximum size of a step is updated at each step. |
| 140 | 1 | pfleura2 | ! If energy goes up, Smax=Smax*0.8, if not Smax=Smax*1.2. |
| 141 | 1 | pfleura2 | ! It is ensured that the dynamical Smax is within [0.5*SMax_0,2*Smax_0] |
| 142 | 1 | pfleura2 | ! |
| 143 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!! |
| 144 | 1 | pfleura2 | ! v4.1 |
| 145 | 1 | pfleura2 | ! * Para mode has been partly implemented for Gaussian. |
| 146 | 1 | pfleura2 | ! VaspMode is thus now 'RunMode' and can be Serial or Para |
| 147 | 1 | pfleura2 | ! Only Gaussian and VASP are supported for Para mode now. |
| 148 | 1 | pfleura2 | ! v4.12 |
| 149 | 1 | pfleura2 | ! Some bugs in unconstrained zmat construction are corrected. |
| 150 | 1 | pfleura2 | ! v4.13 |
| 151 | 1 | pfleura2 | ! Prakash has implemented the GEDIIS optimization procedure. |
| 152 | 1 | pfleura2 | ! v4.14 |
| 153 | 1 | pfleura2 | ! There is a small problem for some inputs in VASP, where the |
| 154 | 1 | pfleura2 | ! last geometry is not the one given by the user. |
| 155 | 1 | pfleura2 | ! It seems to come from the fact that some people try to freeze |
| 156 | 1 | pfleura2 | ! some unfrozen atoms |
| 157 | 1 | pfleura2 | ! So some tests have been added to check that frozen atoms do not move. |
| 158 | 1 | pfleura2 | !!! |
| 159 | 1 | pfleura2 | ! v4.15 |
| 160 | 1 | pfleura2 | ! There were some bugs when reading and expanding cartlist and frozenlist |
| 161 | 1 | pfleura2 | ! I have changed the way frozen atoms are compared by adding partial alignment. |
| 162 | 1 | pfleura2 | ! v4.16 |
| 163 | 1 | pfleura2 | ! Some bugs were corrected. |
| 164 | 1 | pfleura2 | ! v4.17 |
| 165 | 1 | pfleura2 | ! Added MOPAC as a program. |
| 166 | 1 | pfleura2 | ! v4.175 |
| 167 | 1 | pfleura2 | ! Added Three more parameters for defining the input and output names for |
| 168 | 1 | pfleura2 | ! the calculations. |
| 169 | 1 | pfleura2 | ! CalcName: Prefix for the files used for the energy and gradient calculations |
| 170 | 1 | pfleura2 | ! ISuffix: Suffix for the input file |
| 171 | 1 | pfleura2 | ! OSuffix: suffix for the output file. |
| 172 | 1 | pfleura2 | ! This maters for Gaussian for example. |
| 173 | 1 | pfleura2 | ! |
| 174 | 1 | pfleura2 | ! v4.177 (P) 2010 Nov 22 |
| 175 | 1 | pfleura2 | ! - We add TurboMole as a new external code. |
| 176 | 1 | pfleura2 | ! - Subtle change for Input: the default is XYZ whatever the code, except |
| 177 | 1 | pfleura2 | ! for VASP. |
| 178 | 1 | pfleura2 | ! |
| 179 | 1 | pfleura2 | ! v4.178 (P) 2010 Nov 28 |
| 180 | 1 | pfleura2 | ! - We add the possibility to call CHAMFRE reactive force field using |
| 181 | 1 | pfleura2 | ! prog=TEST2 or CHAMFRE |
| 182 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 183 | 1 | pfleura2 | ! OpenPath v1.4 2011 May-June |
| 184 | 1 | pfleura2 | ! - Also added two flags: CalcEReac and CalcEProd. If .TRUE. Path will |
| 185 | 1 | pfleura2 | ! compute the energy of the reactant |
| 186 | 1 | pfleura2 | ! (and/or Product) at the begining of the calculations. |
| 187 | 1 | pfleura2 | ! This is useful if you start from non optimized points. |
| 188 | 1 | pfleura2 | ! |
| 189 | 1 | pfleura2 | ! - Also added more methods for Hessian updates. The following methods are |
| 190 | 1 | pfleura2 | ! now availables: |
| 191 | 1 | pfleura2 | ! For inverse Hessian: BFGS, DFP, MS. |
| 192 | 1 | pfleura2 | ! For Hessian: BFGS, DFP, MS, Bofill |
| 193 | 1 | pfleura2 | ! |
| 194 | 1 | pfleura2 | ! -Small change: HesUpd is replaced by Hupdate |
| 195 | 1 | pfleura2 | ! |
| 196 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 197 | 1 | pfleura2 | ! TO DO |
| 198 | 1 | pfleura2 | ! - Trying to improve the output of Path. In particular, we now create |
| 199 | 1 | pfleura2 | ! a .datl file containing the image index, curvilinear coordinate and energy |
| 200 | 1 | pfleura2 | ! in the spirit of the AnaPath tool. |
| 201 | 1 | pfleura2 | ! AnaPath is still usefull as it can extract geometrical parameters on top |
| 202 | 1 | pfleura2 | ! of the energy |
| 203 | 1 | pfleura2 | ! - When using Hessian update, it is more efficient to use Cholesky |
| 204 | 1 | pfleura2 | ! decomposition, and to update this decomposition rather than the Hessian. |
| 205 | 1 | pfleura2 | ! See Nocedal&Wright p141. |
| 206 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 207 | 1 | pfleura2 | ! Project Name has changed to Opt'n Path |
| 208 | 1 | pfleura2 | ! OpenPaht 2011 May-June -> Opt'n Path v1.4 |
| 209 | 1 | pfleura2 | |
| 210 | 1 | pfleura2 | |
| 211 | 1 | pfleura2 | PROGRAM PathOpt |
| 212 | 1 | pfleura2 | |
| 213 | 1 | pfleura2 | use VarTypes |
| 214 | 1 | pfleura2 | use Path_module |
| 215 | 1 | pfleura2 | use Io_module |
| 216 | 1 | pfleura2 | |
| 217 | 1 | pfleura2 | IMPLICIT NONE |
| 218 | 1 | pfleura2 | |
| 219 | 1 | pfleura2 | CHARACTER(132) :: FileIn, FileOut, Line,Line2 |
| 220 | 1 | pfleura2 | CHARACTER(32) :: Input,poscar |
| 221 | 1 | pfleura2 | |
| 222 | 1 | pfleura2 | INTEGER(KINT) :: I,J,K,IGeom,iat, IGeom0, IGeomF |
| 223 | 1 | pfleura2 | INTEGER(KINT) :: IOpt |
| 224 | 1 | pfleura2 | INTEGER(KINT) :: Idx, LineL,LenLine |
| 225 | 1 | pfleura2 | INTEGER(KINT) :: N3at, NFree, Nfr |
| 226 | 1 | pfleura2 | ! Temporary integer counter |
| 227 | 1 | pfleura2 | INTEGER(KINT) :: NTmp |
| 228 | 1 | pfleura2 | |
| 229 | 1 | pfleura2 | INTEGER(KINT) :: List(2*MaxFroz) |
| 230 | 1 | pfleura2 | |
| 231 | 1 | pfleura2 | REAL(KREAL) :: E,FactStep,B(3) !E=Energy |
| 232 | 1 | pfleura2 | REAL(KREAL) :: Alpha,sa,ca,norm,s,NormStep,NormGrad |
| 233 | 1 | pfleura2 | REAL(KREAL) :: EReac,EProd,HP,HEAT ! HEAT=E |
| 234 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: GeomTmp(:),GradTmp(:),ZeroVec(:) !NCoord |
| 235 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: GradOld(:,:) ! (NGeomF,NCoord) |
| 236 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: GeomTmp2(:),GradTmp2(:) ! NCoord |
| 237 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: HessTmp(:,:) |
| 238 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: Hprim(:,:) !(NPrim,NPrim) |
| 239 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: HprimU(:,:) !(NPrim,3*Nat-6)) |
| 240 | 1 | pfleura2 | LOGICAL, SAVE :: allocation_flag |
| 241 | 1 | pfleura2 | |
| 242 | 1 | pfleura2 | ! Flag to see if frozen atoms are frozen (see below) |
| 243 | 1 | pfleura2 | LOGICAL :: FChkFrozen |
| 244 | 1 | pfleura2 | |
| 245 | 1 | pfleura2 | ! Energies for all points along the path at the previous iteration |
| 246 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: EPathold(:) ! NGeomF, where it is deallocated: Prakash |
| 247 | 1 | pfleura2 | ! Maximum step allowed for this geometry |
| 248 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: MaxStep(:) ! NGeomF, where it is deallocated: Prakash |
| 249 | 1 | pfleura2 | |
| 250 | 1 | pfleura2 | ! these are used to read temporary coordinates |
| 251 | 1 | pfleura2 | REAL(KREAL) :: xtmp,ytmp,ztmp |
| 252 | 1 | pfleura2 | |
| 253 | 1 | pfleura2 | LOGICAL :: FFrozen,FCart |
| 254 | 1 | pfleura2 | |
| 255 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 256 | 1 | pfleura2 | ! |
| 257 | 1 | pfleura2 | ! To analyse the frozen atoms |
| 258 | 1 | pfleura2 | ! |
| 259 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: x1(:),y1(:),z1(:) ! nat |
| 260 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: x2(:),y2(:),z2(:) ! nat |
| 261 | 1 | pfleura2 | REAL(KREAL) :: MRot(3,3),Norm1,Norm2,Dist |
| 262 | 1 | pfleura2 | LOGICAL, ALLOCATABLE :: ListAtFroz(:) |
| 263 | 1 | pfleura2 | INTEGER(KINT) :: Iat1, Iat2, Iat3 |
| 264 | 1 | pfleura2 | |
| 265 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 266 | 1 | pfleura2 | ! |
| 267 | 1 | pfleura2 | ! For VASP |
| 268 | 1 | pfleura2 | ! |
| 269 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: NbAtType(:) !na |
| 270 | 1 | pfleura2 | INTEGER(KINT) :: NbType, NbTypeUser |
| 271 | 1 | pfleura2 | |
| 272 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 273 | 1 | pfleura2 | |
| 274 | 1 | pfleura2 | LOGICAL :: TChk |
| 275 | 1 | pfleura2 | LOGICAL :: Debug, Fini,Flag_Opt_Geom |
| 276 | 1 | pfleura2 | |
| 277 | 1 | pfleura2 | ! INTEGER(KINT), EXTERNAL :: Iargc |
| 278 | 1 | pfleura2 | INTEGER(KINT), EXTERNAL :: ConvertNumAt |
| 279 | 1 | pfleura2 | |
| 280 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 281 | 1 | pfleura2 | ! |
| 282 | 1 | pfleura2 | ! For Debugging purposes |
| 283 | 1 | pfleura2 | ! |
| 284 | 1 | pfleura2 | LOGICAL :: FCalcHess |
| 285 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 286 | 1 | pfleura2 | |
| 287 | 1 | pfleura2 | |
| 288 | 1 | pfleura2 | INTERFACE |
| 289 | 1 | pfleura2 | function valid(string) result (isValid) |
| 290 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 291 | 1 | pfleura2 | logical :: isValid |
| 292 | 1 | pfleura2 | END function VALID |
| 293 | 1 | pfleura2 | |
| 294 | 1 | pfleura2 | SUBROUTINE Read_Geom(Input) |
| 295 | 1 | pfleura2 | CHARACTER(32), INTENT(IN) :: input |
| 296 | 1 | pfleura2 | END SUBROUTINE READ_GEOM |
| 297 | 1 | pfleura2 | |
| 298 | 1 | pfleura2 | subroutine hupdate_all (n, dx, dgrad, HessOld) |
| 299 | 1 | pfleura2 | |
| 300 | 1 | pfleura2 | IMPLICIT NONE |
| 301 | 1 | pfleura2 | |
| 302 | 1 | pfleura2 | INTEGER, PARAMETER :: KINT=KIND(1) |
| 303 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=KIND(1.0D0) |
| 304 | 1 | pfleura2 | |
| 305 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: n |
| 306 | 1 | pfleura2 | real(KREAL) :: dx(n), dgrad(n), HessOld(n*n) |
| 307 | 1 | pfleura2 | END subroutine hupdate_all |
| 308 | 1 | pfleura2 | |
| 309 | 1 | pfleura2 | SUBROUTINE Hinvup_BFGS_new(Nfree,ds,dgrad,Hess) |
| 310 | 1 | pfleura2 | |
| 311 | 1 | pfleura2 | IMPLICIT NONE |
| 312 | 1 | pfleura2 | |
| 313 | 1 | pfleura2 | INTEGER, PARAMETER :: KINT=KIND(1) |
| 314 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=KIND(1.D0) |
| 315 | 1 | pfleura2 | |
| 316 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: NFREE |
| 317 | 1 | pfleura2 | REAL(KREAL), INTENT(INOUT) :: Hess(Nfree,Nfree) |
| 318 | 1 | pfleura2 | REAL(KREAL), INTENT(IN) :: ds(Nfree) |
| 319 | 1 | pfleura2 | REAL(KREAL), INTENT(IN) :: dGrad(Nfree) |
| 320 | 1 | pfleura2 | |
| 321 | 1 | pfleura2 | END subroutine Hinvup_BFGS_new |
| 322 | 1 | pfleura2 | |
| 323 | 1 | pfleura2 | |
| 324 | 1 | pfleura2 | END INTERFACE |
| 325 | 1 | pfleura2 | |
| 326 | 1 | pfleura2 | Namelist/path/fact,r_cov,nat,ngeomi,ngeomf,debugFile, & |
| 327 | 1 | pfleura2 | MW,mass,Ffrozen, renum, OptReac,OptProd,Coord,Step_method,MaxCyc, & |
| 328 | 1 | pfleura2 | SMax, SThresh, GThresh,IReparam, IReparamT,Hinv, ISpline, PathOnly,Fcart, & |
| 329 | 1 | pfleura2 | input,prog, ProgExe,RunMode, AtTypes,poscar,PathName, & |
| 330 | 1 | pfleura2 | OptGeom,IniHup, HupNeighbour, hesUpd, HUpdate, & |
| 331 | 1 | pfleura2 | FTan, EReac, EProd, IGeomRef, Vmd, AutoCart, DynMaxStep, & |
| 332 | 1 | pfleura2 | NMaxPtPath, FrozTol, BoxTol,CalcName,ISuffix,OSuffix, WriteVasp, & |
| 333 | 1 | pfleura2 | NGintMax, Align, CalcEReac,CalcEProd |
| 334 | 1 | pfleura2 | |
| 335 | 1 | pfleura2 | Namelist/cartlist/list |
| 336 | 1 | pfleura2 | Namelist/frozenlist/list |
| 337 | 1 | pfleura2 | |
| 338 | 1 | pfleura2 | |
| 339 | 1 | pfleura2 | Flag_Opt_Geom = .FALSE. ! Initialized. |
| 340 | 1 | pfleura2 | |
| 341 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!! |
| 342 | 1 | pfleura2 | ! |
| 343 | 1 | pfleura2 | ! We print the Version info in file |
| 344 | 1 | pfleura2 | ! |
| 345 | 1 | pfleura2 | WRITE(*,'(1X,A)') "OpenPath v1.4 (c) PFL/PD 2007-2011" |
| 346 | 1 | pfleura2 | |
| 347 | 1 | pfleura2 | ! We read the files names |
| 348 | 1 | pfleura2 | ! SELECT CASE (iargc()) |
| 349 | 1 | pfleura2 | SELECT CASE (command_argument_count()) |
| 350 | 1 | pfleura2 | CASE (2) |
| 351 | 1 | pfleura2 | call getarg(1,FileIn) |
| 352 | 1 | pfleura2 | OPEN(IOIN,FILE=FileIn,STATUS='UNKNOWN') |
| 353 | 1 | pfleura2 | call getarg(2,FileOut) |
| 354 | 1 | pfleura2 | OPEN(IOOUT,FILE=FileOut,STATUS='UNKNOWN') |
| 355 | 1 | pfleura2 | CASE (1) |
| 356 | 1 | pfleura2 | call getarg(1,FileIn) |
| 357 | 1 | pfleura2 | IF ((FileIn=="-help").OR.(FileIn=="--help")) THEN |
| 358 | 1 | pfleura2 | WRITE(*,*) "Path mini-help" |
| 359 | 1 | pfleura2 | WRITE(*,*) "--------------" |
| 360 | 1 | pfleura2 | WRITE(*,*) "" |
| 361 | 1 | pfleura2 | WRITE(*,*) "Use: Path Input_file Output_file" |
| 362 | 1 | pfleura2 | WRITE(*,*) "Input_file starts with a Namelist called path" |
| 363 | 1 | pfleura2 | WRITE(*,*) "" |
| 364 | 1 | pfleura2 | WRITE(*,*) "Compulsory variables are:" |
| 365 | 1 | pfleura2 | WRITE(*,*) "NGeomi: Number of geometries defining the Initial path" |
| 366 | 1 | pfleura2 | WRITE(*,*) "NGeomf: Number of geometries defining the Final path" |
| 367 | 1 | pfleura2 | WRITE(*,*) "Nat : Number of atoms" |
| 368 | 1 | pfleura2 | WRITE(*,*) "" |
| 369 | 1 | pfleura2 | WRITE(*,*) "" |
| 370 | 1 | pfleura2 | WRITE(*,*) "Other options" |
| 371 | 1 | pfleura2 | WRITE(*,*) "Input: string that indicates the type of the input geometries." |
| 372 | 1 | pfleura2 | WRITE(*,*) "Accepted values are: Cart (or Xmol or Xyz) or Vasp" |
| 373 | 1 | pfleura2 | WRITE(*,*) "Prog: string that indicates the program that will be used for energy and gradient calculations." |
| 374 | 1 | pfleura2 | WRITE(*,*) " Accepted values are: Gaussian, Vasp, Mopac or Ext" |
| 375 | 1 | pfleura2 | WRITE(*,*) " In case of a Gaussian or Mopac calculations, input must be set to Cart." |
| 376 | 1 | pfleura2 | WRITE(*,*) " One example of a gaussian/mopac input should be added at the end of the" |
| 377 | 1 | pfleura2 | WRITE(*,*) " input file.See example file Test_G03.path or Test_Mopac.path" |
| 378 | 1 | pfleura2 | WRITE(*,*) " In the case of a VASP calculation, if input is set to Cart, then" |
| 379 | 1 | pfleura2 | WRITE(*,*) " the preamble of a VASP calculation should be added at the end of" |
| 380 | 1 | pfleura2 | WRITE(*,*) " the input file. See example file Test_VASP_cart.path" |
| 381 | 1 | pfleura2 | WRITE(*,*) " In the case of a VASP calculation, one should also give value of the " |
| 382 | 1 | pfleura2 | WRITE(*,*) " Runmode variable" |
| 383 | 1 | pfleura2 | WRITE(*,*) "Runmode: This indicates wether one should use VASP routine to calculate the energy" |
| 384 | 1 | pfleura2 | WRITE(*,*) " and gradient of the whole path or not. If one wants to use VASP," |
| 385 | 1 | pfleura2 | WRITE(*,*) " Runmode must be set to PARA." |
| 386 | 1 | pfleura2 | WRITE(*,*) "PathName: Prefix used to save the path. Default is Path" |
| 387 | 1 | pfleura2 | WRITE(*,*) "Poscar: string that will be used as the prefix for the different " |
| 388 | 1 | pfleura2 | WRITE(*,*) " POSCAR files in a VASP calculations. Usefull only if PathOnly=.TRUE.," |
| 389 | 1 | pfleura2 | WRITE(*,*) " not used for internal calculations." |
| 390 | 1 | pfleura2 | WRITE(*,*) " CalcName: Prefix for the files used for the energy and gradient calculations" |
| 391 | 1 | pfleura2 | WRITE(*,*) " ISuffix: Suffix for the input file." |
| 392 | 1 | pfleura2 | WRITE(*,*) " OSuffix: suffix for the output file." |
| 393 | 1 | pfleura2 | WRITE(*,*) "IGeomRef: Index of the geometry used to construct the internal coordinates." |
| 394 | 1 | pfleura2 | WRITE(*,*) " Valid only for Coord=Zmat, Hybrid or Mixed" |
| 395 | 1 | pfleura2 | WRITE(*,*) "Fact: REAL used to define if two atoms are linked." |
| 396 | 1 | pfleura2 | WRITE(*,*) " If d(A,B)<=fact*(rcov(A)+rcov(B)), then A and B are considered Linked." |
| 397 | 1 | pfleura2 | WRITE(*,*) "debugFile: Name of the file that indicates which subroutine should print debug info." |
| 398 | 1 | pfleura2 | WRITE(*,*) "Coord: System of coordinates to use. Possible choices are:" |
| 399 | 1 | pfleura2 | WRITE(*,*) " - CART (or Xyz): works in cartesian" |
| 400 | 1 | pfleura2 | WRITE(*,*) " - Zmat: works in internal coordinates (Zmat)" |
| 401 | 1 | pfleura2 | WRITE(*,*) " - Mixed: frozen atoms, as well as atoms defined by the " |
| 402 | 1 | pfleura2 | WRITE(*,*) " 'cart' array(see below) are describe in CARTESIAN, whereas the" |
| 403 | 1 | pfleura2 | WRITE(*,*) " others are described in Zmat" |
| 404 | 1 | pfleura2 | WRITE(*,*) " - Baker: use of Baker coordinates, also called delocalized internal coordinates" |
| 405 | 1 | pfleura2 | WRITE(*,*) " - Hybrid: geometries are described in zmat, but the gradient are used in cartesian" |
| 406 | 1 | pfleura2 | WRITE(*,*) "Step_method: method to compute the step for optimizing a geometry; choices are:" |
| 407 | 1 | pfleura2 | WRITE(*,*) " - RFO: Rational function optimization" |
| 408 | 1 | pfleura2 | WRITE(*,*) " - GDIIS: Geometry optimization using direct inversion in the iterative supspace" |
| 409 | 1 | pfleura2 | ! WRITE(*,*) " HesUpd: Deprecated. Use Hupdate." |
| 410 | 1 | pfleura2 | WRITE(*,*) " HUpdate: method to update the hessian. By default, it is Murtagh-Sargent" |
| 411 | 1 | pfleura2 | WRITE(*,*) " Except for geometry optimization where it is BFGS." |
| 412 | 1 | pfleura2 | WRITE(*,*) "MaxCyc: maximum number of iterations for the path optimization" |
| 413 | 1 | pfleura2 | WRITE(*,*) "Smax: Maximum length of a step during path optimization" |
| 414 | 1 | pfleura2 | WRITE(*,*) "SThresh: Step Threshold to consider that the path is stationary" |
| 415 | 1 | pfleura2 | WRITE(*,*) "GThresh: Gradient Threshold to consider that the path is stationary, only orthogonal part is taken" |
| 416 | 1 | pfleura2 | WRITE(*,*) "FTan: We moving the path, this gives the proportion of the displacement tangent to the path" |
| 417 | 1 | pfleura2 | WRITE(*,*) " that is kept. FTan=1. corresponds to the full displacement, " |
| 418 | 1 | pfleura2 | WRITE(*,*) " whereas FTan=0. gives a displacement orthogonal to the path." |
| 419 | 1 | pfleura2 | WRITE(*,*) "IReparam: The path is not reparameterised at each iteration. This gives the frequency of reparameterization." |
| 420 | 1 | pfleura2 | WRITE(*,*) "ISpline: By default, a linear interpolation is used to generate the path." |
| 421 | 1 | pfleura2 | WRITE(*,*) " This option indicates the first step where spline interpolation is used." |
| 422 | 1 | pfleura2 | WRITE(*,*) "Boxtol: Real between 0. and 1. When doing periodic calculations, " |
| 423 | 1 | pfleura2 | WRITE(*,*) " it might happen that an atom moves out of the unit cell." |
| 424 | 1 | pfleura2 | WRITE(*,*) " Path detects this by comparing the displacement to boxtol:" |
| 425 | 1 | pfleura2 | WRITE(*,*) " if an atom moves by more than Boxtol, then it is moved back into the unit cell. Default value: 0.5" |
| 426 | 1 | pfleura2 | WRITE(*,*) "" |
| 427 | 1 | pfleura2 | WRITE(*,*) "Arrays:" |
| 428 | 1 | pfleura2 | WRITE(*,*) "Rcov: Array containing the covalent radii of the first 80 elements." |
| 429 | 1 | pfleura2 | WRITE(*,*) " You can modify it using, rcov(6)=0.8." |
| 430 | 1 | pfleura2 | WRITE(*,*) "Mass: Array containing the atomic mass of the first 80 elements." |
| 431 | 1 | pfleura2 | WRITE(*,*) "AtTypes: Name of the different atoms used in a VASP calculations." |
| 432 | 1 | pfleura2 | WRITe(*,*) "If not given, Path will read the POTCAR file." |
| 433 | 1 | pfleura2 | WRITE(*,*) "" |
| 434 | 1 | pfleura2 | WRITE(*,*) "Flags:" |
| 435 | 1 | pfleura2 | WRITE(*,*) "MW: Flag. True if one wants to work in Mass Weighted coordinates. Default=.TRUE." |
| 436 | 1 | pfleura2 | WRITE(*,*) "Renum: Flag. True if one wants to reoder the atoms in the initial order. default is .TRUE. most of the time." |
| 437 | 1 | pfleura2 | WRITE(*,*) "OptProd: True if one wants to optimize the geometry of the products." |
| 438 | 1 | pfleura2 | WRITE(*,*) "OptReac: True if one wants to optimize the geometry of the reactants." |
| 439 | 1 | pfleura2 | WRITE(*,*) "CalcEReac: if TRUE the reactants energy will be computed. Default is FALSE. Not Compatible with RunMode=Para" |
| 440 | 1 | pfleura2 | WRITE(*,*) "CalcEProd: if TRUE the products energy will be computed. Default is FALSE. Not compatible with RunMode=Para" |
| 441 | 1 | pfleura2 | WRITE(*,*) "PathOnly:TRUE if one wants to generate the initial path, and stops." |
| 442 | 1 | pfleura2 | WRITE(*,*) "Hinv: if True, then Hessian inversed is used." |
| 443 | 1 | pfleura2 | WRITE(*,*) "IniHup: if True, then Hessian inverse is extrapolated using the initial path calculations." |
| 444 | 1 | pfleura2 | WRITE(*,*) "HupNeighbour: if True, then Hessian inverse is extrapolated using the neighbouring points of the path." |
| 445 | 1 | pfleura2 | WRITE(*,*) "FFrozen: True if one wants to freeze the positions of some atoms." |
| 446 | 1 | pfleura2 | WRITE(*,*) " If True, a &frozenlist namelist containing the list of frozen atoms must be given." |
| 447 | 1 | pfleura2 | WRITE(*,*) " If VASP is used, and frozen is not given" |
| 448 | 1 | pfleura2 | WRITE(*,*) " here, the program will use the F flags of the input geometry" |
| 449 | 1 | pfleura2 | WRITE(*,*) "FCart: True if one wants to describe some atoms using cartesian coordinates. " |
| 450 | 1 | pfleura2 | WRITE(*,*) " *** Only used in 'mixed' calculations. ***" |
| 451 | 1 | pfleura2 | WRITE(*,*) " If True, a &cartlist namelist containing the list of cart atoms must be given." |
| 452 | 1 | pfleura2 | WRITE(*,*) " By default, only frozen atoms are described in cartesian coordinates." |
| 453 | 1 | pfleura2 | WRITE(*,*) "" |
| 454 | 1 | pfleura2 | WRITE(*,*) "DynMaxStep: if TRUE, the maximum allowed step is updated at each step, for each geometry." |
| 455 | 1 | pfleura2 | WRITE(*,*) " If energy goes up, Smax=Smax*0.8, if not Smax=Smax*1.2. " |
| 456 | 1 | pfleura2 | WRITE(*,*) " It is ensured that the dynamical Smax is within [0.5*SMax_0,2*Smax_0]" |
| 457 | 1 | pfleura2 | WRITE(*,*) "Autocart: True if you want to let the program choosing the cartesian atoms." |
| 458 | 1 | pfleura2 | WRITE(*,*) "VMD: TRUE if you want to use VMD to look at the Path. Used only for VASP for now" |
| 459 | 1 | pfleura2 | WRITE(*,*) "WriteVASP: TRUE if you want to print the images coordinates in POSCAR files." |
| 460 | 1 | pfleura2 | WRITE(*,*) "See also the POSCAR option. This can be used only if prog or input=VASP." |
| 461 | 1 | pfleura2 | WRITE(*,*) "" |
| 462 | 1 | pfleura2 | STOP |
| 463 | 1 | pfleura2 | END IF |
| 464 | 1 | pfleura2 | OPEN(IOIN,FILE=FileIn,STATUS='UNKNOWN') |
| 465 | 1 | pfleura2 | IOOUT=6 |
| 466 | 1 | pfleura2 | CASE (0) |
| 467 | 1 | pfleura2 | IOIN=5 |
| 468 | 1 | pfleura2 | IOOUT=6 |
| 469 | 1 | pfleura2 | END SELECT |
| 470 | 1 | pfleura2 | |
| 471 | 1 | pfleura2 | |
| 472 | 1 | pfleura2 | |
| 473 | 1 | pfleura2 | ! We initiliaze variables |
| 474 | 1 | pfleura2 | Pi=dacos(-1.0d0) |
| 475 | 1 | pfleura2 | Nat=1 |
| 476 | 1 | pfleura2 | Fact=1.1 |
| 477 | 1 | pfleura2 | IGeomRef=-1 |
| 478 | 1 | pfleura2 | NGeomI=1 |
| 479 | 1 | pfleura2 | NGeomF=8 |
| 480 | 1 | pfleura2 | IReparam=5 |
| 481 | 1 | pfleura2 | IReparamT=-1 |
| 482 | 1 | pfleura2 | ISpline=5 |
| 483 | 1 | pfleura2 | debug=.False. |
| 484 | 1 | pfleura2 | MW=.TRUE. |
| 485 | 1 | pfleura2 | bohr=.False. |
| 486 | 1 | pfleura2 | Coord='ZMAT' |
| 487 | 1 | pfleura2 | Step_method='RFO' |
| 488 | 1 | pfleura2 | DebugFile='Path.valid' |
| 489 | 1 | pfleura2 | PathName="Path" |
| 490 | 1 | pfleura2 | MaxCyc=50 |
| 491 | 1 | pfleura2 | SMax=0.1D0 |
| 492 | 1 | pfleura2 | SThresh=-1. |
| 493 | 1 | pfleura2 | GThresh=-1. |
| 494 | 1 | pfleura2 | FTan=0. |
| 495 | 1 | pfleura2 | Hinv=.TRUE. |
| 496 | 1 | pfleura2 | IniHUp=.FALSE. |
| 497 | 1 | pfleura2 | HupNeighbour=.FALSE. |
| 498 | 1 | pfleura2 | HesUpd="EMPTY" |
| 499 | 1 | pfleura2 | HUpdate="MS" |
| 500 | 1 | pfleura2 | FFrozen=.FALSE. |
| 501 | 1 | pfleura2 | FCart=.FALSE. |
| 502 | 1 | pfleura2 | List=0 |
| 503 | 1 | pfleura2 | renum=.TRUE. |
| 504 | 1 | pfleura2 | OptReac=.FALSE. |
| 505 | 1 | pfleura2 | OptProd=.FALSE. |
| 506 | 1 | pfleura2 | CalcEReac=.FALSE. |
| 507 | 1 | pfleura2 | CalcEProd=.FALSE. |
| 508 | 1 | pfleura2 | EReac=0.d0 |
| 509 | 1 | pfleura2 | EProd=0.d0 |
| 510 | 1 | pfleura2 | OptGeom=-1 |
| 511 | 1 | pfleura2 | PathOnly=.FALSE. |
| 512 | 1 | pfleura2 | Prog='EMPTY' |
| 513 | 1 | pfleura2 | ProgExe='EMPTY' |
| 514 | 1 | pfleura2 | Runmode='SERIAL' |
| 515 | 1 | pfleura2 | Input='EMPTY' |
| 516 | 1 | pfleura2 | Poscar="POSCAR" |
| 517 | 1 | pfleura2 | AutoCart=.FALSE. |
| 518 | 1 | pfleura2 | VMD=.TRUE. |
| 519 | 1 | pfleura2 | WriteVASP=.FALSE. |
| 520 | 1 | pfleura2 | DynMaxStep=.FALSE. |
| 521 | 1 | pfleura2 | CalcName="EMPTY" |
| 522 | 1 | pfleura2 | ISuffix="EMPTY" |
| 523 | 1 | pfleura2 | OSuffix="EMPTY" |
| 524 | 1 | pfleura2 | NGintMax=10 |
| 525 | 1 | pfleura2 | Align=.TRUE. |
| 526 | 1 | pfleura2 | |
| 527 | 1 | pfleura2 | ! Number of point used to compute the length of the path, |
| 528 | 1 | pfleura2 | ! and to reparameterize the path |
| 529 | 1 | pfleura2 | NMaxPtPath=-1 |
| 530 | 1 | pfleura2 | FrozTol=1e-4 |
| 531 | 1 | pfleura2 | |
| 532 | 1 | pfleura2 | ! Read the namelist |
| 533 | 1 | pfleura2 | read (IOIN,path) |
| 534 | 1 | pfleura2 | |
| 535 | 1 | pfleura2 | debug=valid("Main")
|
| 536 | 1 | pfleura2 | FCalcHess=valid("CalcHess")
|
| 537 | 1 | pfleura2 | PathName=AdjustL(PathName) |
| 538 | 1 | pfleura2 | Coord=AdjustL(Coord) |
| 539 | 1 | pfleura2 | CALL UpCase(coord) |
| 540 | 1 | pfleura2 | |
| 541 | 1 | pfleura2 | Step_method=AdjustL(Step_method) |
| 542 | 1 | pfleura2 | CALL UpCase(Step_method) |
| 543 | 1 | pfleura2 | |
| 544 | 1 | pfleura2 | Prog=AdjustL(Prog) |
| 545 | 1 | pfleura2 | CALL UpCase(prog) |
| 546 | 1 | pfleura2 | |
| 547 | 1 | pfleura2 | Input=AdjustL(Input) |
| 548 | 1 | pfleura2 | CALL UpCase(input) |
| 549 | 1 | pfleura2 | |
| 550 | 1 | pfleura2 | Runmode=AdjustL(Runmode) |
| 551 | 1 | pfleura2 | Call UpCase(Runmode) |
| 552 | 1 | pfleura2 | IF (Runmode(1:4).EQ.'PARA') Runmode="PARA" |
| 553 | 1 | pfleura2 | |
| 554 | 1 | pfleura2 | if ((RunMode.EQ."PARA").AND.(CalcEReac.OR.CalcEProd)) THEN |
| 555 | 1 | pfleura2 | WRITE(*,*) "CalcEReac and CalcEProd are not compatible (for now) with RunMode='PARA'" |
| 556 | 1 | pfleura2 | WRITE(*,*) "Setting CalcERead and CalcEProd to FALSE" |
| 557 | 1 | pfleura2 | CalcEReac=.FALSE. |
| 558 | 1 | pfleura2 | CalcEProd=.FALSE. |
| 559 | 1 | pfleura2 | END IF |
| 560 | 1 | pfleura2 | |
| 561 | 1 | pfleura2 | If (IReparamT<=0) IReparamT=IReparam |
| 562 | 1 | pfleura2 | |
| 563 | 1 | pfleura2 | ! We take care of HesUpd flag |
| 564 | 1 | pfleura2 | ! this is needed because some users might still use it |
| 565 | 1 | pfleura2 | if (HesUpd.NE."EMPTY") THEN |
| 566 | 1 | pfleura2 | ! We are pityless: |
| 567 | 1 | pfleura2 | WRITE(IOOUT,*) "HesUpd is deprecated. Use Hupdate instead" |
| 568 | 1 | pfleura2 | WRITE(*,*) "HesUpd is deprecated. Use Hupdate instead" |
| 569 | 1 | pfleura2 | STOP |
| 570 | 1 | pfleura2 | END IF |
| 571 | 1 | pfleura2 | |
| 572 | 1 | pfleura2 | |
| 573 | 1 | pfleura2 | IF (COORD.EQ.'CART') THEN |
| 574 | 1 | pfleura2 | Renum=.FALSE. |
| 575 | 1 | pfleura2 | IGeomRef=1 |
| 576 | 1 | pfleura2 | END IF |
| 577 | 1 | pfleura2 | |
| 578 | 1 | pfleura2 | if (Prog.EQ.'EMPTY') THEN |
| 579 | 1 | pfleura2 | Prog='GAUSSIAN' |
| 580 | 1 | pfleura2 | If (ProgExe=="EMPTY") ProgExe="g09" |
| 581 | 1 | pfleura2 | END IF |
| 582 | 1 | pfleura2 | if (Prog.EQ.'G03') THEN |
| 583 | 1 | pfleura2 | Prog='GAUSSIAN' |
| 584 | 1 | pfleura2 | If (ProgExe=="EMPTY") ProgExe="g03" |
| 585 | 1 | pfleura2 | END IF |
| 586 | 1 | pfleura2 | if (Prog.EQ.'G09') THEN |
| 587 | 1 | pfleura2 | Prog='GAUSSIAN' |
| 588 | 1 | pfleura2 | If (ProgExe=="EMPTY") ProgExe="g09" |
| 589 | 1 | pfleura2 | END IF |
| 590 | 1 | pfleura2 | |
| 591 | 1 | pfleura2 | if (Prog.EQ.'TM') Prog="TURBOMOLE" |
| 592 | 1 | pfleura2 | if (Prog.EQ.'TEST2') Prog="CHAMFRE" |
| 593 | 3 | pfleura2 | if (Prog.EQ.'TEST3') Prog="LEPS" |
| 594 | 1 | pfleura2 | |
| 595 | 1 | pfleura2 | |
| 596 | 1 | pfleura2 | Select Case (Prog) |
| 597 | 1 | pfleura2 | CASE ("EXT")
|
| 598 | 1 | pfleura2 | if (CalcName=="EMPTY") CalcName="Ext" |
| 599 | 1 | pfleura2 | if (ISuffix=="EMPTY") ISuffix="in" |
| 600 | 1 | pfleura2 | if (OSuffix=="EMPTY") OSuffix="out" |
| 601 | 1 | pfleura2 | CASE ('MOPAC')
|
| 602 | 1 | pfleura2 | if (CalcName=="EMPTY") CalcName="Path" |
| 603 | 1 | pfleura2 | if (ISuffix=="EMPTY") ISuffix="mop" |
| 604 | 1 | pfleura2 | if (OSuffix=="EMPTY") OSuffix="out" |
| 605 | 1 | pfleura2 | CASE ("GAUSSIAN")
|
| 606 | 1 | pfleura2 | if (CalcName=="EMPTY") CalcName="Path" |
| 607 | 1 | pfleura2 | if (ISuffix=="EMPTY") ISuffix="com" |
| 608 | 1 | pfleura2 | if (OSuffix=="EMPTY") OSuffix="log" |
| 609 | 1 | pfleura2 | CASE DEFAULT |
| 610 | 1 | pfleura2 | if (CalcName=="EMPTY") CalcName="Path" |
| 611 | 1 | pfleura2 | if (ISuffix=="EMPTY") ISuffix="in" |
| 612 | 1 | pfleura2 | if (OSuffix=="EMPTY") OSuffix="out" |
| 613 | 1 | pfleura2 | END SELECT |
| 614 | 1 | pfleura2 | |
| 615 | 1 | pfleura2 | if (Input.EQ.'EMPTY') THEN |
| 616 | 1 | pfleura2 | Select Case (Prog) |
| 617 | 1 | pfleura2 | CASE ("VASP")
|
| 618 | 1 | pfleura2 | Input=Prog |
| 619 | 1 | pfleura2 | CASE ("CHAMFRE")
|
| 620 | 1 | pfleura2 | Input="VASP" |
| 621 | 1 | pfleura2 | CASE DEFAULT |
| 622 | 1 | pfleura2 | Input='XYZ' |
| 623 | 1 | pfleura2 | END SELECT |
| 624 | 1 | pfleura2 | WRITE(*,*) "Input has been set to the default: ",INPUT |
| 625 | 1 | pfleura2 | END IF |
| 626 | 1 | pfleura2 | |
| 627 | 1 | pfleura2 | WriteVASP=WriteVASP.AND.((Prog=="VASP").OR.(Input=="VASP")) |
| 628 | 1 | pfleura2 | |
| 629 | 1 | pfleura2 | IF ((RunMode=="PARA").AND.((Prog/="GAUSSIAN").AND.(Prog/="VASP"))) THEN |
| 630 | 1 | pfleura2 | WRITE(*,*) "Program=",TRIM(Prog)," not yet supported for Para mode." |
| 631 | 1 | pfleura2 | STOP |
| 632 | 1 | pfleura2 | END IF |
| 633 | 1 | pfleura2 | |
| 634 | 1 | pfleura2 | if (OptGeom.GE.1) THEN |
| 635 | 1 | pfleura2 | HUpdate="BFGS" |
| 636 | 1 | pfleura2 | IF (IGeomRef.LE.0) THEN |
| 637 | 1 | pfleura2 | IGeomRef=OptGeom |
| 638 | 1 | pfleura2 | ELSE |
| 639 | 1 | pfleura2 | IF (IGeomRef.NE.OptGeom) THEN |
| 640 | 1 | pfleura2 | WRITE(IOOUT,*) "STOP: IGeomRef and OptGeom both set... but to different values !" |
| 641 | 1 | pfleura2 | WRITE(IOOUT,*) "Check it : IGeomRef=",IGeomRef," OptGeom=",OptGeom |
| 642 | 1 | pfleura2 | |
| 643 | 1 | pfleura2 | WRITE(*,*) "STOP: IGeomRef and OptGeom both set... but to different values !" |
| 644 | 1 | pfleura2 | WRITE(*,*) "Check it : IGeomRef=",IGeomRef," OptGeom=",OptGeom |
| 645 | 1 | pfleura2 | STOP |
| 646 | 1 | pfleura2 | END IF |
| 647 | 1 | pfleura2 | END IF |
| 648 | 1 | pfleura2 | END IF |
| 649 | 1 | pfleura2 | |
| 650 | 1 | pfleura2 | IF (ProgExe.EQ.'EMPTY') THEN |
| 651 | 1 | pfleura2 | SELECT CASE (PROG) |
| 652 | 1 | pfleura2 | CASE ("GAUSSIAN")
|
| 653 | 1 | pfleura2 | ProgExe="g03" |
| 654 | 1 | pfleura2 | CASE ("MOPAC")
|
| 655 | 1 | pfleura2 | ProgExe="mopac" |
| 656 | 1 | pfleura2 | CASE ("EXT")
|
| 657 | 1 | pfleura2 | ProgExe="./Ext.exe" |
| 658 | 1 | pfleura2 | CASE ("VASP")
|
| 659 | 1 | pfleura2 | ProgExe='VASP' |
| 660 | 1 | pfleura2 | CASE ("TURBOMOLE")
|
| 661 | 1 | pfleura2 | ProgExe='jobex -c 1 -keep' |
| 662 | 1 | pfleura2 | CASE ("TEST")
|
| 663 | 1 | pfleura2 | ProgExe="" |
| 664 | 1 | pfleura2 | CASE ("CHAMFRE")
|
| 665 | 1 | pfleura2 | ProgExe="" |
| 666 | 1 | pfleura2 | CASE DEFAULT |
| 667 | 1 | pfleura2 | WRITE(*,*) "Prog=",Adjustl(trim(Prog))," not recognized. STOP" |
| 668 | 1 | pfleura2 | STOP |
| 669 | 1 | pfleura2 | END SELECT |
| 670 | 1 | pfleura2 | END IF |
| 671 | 1 | pfleura2 | |
| 672 | 1 | pfleura2 | if (FCart.AND.FFrozen) THEN |
| 673 | 1 | pfleura2 | ! We have to be carreful because user might use any order |
| 674 | 1 | pfleura2 | ! to give the two lists CartList and FrozenList |
| 675 | 1 | pfleura2 | READ(IOIN,'(A)') Line |
| 676 | 1 | pfleura2 | Call Upcase(Line) |
| 677 | 1 | pfleura2 | if (Index(Line,"CART").NE.0) THEN |
| 678 | 1 | pfleura2 | ALLOCATE(Cart(Nat)) |
| 679 | 1 | pfleura2 | BackSpace(IOIN) |
| 680 | 1 | pfleura2 | List=0 |
| 681 | 1 | pfleura2 | READ(IOIN,cartlist) |
| 682 | 1 | pfleura2 | IF (COORD.NE.'CART') THEN |
| 683 | 1 | pfleura2 | Cart=List(1:Nat) |
| 684 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path L512 Cart",Cart |
| 685 | 1 | pfleura2 | ELSE |
| 686 | 1 | pfleura2 | WRITE(*,*) "FCart=T is not allowed when Coord='CART'" |
| 687 | 1 | pfleura2 | WRITE(*,*) "I will discard the cartlist" |
| 688 | 1 | pfleura2 | Cart=0 |
| 689 | 1 | pfleura2 | END IF |
| 690 | 1 | pfleura2 | |
| 691 | 1 | pfleura2 | ALLOCATE(Frozen(Nat)) |
| 692 | 1 | pfleura2 | BACKSPACE(IOIN) |
| 693 | 1 | pfleura2 | List=0 |
| 694 | 1 | pfleura2 | READ(IOIN,Frozenlist) |
| 695 | 1 | pfleura2 | Frozen=List(1:Nat) |
| 696 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path L517 Frozen",Frozen |
| 697 | 1 | pfleura2 | ELSE |
| 698 | 1 | pfleura2 | ALLOCATE(Frozen(Nat)) |
| 699 | 1 | pfleura2 | BACKSPACE(IOIN) |
| 700 | 1 | pfleura2 | List=0 |
| 701 | 1 | pfleura2 | READ(IOIN,Frozenlist) |
| 702 | 1 | pfleura2 | Frozen=List(1:Nat) |
| 703 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path L523 Frozen",Frozen |
| 704 | 1 | pfleura2 | ALLOCATE(Cart(Nat)) |
| 705 | 1 | pfleura2 | BackSpace(IOIN) |
| 706 | 1 | pfleura2 | List=0 |
| 707 | 1 | pfleura2 | READ(IOIN,cartlist) |
| 708 | 1 | pfleura2 | IF (COORD.NE.'CART') THEN |
| 709 | 1 | pfleura2 | Cart=List(1:Nat) |
| 710 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path L548 Cart",Cart |
| 711 | 1 | pfleura2 | ELSE |
| 712 | 1 | pfleura2 | WRITE(*,*) "FCart=T is not allowed when Coord='CART'" |
| 713 | 1 | pfleura2 | WRITE(*,*) "I will discard the cartlist" |
| 714 | 1 | pfleura2 | Cart=0 |
| 715 | 1 | pfleura2 | END IF |
| 716 | 1 | pfleura2 | END IF |
| 717 | 1 | pfleura2 | ELSE |
| 718 | 1 | pfleura2 | if (FCart) THEN |
| 719 | 1 | pfleura2 | ALLOCATE(Cart(Nat)) |
| 720 | 1 | pfleura2 | List=0 |
| 721 | 1 | pfleura2 | READ(IOIN,cartlist) |
| 722 | 1 | pfleura2 | IF (COORD.NE.'CART') THEN |
| 723 | 1 | pfleura2 | Cart=List(1:Nat) |
| 724 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path L561 Cart",Cart |
| 725 | 1 | pfleura2 | ELSE |
| 726 | 1 | pfleura2 | WRITE(*,*) "FCart=T is not allowed when Coord='CART'" |
| 727 | 1 | pfleura2 | WRITE(*,*) "I will discard the cartlist" |
| 728 | 1 | pfleura2 | Cart=0 |
| 729 | 1 | pfleura2 | END IF |
| 730 | 1 | pfleura2 | ELSE |
| 731 | 1 | pfleura2 | IF ((PROG=="VASP").OR.(AutoCart)) THEN |
| 732 | 1 | pfleura2 | ALLOCATE(Cart(Nat)) |
| 733 | 1 | pfleura2 | ELSE |
| 734 | 1 | pfleura2 | ALLOCATE(Cart(1)) |
| 735 | 1 | pfleura2 | END IF |
| 736 | 1 | pfleura2 | Cart=0 |
| 737 | 1 | pfleura2 | END IF |
| 738 | 1 | pfleura2 | |
| 739 | 1 | pfleura2 | if (FFrozen) THEN |
| 740 | 1 | pfleura2 | ALLOCATE(Frozen(Nat)) |
| 741 | 1 | pfleura2 | List=0 |
| 742 | 1 | pfleura2 | READ(IOIN,Frozenlist) |
| 743 | 1 | pfleura2 | Frozen=List(1:Nat) |
| 744 | 1 | pfleura2 | WRITE(*,*) Frozen |
| 745 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path L549 Frozen",Frozen |
| 746 | 1 | pfleura2 | ELSE |
| 747 | 1 | pfleura2 | IF (PROG=="VASP") THEN |
| 748 | 1 | pfleura2 | ALLOCATE(Frozen(Nat)) |
| 749 | 1 | pfleura2 | ELSE |
| 750 | 1 | pfleura2 | ALLOCATE(Frozen(1)) |
| 751 | 1 | pfleura2 | END IF |
| 752 | 1 | pfleura2 | Frozen=0 |
| 753 | 1 | pfleura2 | END IF |
| 754 | 1 | pfleura2 | END IF |
| 755 | 1 | pfleura2 | |
| 756 | 1 | pfleura2 | |
| 757 | 1 | pfleura2 | If (FCart) Call Expand(Cart,NCart,Nat) |
| 758 | 1 | pfleura2 | IF (FFrozen) Call Expand(Frozen,NFroz,Nat) |
| 759 | 1 | pfleura2 | |
| 760 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Main L609, Ncart,Cart",NCart,Cart |
| 761 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Main L610, NFroz,Frozen", NFroz,Frozen |
| 762 | 1 | pfleura2 | |
| 763 | 1 | pfleura2 | if (NMaxPtPath.EQ.-1) then |
| 764 | 1 | pfleura2 | NMaxPtPath=min(50*NGeomF,2000) |
| 765 | 1 | pfleura2 | NMaxPtPath=max(20*NGeomF,NMaxPtPath) |
| 766 | 1 | pfleura2 | end if |
| 767 | 1 | pfleura2 | |
| 768 | 1 | pfleura2 | ! NMaxPtPath=10000 |
| 769 | 1 | pfleura2 | |
| 770 | 1 | pfleura2 | ! We ensure that FTan is in [0.:1.] |
| 771 | 1 | pfleura2 | FTan=min(abs(FTan),1.d0) |
| 772 | 1 | pfleura2 | |
| 773 | 1 | pfleura2 | ! PFL 2011 Mar 14 -> |
| 774 | 1 | pfleura2 | ! Added some printing for analyses with Anapath |
| 775 | 1 | pfleura2 | if (debug) THEN |
| 776 | 1 | pfleura2 | WRITE(IOOUT,path) |
| 777 | 1 | pfleura2 | ELSE |
| 778 | 1 | pfleura2 | ! Even when debug is off we print NAT, NGEOMI, NGEOMF, MAXCYC |
| 779 | 1 | pfleura2 | ! and PATHNAME |
| 780 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A,I5)') "NAT = ", nat |
| 781 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A,I5)') "NGEOMI = ", NGeomI |
| 782 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A,I5)') "NGEOMF = ", NGeomF |
| 783 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A,I5)') "MAXCYC = ", MaxCYC |
| 784 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A,1X,A)') "PATHNAME = ", Trim(PATHNAME) |
| 785 | 1 | pfleura2 | END IF |
| 786 | 1 | pfleura2 | |
| 787 | 1 | pfleura2 | FTan=1.-FTan |
| 788 | 1 | pfleura2 | |
| 789 | 1 | pfleura2 | !Thresholds... |
| 790 | 1 | pfleura2 | if (SThresh.LE.0) SThresh=0.01d0 |
| 791 | 1 | pfleura2 | If (GThresh.LE.0) GThresh=SThresh/4. |
| 792 | 1 | pfleura2 | SThreshRms=Sthresh*2./3. |
| 793 | 1 | pfleura2 | GThreshRms=Gthresh*2./3. |
| 794 | 1 | pfleura2 | |
| 795 | 1 | pfleura2 | ! First batch of allocations. Arrays that depend only on NGeomI, Nat |
| 796 | 1 | pfleura2 | ALLOCATE(XyzGeomI(NGeomI,3,Nat), AtName(NAt)) |
| 797 | 1 | pfleura2 | ALLOCATE(IndZmat(Nat,5),Order(Nat),Atome(Nat)) |
| 798 | 1 | pfleura2 | ALLOCATE(MassAt(NAt),OrderInv(Nat)) |
| 799 | 1 | pfleura2 | |
| 800 | 1 | pfleura2 | ! We read the initial geometries |
| 801 | 1 | pfleura2 | Call Read_Geom(input) |
| 802 | 1 | pfleura2 | |
| 803 | 1 | pfleura2 | ! We convert atome names into atom mass number |
| 804 | 1 | pfleura2 | DO I=1,NAt |
| 805 | 1 | pfleura2 | ! WRITE(*,*) 'I,AtName',I,AtName(I) |
| 806 | 1 | pfleura2 | Atome(I)=ConvertNumAt(AtName(I)) |
| 807 | 1 | pfleura2 | END DO |
| 808 | 1 | pfleura2 | |
| 809 | 1 | pfleura2 | |
| 810 | 1 | pfleura2 | ! PFL 23 Sep 2008 -> |
| 811 | 1 | pfleura2 | ! We check that frozen atoms are really frozen, ie that their coordinates do not change |
| 812 | 1 | pfleura2 | ! between the first geometry and the others. |
| 813 | 1 | pfleura2 | IF (NFroz.GT.0) THEN |
| 814 | 1 | pfleura2 | ALLOCATE(ListAtFroz(Nat),x1(Nat),y1(nat),z1(nat)) |
| 815 | 1 | pfleura2 | ALLOCATE(x2(nat),y2(nat),z2(nat)) |
| 816 | 1 | pfleura2 | ListAtFroz=.FALSE. |
| 817 | 1 | pfleura2 | |
| 818 | 1 | pfleura2 | x1(1:Nat)=XyzgeomI(1,1,1:Nat) |
| 819 | 1 | pfleura2 | y1(1:Nat)=XyzgeomI(1,2,1:Nat) |
| 820 | 1 | pfleura2 | z1(1:Nat)=XyzgeomI(1,3,1:Nat) |
| 821 | 1 | pfleura2 | |
| 822 | 1 | pfleura2 | SELECT CASE (NFroz) |
| 823 | 1 | pfleura2 | ! We have Frozen atoms |
| 824 | 1 | pfleura2 | ! PFL 28 Oct 2008 -> |
| 825 | 1 | pfleura2 | ! It might happen that the geometries are translated/rotated. |
| 826 | 1 | pfleura2 | ! So if we have 3 (or more) frozen atoms, we re-orient the geometries, based on the first |
| 827 | 1 | pfleura2 | ! three frozen atoms. |
| 828 | 1 | pfleura2 | |
| 829 | 1 | pfleura2 | CASE (3:) |
| 830 | 1 | pfleura2 | DO I=1,NFroz |
| 831 | 1 | pfleura2 | ListAtFroz(Frozen(I))=.TRUE. |
| 832 | 1 | pfleura2 | END DO |
| 833 | 1 | pfleura2 | CASE (2) |
| 834 | 1 | pfleura2 | IAt1=Frozen(1) |
| 835 | 1 | pfleura2 | IAt2=Frozen(2) |
| 836 | 1 | pfleura2 | ListAtFroz(Iat1)=.TRUE. |
| 837 | 1 | pfleura2 | ListAtFroz(Iat2)=.TRUE. |
| 838 | 1 | pfleura2 | x2(1)=x1(Iat2)-x1(Iat1) |
| 839 | 1 | pfleura2 | y2(1)=y1(Iat2)-y1(Iat1) |
| 840 | 1 | pfleura2 | z2(1)=z1(Iat2)-z1(Iat1) |
| 841 | 1 | pfleura2 | Norm1=sqrt(x2(1)**2+y2(1)**2+z2(1)**2) |
| 842 | 1 | pfleura2 | Dist=-1. |
| 843 | 1 | pfleura2 | ! We scan all atoms to find one that is not aligned with Iat1-Iat2 |
| 844 | 1 | pfleura2 | DO I=1,Nat |
| 845 | 1 | pfleura2 | if ((I.EQ.Iat1).OR.(I.EQ.Iat2)) Cycle |
| 846 | 1 | pfleura2 | x2(2)=x1(Iat2)-x1(I) |
| 847 | 1 | pfleura2 | y2(2)=y1(Iat2)-y1(I) |
| 848 | 1 | pfleura2 | z2(2)=z1(Iat2)-z1(I) |
| 849 | 1 | pfleura2 | Norm2=sqrt(x2(2)**2+y2(2)**2+z2(2)**2) |
| 850 | 1 | pfleura2 | ca=(x2(1)*x2(2)+y2(1)*y2(2)+z2(1)*Z2(2))/(Norm1*Norm2) |
| 851 | 1 | pfleura2 | if (abs(ca)<0.9) THEN |
| 852 | 1 | pfleura2 | IF (Norm2>Dist) THEN |
| 853 | 1 | pfleura2 | Iat3=I |
| 854 | 1 | pfleura2 | Dist=Norm2 |
| 855 | 1 | pfleura2 | END IF |
| 856 | 1 | pfleura2 | END IF |
| 857 | 1 | pfleura2 | END DO |
| 858 | 1 | pfleura2 | ListAtFroz(Iat3)=.TRUE. |
| 859 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path, NFroz=2, third frozen=",Iat3 |
| 860 | 1 | pfleura2 | CASE (1) |
| 861 | 1 | pfleura2 | IAt1=Frozen(1) |
| 862 | 1 | pfleura2 | ListAtFroz(Iat1)=.TRUE. |
| 863 | 1 | pfleura2 | Dist=-1. |
| 864 | 1 | pfleura2 | ! We scan all atoms to find one that is further from At1 |
| 865 | 1 | pfleura2 | DO I=1,Nat |
| 866 | 1 | pfleura2 | if (I.EQ.Iat1) Cycle |
| 867 | 1 | pfleura2 | x2(1)=x1(Iat1)-x1(I) |
| 868 | 1 | pfleura2 | y2(1)=y1(Iat1)-y1(I) |
| 869 | 1 | pfleura2 | z2(1)=z1(Iat1)-z1(I) |
| 870 | 1 | pfleura2 | Norm1=sqrt(x2(1)**2+y2(1)**2+z2(1)**2) |
| 871 | 1 | pfleura2 | IF (Norm1>Dist) THEN |
| 872 | 1 | pfleura2 | Iat2=I |
| 873 | 1 | pfleura2 | Dist=Norm1 |
| 874 | 1 | pfleura2 | END IF |
| 875 | 1 | pfleura2 | END DO |
| 876 | 1 | pfleura2 | IAt2=Frozen(2) |
| 877 | 1 | pfleura2 | ListAtFroz(Iat2)=.TRUE. |
| 878 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path, NFroz=1, second frozen=",Iat2 |
| 879 | 1 | pfleura2 | x2(1)=x1(Iat2)-x1(Iat1) |
| 880 | 1 | pfleura2 | y2(1)=y1(Iat2)-y1(Iat1) |
| 881 | 1 | pfleura2 | z2(1)=z1(Iat2)-z1(Iat1) |
| 882 | 1 | pfleura2 | Norm1=sqrt(x2(1)**2+y2(1)**2+z2(1)**2) |
| 883 | 1 | pfleura2 | Dist=-1. |
| 884 | 1 | pfleura2 | ! We scan all atoms to find one that is not aligned with Iat1-Iat2 |
| 885 | 1 | pfleura2 | DO I=1,Nat |
| 886 | 1 | pfleura2 | if ((I.EQ.Iat1).OR.(I.EQ.Iat2)) Cycle |
| 887 | 1 | pfleura2 | x2(2)=x1(Iat2)-x1(I) |
| 888 | 1 | pfleura2 | y2(2)=y1(Iat2)-y1(I) |
| 889 | 1 | pfleura2 | z2(2)=z1(Iat2)-z1(I) |
| 890 | 1 | pfleura2 | Norm2=sqrt(x2(2)**2+y2(2)**2+z2(2)**2) |
| 891 | 1 | pfleura2 | ca=(x2(1)*x2(2)+y2(1)*y2(2)+z2(1)*Z2(2))/(Norm1*Norm2) |
| 892 | 1 | pfleura2 | if (abs(ca)<0.9) THEN |
| 893 | 1 | pfleura2 | IF (Norm2>Dist) THEN |
| 894 | 1 | pfleura2 | Iat3=I |
| 895 | 1 | pfleura2 | Dist=Norm2 |
| 896 | 1 | pfleura2 | END IF |
| 897 | 1 | pfleura2 | END IF |
| 898 | 1 | pfleura2 | END DO |
| 899 | 1 | pfleura2 | ListAtFroz(Iat3)=.TRUE. |
| 900 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path, NFroz=1, third frozen=",Iat3 |
| 901 | 1 | pfleura2 | END SELECT |
| 902 | 1 | pfleura2 | |
| 903 | 1 | pfleura2 | DO I=2,NGeomI |
| 904 | 1 | pfleura2 | ! First, we align the Ith geometry on the first one, using only |
| 905 | 1 | pfleura2 | ! the positions of the "frozen" atoms. (see above: it might be that |
| 906 | 1 | pfleura2 | ! ListAtFroz contains non frozen atoms usd to align the geometries |
| 907 | 1 | pfleura2 | x2(1:Nat)=XyzgeomI(I,1,1:Nat) |
| 908 | 1 | pfleura2 | y2(1:Nat)=XyzgeomI(I,2,1:Nat) |
| 909 | 1 | pfleura2 | z2(1:Nat)=XyzgeomI(I,3,1:Nat) |
| 910 | 1 | pfleura2 | Call Alignpartial(Nat,x1,y1,z1,x2,y2,z2,ListAtFroz,MRot) |
| 911 | 1 | pfleura2 | |
| 912 | 1 | pfleura2 | |
| 913 | 1 | pfleura2 | FChkFrozen=.FALSE. |
| 914 | 1 | pfleura2 | DO J=1,NFroz |
| 915 | 1 | pfleura2 | IAt=Frozen(J) |
| 916 | 1 | pfleura2 | IF ((abs(X1(Iat)-X2(Iat)).GT.FrozTol).OR. & |
| 917 | 1 | pfleura2 | (abs(y1(Iat)-y2(Iat)).GT.FrozTol).OR. & |
| 918 | 1 | pfleura2 | (abs(z1(Iat)-z2(Iat)).GT.FrozTol)) THEN |
| 919 | 1 | pfleura2 | IF (.NOT.FChkFrozen) WRITE(*,*) "*** WARNING ****" |
| 920 | 1 | pfleura2 | FChkFrozen=.TRUE. |
| 921 | 1 | pfleura2 | WRITE(*,*) "Atom ",Iat," is set to Frozen but its coordinates change" |
| 922 | 1 | pfleura2 | WRITE(*,*) "from geometry 1 to geometry ",I |
| 923 | 1 | pfleura2 | END IF |
| 924 | 1 | pfleura2 | END DO |
| 925 | 1 | pfleura2 | END DO |
| 926 | 1 | pfleura2 | IF (FChkFrozen) THEN |
| 927 | 1 | pfleura2 | WRITE(*,*) "Some frozen atoms are not frozen... check this and play again" |
| 928 | 1 | pfleura2 | STOP |
| 929 | 1 | pfleura2 | END IF |
| 930 | 1 | pfleura2 | END IF |
| 931 | 1 | pfleura2 | |
| 932 | 1 | pfleura2 | |
| 933 | 1 | pfleura2 | N3at=3*Nat |
| 934 | 1 | pfleura2 | NFree=N3at-6 ! ATTENTION: THIS IS NOT VALID FOR ALL TYPES OF COORDINATES. |
| 935 | 1 | pfleura2 | |
| 936 | 1 | pfleura2 | ! if prog=gaussian, we have to read a full input |
| 937 | 1 | pfleura2 | ! to mimic it later |
| 938 | 1 | pfleura2 | if (prog=='GAUSSIAN') THEN |
| 939 | 1 | pfleura2 | ! We read the Gaussian input file |
| 940 | 1 | pfleura2 | ! First, the root |
| 941 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Gauss Root" |
| 942 | 1 | pfleura2 | ALLOCATE(Gauss_Root) |
| 943 | 1 | pfleura2 | NULLIFY(Gauss_Root%next) |
| 944 | 1 | pfleura2 | Current => Gauss_root |
| 945 | 1 | pfleura2 | LineL=1 |
| 946 | 1 | pfleura2 | DO WHILE (LineL.NE.0) |
| 947 | 1 | pfleura2 | READ(IOIN,'(A)') Line |
| 948 | 1 | pfleura2 | Line=AdjustL(Line) |
| 949 | 1 | pfleura2 | LineL=len(Trim(Line)) |
| 950 | 1 | pfleura2 | Idx=INDEX(Line,"chk") |
| 951 | 1 | pfleura2 | IF ((LineL.NE.0).AND.(Idx.EQ.0)) THEN |
| 952 | 1 | pfleura2 | current%Line=TRIM(Line) |
| 953 | 1 | pfleura2 | ALLOCATE(current%next) |
| 954 | 1 | pfleura2 | Current => Current%next |
| 955 | 1 | pfleura2 | Nullify(Current%next) |
| 956 | 1 | pfleura2 | END IF |
| 957 | 1 | pfleura2 | END DO |
| 958 | 1 | pfleura2 | |
| 959 | 1 | pfleura2 | ! Current => Gauss_root |
| 960 | 1 | pfleura2 | ! DO WHILE (ASSOCIATED(Current%next)) |
| 961 | 1 | pfleura2 | ! WRITE(*,'(1X,A)') Trim(current%line) |
| 962 | 1 | pfleura2 | ! Current => current%next |
| 963 | 1 | pfleura2 | ! END DO |
| 964 | 1 | pfleura2 | |
| 965 | 1 | pfleura2 | ! Now the comment... |
| 966 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Gauss Comment" |
| 967 | 1 | pfleura2 | ALLOCATE(Gauss_Comment) |
| 968 | 1 | pfleura2 | NuLLIFY(Gauss_Comment%Next) |
| 969 | 1 | pfleura2 | Current => Gauss_comment |
| 970 | 1 | pfleura2 | LineL=1 |
| 971 | 1 | pfleura2 | DO WHILE (LineL.NE.0) |
| 972 | 1 | pfleura2 | READ(IOIN,'(A)') Line |
| 973 | 1 | pfleura2 | Line=AdjustL(Line) |
| 974 | 1 | pfleura2 | LineL=len(Trim(Line)) |
| 975 | 1 | pfleura2 | IF (LineL.NE.0) THEN |
| 976 | 1 | pfleura2 | current%Line=TRIM(Line) |
| 977 | 1 | pfleura2 | ALLOCATE(current%next) |
| 978 | 1 | pfleura2 | Current => Current%next |
| 979 | 1 | pfleura2 | Nullify(Current%next) |
| 980 | 1 | pfleura2 | END IF |
| 981 | 1 | pfleura2 | END DO |
| 982 | 1 | pfleura2 | |
| 983 | 1 | pfleura2 | ! Current => Gauss_comment |
| 984 | 1 | pfleura2 | ! DO WHILE (ASSOCIATED(Current%next)) |
| 985 | 1 | pfleura2 | ! WRITE(*,'(1X,A)') Trim(current%line) |
| 986 | 1 | pfleura2 | ! Current => current%next |
| 987 | 1 | pfleura2 | ! END DO |
| 988 | 1 | pfleura2 | |
| 989 | 1 | pfleura2 | ! Now the charge |
| 990 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Gauss Charge" |
| 991 | 1 | pfleura2 | READ(IOIN,'(A)') Gauss_Charge |
| 992 | 1 | pfleura2 | ! WRITE(*,*) Gauss_charge |
| 993 | 1 | pfleura2 | ! We now read the Paste part... |
| 994 | 1 | pfleura2 | ALLOCATE(Gauss_Paste(NAt)) |
| 995 | 1 | pfleura2 | LenLine=1 |
| 996 | 1 | pfleura2 | Iat=0 |
| 997 | 1 | pfleura2 | Gauss_paste=" " |
| 998 | 1 | pfleura2 | DO While (LenLine.GT.0) |
| 999 | 1 | pfleura2 | READ(IOIN,'(A)') Line |
| 1000 | 1 | pfleura2 | Line=AdjustL(Line) |
| 1001 | 1 | pfleura2 | LenLine=Len_TRIM(Line) |
| 1002 | 1 | pfleura2 | IF (LenLine.GT.0) Iat=Iat+1 |
| 1003 | 1 | pfleura2 | Idx=Index(Line,'.',BACK=.TRUE.) |
| 1004 | 1 | pfleura2 | ! WRITE(*,*) Idx,TRIM(Line) |
| 1005 | 1 | pfleura2 | ! WRITE(*,*) Idx,TRIM(Line(Idx+1:)) |
| 1006 | 1 | pfleura2 | Line=ADJUSTL(Line(Idx+1:)) |
| 1007 | 1 | pfleura2 | Idx=Index(Line," ") |
| 1008 | 1 | pfleura2 | LineL=LEN_TRIM(Line(Idx:)) |
| 1009 | 1 | pfleura2 | ! WRITE(*,*) LineL,TRIM(Line(Idx:)) |
| 1010 | 1 | pfleura2 | IF (LineL.GT.0) THEN |
| 1011 | 1 | pfleura2 | Gauss_paste(Iat)=Line(Idx:) |
| 1012 | 1 | pfleura2 | END IF |
| 1013 | 1 | pfleura2 | END DO |
| 1014 | 1 | pfleura2 | IF (Iat.NE.Nat) THEN |
| 1015 | 1 | pfleura2 | WRITE(*,*) "I found ", Iat," lines for the geometry instead of ",Nat |
| 1016 | 1 | pfleura2 | WRITE(*,*) "ERROR. STOP" |
| 1017 | 1 | pfleura2 | WRITE(IOOUT,*) "I found ", Iat," lines for the geometry instead of ",Nat |
| 1018 | 1 | pfleura2 | WRITE(IOOUT,*) "ERROR. STOP" |
| 1019 | 1 | pfleura2 | STOP |
| 1020 | 1 | pfleura2 | END IF |
| 1021 | 1 | pfleura2 | ! We now read the last part |
| 1022 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Gauss End" |
| 1023 | 1 | pfleura2 | ! READ(IOIN,'(A)') Line |
| 1024 | 1 | pfleura2 | ALLOCATE(Gauss_End) |
| 1025 | 1 | pfleura2 | NuLLIFY(Gauss_End%Next) |
| 1026 | 1 | pfleura2 | Current => Gauss_End |
| 1027 | 1 | pfleura2 | LineL=1 |
| 1028 | 1 | pfleura2 | DO WHILE (1.EQ.1) |
| 1029 | 1 | pfleura2 | READ(IOIN,'(A)',END=999) Line |
| 1030 | 1 | pfleura2 | Line=AdjustL(Line) |
| 1031 | 1 | pfleura2 | LineL=len(Trim(Line)) |
| 1032 | 1 | pfleura2 | current%Line=TRIM(Line) |
| 1033 | 1 | pfleura2 | ALLOCATE(current%next) |
| 1034 | 1 | pfleura2 | Current => Current%next |
| 1035 | 1 | pfleura2 | Nullify(Current%next) |
| 1036 | 1 | pfleura2 | END DO |
| 1037 | 1 | pfleura2 | 999 CONTINUE |
| 1038 | 1 | pfleura2 | |
| 1039 | 1 | pfleura2 | ! ! Write the gaussian input file for testing purposes |
| 1040 | 1 | pfleura2 | ! Current => Gauss_root |
| 1041 | 1 | pfleura2 | ! DO WHILE (ASSOCIATED(Current%next)) |
| 1042 | 1 | pfleura2 | ! WRITE(*,'(1X,A)') Trim(current%line) |
| 1043 | 1 | pfleura2 | ! Current => current%next |
| 1044 | 1 | pfleura2 | ! END DO |
| 1045 | 1 | pfleura2 | |
| 1046 | 1 | pfleura2 | ! WRITE(*,*) |
| 1047 | 1 | pfleura2 | ! WRITE(*,*) 'Comment original' |
| 1048 | 1 | pfleura2 | |
| 1049 | 1 | pfleura2 | ! Current => Gauss_comment |
| 1050 | 1 | pfleura2 | ! DO WHILE (ASSOCIATED(Current%next)) |
| 1051 | 1 | pfleura2 | ! WRITE(*,'(1X,A)') Trim(current%line) |
| 1052 | 1 | pfleura2 | ! Current => current%next |
| 1053 | 1 | pfleura2 | ! END DO |
| 1054 | 1 | pfleura2 | |
| 1055 | 1 | pfleura2 | ! WRITE(*,*) |
| 1056 | 1 | pfleura2 | ! WRITE(*,*) Trim(Gauss_charge) |
| 1057 | 1 | pfleura2 | |
| 1058 | 1 | pfleura2 | ! DO I=1,Nat |
| 1059 | 1 | pfleura2 | ! WRITE(*,'(1X,A10,3(1X,F15.8),A)') Trim(AtName(I)),XyzGeomI(1:3,I,1), TRIM(Gauss_Paste(I)) |
| 1060 | 1 | pfleura2 | ! END DO |
| 1061 | 1 | pfleura2 | |
| 1062 | 1 | pfleura2 | ! WRITE(*,*) |
| 1063 | 1 | pfleura2 | ! Current => Gauss_End |
| 1064 | 1 | pfleura2 | ! DO WHILE (ASSOCIATED(Current%next)) |
| 1065 | 1 | pfleura2 | ! WRITE(*,'(1X,A)') Trim(current%line) |
| 1066 | 1 | pfleura2 | ! Current => current%next |
| 1067 | 1 | pfleura2 | ! END DO |
| 1068 | 1 | pfleura2 | |
| 1069 | 1 | pfleura2 | ! WRITE(*,*) |
| 1070 | 1 | pfleura2 | |
| 1071 | 1 | pfleura2 | END IF |
| 1072 | 1 | pfleura2 | |
| 1073 | 1 | pfleura2 | ! if prog=mopac, we have to read a full input to reproduce it later |
| 1074 | 1 | pfleura2 | ! The structure is: |
| 1075 | 1 | pfleura2 | ! A MOPAC data set normally consists of one line of keywords, two lines of user-defined text, then the coordinates |
| 1076 | 1 | pfleura2 | ! Then a blank line or a line of 0. |
| 1077 | 1 | pfleura2 | ! then the symmetry description. |
| 1078 | 1 | pfleura2 | ! comment lines start with * and can be anywhere !!! |
| 1079 | 1 | pfleura2 | |
| 1080 | 1 | pfleura2 | if (prog=='MOPAC') THEN |
| 1081 | 1 | pfleura2 | ! We read the Gaussian input file |
| 1082 | 1 | pfleura2 | ! First, the root |
| 1083 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Mopac input" |
| 1084 | 1 | pfleura2 | ALLOCATE(Mopac_Root) |
| 1085 | 1 | pfleura2 | NULLIFY(Mopac_Root%next) |
| 1086 | 1 | pfleura2 | ALLOCATE(Mopac_Comment) |
| 1087 | 1 | pfleura2 | NULLIFY(Mopac_Comment%next) |
| 1088 | 1 | pfleura2 | ALLOCATE(Mopac_End) |
| 1089 | 1 | pfleura2 | NuLLIFY(Mopac_End%Next) |
| 1090 | 1 | pfleura2 | Current => Mopac_root |
| 1091 | 1 | pfleura2 | CurCom => Mopac_Comment |
| 1092 | 1 | pfleura2 | LineL=1 |
| 1093 | 1 | pfleura2 | NTmp=0 |
| 1094 | 1 | pfleura2 | DO WHILE (NTmp.LT.3) |
| 1095 | 1 | pfleura2 | READ(IOIN,'(A)') Line |
| 1096 | 1 | pfleura2 | Line=AdjustL(Line) |
| 1097 | 1 | pfleura2 | LineL=len(Trim(Line)) |
| 1098 | 1 | pfleura2 | IF (Line(1:1)/="*") THEN |
| 1099 | 1 | pfleura2 | IF (NTmp==0) THEN |
| 1100 | 1 | pfleura2 | Line2=Line |
| 1101 | 1 | pfleura2 | Call UpCase(Line2) |
| 1102 | 1 | pfleura2 | Idx=Index(Line2,'GRADIENTS') |
| 1103 | 1 | pfleura2 | If (Idx==0) Line=TRIM(Line) // " GRADIENTS" |
| 1104 | 1 | pfleura2 | Idx=Index(Line2,'1SCF') |
| 1105 | 1 | pfleura2 | If (Idx==0) Line=TRIM(Line) // " 1SCF" |
| 1106 | 1 | pfleura2 | END IF |
| 1107 | 1 | pfleura2 | current%Line=TRIM(Line) |
| 1108 | 1 | pfleura2 | ALLOCATE(current%next) |
| 1109 | 1 | pfleura2 | Current => Current%next |
| 1110 | 1 | pfleura2 | Nullify(Current%next) |
| 1111 | 1 | pfleura2 | NTmp=NTmp+1 |
| 1112 | 1 | pfleura2 | ELSE |
| 1113 | 1 | pfleura2 | CurCom%Line=TRIM(LINE) |
| 1114 | 1 | pfleura2 | ALLOCATE(CurCom%Next) |
| 1115 | 1 | pfleura2 | CurCom => CurCom%Next |
| 1116 | 1 | pfleura2 | NULLIFY(CurCom%Next) |
| 1117 | 1 | pfleura2 | END IF |
| 1118 | 1 | pfleura2 | END DO |
| 1119 | 1 | pfleura2 | |
| 1120 | 1 | pfleura2 | ! Current => Mopac_root |
| 1121 | 1 | pfleura2 | ! DO WHILE (ASSOCIATED(Current%next)) |
| 1122 | 1 | pfleura2 | ! WRITE(*,'(1X,A)') Trim(current%line) |
| 1123 | 1 | pfleura2 | ! Current => current%next |
| 1124 | 1 | pfleura2 | ! END DO |
| 1125 | 1 | pfleura2 | |
| 1126 | 1 | pfleura2 | ! Now the geometry... that we just skip :) |
| 1127 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Mopac Geometry" |
| 1128 | 1 | pfleura2 | Mopac_EndGeom="" |
| 1129 | 1 | pfleura2 | LineL=1 |
| 1130 | 1 | pfleura2 | DO WHILE (LineL.NE.0) |
| 1131 | 1 | pfleura2 | READ(IOIN,'(A)',END=989) Line |
| 1132 | 1 | pfleura2 | Line=AdjustL(Line) |
| 1133 | 1 | pfleura2 | LineL=len(Trim(Line)) |
| 1134 | 1 | pfleura2 | ! The last line might be either blank or filled with 0 |
| 1135 | 1 | pfleura2 | IF (Line(1:1)=="0") THEN |
| 1136 | 1 | pfleura2 | LineL=0 |
| 1137 | 1 | pfleura2 | Mopac_EndGeom=Trim(Line) |
| 1138 | 1 | pfleura2 | END IF |
| 1139 | 1 | pfleura2 | IF (Line(1:1)=="*") THEN |
| 1140 | 1 | pfleura2 | CurCom%Line=TRIM(LINE) |
| 1141 | 1 | pfleura2 | ALLOCATE(CurCom%Next) |
| 1142 | 1 | pfleura2 | CurCom => CurCom%Next |
| 1143 | 1 | pfleura2 | NULLIFY(CurCom%Next) |
| 1144 | 1 | pfleura2 | END IF |
| 1145 | 1 | pfleura2 | END DO |
| 1146 | 1 | pfleura2 | |
| 1147 | 1 | pfleura2 | ! If we are here, there might be something else to read: Mopac_end |
| 1148 | 1 | pfleura2 | |
| 1149 | 1 | pfleura2 | ! We now read the last part |
| 1150 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Mopac End" |
| 1151 | 1 | pfleura2 | ! READ(IOIN,'(A)') Line |
| 1152 | 1 | pfleura2 | Current => Mopac_End |
| 1153 | 1 | pfleura2 | LineL=1 |
| 1154 | 1 | pfleura2 | DO WHILE (1.EQ.1) |
| 1155 | 1 | pfleura2 | READ(IOIN,'(A)',END=989) Line |
| 1156 | 1 | pfleura2 | Line=AdjustL(Line) |
| 1157 | 1 | pfleura2 | LineL=len(Trim(Line)) |
| 1158 | 1 | pfleura2 | IF (Line(1:1)/="*") THEN |
| 1159 | 1 | pfleura2 | current%Line=TRIM(Line) |
| 1160 | 1 | pfleura2 | ALLOCATE(current%next) |
| 1161 | 1 | pfleura2 | Current => Current%next |
| 1162 | 1 | pfleura2 | Nullify(Current%next) |
| 1163 | 1 | pfleura2 | NTmp=NTmp+1 |
| 1164 | 1 | pfleura2 | ELSE |
| 1165 | 1 | pfleura2 | CurCom%Line=TRIM(LINE) |
| 1166 | 1 | pfleura2 | ALLOCATE(CurCom%Next) |
| 1167 | 1 | pfleura2 | CurCom => CurCom%Next |
| 1168 | 1 | pfleura2 | NULLIFY(CurCom%Next) |
| 1169 | 1 | pfleura2 | END IF |
| 1170 | 1 | pfleura2 | END DO |
| 1171 | 1 | pfleura2 | 989 CONTINUE |
| 1172 | 1 | pfleura2 | |
| 1173 | 1 | pfleura2 | END IF ! IF (PROG="MOPAC") |
| 1174 | 1 | pfleura2 | |
| 1175 | 1 | pfleura2 | if ((Prog=="VASP").AND.(input/="VASP")) THEN |
| 1176 | 1 | pfleura2 | ! Input was not Vasp, so many parameters are missing like lattice |
| 1177 | 1 | pfleura2 | ! constants... |
| 1178 | 1 | pfleura2 | ! we read them now ! |
| 1179 | 1 | pfleura2 | ALLOCATE(FFF(3,nat)) |
| 1180 | 1 | pfleura2 | ! First geometry is a bit special for VASP as we have to set |
| 1181 | 1 | pfleura2 | ! many things |
| 1182 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Reading Vasp Parameters" |
| 1183 | 1 | pfleura2 | READ(IOIN,'(A)') Vasp_Title |
| 1184 | 1 | pfleura2 | READ(IOIN,*) Vasp_param |
| 1185 | 1 | pfleura2 | |
| 1186 | 1 | pfleura2 | READ(IOIN,*) Lat_a |
| 1187 | 1 | pfleura2 | READ(IOIN,*) Lat_b |
| 1188 | 1 | pfleura2 | READ(IOIN,*) Lat_c |
| 1189 | 1 | pfleura2 | |
| 1190 | 1 | pfleura2 | Lat_a=Lat_a*Vasp_param |
| 1191 | 1 | pfleura2 | Lat_b=Lat_b*Vasp_param |
| 1192 | 1 | pfleura2 | Lat_c=Lat_c*Vasp_param |
| 1193 | 1 | pfleura2 | |
| 1194 | 1 | pfleura2 | ALLOCATE(NbAtType(nat)) |
| 1195 | 1 | pfleura2 | READ(IOIN,'(A)') Vasp_types |
| 1196 | 1 | pfleura2 | ! First, how many different types ? |
| 1197 | 1 | pfleura2 | NbAtType=0 |
| 1198 | 1 | pfleura2 | READ(Vasp_types,*,END=998) NbAtType |
| 1199 | 1 | pfleura2 | 998 CONTINUE |
| 1200 | 1 | pfleura2 | NbType=0 |
| 1201 | 1 | pfleura2 | DO WHILE (NbAtType(NbType+1).NE.0) |
| 1202 | 1 | pfleura2 | NbType=NbType+1 |
| 1203 | 1 | pfleura2 | END DO |
| 1204 | 1 | pfleura2 | |
| 1205 | 1 | pfleura2 | ! Do we know the atom types ? |
| 1206 | 1 | pfleura2 | IF (AtTypes(1).EQ.' ') THEN |
| 1207 | 1 | pfleura2 | ! user has not provided atom types... we have to find them ourselves |
| 1208 | 1 | pfleura2 | ! by looking into the POTCAR file... |
| 1209 | 1 | pfleura2 | INQUIRE(File="POTCAR", EXIST=Tchk) |
| 1210 | 1 | pfleura2 | IF (.NOT.Tchk) THEN |
| 1211 | 1 | pfleura2 | WRITE(*,*) "ERROR! No AtTypes provided, and POTCAR file not found" |
| 1212 | 1 | pfleura2 | STOP |
| 1213 | 1 | pfleura2 | END IF |
| 1214 | 1 | pfleura2 | OPEN(IOTMP,File="POTCAR") |
| 1215 | 1 | pfleura2 | DO I=1,NbType |
| 1216 | 1 | pfleura2 | Line='Empty' |
| 1217 | 1 | pfleura2 | DO WHILE (Line(1:2).NE.'US') |
| 1218 | 1 | pfleura2 | READ(IOTMP,'(A)') Line |
| 1219 | 1 | pfleura2 | Line=AdjustL(Line) |
| 1220 | 1 | pfleura2 | END DO |
| 1221 | 1 | pfleura2 | Line=adjustl(Line(3:)) |
| 1222 | 1 | pfleura2 | AtTypes(I)=Line(1:2) |
| 1223 | 1 | pfleura2 | END DO |
| 1224 | 1 | pfleura2 | if (debug) WRITE(*,'(A,100(1X,A2))') "ReadG:VASP AtTypes",AtTypes(1:NbType) |
| 1225 | 1 | pfleura2 | CLOSE(IOTMP) |
| 1226 | 1 | pfleura2 | |
| 1227 | 1 | pfleura2 | ELSE !AtTypes(1).EQ.' ' |
| 1228 | 1 | pfleura2 | ! user has provided atom types |
| 1229 | 1 | pfleura2 | NbTypeUser=0 |
| 1230 | 1 | pfleura2 | DO WHILE (AtTypes(NbTypeUser+1).NE.' ') |
| 1231 | 1 | pfleura2 | NbTypeUser=NbTypeUser+1 |
| 1232 | 1 | pfleura2 | END DO |
| 1233 | 1 | pfleura2 | IF (NbType.NE.NbTypeUser) THEN |
| 1234 | 1 | pfleura2 | WRITE(*,*) "ERROR Read_Geom : NbType in POSCAR do not match AtTypes" |
| 1235 | 1 | pfleura2 | STOP |
| 1236 | 1 | pfleura2 | END IF |
| 1237 | 1 | pfleura2 | END IF |
| 1238 | 1 | pfleura2 | |
| 1239 | 1 | pfleura2 | IAt=1 |
| 1240 | 1 | pfleura2 | DO I=1,NbType |
| 1241 | 1 | pfleura2 | DO J=1,NbAtType(I) |
| 1242 | 1 | pfleura2 | AtName(Iat)=AtTypes(I) |
| 1243 | 1 | pfleura2 | Iat=Iat+1 |
| 1244 | 1 | pfleura2 | END DO |
| 1245 | 1 | pfleura2 | END DO |
| 1246 | 1 | pfleura2 | DEALLOCATE(NbAtType) |
| 1247 | 1 | pfleura2 | |
| 1248 | 1 | pfleura2 | NbTypes=NbType |
| 1249 | 1 | pfleura2 | |
| 1250 | 1 | pfleura2 | READ(IOIN,'(A)') Vasp_comment |
| 1251 | 1 | pfleura2 | READ(IOIN,'(A)') Vasp_direct |
| 1252 | 1 | pfleura2 | V_direct=Adjustl(Vasp_direct) |
| 1253 | 1 | pfleura2 | Call UpCase(V_direct) |
| 1254 | 1 | pfleura2 | ! PFL 2011 Mar 8 -> |
| 1255 | 1 | pfleura2 | ! We have to read the FFF flags : |
| 1256 | 1 | pfleura2 | DO I=1,Nat |
| 1257 | 1 | pfleura2 | READ(IOIN,*) Xtmp,ytmp,ztmp,FFF(1:3,I) |
| 1258 | 1 | pfleura2 | DO J=1,3 |
| 1259 | 1 | pfleura2 | FFF(J,I)=AdjustL(FFF(J,I)) |
| 1260 | 1 | pfleura2 | CALL Upcase(FFF(J,I)) |
| 1261 | 1 | pfleura2 | END DO |
| 1262 | 1 | pfleura2 | END DO |
| 1263 | 1 | pfleura2 | ! <- PFL 2011 Mar 8 |
| 1264 | 1 | pfleura2 | |
| 1265 | 1 | pfleura2 | END IF |
| 1266 | 1 | pfleura2 | |
| 1267 | 1 | pfleura2 | ! In the case of VASP there is always the problem of moving from one side |
| 1268 | 1 | pfleura2 | ! of the box to the other... |
| 1269 | 1 | pfleura2 | ! PFL 2011 Mar 14 -> |
| 1270 | 1 | pfleura2 | ! In fact, we have to make this check as soon as either |
| 1271 | 1 | pfleura2 | ! Input and/or Prog = VASP |
| 1272 | 1 | pfleura2 | ! PFL 2010 Dec 2 -> |
| 1273 | 1 | pfleura2 | ! Here we deal with input and not prog in fact |
| 1274 | 1 | pfleura2 | ! if (prog.EQ.'VASP') THEN |
| 1275 | 1 | pfleura2 | if ((Input.EQ.'VASP').OR.(Prog.EQ.'VASP')) THEN |
| 1276 | 1 | pfleura2 | ! <- PFL 2010 Dec 2 |
| 1277 | 1 | pfleura2 | ! <- PFL 2011 Mar 14 |
| 1278 | 1 | pfleura2 | Renum=.TRUE. |
| 1279 | 1 | pfleura2 | |
| 1280 | 1 | pfleura2 | ! V_direct has been set in Read_geom |
| 1281 | 1 | pfleura2 | IF (V_direct(1:6).EQ.'DIRECT') THEN |
| 1282 | 1 | pfleura2 | Latr(1:3,1)=Lat_a |
| 1283 | 1 | pfleura2 | Latr(1:3,2)=Lat_b |
| 1284 | 1 | pfleura2 | Latr(1:3,3)=Lat_c |
| 1285 | 1 | pfleura2 | B=1. |
| 1286 | 1 | pfleura2 | CALL Gaussj(Latr,3,3,B,1,1) |
| 1287 | 1 | pfleura2 | ELSE |
| 1288 | 1 | pfleura2 | Latr=0. |
| 1289 | 1 | pfleura2 | Latr(1,1)=1.d0 |
| 1290 | 1 | pfleura2 | Latr(2,2)=1.d0 |
| 1291 | 1 | pfleura2 | Latr(3,3)=1.d0 |
| 1292 | 1 | pfleura2 | END IF |
| 1293 | 1 | pfleura2 | |
| 1294 | 1 | pfleura2 | ! Actualization of Frozen using the FFFF... |
| 1295 | 1 | pfleura2 | ! Frozen has the advantage ie if given, it imposes _ALL_ the FFF flags. |
| 1296 | 1 | pfleura2 | IF (Frozen(1).NE.0) THEN |
| 1297 | 1 | pfleura2 | WRITE(IOOUT,*) "Frozen is given. Flags of the given POSCAR are overriden" |
| 1298 | 1 | pfleura2 | FFF='T' |
| 1299 | 1 | pfleura2 | |
| 1300 | 1 | pfleura2 | NFroz=0 |
| 1301 | 1 | pfleura2 | DO WHILE (Frozen(NFroz+1).NE.0) |
| 1302 | 1 | pfleura2 | NFroz=NFroz+1 |
| 1303 | 1 | pfleura2 | FFF(1:3,Frozen(NFroz))='F' |
| 1304 | 1 | pfleura2 | END DO |
| 1305 | 1 | pfleura2 | ELSE |
| 1306 | 1 | pfleura2 | WRITE(IOOUT,*) "Frozen not given : using Flags of the given POSCAR" |
| 1307 | 1 | pfleura2 | NFroz=0 |
| 1308 | 1 | pfleura2 | Frozen=0 |
| 1309 | 1 | pfleura2 | DO I=1,Nat |
| 1310 | 1 | pfleura2 | IF ((FFF(1,I).EQ.'F').OR.(FFF(2,I).EQ.'F').OR.(FFF(3,I).EQ.'F')) THEN |
| 1311 | 1 | pfleura2 | FFF(1:3,I)='F' |
| 1312 | 1 | pfleura2 | NFroz=NFroz+1 |
| 1313 | 1 | pfleura2 | Frozen(NFroz)=I |
| 1314 | 1 | pfleura2 | END IF |
| 1315 | 1 | pfleura2 | END DO |
| 1316 | 1 | pfleura2 | WRITE(IOOUT,*) "Frozen atoms:",Frozen(1:NFroz) |
| 1317 | 1 | pfleura2 | END IF |
| 1318 | 1 | pfleura2 | |
| 1319 | 1 | pfleura2 | |
| 1320 | 1 | pfleura2 | END IF |
| 1321 | 1 | pfleura2 | |
| 1322 | 1 | pfleura2 | IF (Prog=="VASP") THEN |
| 1323 | 1 | pfleura2 | IF (Vmd) THEN |
| 1324 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG MAIN, L803, VMD=T,NbTypes,AtTypes",NbTypes,AtTypes(1:NbTypes) |
| 1325 | 1 | pfleura2 | Line="" |
| 1326 | 1 | pfleura2 | DO I=1,NbTypes |
| 1327 | 1 | pfleura2 | Line=TRIM(Line) // " " // TRIM(AdjustL(AtTypes(I))) |
| 1328 | 1 | pfleura2 | END DO |
| 1329 | 1 | pfleura2 | Vasp_Title=Trim(Line) // " " // Trim(adjustL(Vasp_Title)) |
| 1330 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG MAIN, L809, VMD=T, Vasp_Title=",TRIM(Vasp_Title) |
| 1331 | 1 | pfleura2 | END IF |
| 1332 | 1 | pfleura2 | Call CheckPeriodicBound |
| 1333 | 1 | pfleura2 | END IF |
| 1334 | 1 | pfleura2 | |
| 1335 | 1 | pfleura2 | IF (COORD=="MIXED") Call TestCart(AutoCart) |
| 1336 | 1 | pfleura2 | |
| 1337 | 1 | pfleura2 | SELECT CASE(NFroz) |
| 1338 | 1 | pfleura2 | CASE (2) |
| 1339 | 1 | pfleura2 | IntFroz=1 |
| 1340 | 1 | pfleura2 | CASE (3) |
| 1341 | 1 | pfleura2 | IntFroz=3 |
| 1342 | 1 | pfleura2 | CASE (4:) |
| 1343 | 1 | pfleura2 | IntFroz=(NFroz-2)*3 !(NFroz-3)*3+3 |
| 1344 | 1 | pfleura2 | END SELECT |
| 1345 | 1 | pfleura2 | |
| 1346 | 1 | pfleura2 | if (debug) WRITE(*,'(1X,A,A,5I5)') "DBG Path, L825, Coord, NCart, NCoord, N3at, NFroz: "& |
| 1347 | 1 | pfleura2 | ,TRIM(COORD),Ncart,NCoord,N3at,NFroz |
| 1348 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path, L827, Cart",Cart |
| 1349 | 1 | pfleura2 | |
| 1350 | 1 | pfleura2 | if (((NCart+NFroz).EQ.0).AND.(Coord=="MIXED")) THEN |
| 1351 | 1 | pfleura2 | WRITE(IOOUT,*) "Coord=MIXED but Cart list empty: taking Coord=ZMAT." |
| 1352 | 1 | pfleura2 | COORD="ZMAT" |
| 1353 | 1 | pfleura2 | END IF |
| 1354 | 1 | pfleura2 | |
| 1355 | 1 | pfleura2 | IF ((Coord=="MIXED").AND.(NFroz.NE.0)) IntFroz=3*NFroz |
| 1356 | 1 | pfleura2 | |
| 1357 | 1 | pfleura2 | SELECT CASE(COORD) |
| 1358 | 1 | pfleura2 | CASE ('ZMAT')
|
| 1359 | 1 | pfleura2 | NCoord=Nfree |
| 1360 | 1 | pfleura2 | ALLOCATE(dzdc(3,nat,3,nat)) |
| 1361 | 1 | pfleura2 | CASE ('MIXED')
|
| 1362 | 1 | pfleura2 | SELECT CASE (NCart+NFroz) |
| 1363 | 1 | pfleura2 | CASE (1) |
| 1364 | 1 | pfleura2 | NCoord=N3At-3 |
| 1365 | 1 | pfleura2 | CASE (2) |
| 1366 | 1 | pfleura2 | NCoord=N3At-1 |
| 1367 | 1 | pfleura2 | CASE (3:) |
| 1368 | 1 | pfleura2 | NCoord=N3At |
| 1369 | 1 | pfleura2 | END SELECT |
| 1370 | 1 | pfleura2 | ALLOCATE(dzdc(3,nat,3,nat)) |
| 1371 | 1 | pfleura2 | CASE ('BAKER')
|
| 1372 | 1 | pfleura2 | Symmetry_elimination=0 |
| 1373 | 1 | pfleura2 | NCoord=3*Nat-6-Symmetry_elimination !NFree = 3*Nat-6 |
| 1374 | 1 | pfleura2 | ALLOCATE(BMat_BakerT(3*Nat,NCoord)) |
| 1375 | 1 | pfleura2 | ALLOCATE(BTransInv(NCoord,3*Nat)) |
| 1376 | 1 | pfleura2 | ALLOCATE(BTransInv_local(NCoord,3*Nat)) |
| 1377 | 1 | pfleura2 | CASE ('HYBRID')
|
| 1378 | 1 | pfleura2 | NCoord=N3at |
| 1379 | 1 | pfleura2 | CASE ('CART')
|
| 1380 | 1 | pfleura2 | NCoord=N3at |
| 1381 | 1 | pfleura2 | END SELECT |
| 1382 | 1 | pfleura2 | |
| 1383 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Path, L826, Coord, NCart,NCoord, N3At",TRIM(COORD),Ncart, NCoord,N3at |
| 1384 | 1 | pfleura2 | |
| 1385 | 1 | pfleura2 | ALLOCATE(IntCoordI(NGeomI,NCoord),IntCoordF(NGeomF,NCoord)) |
| 1386 | 1 | pfleura2 | ALLOCATE(XyzGeomF(NGeomF,3,Nat),XyzTangent(NGeomF,3*Nat)) |
| 1387 | 1 | pfleura2 | ALLOCATE(Vfree(NCoord,NCoord),IntTangent(NGeomF,NCoord)) |
| 1388 | 1 | pfleura2 | ALLOCATE(Energies(NgeomF),ZeroVec(NCoord)) ! Energies is declared in Path_module.f90 |
| 1389 | 1 | pfleura2 | ALLOCATE(Grad(NGeomF,NCoord),GeomTmp(NCoord),GradTmp(NCoord)) |
| 1390 | 1 | pfleura2 | ALLOCATE(GeomOld_all(NGeomF,NCoord),GradOld(NGeomF,NCoord)) |
| 1391 | 1 | pfleura2 | ALLOCATE(Hess(NGeomF,NCoord,NCoord),SGeom(NGeomF)) ! SGeom is declared in Path_module.f90 |
| 1392 | 1 | pfleura2 | ALLOCATE(EPathOld(NGeomF),MaxStep(NGeomF)) |
| 1393 | 1 | pfleura2 | |
| 1394 | 1 | pfleura2 | ZeroVec=0.d0 |
| 1395 | 1 | pfleura2 | DO I =1, NGeomF |
| 1396 | 1 | pfleura2 | IntTangent(I,:)=0.d0 |
| 1397 | 1 | pfleura2 | END DO |
| 1398 | 1 | pfleura2 | |
| 1399 | 1 | pfleura2 | if (debug) THEN |
| 1400 | 1 | pfleura2 | Print *, 'L886, IntTangent(1,:)=' |
| 1401 | 1 | pfleura2 | Print *, IntTangent(1,:) |
| 1402 | 1 | pfleura2 | END IF |
| 1403 | 1 | pfleura2 | |
| 1404 | 1 | pfleura2 | if (.NOT.OptReac) Energies(1)=Ereac |
| 1405 | 1 | pfleura2 | if (.NOT.OptProd) Energies(NGeomF)=EProd |
| 1406 | 1 | pfleura2 | MaxStep=SMax |
| 1407 | 1 | pfleura2 | |
| 1408 | 1 | pfleura2 | ! We initialize the mass array |
| 1409 | 1 | pfleura2 | if (MW) THEN |
| 1410 | 1 | pfleura2 | WRITE(*,*) 'Working in MW coordinates' |
| 1411 | 1 | pfleura2 | DO I=1,Nat |
| 1412 | 1 | pfleura2 | massAt(I)=Mass(Atome(I)) |
| 1413 | 1 | pfleura2 | END DO |
| 1414 | 1 | pfleura2 | ELSE |
| 1415 | 1 | pfleura2 | DO I=1,Nat |
| 1416 | 1 | pfleura2 | MassAt(I)=1.d0 |
| 1417 | 1 | pfleura2 | END DO |
| 1418 | 1 | pfleura2 | END IF |
| 1419 | 1 | pfleura2 | |
| 1420 | 1 | pfleura2 | WRITE(*,*) "Prog=",TRIM(PROG) |
| 1421 | 1 | pfleura2 | |
| 1422 | 1 | pfleura2 | ALLOCATE(FrozAtoms(Nat)) |
| 1423 | 1 | pfleura2 | |
| 1424 | 1 | pfleura2 | ! IF (debug) WRITe(*,*) "DBG Main L940 NFroz",NFroz |
| 1425 | 1 | pfleura2 | ! IF (debug) WRITe(*,*) "DBG Main L940 Frozen",Frozen |
| 1426 | 1 | pfleura2 | ! IF (debug) WRITe(*,*) "DBG Main L940 FrozAtoms",FrozAtoms |
| 1427 | 1 | pfleura2 | IF (NFroz.EQ.0) THEN |
| 1428 | 1 | pfleura2 | FrozAtoms=.TRUE. |
| 1429 | 1 | pfleura2 | ELSE |
| 1430 | 1 | pfleura2 | I=1 |
| 1431 | 1 | pfleura2 | NFr=0 |
| 1432 | 1 | pfleura2 | FrozAtoms=.False. |
| 1433 | 1 | pfleura2 | DO WHILE (Frozen(I).NE.0) |
| 1434 | 1 | pfleura2 | IF (Frozen(I).LT.0) THEN |
| 1435 | 1 | pfleura2 | DO J=Frozen(I-1),abs(Frozen(I)) |
| 1436 | 1 | pfleura2 | IF (.NOT.FrozAtoms(J)) THEN |
| 1437 | 1 | pfleura2 | NFr=NFr+1 |
| 1438 | 1 | pfleura2 | FrozAtoms(J)=.TRUE. |
| 1439 | 1 | pfleura2 | END IF |
| 1440 | 1 | pfleura2 | END DO |
| 1441 | 1 | pfleura2 | ELSEIF (.NOT.FrozAtoms(Frozen(I))) THEN |
| 1442 | 1 | pfleura2 | FrozAtoms(Frozen(I))=.TRUE. |
| 1443 | 1 | pfleura2 | NFr=NFr+1 |
| 1444 | 1 | pfleura2 | END IF |
| 1445 | 1 | pfleura2 | I=I+1 |
| 1446 | 1 | pfleura2 | END DO |
| 1447 | 1 | pfleura2 | IF (NFr.NE.NFroz) THEN |
| 1448 | 1 | pfleura2 | WRITE(*,*) "Pb in PATH: Number of Frozen atoms not good :-( ",NFroz,NFr |
| 1449 | 1 | pfleura2 | STOP |
| 1450 | 1 | pfleura2 | END IF |
| 1451 | 1 | pfleura2 | END IF |
| 1452 | 1 | pfleura2 | |
| 1453 | 1 | pfleura2 | if (debug) THEN |
| 1454 | 1 | pfleura2 | !Print *, 'L968, IntTangent(1,:)=' |
| 1455 | 1 | pfleura2 | !Print *, IntTangent(1,:) |
| 1456 | 1 | pfleura2 | END IF |
| 1457 | 1 | pfleura2 | |
| 1458 | 1 | pfleura2 | ! We have read everything we needed... time to work :-) |
| 1459 | 1 | pfleura2 | IOpt=0 |
| 1460 | 1 | pfleura2 | FirstTimePathCreate = .TRUE. ! Initialized. |
| 1461 | 1 | pfleura2 | Call PathCreate(IOpt) ! IntTangent is also computed in PathCreate. |
| 1462 | 1 | pfleura2 | FirstTimePathCreate = .FALSE. |
| 1463 | 1 | pfleura2 | |
| 1464 | 1 | pfleura2 | if (debug) THEN |
| 1465 | 1 | pfleura2 | Print *, 'L980, IntTangent(1,:)=' |
| 1466 | 1 | pfleura2 | Print *, IntTangent(1,:) |
| 1467 | 1 | pfleura2 | END IF |
| 1468 | 1 | pfleura2 | |
| 1469 | 1 | pfleura2 | ! PFL 30 Mar 2008 -> |
| 1470 | 1 | pfleura2 | ! The following is now allocated in Calc_Baker. This is more logical to me |
| 1471 | 1 | pfleura2 | ! IF (COORD .EQ. "BAKER") Then |
| 1472 | 1 | pfleura2 | ! ALLOCATE(XprimitiveF(NgeomF,NbCoords)) |
| 1473 | 1 | pfleura2 | ! ALLOCATE(UMatF(NGeomF,NbCoords,NCoord)) |
| 1474 | 1 | pfleura2 | ! ALLOCATE(BTransInvF(NGeomF,NCoord,3*Nat)) |
| 1475 | 1 | pfleura2 | ! END IF |
| 1476 | 1 | pfleura2 | ! <- PFL 30 mar 2008 |
| 1477 | 1 | pfleura2 | |
| 1478 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1479 | 1 | pfleura2 | ! |
| 1480 | 1 | pfleura2 | ! For Debugging purposes |
| 1481 | 1 | pfleura2 | ! |
| 1482 | 1 | pfleura2 | ! OptGeom is the index of the geometry which is to be optimized. |
| 1483 | 1 | pfleura2 | IF (Optgeom.GT.0) THEN |
| 1484 | 1 | pfleura2 | Flag_Opt_Geom=.TRUE. |
| 1485 | 1 | pfleura2 | SELECT CASE(Coord) |
| 1486 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 1487 | 1 | pfleura2 | !!! CAUTION : PFL 29.AUG.2008 -> |
| 1488 | 1 | pfleura2 | ! XyzGeomI/F stored in (NGeomI/F,3,Nat) and NOT (NGeomI/F,Nat,3) |
| 1489 | 1 | pfleura2 | ! This should be made consistent !!!!!!!!!!!!!!! |
| 1490 | 1 | pfleura2 | GeomTmp=Reshape(reshape(XyzGeomF(OptGeom,:,:),(/Nat,3/),ORDER=(/2,1/)),(/3*Nat/)) |
| 1491 | 1 | pfleura2 | ! GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/)) |
| 1492 | 1 | pfleura2 | !!! <- CAUTION : PFL 29.AUG.2008 |
| 1493 | 1 | pfleura2 | CASE ('ZMAT','MIXED')
|
| 1494 | 1 | pfleura2 | !GeomTmp=IntCoordF(OptGeom,:) |
| 1495 | 1 | pfleura2 | GeomTmp=IntCoordI(OptGeom,:) |
| 1496 | 1 | pfleura2 | CASE ('BAKER')
|
| 1497 | 1 | pfleura2 | !GeomTmp=IntCoordF(OptGeom,:) |
| 1498 | 1 | pfleura2 | GeomTmp=IntCoordI(OptGeom,:) |
| 1499 | 1 | pfleura2 | CASE DEFAULT |
| 1500 | 1 | pfleura2 | WRITE(*,*) "Coord=",TRIM(COORD)," not recognized in Path L935.STOP" |
| 1501 | 1 | pfleura2 | STOP |
| 1502 | 1 | pfleura2 | END SELECT |
| 1503 | 1 | pfleura2 | |
| 1504 | 1 | pfleura2 | ! NCoord = NFree, Coord = Type of coordinate; e.g.: Baker |
| 1505 | 1 | pfleura2 | Flag_Opt_Geom = .TRUE. |
| 1506 | 1 | pfleura2 | Call Opt_geom(OptGeom,Nat,Ncoord,Coord,GeomTmp,E,Flag_Opt_Geom,Step_method) |
| 1507 | 1 | pfleura2 | |
| 1508 | 1 | pfleura2 | WRITE(Line,"('Geometry ',I3,' optimized')") Optgeom
|
| 1509 | 1 | pfleura2 | WRITE(*,*) "Before PrintGeom, L1059, Path.f90" |
| 1510 | 1 | pfleura2 | Call PrintGeom(Line,Nat,NCoord,GeomTmp,Coord,IoOut,Atome,Order,OrderInv,IndZmat) |
| 1511 | 1 | pfleura2 | STOP |
| 1512 | 1 | pfleura2 | END IF ! IF (Optgeom.GT.0) THEN |
| 1513 | 1 | pfleura2 | |
| 1514 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1515 | 1 | pfleura2 | ! End of GeomOpt |
| 1516 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1517 | 1 | pfleura2 | |
| 1518 | 1 | pfleura2 | IF (PathOnly) THEN |
| 1519 | 1 | pfleura2 | WRITE(*,*) "PathOnly=.T. , Stop here" |
| 1520 | 1 | pfleura2 | Call Write_path(-1) |
| 1521 | 1 | pfleura2 | if ((prog.EQ.'VASP').OR.WriteVasp) Call Write_vasp(poscar) |
| 1522 | 1 | pfleura2 | STOP |
| 1523 | 1 | pfleura2 | END IF |
| 1524 | 1 | pfleura2 | |
| 1525 | 1 | pfleura2 | if ((debug.AND.(prog.EQ.'VASP')).OR.WriteVasp) Call Write_vasp(poscar) |
| 1526 | 1 | pfleura2 | |
| 1527 | 1 | pfleura2 | DEALLOCATE(XyzGeomI,IntCoordI) |
| 1528 | 1 | pfleura2 | NGeomI=NGeomF |
| 1529 | 1 | pfleura2 | ALLOCATE(XyzGeomI(NGeomF,3,Nat),IntCoordI(NGeomF,NCoord)) |
| 1530 | 1 | pfleura2 | |
| 1531 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) ' Back from PathCreate, L965, Path.f90' |
| 1532 | 1 | pfleura2 | ! we print this path, which is the first one :-) called Iteration0 |
| 1533 | 1 | pfleura2 | ! we now have to calculate the gradient for each point (and the energy |
| 1534 | 1 | pfleura2 | ! if we work at 0K) |
| 1535 | 1 | pfleura2 | |
| 1536 | 1 | pfleura2 | if (DEBUG.AND.(COORD.EQ."BAKER")) THEN |
| 1537 | 1 | pfleura2 | DO IGeom=1,NGeomF |
| 1538 | 1 | pfleura2 | WRITE(*,*) "Before Calc_baker_allgeomf UMatF for IGeom=",IGeom |
| 1539 | 1 | pfleura2 | DO I=1,3*Nat-6 |
| 1540 | 1 | pfleura2 | WRITE(*,'(50(1X,F12.8))') UMatF(IGeom,:,I) |
| 1541 | 1 | pfleura2 | END DO |
| 1542 | 1 | pfleura2 | END DO |
| 1543 | 1 | pfleura2 | END IF |
| 1544 | 1 | pfleura2 | |
| 1545 | 1 | pfleura2 | ! To calculate B^T^-1 for all extrapolated final geometries: |
| 1546 | 1 | pfleura2 | ! PFL 18 Jan 2008 -> |
| 1547 | 1 | pfleura2 | ! Added a test for COORD=BAKER before the call to calc_baker_allgeomF |
| 1548 | 1 | pfleura2 | IF (COORD.EQ."BAKER") Call Calc_baker_allGeomF() |
| 1549 | 1 | pfleura2 | ! <-- PFL 18 Jan 2008 |
| 1550 | 1 | pfleura2 | |
| 1551 | 1 | pfleura2 | if (DEBUG.AND.(COORD.EQ."BAKER")) THEN |
| 1552 | 1 | pfleura2 | DO IGeom=1,NGeomF |
| 1553 | 1 | pfleura2 | WRITE(*,*) "After Calc_baker_allgeomf UMatF for IGeom=",IGeom |
| 1554 | 1 | pfleura2 | DO I=1,3*Nat-6 |
| 1555 | 1 | pfleura2 | WRITE(*,'(50(1X,F12.8))') UMatF(IGeom,:,I) |
| 1556 | 1 | pfleura2 | END DO |
| 1557 | 1 | pfleura2 | END DO |
| 1558 | 1 | pfleura2 | END IF |
| 1559 | 1 | pfleura2 | |
| 1560 | 1 | pfleura2 | IOpt=0 |
| 1561 | 2 | pfleura2 | Call EgradPath(IOpt) |
| 1562 | 1 | pfleura2 | |
| 1563 | 1 | pfleura2 | if (debug) WRITE(*,*) "Calling Write_path, L1002, Path.f90, IOpt=",IOpt |
| 1564 | 1 | pfleura2 | Call Write_path(IOpt) |
| 1565 | 1 | pfleura2 | if ((debug.AND.(prog.EQ.'VASP')).OR.WriteVasp) Call Write_vasp(poscar) |
| 1566 | 1 | pfleura2 | |
| 1567 | 1 | pfleura2 | ! We have the geometries, the first gradients... we will generate the first hessian matrices :-) |
| 1568 | 1 | pfleura2 | ! ... v3.71 Only if IniHUp=.TRUE. which is not the default. In this version, we take the hessian |
| 1569 | 1 | pfleura2 | ! of end points as Unity matrices, and we update them along the path. |
| 1570 | 1 | pfleura2 | |
| 1571 | 1 | pfleura2 | ! By default, Hess=Id |
| 1572 | 1 | pfleura2 | Hess=0. |
| 1573 | 1 | pfleura2 | IF(Coord .EQ. "ZMAT") Then |
| 1574 | 1 | pfleura2 | ! We use the fact that we know that approximate good hessian values |
| 1575 | 1 | pfleura2 | ! are 0.5 for bonds, 0.1 for valence angle and 0.02 for dihedral angles |
| 1576 | 1 | pfleura2 | DO IGeom=1,NGeomF |
| 1577 | 1 | pfleura2 | Hess(IGeom,1,1)=0.5d0 |
| 1578 | 1 | pfleura2 | Hess(IGeom,2,2)=0.5d0 |
| 1579 | 1 | pfleura2 | Hess(IGeom,3,3)=0.1d0 |
| 1580 | 1 | pfleura2 | DO J=1,Nat-3 |
| 1581 | 1 | pfleura2 | Hess(IGeom,3*J+1,3*J+1)=0.5d0 |
| 1582 | 1 | pfleura2 | Hess(IGeom,3*J+2,3*J+2)=0.1d0 |
| 1583 | 1 | pfleura2 | Hess(IGeom,3*J+3,3*J+3)=0.02d0 |
| 1584 | 1 | pfleura2 | END DO |
| 1585 | 1 | pfleura2 | IF (HInv) THEN |
| 1586 | 1 | pfleura2 | DO I=1,NCoord |
| 1587 | 1 | pfleura2 | Hess(IGeom,I,I)=1.d0/Hess(IGeom,I,I) |
| 1588 | 1 | pfleura2 | END DO |
| 1589 | 1 | pfleura2 | END IF |
| 1590 | 1 | pfleura2 | END DO |
| 1591 | 1 | pfleura2 | ELSE |
| 1592 | 1 | pfleura2 | DO I=1,NCoord |
| 1593 | 1 | pfleura2 | DO J=1,NGeomF |
| 1594 | 1 | pfleura2 | Hess(J,I,I)=1.d0 |
| 1595 | 1 | pfleura2 | END DO |
| 1596 | 1 | pfleura2 | END DO |
| 1597 | 1 | pfleura2 | END IF |
| 1598 | 1 | pfleura2 | |
| 1599 | 1 | pfleura2 | IF (COORD .EQ. "BAKER") THEN |
| 1600 | 1 | pfleura2 | ! UMat(NPrim,NCoord) |
| 1601 | 1 | pfleura2 | ALLOCATE(Hprim(NPrim,NPrim),HprimU(NPrim,3*Nat-6)) |
| 1602 | 1 | pfleura2 | Hprim=0.d0 |
| 1603 | 1 | pfleura2 | ScanCoord=>Coordinate |
| 1604 | 1 | pfleura2 | I=0 |
| 1605 | 1 | pfleura2 | DO WHILE (Associated(ScanCoord%next)) |
| 1606 | 1 | pfleura2 | I=I+1 |
| 1607 | 1 | pfleura2 | SELECT CASE (ScanCoord%Type) |
| 1608 | 1 | pfleura2 | CASE ('BOND')
|
| 1609 | 1 | pfleura2 | !DO J=1,NGeomF ! why all geometries?? Should be only 1st and NGeomF?? |
| 1610 | 1 | pfleura2 | Hprim(I,I) = 0.5d0 |
| 1611 | 1 | pfleura2 | !END DO |
| 1612 | 1 | pfleura2 | CASE ('ANGLE')
|
| 1613 | 1 | pfleura2 | Hprim(I,I) = 0.2d0 |
| 1614 | 1 | pfleura2 | CASE ('DIHEDRAL')
|
| 1615 | 1 | pfleura2 | Hprim(I,I) = 0.1d0 |
| 1616 | 1 | pfleura2 | END SELECT |
| 1617 | 1 | pfleura2 | ScanCoord => ScanCoord%next |
| 1618 | 1 | pfleura2 | END DO |
| 1619 | 1 | pfleura2 | |
| 1620 | 1 | pfleura2 | ! HprimU = H^prim U: |
| 1621 | 1 | pfleura2 | HprimU=0.d0 |
| 1622 | 1 | pfleura2 | DO I=1, 3*Nat-6 |
| 1623 | 1 | pfleura2 | DO J=1,NPrim |
| 1624 | 1 | pfleura2 | HprimU(:,I) = HprimU(:,I) + Hprim(:,J)*UMat(J,I) |
| 1625 | 1 | pfleura2 | END DO |
| 1626 | 1 | pfleura2 | END DO |
| 1627 | 1 | pfleura2 | |
| 1628 | 1 | pfleura2 | ! Hess = U^T HprimU = U^T H^prim U: |
| 1629 | 1 | pfleura2 | Hess=0.d0 |
| 1630 | 1 | pfleura2 | DO I=1, 3*Nat-6 |
| 1631 | 1 | pfleura2 | DO J=1,NPrim |
| 1632 | 1 | pfleura2 | ! UMat^T is needed below. |
| 1633 | 1 | pfleura2 | Hess(1,:,I) = Hess(1,:,I) + UMat(J,:)*HprimU(J,I) |
| 1634 | 1 | pfleura2 | END DO |
| 1635 | 1 | pfleura2 | END DO |
| 1636 | 1 | pfleura2 | DO K=2,NGeomF |
| 1637 | 1 | pfleura2 | Hess(K,:,:)=Hess(1,:,:) |
| 1638 | 1 | pfleura2 | END DO |
| 1639 | 1 | pfleura2 | DEALLOCATE(Hprim,HprimU) |
| 1640 | 1 | pfleura2 | end if ! ends IF COORD=BAKER |
| 1641 | 1 | pfleura2 | ALLOCATE(GradTmp2(NCoord),GeomTmp2(NCoord)) |
| 1642 | 1 | pfleura2 | ALLOCATE(HessTmp(NCoord,NCoord)) |
| 1643 | 1 | pfleura2 | |
| 1644 | 1 | pfleura2 | IF (IniHUp) THEN |
| 1645 | 1 | pfleura2 | IF (FCalcHess) THEN |
| 1646 | 1 | pfleura2 | ! The numerical calculation of the Hessian has been switched on |
| 1647 | 1 | pfleura2 | DO IGeom=1,NGeomF |
| 1648 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1649 | 1 | pfleura2 | GeomTmp=IntCoordF(IGeom,:) |
| 1650 | 1 | pfleura2 | ELSE |
| 1651 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/)) |
| 1652 | 1 | pfleura2 | END IF |
| 1653 | 1 | pfleura2 | Call CalcHess(NCoord,GeomTmp,Hess(IGeom,:,:),IGeom,Iopt) |
| 1654 | 1 | pfleura2 | END DO |
| 1655 | 1 | pfleura2 | ELSE |
| 1656 | 1 | pfleura2 | ! We generate a forward hessian and a backward one and we mix them. |
| 1657 | 1 | pfleura2 | ! First, the forward way: |
| 1658 | 1 | pfleura2 | DO IGeom=2,NGeomF-1 |
| 1659 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1660 | 1 | pfleura2 | GeomTmp=IntCoordF(IGeom,:)-IntCoordF(IGeom-1,:) |
| 1661 | 1 | pfleura2 | ELSE |
| 1662 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/))-Reshape(XyzGeomF(IGeom-1,:,:),(/3*Nat/)) |
| 1663 | 1 | pfleura2 | END IF |
| 1664 | 1 | pfleura2 | GradTmp=Grad(IGeom-1,:)-Grad(IGeom,:) |
| 1665 | 1 | pfleura2 | HessTmp=Hess(IGeom-1,:,:) |
| 1666 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 1667 | 1 | pfleura2 | Hess(IGeom,:,:)=HessTmp |
| 1668 | 1 | pfleura2 | END DO |
| 1669 | 1 | pfleura2 | |
| 1670 | 1 | pfleura2 | ! Now, the backward way: |
| 1671 | 1 | pfleura2 | HessTmp=Hess(NGeomF,:,:) |
| 1672 | 1 | pfleura2 | DO IGeom=NGeomF-1,2,-1 |
| 1673 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1674 | 1 | pfleura2 | GeomTmp=IntCoordF(IGeom,:)-IntCoordF(IGeom+1,:) |
| 1675 | 1 | pfleura2 | ELSE |
| 1676 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/))-Reshape(XyzGeomF(IGeom+1,:,:),(/3*Nat/)) |
| 1677 | 1 | pfleura2 | END IF |
| 1678 | 1 | pfleura2 | GradTmp=Grad(IGeom,:)-Grad(IGeom+1,:) |
| 1679 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 1680 | 1 | pfleura2 | alpha=0.5d0*Pi*(IGeom-1.)/(NGeomF-1.) |
| 1681 | 1 | pfleura2 | ca=cos(alpha) |
| 1682 | 1 | pfleura2 | sa=sin(alpha) |
| 1683 | 1 | pfleura2 | Hess(IGeom,:,:)=ca*Hess(IGeom,:,:)+sa*HessTmp(:,:) |
| 1684 | 1 | pfleura2 | END DO |
| 1685 | 1 | pfleura2 | END IF ! matches IF (FCalcHess) |
| 1686 | 1 | pfleura2 | END IF ! matches IF (IniHUp) THEN |
| 1687 | 1 | pfleura2 | |
| 1688 | 1 | pfleura2 | ! For debug purposes, we diagonalize the Hessian matrices |
| 1689 | 1 | pfleura2 | IF (debug) THEN |
| 1690 | 1 | pfleura2 | !WRITE(*,*) "DBG Main, L1104, - EigenSystem for Hessian matrices" |
| 1691 | 1 | pfleura2 | DO I=1,NGeomF |
| 1692 | 1 | pfleura2 | WRITE(*,*) "DBG Main - Point ",I |
| 1693 | 1 | pfleura2 | Call Jacobi(Hess(I,:,:),NCoord,GradTmp2,HessTmp,NCoord) |
| 1694 | 1 | pfleura2 | DO J=1,NCoord |
| 1695 | 1 | pfleura2 | WRITE(*,'(1X,I3,1X,F10.6," : ",20(1X,F8.4))') J,GradTmp2(J),HessTmp(J,1:min(20,NCoord)) |
| 1696 | 1 | pfleura2 | END DO |
| 1697 | 1 | pfleura2 | END DO |
| 1698 | 1 | pfleura2 | END IF ! matches IF (debug) THEN |
| 1699 | 1 | pfleura2 | |
| 1700 | 1 | pfleura2 | ! we have the hessian matrices and the gradients, we can start the optimizations ! |
| 1701 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1702 | 1 | pfleura2 | ! |
| 1703 | 1 | pfleura2 | ! Main LOOP : Optimization of the Path |
| 1704 | 1 | pfleura2 | ! |
| 1705 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1706 | 1 | pfleura2 | if (debug) Print *, 'NGeomF=', NGeomF |
| 1707 | 1 | pfleura2 | allocation_flag = .TRUE. |
| 1708 | 1 | pfleura2 | |
| 1709 | 1 | pfleura2 | Fini=.FALSE. |
| 1710 | 1 | pfleura2 | |
| 1711 | 1 | pfleura2 | DO WHILE ((IOpt.LT.MaxCyc).AND.(.NOT. Fini)) |
| 1712 | 1 | pfleura2 | if (debug) Print *, 'IOpt at the begining of the loop, L1128=', IOpt |
| 1713 | 1 | pfleura2 | IOpt=IOpt+1 |
| 1714 | 1 | pfleura2 | |
| 1715 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1716 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 1717 | 1 | pfleura2 | GeomOld_all=IntCoordF |
| 1718 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 1719 | 1 | pfleura2 | GeomOld_all=Reshape(XyzGeomF,(/NGeomF,NCoord/)) |
| 1720 | 1 | pfleura2 | CASE DEFAULT |
| 1721 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1149.STOP' |
| 1722 | 1 | pfleura2 | STOP |
| 1723 | 1 | pfleura2 | END SELECT |
| 1724 | 1 | pfleura2 | |
| 1725 | 1 | pfleura2 | IF (((COORD.EQ.'ZMAT').OR.(COORD.EQ.'BAKER').OR.(COORD.EQ.'MIXED')).AND. & |
| 1726 | 1 | pfleura2 | valid("printtangent")) THEN
|
| 1727 | 1 | pfleura2 | WRITE(*,*) "Visualization of tangents" |
| 1728 | 1 | pfleura2 | Idx=min(12,NCoord) |
| 1729 | 1 | pfleura2 | DO I=1,NGeomF |
| 1730 | 1 | pfleura2 | WRITE(*,'(12(1X,F12.5))') IntCoordF(I,1:Idx)-0.5d0*IntTangent(I,1:Idx) |
| 1731 | 1 | pfleura2 | WRITE(*,'(12(1X,F12.5))') IntCoordF(I,1:Idx)+0.5d0*IntTangent(I,1:Idx) |
| 1732 | 1 | pfleura2 | WRITE(*,*) |
| 1733 | 1 | pfleura2 | END DO |
| 1734 | 1 | pfleura2 | WRITE(*,*) "END of tangents" |
| 1735 | 1 | pfleura2 | END IF |
| 1736 | 1 | pfleura2 | |
| 1737 | 1 | pfleura2 | IF (((COORD.EQ.'ZMAT').OR.(COORD.EQ.'BAKER').OR.(COORD.EQ.'MIXED')).AND. & |
| 1738 | 1 | pfleura2 | valid("printgrad")) THEN
|
| 1739 | 1 | pfleura2 | WRITE(*,*) "Visualization of gradients" |
| 1740 | 1 | pfleura2 | Idx=min(12,NCoord) |
| 1741 | 1 | pfleura2 | DO I=1,NGeomF |
| 1742 | 1 | pfleura2 | WRITE(*,'(12(1X,F12.5))') IntCoordF(I,1:Idx)-1.d0*Grad(I,1:Idx) |
| 1743 | 1 | pfleura2 | WRITE(*,'(12(1X,F12.5))') IntCoordF(I,1:Idx)+1.d0*Grad(I,1:Idx) |
| 1744 | 1 | pfleura2 | WRITe(*,*) |
| 1745 | 1 | pfleura2 | END DO |
| 1746 | 1 | pfleura2 | WRITE(*,*) "END of gradients" |
| 1747 | 1 | pfleura2 | END IF |
| 1748 | 1 | pfleura2 | |
| 1749 | 1 | pfleura2 | Fini=.TRUE. |
| 1750 | 1 | pfleura2 | IF (OptReac) THEN !OptReac: True if one wants to optimize the geometry of the reactants. Default is FALSE. |
| 1751 | 1 | pfleura2 | IGeom=1 |
| 1752 | 1 | pfleura2 | if (debug) WRITE(*,*) '**************************************' |
| 1753 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Optimizing reactant' |
| 1754 | 1 | pfleura2 | if (debug) WRITE(*,*) '**************************************' |
| 1755 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1756 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 1757 | 1 | pfleura2 | SELECT CASE (Step_method) |
| 1758 | 1 | pfleura2 | CASE ('RFO')
|
| 1759 | 1 | pfleura2 | !GradTmp(NCoord) becomes Step in Step_RFO_all and has INTENT(OUT). |
| 1760 | 1 | pfleura2 | Call Step_RFO_all(NCoord,GradTmp,1,IntCoordF(1,:),Grad(1,:),Hess(1,:,:),ZeroVec) |
| 1761 | 1 | pfleura2 | Print *, GradTmp |
| 1762 | 1 | pfleura2 | CASE ('GDIIS')
|
| 1763 | 1 | pfleura2 | ! GradTmp(NCoord) becomes "step" below and has INTENT(OUT).: |
| 1764 | 1 | pfleura2 | Call Step_DIIS_all(NGeomF,1,GradTmp,IntCoordF(1,:),Grad(1,:),HP,HEAT,& |
| 1765 | 1 | pfleura2 | Hess(1,:,:),NCoord,allocation_flag,ZeroVec) |
| 1766 | 1 | pfleura2 | Print *, 'OptReac, Steps from GDIIS, GeomNew - IntCoordF(1,:)=' |
| 1767 | 1 | pfleura2 | Print *, GradTmp |
| 1768 | 1 | pfleura2 | CASE ('GEDIIS')
|
| 1769 | 1 | pfleura2 | ! GradTmp(NCoord) becomes "step" below and has INTENT(OUT).: |
| 1770 | 1 | pfleura2 | ! Energies are updated in EgradPath.f90 |
| 1771 | 1 | pfleura2 | Call Step_GEDIIS_All(NGeomF,1,GradTmp,IntCoordF(1,:),Grad(1,:),Energies(1),Hess(1,:,:),& |
| 1772 | 1 | pfleura2 | NCoord,allocation_flag,ZeroVec) |
| 1773 | 1 | pfleura2 | !Call Step_GEDIIS(GeomTmp,IntCoordF(1,:),Grad(1,:),Energies(1),Hess(1,:,:),NCoord,allocation_flag) |
| 1774 | 1 | pfleura2 | !GradTmp = GeomTmp - IntCoordF(1,:) |
| 1775 | 1 | pfleura2 | !Print *, 'Old Geometry:' |
| 1776 | 1 | pfleura2 | !Print *, IntCoordF(1,:) |
| 1777 | 1 | pfleura2 | Print *, 'OptReac, Steps from GEDIIS, GradTmp = GeomTmp - IntCoordF(1,:)=' |
| 1778 | 1 | pfleura2 | Print *, GradTmp |
| 1779 | 1 | pfleura2 | !Print *, 'GeomTmp:' |
| 1780 | 1 | pfleura2 | !Print *, GeomTmp |
| 1781 | 1 | pfleura2 | GeomTmp(:) = GradTmp(:) + IntCoordF(1,:) |
| 1782 | 1 | pfleura2 | CASE DEFAULT |
| 1783 | 1 | pfleura2 | WRITE (*,*) "Step_method=",TRIM(Step_method)," not recognized, Path.f90, L1194. Stop" |
| 1784 | 1 | pfleura2 | STOP |
| 1785 | 1 | pfleura2 | END SELECT |
| 1786 | 1 | pfleura2 | CASE ('HYBRID','CART')
|
| 1787 | 1 | pfleura2 | Call Step_RFO_all(NCoord,GradTmp,1,XyzGeomF(1,:,:),Grad(1,:),Hess(1,:,:),ZeroVec) |
| 1788 | 1 | pfleura2 | CASE DEFAULT |
| 1789 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1200. STOP' |
| 1790 | 1 | pfleura2 | STOP |
| 1791 | 1 | pfleura2 | END SELECT |
| 1792 | 1 | pfleura2 | |
| 1793 | 1 | pfleura2 | IF (debug) THEN |
| 1794 | 1 | pfleura2 | WRITE(Line,*) 'DBG Path, L1227,', TRIM(Step_method), 'Step for IOpt=',IOpt, ', IGeom=1' |
| 1795 | 1 | pfleura2 | Call PrintGeom(Line,Nat,NCoord,GeomTmp,Coord,6,Atome,Order,OrderInv,IndZmat) |
| 1796 | 1 | pfleura2 | END IF |
| 1797 | 1 | pfleura2 | |
| 1798 | 1 | pfleura2 | ! we have the Newton+RFO step, we will check that the maximum displacement is not greater than Smax |
| 1799 | 1 | pfleura2 | NormStep=sqrt(DOT_Product(GradTmp,GradTmp)) |
| 1800 | 1 | pfleura2 | FactStep=min(1.d0,MaxStep(Igeom)/NormStep) |
| 1801 | 1 | pfleura2 | Fini=(Fini.AND.(NormStep.LE.SThresh)) |
| 1802 | 1 | pfleura2 | OptReac=(NormStep.GT.SThresh) |
| 1803 | 1 | pfleura2 | IF (debug) WRITE(*,*) "NormStep, SThresh, OptReac=",NormStep, SThresh, OptReac |
| 1804 | 1 | pfleura2 | NormGrad=sqrt(DOT_Product(reshape(Grad(1,:),(/Nfree/)),reshape(Grad(1,:),(/NFree/)))) |
| 1805 | 1 | pfleura2 | Fini=(Fini.AND.(NormGrad.LE.GThresh)) |
| 1806 | 1 | pfleura2 | OptReac=(OptReac.OR.(NormGrad.GT.GThresh)) |
| 1807 | 1 | pfleura2 | !Print *, 'Grad(1,:):' |
| 1808 | 1 | pfleura2 | !Print *, Grad(1,:) |
| 1809 | 1 | pfleura2 | IF (debug) WRITE(*,*) "NormGrad, GThresh, OptReac=",NormGrad, GThresh, OptReac |
| 1810 | 1 | pfleura2 | |
| 1811 | 1 | pfleura2 | GradTmp=GradTmp*FactStep |
| 1812 | 1 | pfleura2 | |
| 1813 | 1 | pfleura2 | ! we take care that frozen atoms do not move. |
| 1814 | 1 | pfleura2 | IF (NFroz.NE.0) THEN |
| 1815 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1816 | 1 | pfleura2 | CASE ('ZMAT','MIXED')
|
| 1817 | 1 | pfleura2 | GradTmp(1:IntFroz)=0.d0 |
| 1818 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 1819 | 1 | pfleura2 | DO I=1,Nat |
| 1820 | 1 | pfleura2 | IF (FrozAtoms(I)) THEN |
| 1821 | 1 | pfleura2 | Iat=Order(I) |
| 1822 | 1 | pfleura2 | GradTmp(3*Iat-2:3*Iat)=0.d0 |
| 1823 | 1 | pfleura2 | END IF |
| 1824 | 1 | pfleura2 | END DO |
| 1825 | 1 | pfleura2 | CASE('BAKER')
|
| 1826 | 1 | pfleura2 | GradTmp(1:IntFroz)=0.d0 !GradTmp is "step" in Step_RFO_all(..) |
| 1827 | 1 | pfleura2 | CASE DEFAULT |
| 1828 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1323.STOP' |
| 1829 | 1 | pfleura2 | STOP |
| 1830 | 1 | pfleura2 | END SELECT |
| 1831 | 1 | pfleura2 | END IF ! matches IF (NFroz.NE.0) THEN |
| 1832 | 1 | pfleura2 | |
| 1833 | 1 | pfleura2 | IF (debug) THEN |
| 1834 | 1 | pfleura2 | !WRITE(Line,*) 'DBG Path, L1244, Step for IOpt=',IOpt, ', IGeom=1' |
| 1835 | 1 | pfleura2 | !Call PrintGeom(Line,Nat,NCoord,GradTmp,Coord,6,Atome,Order,OrderInv,IndZmat) |
| 1836 | 1 | pfleura2 | END IF |
| 1837 | 1 | pfleura2 | |
| 1838 | 1 | pfleura2 | IF (debug) THEN |
| 1839 | 1 | pfleura2 | !WRITE(*,*) "DBG Main, L1249, IOpt=",IOpt, ', IGeom=1' |
| 1840 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1841 | 1 | pfleura2 | WRITE(*,'(12(1X,F8.3))') IntCoordF(1,1:min(12,NFree)) |
| 1842 | 1 | pfleura2 | ELSE |
| 1843 | 1 | pfleura2 | DO Iat=1,Nat |
| 1844 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(Iat)), & |
| 1845 | 1 | pfleura2 | XyzGeomF(IGeom,1:3,Iat) |
| 1846 | 1 | pfleura2 | END DO |
| 1847 | 1 | pfleura2 | END IF |
| 1848 | 1 | pfleura2 | END IF ! matches IF (debug) THEN |
| 1849 | 1 | pfleura2 | |
| 1850 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1851 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 1852 | 1 | pfleura2 | IntcoordF(1,:)=IntcoordF(1,:)+GradTmp(:) !IGeom=1 |
| 1853 | 1 | pfleura2 | CASE ('HYBRID','CART')
|
| 1854 | 1 | pfleura2 | XyzGeomF(1,:,:)=XyzGeomF(1,:,:)+reshape(GradTmp(:),(/3,Nat/)) |
| 1855 | 1 | pfleura2 | CASE DEFAULT |
| 1856 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1201.STOP' |
| 1857 | 1 | pfleura2 | STOP |
| 1858 | 1 | pfleura2 | END SELECT |
| 1859 | 1 | pfleura2 | |
| 1860 | 1 | pfleura2 | IF (debug) THEN |
| 1861 | 1 | pfleura2 | WRITE(*,*) "DBG Main, L1271, IOpt=",IOpt, ', IGeom=1' |
| 1862 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1863 | 1 | pfleura2 | WRITE(*,'(12(1X,F8.3))') IntCoordF(1,1:min(12,NFree)) |
| 1864 | 1 | pfleura2 | ELSE |
| 1865 | 1 | pfleura2 | DO Iat=1,Nat |
| 1866 | 1 | pfleura2 | |
| 1867 | 1 | pfleura2 | !!!!!!!!!! There was an OrderInv here... should I put it back ? |
| 1868 | 1 | pfleura2 | ! It was with indzmat. IndZmat cannot appear here... |
| 1869 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(Iat)), & |
| 1870 | 1 | pfleura2 | XyzGeomF(IGeom,1:3,Iat) |
| 1871 | 1 | pfleura2 | END DO |
| 1872 | 1 | pfleura2 | END IF |
| 1873 | 1 | pfleura2 | END IF ! matches IF (debug) THEN |
| 1874 | 1 | pfleura2 | |
| 1875 | 1 | pfleura2 | IF (.NOT.OptReac) WRITE(*,*) "Reactants optimized" |
| 1876 | 1 | pfleura2 | ELSE ! Optreac |
| 1877 | 1 | pfleura2 | IF (debug) WRITE(*,*) "Reactants already optimized, Fini=",Fini |
| 1878 | 1 | pfleura2 | END IF ! matches IF (OptReac) THEN |
| 1879 | 1 | pfleura2 | |
| 1880 | 1 | pfleura2 | IF (OptProd) THEN !OptProd: True if one wants to optimize the geometry of the products. Default is FALSE. |
| 1881 | 1 | pfleura2 | IGeom=NGeomF |
| 1882 | 1 | pfleura2 | if (debug) WRITE(*,*) '******************' |
| 1883 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Optimizing product' |
| 1884 | 1 | pfleura2 | if (debug) WRITE(*,*) '******************' |
| 1885 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1886 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 1887 | 1 | pfleura2 | Print *, 'Optimizing product' |
| 1888 | 1 | pfleura2 | SELECT CASE (Step_method) |
| 1889 | 1 | pfleura2 | CASE ('RFO')
|
| 1890 | 1 | pfleura2 | !GradTmp(NCoord)) becomes "Step" in Step_RFO_all and has INTENT(OUT). |
| 1891 | 1 | pfleura2 | Call Step_RFO_all(NCoord,GradTmp,NGeomF,IntCoordF(NGeomF,:),Grad(NGeomF,:),Hess(NGeomF,:,:),ZeroVec) |
| 1892 | 1 | pfleura2 | Print *, GradTmp |
| 1893 | 1 | pfleura2 | CASE ('GDIIS')
|
| 1894 | 1 | pfleura2 | ! GradTmp becomes "step" below and has INTENT(OUT): |
| 1895 | 1 | pfleura2 | Call Step_DIIS_all(NGeomF,NGeomF,GradTmp,IntCoordF(NGeomF,:),Grad(NGeomF,:),& |
| 1896 | 1 | pfleura2 | HP,HEAT,Hess(NGeomF,:,:),NCoord,allocation_flag,ZeroVec) |
| 1897 | 1 | pfleura2 | Print *, 'OptProd, Steps from GDIIS, GeomNew - IntCoordF(NGeomF,:)=' |
| 1898 | 1 | pfleura2 | Print *, GradTmp |
| 1899 | 1 | pfleura2 | CASE ('GEDIIS')
|
| 1900 | 1 | pfleura2 | ! GradTmp(NCoord) becomes "step" below and has INTENT(OUT): |
| 1901 | 1 | pfleura2 | Call Step_GEDIIS_All(NGeomF,NGeomF,GradTmp,IntCoordF(NGeomF,:),Grad(NGeomF,:),Energies(NGeomF),& |
| 1902 | 1 | pfleura2 | Hess(NGeomF,:,:),NCoord,allocation_flag,ZeroVec) |
| 1903 | 1 | pfleura2 | Print *, 'OptProd, Steps from GEDIIS, GeomNew - IntCoordF(NGeomF,:)=' |
| 1904 | 1 | pfleura2 | Print *, GradTmp |
| 1905 | 1 | pfleura2 | CASE DEFAULT |
| 1906 | 1 | pfleura2 | WRITE (*,*) "Step_method=",TRIM(Step_method)," not recognized, Path.f90, L1309. Stop" |
| 1907 | 1 | pfleura2 | STOP |
| 1908 | 1 | pfleura2 | END SELECT |
| 1909 | 1 | pfleura2 | CASE ('HYBRID','CART')
|
| 1910 | 1 | pfleura2 | Call Step_RFO_all(NCoord,GradTmp,IGeom,XyzGeomF(NGeomF,:,:),Grad(NGeomF,:),Hess(NGeomF,:,:),ZeroVec) |
| 1911 | 1 | pfleura2 | CASE DEFAULT |
| 1912 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1460.STOP' |
| 1913 | 1 | pfleura2 | STOP |
| 1914 | 1 | pfleura2 | END SELECT |
| 1915 | 1 | pfleura2 | |
| 1916 | 1 | pfleura2 | ! we have the Newton+RFO step, we will check that the displacement is not greater than Smax |
| 1917 | 1 | pfleura2 | NormStep=sqrt(DOT_Product(GradTmp,GradTmp)) |
| 1918 | 1 | pfleura2 | FactStep=min(1.d0,MaxStep(IGeom)/NormStep) |
| 1919 | 1 | pfleura2 | Fini=(Fini.AND.(NormStep.LE.SThresh)) |
| 1920 | 1 | pfleura2 | OptProd=.NOT.(NormStep.LE.SThresh) |
| 1921 | 1 | pfleura2 | NormGrad=sqrt(DOT_Product(reshape(Grad(NGeomF,:),(/Nfree/)),reshape(Grad(NGeomF,:),(/NFree/)))) |
| 1922 | 1 | pfleura2 | Fini=(Fini.AND.(NormGrad.LE.GThresh)) |
| 1923 | 1 | pfleura2 | OptProd=(OptProd.OR.(NormGrad.GT.GThresh)) |
| 1924 | 1 | pfleura2 | IF (debug) WRITE(*,*) "NormGrad, GThresh, OptProd=",NormGrad, GThresh, OptProd |
| 1925 | 1 | pfleura2 | |
| 1926 | 1 | pfleura2 | GradTmp=GradTmp*FactStep |
| 1927 | 1 | pfleura2 | |
| 1928 | 1 | pfleura2 | ! we take care that frozen atoms do not move |
| 1929 | 1 | pfleura2 | IF (NFroz.NE.0) THEN |
| 1930 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1931 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 1932 | 1 | pfleura2 | GradTmp(1:IntFroz)=0.d0 |
| 1933 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 1934 | 1 | pfleura2 | DO I=1,Nat |
| 1935 | 1 | pfleura2 | IF (FrozAtoms(I)) THEN |
| 1936 | 1 | pfleura2 | Iat=Order(I) |
| 1937 | 1 | pfleura2 | GradTmp(3*Iat-2:3*Iat)=0.d0 |
| 1938 | 1 | pfleura2 | END IF |
| 1939 | 1 | pfleura2 | END DO |
| 1940 | 1 | pfleura2 | CASE DEFAULT |
| 1941 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1045.STOP' |
| 1942 | 1 | pfleura2 | STOP |
| 1943 | 1 | pfleura2 | END SELECT |
| 1944 | 1 | pfleura2 | END IF ! matches IF (NFroz.NE.0) THEN |
| 1945 | 1 | pfleura2 | |
| 1946 | 1 | pfleura2 | IF (debug) THEN |
| 1947 | 1 | pfleura2 | WRITE(*,*) "DBG Main, L1354, IGeom=, IOpt=",IGeom,IOpt |
| 1948 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1949 | 1 | pfleura2 | WRITE(*,'(12(1X,F8.3))') IntCoordF(IGeom,1:min(12,NFree)) |
| 1950 | 1 | pfleura2 | ELSE |
| 1951 | 1 | pfleura2 | DO Iat=1,Nat |
| 1952 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(Iat)), & |
| 1953 | 1 | pfleura2 | XyzGeomF(IGeom,1:3,Iat) |
| 1954 | 1 | pfleura2 | END DO |
| 1955 | 1 | pfleura2 | END IF |
| 1956 | 1 | pfleura2 | END IF |
| 1957 | 1 | pfleura2 | |
| 1958 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1959 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 1960 | 1 | pfleura2 | IntcoordF(NGeomF,:)=IntcoordF(NGeomF,:)+GradTmp(:) ! IGeom is NGeomF. |
| 1961 | 1 | pfleura2 | CASE ('HYBRID','CART')
|
| 1962 | 1 | pfleura2 | XyzGeomF(IGeom,:,:)=XyzGeomF(IGeom,:,:)+reshape(GradTmp(:),(/3,Nat/)) |
| 1963 | 1 | pfleura2 | CASE DEFAULT |
| 1964 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1050.STOP' |
| 1965 | 1 | pfleura2 | STOP |
| 1966 | 1 | pfleura2 | END SELECT |
| 1967 | 1 | pfleura2 | |
| 1968 | 1 | pfleura2 | IF (debug) THEN |
| 1969 | 1 | pfleura2 | WRITE(*,*) "DBG Main, L1376, IGeom=, IOpt=",IGeom,IOpt |
| 1970 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 1971 | 1 | pfleura2 | WRITE(*,'(12(1X,F8.3))') IntCoordF(IGeom,1:min(12,NFree)) |
| 1972 | 1 | pfleura2 | ELSE |
| 1973 | 1 | pfleura2 | DO Iat=1,Nat |
| 1974 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(Iat)), & |
| 1975 | 1 | pfleura2 | XyzGeomF(IGeom,1:3,Iat) |
| 1976 | 1 | pfleura2 | END DO |
| 1977 | 1 | pfleura2 | END IF |
| 1978 | 1 | pfleura2 | END IF |
| 1979 | 1 | pfleura2 | ELSE ! Optprod |
| 1980 | 1 | pfleura2 | IF (debug) WRITE(*,*) "Product already optimized, Fini=",Fini |
| 1981 | 1 | pfleura2 | END IF !matches IF (OptProd) THEN |
| 1982 | 1 | pfleura2 | |
| 1983 | 1 | pfleura2 | IF (debug) WRITE(*,*) "Fini before L1491 path:",Fini |
| 1984 | 1 | pfleura2 | |
| 1985 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1986 | 1 | pfleura2 | ! |
| 1987 | 1 | pfleura2 | ! Optimizing other geometries |
| 1988 | 1 | pfleura2 | ! |
| 1989 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1990 | 1 | pfleura2 | |
| 1991 | 1 | pfleura2 | |
| 1992 | 1 | pfleura2 | |
| 1993 | 1 | pfleura2 | DO IGeom=2,NGeomF-1 ! matches at L1556 |
| 1994 | 1 | pfleura2 | if (debug) WRITE(*,*) '****************************' |
| 1995 | 1 | pfleura2 | if (debug) WRITE(*,*) 'All other geometries, IGeom=',IGeom |
| 1996 | 1 | pfleura2 | if (debug) WRITE(*,*) '****************************' |
| 1997 | 1 | pfleura2 | |
| 1998 | 1 | pfleura2 | SELECT CASE (COORD) |
| 1999 | 1 | pfleura2 | CASE ('ZMAT','BAKER','MIXED')
|
| 2000 | 1 | pfleura2 | GradTmp2=reshape(IntTangent(IGeom,:),(/NCoord/)) |
| 2001 | 1 | pfleura2 | ! PFL 6 Apr 2008 -> |
| 2002 | 1 | pfleura2 | ! Special case, if FTan=0. we do not consider Tangent at all. |
| 2003 | 1 | pfleura2 | ! To DO: add the full treatment of FTan |
| 2004 | 1 | pfleura2 | if (FTan==0.) GradTmp2=ZeroVec |
| 2005 | 1 | pfleura2 | ! <- PFL 6 Apr 2008 |
| 2006 | 1 | pfleura2 | if (debug) THEN |
| 2007 | 1 | pfleura2 | Print *, 'L1500, IntTangent(',IGeom,',:)='
|
| 2008 | 1 | pfleura2 | Print *, IntTangent(IGeom,:) |
| 2009 | 1 | pfleura2 | END IF |
| 2010 | 1 | pfleura2 | !GradTmp(NCoord)) is actually "Step" in Step_RFO_all and has INTENT(OUT). |
| 2011 | 1 | pfleura2 | SELECT CASE (Step_method) |
| 2012 | 1 | pfleura2 | CASE ('RFO')
|
| 2013 | 1 | pfleura2 | Call Step_RFO_all(NCoord,GradTmp,IGeom,IntCoordF(IGeom,:),Grad(IGeom,:),Hess(IGeom,:,:),GradTmp2) |
| 2014 | 1 | pfleura2 | CASE ('GDIIS')
|
| 2015 | 1 | pfleura2 | !The following has no effect at IOpt==1 |
| 2016 | 1 | pfleura2 | !Print *, 'Before call of Step_diis_all, All other geometries, IGeom=', IGeom |
| 2017 | 1 | pfleura2 | Call Step_DIIS_all(NGeomF,IGeom,GradTmp,IntCoordF(IGeom,:),Grad(IGeom,:),HP,HEAT,& |
| 2018 | 1 | pfleura2 | Hess(IGeom,:,:),NCoord,allocation_flag,GradTmp2) |
| 2019 | 1 | pfleura2 | Print *, 'All others, Steps from GDIIS, GeomNew - IntCoordF(IGeom,:)=' |
| 2020 | 1 | pfleura2 | Print *, GradTmp |
| 2021 | 1 | pfleura2 | CASE ('GEDIIS')
|
| 2022 | 1 | pfleura2 | ! GradTmp(NCoord) becomes "step" below and has INTENT(OUT): |
| 2023 | 1 | pfleura2 | Call Step_GEDIIS_All(NGeomF,IGeom,GradTmp,IntCoordF(IGeom,:),Grad(IGeom,:),Energies(IGeom),& |
| 2024 | 1 | pfleura2 | Hess(IGeom,:,:),NCoord,allocation_flag,GradTmp2) |
| 2025 | 1 | pfleura2 | Print *, 'All others, Steps from GEDIIS, GeomNew - IntCoordF(IGeom,:)=' |
| 2026 | 1 | pfleura2 | Print *, GradTmp |
| 2027 | 1 | pfleura2 | CASE DEFAULT |
| 2028 | 1 | pfleura2 | WRITE (*,*) "Step_method=",TRIM(Step_method)," not recognized, Path.f90, L1430. Stop" |
| 2029 | 1 | pfleura2 | STOP |
| 2030 | 1 | pfleura2 | END SELECT |
| 2031 | 1 | pfleura2 | CASE ('HYBRID','CART')
|
| 2032 | 1 | pfleura2 | ! XyzTangent is implicitely in Nat,3... but all the rest is 3,Nat |
| 2033 | 1 | pfleura2 | ! so we change it |
| 2034 | 1 | pfleura2 | DO I=1,Nat |
| 2035 | 1 | pfleura2 | DO J=1,3 |
| 2036 | 1 | pfleura2 | GradTmp2(J+(I-1)*3)=XyzTangent(IGeom,(J-1)*Nat+I) |
| 2037 | 1 | pfleura2 | END DO |
| 2038 | 1 | pfleura2 | END DO |
| 2039 | 1 | pfleura2 | ! GradTmp2=XyzTangent(IGeom,:) |
| 2040 | 1 | pfleura2 | ! PFL 6 Apr 2008 -> |
| 2041 | 1 | pfleura2 | ! Special case, if FTan=0. we do not consider Tangent at all. |
| 2042 | 1 | pfleura2 | ! To DO: add the full treatment of FTan |
| 2043 | 1 | pfleura2 | if (FTan==0.) GradTmp2=ZeroVec |
| 2044 | 1 | pfleura2 | ! <- PFL 6 Apr 2008 |
| 2045 | 1 | pfleura2 | |
| 2046 | 1 | pfleura2 | Call Step_RFO_all(NCoord,GradTmp,IGeom,XyzGeomF(IGeom,:,:),Grad(IGeom,:),Hess(IGeom,:,:),GradTmp2) |
| 2047 | 1 | pfleura2 | CASE DEFAULT |
| 2048 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1083.STOP' |
| 2049 | 1 | pfleura2 | STOP |
| 2050 | 1 | pfleura2 | END SELECT |
| 2051 | 1 | pfleura2 | |
| 2052 | 1 | pfleura2 | ! we take care that frozen atoms do not move |
| 2053 | 1 | pfleura2 | IF (NFroz.NE.0) THEN |
| 2054 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2055 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 2056 | 1 | pfleura2 | IF (debug) THEN |
| 2057 | 1 | pfleura2 | WRITE(*,*) 'Step computed. Coord=',Coord |
| 2058 | 1 | pfleura2 | WRITE(*,*) 'Zeroing components for frozen atoms. Intfroz=', IntFroz |
| 2059 | 1 | pfleura2 | END IF |
| 2060 | 1 | pfleura2 | GradTmp(1:IntFroz)=0.d0 |
| 2061 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 2062 | 1 | pfleura2 | if (debug) THEN |
| 2063 | 1 | pfleura2 | WRITE(*,*) "DBG Path Zeroing components L1771. Step before zeroing" |
| 2064 | 1 | pfleura2 | DO I=1,Nat |
| 2065 | 1 | pfleura2 | WRITe(*,*) I,GradTmp(3*I-2:3*I) |
| 2066 | 1 | pfleura2 | END DO |
| 2067 | 1 | pfleura2 | END IF |
| 2068 | 1 | pfleura2 | DO I=1,Nat |
| 2069 | 1 | pfleura2 | IF (FrozAtoms(I)) THEN |
| 2070 | 1 | pfleura2 | if (debug) THEN |
| 2071 | 1 | pfleura2 | write(*,*) 'Step Computed. Coord=',Coord |
| 2072 | 1 | pfleura2 | WRITE(*,*) 'Atom',I,' is frozen. Zeroing',Order(I) |
| 2073 | 1 | pfleura2 | END IF |
| 2074 | 1 | pfleura2 | Iat=Order(I) |
| 2075 | 1 | pfleura2 | GradTmp(3*Iat-2:3*Iat)=0.d0 |
| 2076 | 1 | pfleura2 | END IF |
| 2077 | 1 | pfleura2 | END DO |
| 2078 | 1 | pfleura2 | |
| 2079 | 1 | pfleura2 | if (debug) THEN |
| 2080 | 1 | pfleura2 | WRITE(*,*) "DBG Path Zeroing components L1785. Step After zeroing" |
| 2081 | 1 | pfleura2 | DO I=1,Nat |
| 2082 | 1 | pfleura2 | WRITe(*,*) I,GradTmp(3*I-2:3*I) |
| 2083 | 1 | pfleura2 | END DO |
| 2084 | 1 | pfleura2 | END IF |
| 2085 | 1 | pfleura2 | |
| 2086 | 1 | pfleura2 | CASE DEFAULT |
| 2087 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1338.STOP' |
| 2088 | 1 | pfleura2 | STOP |
| 2089 | 1 | pfleura2 | END SELECT |
| 2090 | 1 | pfleura2 | END IF !matches IF (NFroz.NE.0) THEN |
| 2091 | 1 | pfleura2 | |
| 2092 | 1 | pfleura2 | IF (debug) THEN |
| 2093 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2094 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 2095 | 1 | pfleura2 | WRITE(*,'(A,12(1X,F8.3))') 'Step tan:',IntTangent(IGeom,1:min(12,NFree)) |
| 2096 | 1 | pfleura2 | WRITE(*,'(A,12(1X,F8.3))') 'Ortho Step:',GradTmp(1:min(12,NFree)) |
| 2097 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 2098 | 1 | pfleura2 | WRITE(*,'(A,12(1X,F8.3))') 'Step tan:',XyzTangent(IGeom,1:min(12,NFree)) |
| 2099 | 1 | pfleura2 | WRITE(*,'(A,12(1X,F8.3))') 'Ortho Step:',GradTmp(1:min(12,NFree)) |
| 2100 | 1 | pfleura2 | CASE DEFAULT |
| 2101 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1588.STOP' |
| 2102 | 1 | pfleura2 | STOP |
| 2103 | 1 | pfleura2 | END SELECT |
| 2104 | 1 | pfleura2 | END IF ! matches if (debug) THEN |
| 2105 | 1 | pfleura2 | |
| 2106 | 1 | pfleura2 | ! we check that the maximum displacement is not greater than Smax |
| 2107 | 1 | pfleura2 | If (debug) WRITE(*,*) "Fini before test:",Fini |
| 2108 | 1 | pfleura2 | NormStep=sqrt(DOT_Product(GradTmp,GradTmp)) |
| 2109 | 1 | pfleura2 | FactStep=min(1.d0,maxStep(Igeom)/NormStep) |
| 2110 | 1 | pfleura2 | Fini=(Fini.AND.(NormStep.LE.SThresh)) |
| 2111 | 1 | pfleura2 | IF (debug) WRITE(*,*) "IGeom,NormStep, SThresh,Fini",IGeom,NormStep, SThresh, Fini |
| 2112 | 1 | pfleura2 | |
| 2113 | 1 | pfleura2 | GradTmp=GraDTmp*FactStep |
| 2114 | 1 | pfleura2 | |
| 2115 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Main, L1475, FactStep=",FactStep |
| 2116 | 1 | pfleura2 | if (debug.AND.(COORD.EQ.'ZMAT')) WRITE(*,'(A,12(1X,F10.6))') 'Scaled Step:',GradTmp(1:min(12,NFree)) |
| 2117 | 1 | pfleura2 | |
| 2118 | 1 | pfleura2 | IF (debug) THEN |
| 2119 | 1 | pfleura2 | WRITE(*,*) "DBG Main, L1479, IGeom=, IOpt=",IGeom,IOpt |
| 2120 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 2121 | 1 | pfleura2 | WRITE(*,'(12(1X,F8.3))') IntCoordF(IGeom,1:min(12,NFree)) |
| 2122 | 1 | pfleura2 | ELSE |
| 2123 | 1 | pfleura2 | DO Iat=1,Nat |
| 2124 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(Iat)), & |
| 2125 | 1 | pfleura2 | XyzGeomF(IGeom,1:3,Iat) |
| 2126 | 1 | pfleura2 | END DO |
| 2127 | 1 | pfleura2 | END IF |
| 2128 | 1 | pfleura2 | END IF ! matches if (debug) THEN |
| 2129 | 1 | pfleura2 | |
| 2130 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2131 | 1 | pfleura2 | CASE ('ZMAT')
|
| 2132 | 1 | pfleura2 | IntcoordF(IGeom,:)=IntcoordF(IGeom,:)+GradTmp(:) |
| 2133 | 1 | pfleura2 | if (debug) Print *, 'New Geom=IntcoordF(',IGeom,',:)=', IntcoordF(IGeom,:)
|
| 2134 | 1 | pfleura2 | WRITE(IOOUT,"('Geometry ',I3,'/',I3,' for iteration ',I3)") IGeom,NgeomF,IOpt
|
| 2135 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(1,1)))) |
| 2136 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(2,1)))), & |
| 2137 | 1 | pfleura2 | OrderInv(indzmat(2,2)),IntcoordF(IGeom,1) |
| 2138 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(3,1)))), & |
| 2139 | 1 | pfleura2 | OrderInv(indzmat(3,2)),IntcoordF(IGeom,2), OrderInv(indzmat(3,3)),IntcoordF(IGeom,3)*180./Pi |
| 2140 | 1 | pfleura2 | Idx=4 |
| 2141 | 1 | pfleura2 | DO Iat=4,Nat |
| 2142 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), & |
| 2143 | 1 | pfleura2 | OrderInv(indzmat(iat,2)),IntcoordF(IGeom,Idx), & |
| 2144 | 1 | pfleura2 | OrderInv(indzmat(iat,3)),IntcoordF(IGeom,Idx+1)*180./pi, & |
| 2145 | 1 | pfleura2 | OrderInv(indzmat(iat,4)),IntcoordF(IGeom,Idx+2)*180/Pi |
| 2146 | 1 | pfleura2 | Idx=Idx+3 |
| 2147 | 1 | pfleura2 | END DO |
| 2148 | 1 | pfleura2 | |
| 2149 | 1 | pfleura2 | CASE ('BAKER')
|
| 2150 | 1 | pfleura2 | IntcoordF(IGeom,:)=IntcoordF(IGeom,:)+GradTmp(:) |
| 2151 | 1 | pfleura2 | if (debug) Print *, 'New Geom=IntcoordF(',IGeom,',:)=', IntcoordF(IGeom,:)
|
| 2152 | 1 | pfleura2 | WRITE(IOOUT,"('Geometry ',I3,'/',I3,' for iteration ',I3)") IGeom,NgeomF,IOpt
|
| 2153 | 1 | pfleura2 | WRITE(IOOUT,*) "COORD=BAKER, printing IntCoordF is not meaningfull." |
| 2154 | 1 | pfleura2 | |
| 2155 | 1 | pfleura2 | CASE ('MIXED')
|
| 2156 | 1 | pfleura2 | IntcoordF(IGeom,:)=IntcoordF(IGeom,:)+GradTmp(:) |
| 2157 | 1 | pfleura2 | if (debug) Print *, 'New Geom=IntcoordF(',IGeom,',:)=', IntcoordF(IGeom,:)
|
| 2158 | 1 | pfleura2 | WRITE(IOOUT,"('Geometry ',I3,'/',I3,' for iteration ',I3)") IGeom,NgeomF,IOpt
|
| 2159 | 1 | pfleura2 | DO Iat=1,NCart |
| 2160 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,F13.8))') Nom(Atome(OrderInv(indzmat(1,1)))),IntcoordF(IGeom,3*Iat-2:3*Iat) |
| 2161 | 1 | pfleura2 | END DO |
| 2162 | 1 | pfleura2 | Idx=3*NCart+1 |
| 2163 | 1 | pfleura2 | IF (NCart.EQ.1) THEN |
| 2164 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(2,1)))), & |
| 2165 | 1 | pfleura2 | OrderInv(indzmat(2,2)),IntcoordF(IGeom,4) |
| 2166 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(3,1)))), & |
| 2167 | 1 | pfleura2 | OrderInv(indzmat(3,2)),IntcoordF(IGeom,5), OrderInv(indzmat(3,3)),IntcoordF(IGeom,6)*180./Pi |
| 2168 | 1 | pfleura2 | |
| 2169 | 1 | pfleura2 | Idx=7 |
| 2170 | 1 | pfleura2 | END IF |
| 2171 | 1 | pfleura2 | IF (NCart.EQ.2) THEN |
| 2172 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(3,1)))), & |
| 2173 | 1 | pfleura2 | OrderInv(indzmat(3,2)),IntcoordF(IGeom,7), OrderInv(indzmat(3,3)),IntcoordF(IGeom,8)*180./Pi |
| 2174 | 1 | pfleura2 | Idx=9 |
| 2175 | 1 | pfleura2 | END IF |
| 2176 | 1 | pfleura2 | |
| 2177 | 1 | pfleura2 | |
| 2178 | 1 | pfleura2 | DO Iat=max(NCart+1,4),Nat |
| 2179 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), & |
| 2180 | 1 | pfleura2 | OrderInv(indzmat(iat,2)),IntcoordF(IGeom,Idx), & |
| 2181 | 1 | pfleura2 | OrderInv(indzmat(iat,3)),IntcoordF(IGeom,Idx+1)*180./pi, & |
| 2182 | 1 | pfleura2 | OrderInv(indzmat(iat,4)),IntcoordF(IGeom,Idx+2)*180/Pi |
| 2183 | 1 | pfleura2 | Idx=Idx+3 |
| 2184 | 1 | pfleura2 | END DO |
| 2185 | 1 | pfleura2 | if (debug) Print *, 'New Geom=IntcoordF(',IGeom,',:)=', IntcoordF(IGeom,:)
|
| 2186 | 1 | pfleura2 | |
| 2187 | 1 | pfleura2 | CASE ('HYBRID','CART')
|
| 2188 | 1 | pfleura2 | XyzGeomF(IGeom,:,:)=XyzGeomF(IGeom,:,:)+reshape(GradTmp(:),(/3,Nat/)) |
| 2189 | 1 | pfleura2 | CASE DEFAULT |
| 2190 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1537.STOP' |
| 2191 | 1 | pfleura2 | STOP |
| 2192 | 1 | pfleura2 | END SELECT |
| 2193 | 1 | pfleura2 | |
| 2194 | 1 | pfleura2 | IF (debug) THEN |
| 2195 | 1 | pfleura2 | WRITE(*,*) "DBG Main, L1516, IGeom=, IOpt=",IGeom,IOpt |
| 2196 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 2197 | 1 | pfleura2 | WRITE(*,'(12(1X,F8.3))') IntCoordF(IGeom,1:min(12,NFree)) |
| 2198 | 1 | pfleura2 | ELSE |
| 2199 | 1 | pfleura2 | DO Iat=1,Nat |
| 2200 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(Iat)), & |
| 2201 | 1 | pfleura2 | XyzGeomF(IGeom,1:3,Iat) |
| 2202 | 1 | pfleura2 | END DO |
| 2203 | 1 | pfleura2 | END IF |
| 2204 | 1 | pfleura2 | END IF ! matches if (debug) THEN |
| 2205 | 1 | pfleura2 | |
| 2206 | 1 | pfleura2 | ! We project out the tangential part of the gradient to know if we are done |
| 2207 | 1 | pfleura2 | GradTmp=Grad(IGeom,:) |
| 2208 | 1 | pfleura2 | NormGrad=sqrt(dot_product(GradTmp,GradTmp)) |
| 2209 | 1 | pfleura2 | if (debug) WRITE(*,*) "Norm Grad tot=",NormGrad |
| 2210 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2211 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 2212 | 1 | pfleura2 | S=DOT_PRODUCT(GradTmp,IntTangent(IGeom,:)) |
| 2213 | 1 | pfleura2 | Norm=DOT_PRODUCT(IntTangent(IGeom,:),IntTangent(IGeom,:)) |
| 2214 | 1 | pfleura2 | GradTmp=GradTmp-S/Norm*IntTangent(IGeom,:) |
| 2215 | 1 | pfleura2 | Ca=S/(sqrt(Norm)*NormGrad) |
| 2216 | 1 | pfleura2 | S=DOT_PRODUCT(GradTmp,IntTangent(IGeom,:)) |
| 2217 | 1 | pfleura2 | GradTmp=GradTmp-S/Norm*IntTangent(IGeom,:) |
| 2218 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 2219 | 1 | pfleura2 | S=DOT_PRODUCT(GradTmp,XyzTangent(IGeom,:)) |
| 2220 | 1 | pfleura2 | Norm=DOT_PRODUCT(XyzTangent(IGeom,:),XyzTangent(IGeom,:)) |
| 2221 | 1 | pfleura2 | Ca=S/(sqrt(Norm)*NormGrad) |
| 2222 | 1 | pfleura2 | GradTmp=GradTmp-S/Norm*XyzTangent(IGeom,:) |
| 2223 | 1 | pfleura2 | S=DOT_PRODUCT(GradTmp,XyzTangent(IGeom,:)) |
| 2224 | 1 | pfleura2 | GradTmp=GradTmp-S/Norm*XyzTangent(IGeom,:) |
| 2225 | 1 | pfleura2 | CASE DEFAULT |
| 2226 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1190.STOP' |
| 2227 | 1 | pfleura2 | STOP |
| 2228 | 1 | pfleura2 | END SELECT |
| 2229 | 1 | pfleura2 | IF (debug) WRITE(*,'(1X,A,3(1X,F10.6))') "cos and angle between grad and tangent",ca, acos(ca), acos(ca)*180./pi |
| 2230 | 1 | pfleura2 | NormGrad=sqrt(DOT_Product(GradTmp,GradTmp)) |
| 2231 | 1 | pfleura2 | Fini=(Fini.AND.(NormGrad.LE.GThresh)) |
| 2232 | 1 | pfleura2 | IF (debug) WRITE(*,*) "NormGrad_perp, GThresh, Fini=",NormGrad, GThresh, Fini |
| 2233 | 1 | pfleura2 | |
| 2234 | 1 | pfleura2 | END DO ! matches DO IGeom=2,NGeomF-1 |
| 2235 | 1 | pfleura2 | ! we save the old gradients |
| 2236 | 1 | pfleura2 | GradOld=Grad |
| 2237 | 1 | pfleura2 | EPathOld=Energies |
| 2238 | 1 | pfleura2 | |
| 2239 | 1 | pfleura2 | ! Shall we re-parameterize the path ? |
| 2240 | 1 | pfleura2 | ! PFL 2007/Apr/10 -> |
| 2241 | 1 | pfleura2 | ! We call PathCreate in all cases, it will take care of the |
| 2242 | 1 | pfleura2 | ! reparameterization, as well as calculating the tangents. |
| 2243 | 1 | pfleura2 | ! IF (MOD(IOpt,IReparam).EQ.0) THEN |
| 2244 | 1 | pfleura2 | XyzGeomI=XyzGeomF |
| 2245 | 1 | pfleura2 | IntCoordI=IntCoordF |
| 2246 | 1 | pfleura2 | |
| 2247 | 1 | pfleura2 | Call PathCreate(IOpt) |
| 2248 | 1 | pfleura2 | ! END IF |
| 2249 | 1 | pfleura2 | ! <- PFL 2007/Apr/10 |
| 2250 | 1 | pfleura2 | |
| 2251 | 1 | pfleura2 | if (debug) WRITE(*,'(1X,A,I5,A,I5,A,L2)') 'Path.f90, L1415, IOpt=', IOpt, 'MaxCyc=', MaxCyc,' Fini=', Fini |
| 2252 | 1 | pfleura2 | IF ((.NOT.Fini).AND.(IOpt.LT.MaxCyc)) THEN |
| 2253 | 1 | pfleura2 | |
| 2254 | 1 | pfleura2 | ! We have the new path, we calculate its energy and gradient |
| 2255 | 1 | pfleura2 | |
| 2256 | 2 | pfleura2 | Call EgradPath(IOpt) |
| 2257 | 1 | pfleura2 | !IF(IOPT .EQ. 10) Then |
| 2258 | 1 | pfleura2 | ! Print *, 'Stopping at my checkpoint.' |
| 2259 | 1 | pfleura2 | ! STOP !This is my temporary checkpoint. |
| 2260 | 1 | pfleura2 | !ENDIF |
| 2261 | 1 | pfleura2 | |
| 2262 | 1 | pfleura2 | ! PFL 31 Mar 2008 -> |
| 2263 | 1 | pfleura2 | ! Taken from v3.99 but we added a flag... |
| 2264 | 1 | pfleura2 | ! Added in v3.99 : MaxStep is modified according to the evolution of energies |
| 2265 | 1 | pfleura2 | ! if Energies(IGeom)<=EPathOld then MaxStep is increased by 1.1 |
| 2266 | 1 | pfleura2 | ! else it is decreased by 0.8 |
| 2267 | 1 | pfleura2 | |
| 2268 | 1 | pfleura2 | if (DynMaxStep) THEN |
| 2269 | 1 | pfleura2 | if (debug) WRITE(*,*) "Dynamically updating the Maximum step" |
| 2270 | 1 | pfleura2 | if (OptReac) THEN |
| 2271 | 1 | pfleura2 | If (Energies(1)<EPathOld(1)) Then |
| 2272 | 1 | pfleura2 | MaxStep(1)=min(1.1*MaxStep(1),2.*SMax) |
| 2273 | 1 | pfleura2 | ELSE |
| 2274 | 1 | pfleura2 | MaxStep(1)=max(0.8*MaxStep(1),SMax/2.) |
| 2275 | 1 | pfleura2 | END IF |
| 2276 | 1 | pfleura2 | END IF |
| 2277 | 1 | pfleura2 | |
| 2278 | 1 | pfleura2 | if (OptProd) THEN |
| 2279 | 1 | pfleura2 | If (Energies(NGeomF)<EPathOld(NGeomF)) Then |
| 2280 | 1 | pfleura2 | MaxStep(NGeomF)=min(1.1*MaxStep(NGeomF),2.*SMax) |
| 2281 | 1 | pfleura2 | ELSE |
| 2282 | 1 | pfleura2 | MaxStep(NGeomF)=max(0.8*MaxStep(NGeomF),SMax/2.) |
| 2283 | 1 | pfleura2 | END IF |
| 2284 | 1 | pfleura2 | END IF |
| 2285 | 1 | pfleura2 | |
| 2286 | 1 | pfleura2 | DO IGeom=2,NGeomF-1 |
| 2287 | 1 | pfleura2 | If (Energies(IGeom)<EPathOld(IGeom)) Then |
| 2288 | 1 | pfleura2 | MaxStep(IGeom)=min(1.1*MaxStep(IGeom),2.*SMax) |
| 2289 | 1 | pfleura2 | ELSE |
| 2290 | 1 | pfleura2 | MaxStep(IGeom)=max(0.8*MaxStep(IGeom),SMax/2.) |
| 2291 | 1 | pfleura2 | END IF |
| 2292 | 1 | pfleura2 | END DO |
| 2293 | 1 | pfleura2 | if (debug) WRITE(*,*) "Maximum step",MaxStep(1:NgeomF) |
| 2294 | 1 | pfleura2 | END IF ! test on DynMaxStep |
| 2295 | 1 | pfleura2 | if (debug) WRITE(*,*) "Maximum step",MaxStep(1:NgeomF) |
| 2296 | 1 | pfleura2 | ! <- PFL 31 MAr 2008 |
| 2297 | 1 | pfleura2 | ! Also XyzGeomF is updated in EgradPath for Baker Case. |
| 2298 | 1 | pfleura2 | ! It should get updated for other cases too. |
| 2299 | 1 | pfleura2 | |
| 2300 | 1 | pfleura2 | DO IGeom=1,NGeomF |
| 2301 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2302 | 1 | pfleura2 | CASE('ZMAT')
|
| 2303 | 1 | pfleura2 | WRITE(IOOUT,"('Geometry ',I3,'/',I3,' for iteration ',I3)") IGeom,NgeomF,IOpt
|
| 2304 | 1 | pfleura2 | GeomTmp=IntCoordF(IGeom,:) |
| 2305 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(1,1)))) |
| 2306 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(2,1)))), & |
| 2307 | 1 | pfleura2 | OrderInv(indzmat(2,2)),Geomtmp(1) |
| 2308 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(3,1)))), & |
| 2309 | 1 | pfleura2 | OrderInv(indzmat(3,2)),Geomtmp(2), & |
| 2310 | 1 | pfleura2 | OrderInv(indzmat(3,3)),Geomtmp(3)*180./Pi |
| 2311 | 1 | pfleura2 | Idx=4 |
| 2312 | 1 | pfleura2 | DO Iat=4,Nat |
| 2313 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,I4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), & |
| 2314 | 1 | pfleura2 | OrderInv(indzmat(iat,2)),Geomtmp(Idx), & |
| 2315 | 1 | pfleura2 | OrderInv(indzmat(iat,3)),Geomtmp(Idx+1)*180./pi, & |
| 2316 | 1 | pfleura2 | OrderInv(indzmat(iat,4)),Geomtmp(Idx+2)*180/Pi |
| 2317 | 1 | pfleura2 | Idx=Idx+3 |
| 2318 | 1 | pfleura2 | END DO |
| 2319 | 1 | pfleura2 | CASE('BAKER')
|
| 2320 | 1 | pfleura2 | !WRITE(IOOUT,"('Geometry ',I3,'/',I3,' for iteration ',I3)") IGeom,NgeomF,IOpt
|
| 2321 | 1 | pfleura2 | !GeomTmp=IntCoordF(IGeom,:) |
| 2322 | 1 | pfleura2 | CASE('CART','HYBRID','MIXED')
|
| 2323 | 1 | pfleura2 | WRITE(IOOUT,'(1X,I5)') Nat |
| 2324 | 1 | pfleura2 | WRITE(IOOUT,"('Geometry ',I3,'/',I3,' for iteration ',I3)") IGeom,NgeomF,IOpt
|
| 2325 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/)) |
| 2326 | 1 | pfleura2 | DO I=1,Nat |
| 2327 | 1 | pfleura2 | Iat=I |
| 2328 | 1 | pfleura2 | If (renum) Iat=OrderInv(I) |
| 2329 | 1 | pfleura2 | WRITE(IOOUT,'(1X,A5,3(1X,F11.6))') Nom(Atome(iat)), Geomtmp(3*Iat-2:3*Iat) |
| 2330 | 1 | pfleura2 | END DO |
| 2331 | 1 | pfleura2 | CASE DEFAULT |
| 2332 | 1 | pfleura2 | WRITE(*,*) 'Coord=',TRIM(COORD),' not recognized. Path L1356.STOP' |
| 2333 | 1 | pfleura2 | STOP |
| 2334 | 1 | pfleura2 | END SELECT |
| 2335 | 1 | pfleura2 | END DO ! matches DO IGeom=1,NGeomF |
| 2336 | 1 | pfleura2 | |
| 2337 | 1 | pfleura2 | Call Write_path(IOpt) |
| 2338 | 1 | pfleura2 | |
| 2339 | 1 | pfleura2 | ! We update the Hessian matrices |
| 2340 | 1 | pfleura2 | IF (debug) WRITE(*,*) "Updating Hessian matrices",NCoord |
| 2341 | 1 | pfleura2 | ! First using the displacement from the old path |
| 2342 | 1 | pfleura2 | IGeom0=2 |
| 2343 | 1 | pfleura2 | IGeomF=NGeomF-1 |
| 2344 | 1 | pfleura2 | IF (OptReac) IGeom0=1 |
| 2345 | 1 | pfleura2 | IF (OptProd) IGeomF=NGeomF |
| 2346 | 1 | pfleura2 | |
| 2347 | 1 | pfleura2 | IF (FCalcHess) THEN |
| 2348 | 1 | pfleura2 | DO IGeom=IGeom0,IGeomF |
| 2349 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2350 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 2351 | 1 | pfleura2 | GeomTmp2=IntCoordF(IGeom,:) |
| 2352 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 2353 | 1 | pfleura2 | GeomTmp2=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/)) |
| 2354 | 1 | pfleura2 | CASE DEFAULT |
| 2355 | 1 | pfleura2 | WRITE(*,*) "Coord=",TRIM(COORD)," not recognized. PATH L1267.STOP" |
| 2356 | 1 | pfleura2 | STOP |
| 2357 | 1 | pfleura2 | END SELECT |
| 2358 | 1 | pfleura2 | Call CalcHess(NCoord,GeomTmp2,Hess(IGeom,:,:),IGeom,Iopt) |
| 2359 | 1 | pfleura2 | END DO |
| 2360 | 1 | pfleura2 | ELSE |
| 2361 | 1 | pfleura2 | DO IGeom=IGeom0,IGeomF |
| 2362 | 1 | pfleura2 | GeomTmp=GeomOld_all(IGeom,:) |
| 2363 | 1 | pfleura2 | SELECT CASE (COORD) |
| 2364 | 1 | pfleura2 | CASE ('ZMAT','MIXED','BAKER')
|
| 2365 | 1 | pfleura2 | GeomTmp2=IntCoordF(IGeom,:) |
| 2366 | 1 | pfleura2 | CASE ('CART','HYBRID')
|
| 2367 | 1 | pfleura2 | GeomTmp2=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/)) |
| 2368 | 1 | pfleura2 | CASE DEFAULT |
| 2369 | 1 | pfleura2 | WRITE(*,*) "Coord=",TRIM(COORD)," not recognized. PATH L1267.STOP" |
| 2370 | 1 | pfleura2 | STOP |
| 2371 | 1 | pfleura2 | END SELECT |
| 2372 | 1 | pfleura2 | GeomTmp=GeomTmp2-GeomTmp |
| 2373 | 1 | pfleura2 | GradTmp=Grad(IGeom,:)-GradOld(IGeom,:) |
| 2374 | 1 | pfleura2 | HessTmp=Hess(IGeom,:,:) |
| 2375 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 2376 | 1 | pfleura2 | Hess(IGeom,:,:)=HessTmp |
| 2377 | 1 | pfleura2 | END DO ! matches DO IGeom=IGeom0,IGeomF |
| 2378 | 1 | pfleura2 | |
| 2379 | 1 | pfleura2 | ! Second using the neighbour points |
| 2380 | 1 | pfleura2 | IF (HupNeighbour) THEN |
| 2381 | 1 | pfleura2 | ! Only one point for end points. |
| 2382 | 1 | pfleura2 | IF (OptReac) THEN |
| 2383 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 2384 | 1 | pfleura2 | GeomTmp=IntCoordF(1,:)-IntCoordF(2,:) |
| 2385 | 1 | pfleura2 | ELSE |
| 2386 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(1,:,:),(/3*Nat/))-Reshape(XyzGeomF(2,:,:),(/3*Nat/)) |
| 2387 | 1 | pfleura2 | END IF |
| 2388 | 1 | pfleura2 | GradTmp=Grad(1,:)-Grad(2,:) |
| 2389 | 1 | pfleura2 | HessTmp=Hess(1,:,:) |
| 2390 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 2391 | 1 | pfleura2 | Hess(1,:,:)=HessTmp |
| 2392 | 1 | pfleura2 | END IF |
| 2393 | 1 | pfleura2 | |
| 2394 | 1 | pfleura2 | IF (OptProd) THEN |
| 2395 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 2396 | 1 | pfleura2 | GeomTmp=IntCoordF(NGeomF,:)-IntCoordF(NGeomF-1,:) |
| 2397 | 1 | pfleura2 | ELSE |
| 2398 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(NGeomF,:,:),(/3*Nat/))-Reshape(XyzGeomF(NGeomF-1,:,:),(/3*Nat/)) |
| 2399 | 1 | pfleura2 | END IF |
| 2400 | 1 | pfleura2 | GradTmp=Grad(NGeomF,:)-Grad(NGeomF-1,:) |
| 2401 | 1 | pfleura2 | HessTmp=Hess(NGeomF,:,:) |
| 2402 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 2403 | 1 | pfleura2 | Hess(NGeomF,:,:)=HessTmp |
| 2404 | 1 | pfleura2 | END IF |
| 2405 | 1 | pfleura2 | |
| 2406 | 1 | pfleura2 | ! Two points for the rest of the path |
| 2407 | 1 | pfleura2 | DO IGeom=2,NGeomF-1 |
| 2408 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT').OR.(COORD.EQ.'BAKER')) THEN |
| 2409 | 1 | pfleura2 | GeomTmp=IntCoordF(IGeom,:)-IntCoordF(IGeom+1,:) |
| 2410 | 1 | pfleura2 | ELSE |
| 2411 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/))-Reshape(XyzGeomF(IGeom+1,:,:),(/3*Nat/)) |
| 2412 | 1 | pfleura2 | END IF |
| 2413 | 1 | pfleura2 | GradTmp=Grad(IGeom,:)-Grad(IGeom+1,:) |
| 2414 | 1 | pfleura2 | HessTmp=Hess(IGeom,:,:) |
| 2415 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 2416 | 1 | pfleura2 | |
| 2417 | 1 | pfleura2 | IF ((COORD.EQ.'ZMAT') .OR. (COORD.EQ.'BAKER')) THEN |
| 2418 | 1 | pfleura2 | GeomTmp=IntCoordF(IGeom,:)-IntCoordF(IGeom-1,:) |
| 2419 | 1 | pfleura2 | ELSE |
| 2420 | 1 | pfleura2 | GeomTmp=Reshape(XyzGeomF(IGeom,:,:),(/3*Nat/))-Reshape(XyzGeomF(IGeom-1,:,:),(/3*Nat/)) |
| 2421 | 1 | pfleura2 | END IF |
| 2422 | 1 | pfleura2 | GradTmp=Grad(IGeom,:)-Grad(IGeom-1,:) |
| 2423 | 1 | pfleura2 | |
| 2424 | 1 | pfleura2 | Call Hupdate_all(NCoord,GeomTmp,GradTmp,HessTmp) |
| 2425 | 1 | pfleura2 | Hess(IGeom,:,:)=HessTmp |
| 2426 | 1 | pfleura2 | END DO ! matches DO IGeom=2,NGeomF-1 |
| 2427 | 1 | pfleura2 | END IF !matches IF (HupNeighbour) THEN |
| 2428 | 1 | pfleura2 | END IF ! matches IF (FCalcHess) |
| 2429 | 1 | pfleura2 | END IF ! If (not.fini.).AND.(IOpt.LE.MaxCyc) |
| 2430 | 1 | pfleura2 | END DO ! matches DO WHILE ((IOpt.LT.MaxCyc).AND.(.NOT.Fini)) |
| 2431 | 1 | pfleura2 | |
| 2432 | 2 | pfleura2 | ! IF (PROG=="GAUSSIAN") THEN |
| 2433 | 2 | pfleura2 | ! DEALLOCATE(Gauss_paste) |
| 2434 | 2 | pfleura2 | ! DEALLOCATE(Gauss_root) |
| 2435 | 2 | pfleura2 | ! DEALLOCATE(Gauss_comment) |
| 2436 | 2 | pfleura2 | ! DEALLOCATE(Gauss_end) |
| 2437 | 2 | pfleura2 | ! END IF |
| 2438 | 2 | pfleura2 | |
| 2439 | 1 | pfleura2 | DEALLOCATE(XyzGeomF, IntCoordF) |
| 2440 | 1 | pfleura2 | DEALLOCATE(XyzGeomI, IntCoordI) |
| 2441 | 1 | pfleura2 | DEALLOCATE(XyzTangent,IntTangent) |
| 2442 | 1 | pfleura2 | DEALLOCATE(AtName,IndZmat,Order,Atome,MassAt) |
| 2443 | 1 | pfleura2 | DEALLOCATE(GeomOld_all) |
| 2444 | 1 | pfleura2 | |
| 2445 | 1 | pfleura2 | if (PROG=="GAUSSIAN") THEN |
| 2446 | 1 | pfleura2 | ! We de-allocate the Gauss_XX lists |
| 2447 | 1 | pfleura2 | ! transverse the list and deallocate each node |
| 2448 | 1 | pfleura2 | previous => Gauss_root ! make current point to head of list |
| 2449 | 1 | pfleura2 | DO |
| 2450 | 1 | pfleura2 | IF (.NOT. ASSOCIATED(previous)) EXIT ! exit if null pointer |
| 2451 | 1 | pfleura2 | current => previous%next ! make list point to next node of head |
| 2452 | 1 | pfleura2 | DEALLOCATE(previous) ! deallocate current head node |
| 2453 | 1 | pfleura2 | previous => current ! make current point to new head |
| 2454 | 1 | pfleura2 | END DO |
| 2455 | 1 | pfleura2 | |
| 2456 | 1 | pfleura2 | previous => Gauss_comment ! make current point to head of list |
| 2457 | 1 | pfleura2 | DO |
| 2458 | 1 | pfleura2 | IF (.NOT. ASSOCIATED(previous)) EXIT ! exit if null pointer |
| 2459 | 1 | pfleura2 | current => previous%next ! make list point to next node of head |
| 2460 | 1 | pfleura2 | DEALLOCATE(previous) ! deallocate current head node |
| 2461 | 1 | pfleura2 | previous => current ! make current point to new head |
| 2462 | 1 | pfleura2 | END DO |
| 2463 | 1 | pfleura2 | |
| 2464 | 1 | pfleura2 | previous => Gauss_end ! make current point to head of list |
| 2465 | 1 | pfleura2 | DO |
| 2466 | 1 | pfleura2 | IF (.NOT. ASSOCIATED(previous)) EXIT ! exit if null pointer |
| 2467 | 1 | pfleura2 | current => previous%next ! make list point to next node of head |
| 2468 | 1 | pfleura2 | DEALLOCATE(previous) ! deallocate current head node |
| 2469 | 1 | pfleura2 | previous => current ! make current point to new head |
| 2470 | 1 | pfleura2 | END DO |
| 2471 | 1 | pfleura2 | |
| 2472 | 2 | pfleura2 | |
| 2473 | 1 | pfleura2 | END IF |
| 2474 | 1 | pfleura2 | |
| 2475 | 1 | pfleura2 | DEALLOCATE(GeomTmp, Hess, GradTmp) |
| 2476 | 1 | pfleura2 | IF (COORD.EQ.'ZMAT') DEALLOCATE(dzdc) |
| 2477 | 1 | pfleura2 | IF (COORD.EQ.'BAKER') THEN |
| 2478 | 1 | pfleura2 | DEALLOCATE(BMat_BakerT,BTransInv,BTransInv_local,Xprimitive_t) |
| 2479 | 1 | pfleura2 | DEALLOCATE(XprimitiveF,UMatF,BTransInvF,UMat,UMat_local) |
| 2480 | 1 | pfleura2 | END IF |
| 2481 | 1 | pfleura2 | |
| 2482 | 1 | pfleura2 | WRITE(IOOUT,*) "Exiting Path, IOpt=",IOpt |
| 2483 | 1 | pfleura2 | |
| 2484 | 1 | pfleura2 | END PROGRAM PathOpt |