root / src / PathCreate.f90 @ 3
Historique | Voir | Annoter | Télécharger (37,5 ko)
| 1 |
!================================================================ |
|---|---|
| 2 |
! |
| 3 |
! This subroutine create a path using starting geometries |
| 4 |
! it is 'original' in the sense that the path is generated |
| 5 |
! by interpolating internal coordinates instead of cartesian. |
| 6 |
! Comes from the Extrapol.f subroutine of Cart suite. |
| 7 |
! Rewritten in F90 to be more flexible |
| 8 |
! |
| 9 |
!================================================================ |
| 10 |
|
| 11 |
SUBROUTINE PathCreate(IOpt) |
| 12 |
|
| 13 |
use Io_module |
| 14 |
use Path_module, only : Nat, NGeomI, NCoord, NGeomF, IGeomRef, NMaxL, IReparam, IReparamT, & |
| 15 |
Coord, Frozen, Cart, NCart, NFroz, XyzGeomI, atome, r_cov, fact, & |
| 16 |
IndZmat, Renum, Order, OrderInv, IntCoordI, IntCoordF,Pi, BMat_BakerT, Nom, & |
| 17 |
Hess,IntFroz, ISpline, IntTangent, XyzGeomF, NPrim,Xprimitive_t, OptGeom, & |
| 18 |
UMatF, UMat_local, XyzTangent, Linear, Align, FrozAtoms |
| 19 |
! BMat_BakerT (3*Nat,NCoord), XyzGeomI(NGeomI,3,Nat), IGeomRef=-1 (default value) |
| 20 |
! IntCoordI(NGeomI,NCoord) |
| 21 |
|
| 22 |
IMPLICIT NONE |
| 23 |
|
| 24 |
REAL(KREAL), PARAMETER :: Inf=1e32 |
| 25 |
INTEGER(KINT), INTENT(IN) :: IOpt |
| 26 |
|
| 27 |
REAL(KREAL), ALLOCATABLE :: val_zmat(:,:), val_zmatTmp(:,:) ! (3,Nat) |
| 28 |
REAL(KREAL), ALLOCATABLE :: X0(:), Y0(:), Z0(:) ! Nat |
| 29 |
REAL(KREAL), ALLOCATABLE :: XyzTmp(:,:), XyzTmp2(:,:) ! (Nat,3) |
| 30 |
! REAL(KREAL), ALLOCATABLE :: XyzTmp3(:,:) ! (3,Nat) |
| 31 |
REAL(KREAL), ALLOCATABLE :: IntCoordTmp(:) ! (NCoord) |
| 32 |
INTEGER(KINT), ALLOCATABLE :: IndZmat0(:,:) !Nat,5 |
| 33 |
REAL(KREAL), ALLOCATABLE :: Coef(:,:) ! (NGeomI,NCoord) |
| 34 |
! NPrim=Number of primitive coordinates. |
| 35 |
REAL(KREAL), ALLOCATABLE :: XGeom(:) ! NGeomI |
| 36 |
REAL(KREAL), ALLOCATABLE :: XGeomF(:) ! NGeomF |
| 37 |
INTEGER(KINT) :: NGeomS |
| 38 |
|
| 39 |
REAL(KREAL) :: Rmsd, MRot(3, 3), Delta |
| 40 |
REAL(KREAL), PARAMETER :: TwoPi=360.d0 |
| 41 |
REAL(KREAL) ::s, dist, a_val, d |
| 42 |
INTEGER(KINT) :: I, J, igeom, iat |
| 43 |
INTEGER(KINT) :: Itmp, Jat |
| 44 |
INTEGER(KINT) :: Idx,IBeg |
| 45 |
CHARACTER(LCHARS) :: Title |
| 46 |
REAL(KREAL), ALLOCATABLE :: x(:), y(:), z(:) |
| 47 |
LOGICAL :: debug, print |
| 48 |
LOGICAL, SAVE :: First=.TRUE. |
| 49 |
! Frozen contains the indices of frozen atoms |
| 50 |
LOGICAL, ALLOCATABLE :: FCart(:) ! Nat |
| 51 |
INTEGER, ALLOCATABLE :: AtCart(:) !Nat |
| 52 |
INTEGER(KINT), ALLOCATABLE :: LIAISONS(:,:),LiaisonsIni(:,:) ! (Nat,0:NMaxL) |
| 53 |
INTEGER(KINT), ALLOCATABLE :: Fragment(:),NbAtFrag(:) !nat |
| 54 |
INTEGER(KINT), ALLOCATABLE :: FragAt(:,:) !nat,nat |
| 55 |
INTEGER(KINT) :: NbFrag,NFragRef |
| 56 |
|
| 57 |
|
| 58 |
INTERFACE |
| 59 |
function valid(string) result (isValid) |
| 60 |
CHARACTER(*), intent(in) :: string |
| 61 |
logical :: isValid |
| 62 |
END function VALID |
| 63 |
|
| 64 |
FUNCTION test_zmat(na,ind_zmat) |
| 65 |
|
| 66 |
USE Path_module |
| 67 |
|
| 68 |
logical :: test_zmat |
| 69 |
integer(KINT) :: na |
| 70 |
integer(KINT) :: ind_zmat(Na,5) |
| 71 |
END FUNCTION TEST_ZMAT |
| 72 |
END INTERFACE |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
debug=valid("pathcreate")
|
| 77 |
print=valid("printgeom")
|
| 78 |
if (debug) Call header("Entering PathCreate")
|
| 79 |
if (debug.AND.First) WRITE(*,*) "= First call =" |
| 80 |
|
| 81 |
if (debug) WRITE(*,*) "Iopt,IReparam=",Iopt,IReparam |
| 82 |
|
| 83 |
ALLOCATE(Coef(NGeomI,NCoord),val_zmat(Nat,3),val_zmatTMP(Nat,3)) |
| 84 |
ALLOCATE(X0(Nat),Y0(Nat),Z0(Nat),Indzmat0(Nat,5)) |
| 85 |
ALLOCATE(X(Nat),Y(Nat),Z(Nat),Xgeom(NGeomI),XgeomF(NGeomF)) |
| 86 |
! ALLOCATE(XyzTmp(Nat,3),XyzTmp2(Nat,3),XyzTmp3(3,Nat)) |
| 87 |
ALLOCATE(XyzTmp(Nat,3),XyzTmp2(Nat,3)) |
| 88 |
ALLOCATE(IntCoordTmp(NCoord)) |
| 89 |
|
| 90 |
Do I=1,NGeomI |
| 91 |
XGeom(I)=FLoat(I)-1.d0 |
| 92 |
END DO |
| 93 |
|
| 94 |
! First iteration of the optimization: |
| 95 |
IF (First) THEN ! matches at L484 |
| 96 |
if (debug) WRITE(*,*) "first iteration in PathCreate.90, L93" |
| 97 |
|
| 98 |
! This is the first call, so we might have to generate a Zmat |
| 99 |
First=.FALSE. |
| 100 |
|
| 101 |
IF ( ((COORD.EQ."ZMAT").OR.(COORD.EQ."HYBRID").OR.(COORD.EQ."MIXED") & |
| 102 |
.OR.(COORD.EQ."BAKER")).AND.(IGeomRef.LE.0)) THEN |
| 103 |
|
| 104 |
! User has not defined the Reference geometry, we have to choose it ourselves! |
| 105 |
! This is done by counting the number of fragments of each geometry. The |
| 106 |
! reference geometry is the one with the least fragments. When there are |
| 107 |
! frozen or cart atoms, they are discarded to count the fragments. |
| 108 |
|
| 109 |
ALLOCATE(Liaisons(Nat,0:NMaxL)) |
| 110 |
ALLOCATE(Fragment(nat),NbAtFrag(nat),FragAt(nat,nat),FCart(Nat)) |
| 111 |
FCart=.FALSE. |
| 112 |
! FCart(Nat) was under IF below earlier but is being accessed after this loop. |
| 113 |
IF ((Frozen(1).NE.0).OR.(Cart(1).NE.0)) THEN |
| 114 |
ALLOCATE(AtCart(Nat),LiaisonsIni(Nat,0:NMaxL)) |
| 115 |
FCart=.FALSE. |
| 116 |
NCart=0 |
| 117 |
Idx=1 |
| 118 |
DO WHILE (Frozen(Idx).NE.0) |
| 119 |
IF (Frozen(Idx).LT.0) THEN |
| 120 |
DO I=Frozen(Idx-1),abs(Frozen(Idx)) |
| 121 |
IF (.NOT.FCart(I)) THEN |
| 122 |
NCart=NCart+1 |
| 123 |
AtCart(NCart)=I |
| 124 |
FCart(I)=.TRUE. |
| 125 |
END IF |
| 126 |
END DO |
| 127 |
ELSE IF (.NOT.FCart(Frozen(Idx))) THEN |
| 128 |
FCart(Frozen(Idx))=.TRUE. |
| 129 |
NCart=NCart+1 |
| 130 |
AtCart(NCart)=Frozen(Idx) |
| 131 |
END IF |
| 132 |
Idx=Idx+1 |
| 133 |
END DO ! matches DO WHILE (Frozen(Idx).NE.0) |
| 134 |
NFroz=NCart |
| 135 |
Idx=1 |
| 136 |
DO WHILE (Cart(Idx).NE.0) |
| 137 |
IF (Cart(Idx).LT.0) THEN |
| 138 |
DO I=Cart(Idx-1),abs(Cart(Idx)) |
| 139 |
IF (.NOT.FCart(I)) THEN |
| 140 |
NCart=NCart+1 |
| 141 |
AtCart(NCart)=I |
| 142 |
FCart(I)=.TRUE. |
| 143 |
END IF |
| 144 |
END DO |
| 145 |
ELSEIF (.NOT.FCart(Cart(Idx))) THEN |
| 146 |
FCart(Cart(Idx))=.TRUE. |
| 147 |
NCart=NCart+1 |
| 148 |
AtCart(NCart)=Cart(Idx) |
| 149 |
END IF |
| 150 |
Idx=Idx+1 |
| 151 |
END DO !matches DO WHILE (Cart(Idx).NE.0) |
| 152 |
IF (debug) THEN |
| 153 |
WRITE(*,'(1X,A,I4,A,I4,A)') "DBG PathCreate - GeomRef :: Found ", & |
| 154 |
NFroz," frozen atoms, and a total of ",NCart, & |
| 155 |
" atoms described in cartesian coordinates" |
| 156 |
WRITE(*,*) "AtCart:",AtCart(1:NCart) |
| 157 |
END IF |
| 158 |
END IF ! IF ((Frozen(1).NE.0).OR.(Cart(1).NE.0)) THEN |
| 159 |
|
| 160 |
NFragRef=2*Nat |
| 161 |
DO IGeom=1,NGeomI |
| 162 |
x(1:Nat) = XyzGeomI(IGeom,1,1:Nat) |
| 163 |
y(1:Nat) = XyzGeomI(IGeom,2,1:Nat) |
| 164 |
z(1:Nat) = XyzGeomI(IGeom,3,1:Nat) |
| 165 |
! we calculate the connectivities |
| 166 |
Call CalcCnct(nat,atome,x,y,z,LIAISONS,r_cov,fact) |
| 167 |
! if needed, we get rid of links between cart or frozen atoms |
| 168 |
IF (NCart.GE.2) THEN |
| 169 |
LiaisonsIni=Liaisons |
| 170 |
DO I=1,NCart |
| 171 |
Iat=AtCart(I) |
| 172 |
if (debug) WRITE(*,'(20(1X,I3))') I,Iat, & |
| 173 |
(LiaisonsIni(Iat,Itmp),ITmp=0,LiaisonsIni(Iat,0)) |
| 174 |
DO J=1,LiaisonsIni(Iat,0) |
| 175 |
Jat=LiaisonsIni(Iat,J) |
| 176 |
IF (FCart(Jat)) THEN |
| 177 |
Call Annul(Liaisons,Iat,Jat) |
| 178 |
Call Annul(Liaisons,Jat,Iat) |
| 179 |
Call Annul(LiaisonsIni,Jat,Iat) |
| 180 |
Liaisons(Iat,0)=Liaisons(Iat,0)-1 |
| 181 |
Liaisons(Jat,0)=Liaisons(Jat,0)-1 |
| 182 |
LiaisonsIni(Jat,0)=LiaisonsIni(Jat,0)-1 |
| 183 |
END IF |
| 184 |
END DO |
| 185 |
END DO |
| 186 |
END IF ! matches IF (NCart.GE.2) THEN |
| 187 |
! we now calculate the number of fragments. |
| 188 |
Call Decomp_frag(nat,liaisons,.NOT.Fcart,nbfrag,Fragment,NbAtFrag,FragAt) |
| 189 |
IF (NbFrag.LT.NFragRef) THEN |
| 190 |
NFragRef=NbFrag |
| 191 |
! The reference geometry, IGeomRef, is determined based on the least number |
| 192 |
! of fragments (here if (((COORD.EQ."ZMAT").OR.(COORD.EQ."HYBRID").OR.(COORD |
| 193 |
!.EQ."MIXED")).AND.(IGeomRef.LE.0))), otherwise it still has the value of |
| 194 |
! IGeomRef=-1. |
| 195 |
IGeomRef=IGeom |
| 196 |
END IF |
| 197 |
END DO ! matches DO IGeom=1,NGeomI |
| 198 |
DEALLOCATE(FCart) |
| 199 |
END IF ! matches IF (((COORD.EQ."ZMAT").OR.(COORD.EQ."HYBRID").OR.(COORD.EQ."MIXED") |
| 200 |
! .OR.(COORD.EQ."BAKER")).AND.(IGeomRef.LE.0)). |
| 201 |
|
| 202 |
if (debug) WRITE(*,*) "DBG PathCreate : IGeomRef= ",IGeomRef |
| 203 |
|
| 204 |
! we now compute the internal coordinates for this geometry ! |
| 205 |
! The reference geometry, IGeomRef, is determined based on the least number |
| 206 |
! of fragments if (((COORD.EQ."ZMAT").OR.(COORD.EQ."HYBRID").OR.(COORD |
| 207 |
!.EQ."MIXED")).AND.(IGeomRef.LE.0)), otherwise it has the value of |
| 208 |
! IGeomRef=-1. |
| 209 |
x(1:Nat) = XyzGeomI(IGeomRef,1,1:Nat) ! XyzGeomI(NGeomI,3,Nat) |
| 210 |
y(1:Nat) = XyzGeomI(IGeomRef,2,1:Nat) |
| 211 |
z(1:Nat) = XyzGeomI(IGeomRef,3,1:Nat) |
| 212 |
|
| 213 |
IndZmat=0 |
| 214 |
IndZmat0=0 |
| 215 |
|
| 216 |
SELECT CASE(COORD) |
| 217 |
CASE ('BAKER')
|
| 218 |
! atome(Nat), r_cov(0:Max_Z) |
| 219 |
! Frozen(Nat) contains the indices of frozen atoms |
| 220 |
Call Calc_baker(atome,r_cov,fact,frozen,IGeomRef) |
| 221 |
if (debug) THEN |
| 222 |
WRITE(*,*) "UMat_local after Calc_baker" |
| 223 |
DO I=1,3*Nat-6 |
| 224 |
WRITE(*,'(50(1X,F12.8))') UMat_local(:,I) |
| 225 |
END DO |
| 226 |
END IF |
| 227 |
DO IGeom=1,NGeomF |
| 228 |
UMatF(IGeom,:,:)=UMat_Local(:,:) |
| 229 |
END DO |
| 230 |
|
| 231 |
ALLOCATE(Xprimitive_t(NPrim)) |
| 232 |
! x, y, z corresponds the reference geometry. |
| 233 |
DO I=1,Nat |
| 234 |
Order(I)=I |
| 235 |
OrderInv(I)=I |
| 236 |
END DO |
| 237 |
x0=x |
| 238 |
y0=y |
| 239 |
z0=z |
| 240 |
CASE ('ZMAT','HYBRID')
|
| 241 |
! IN case we are using Hybrid or zmat coordinate system, we have to |
| 242 |
! generate the internal coordinates with a Z-Matrix |
| 243 |
! IN case we have frozen atoms, we generate a constrained Zmat |
| 244 |
IF (Frozen(1).NE.0) THEN |
| 245 |
Renum=.True. |
| 246 |
call Calc_zmat_const_frag(Nat,atome,IndZmat0,val_zmat,x,y,z,r_cov,fact,frozen) |
| 247 |
ELSE |
| 248 |
!no zmat... we create our own |
| 249 |
call Calc_zmat_frag(Nat,atome,IndZmat0,val_zmat,x,y,z,r_cov,fact) |
| 250 |
if (valid('old_zmat')) THEN
|
| 251 |
call Calc_zmat(Nat,atome,IndZmat0,val_zmat,x,y,z,r_cov,fact) |
| 252 |
WRITE(*,*) "DBG PathCreate Calc_Zmat.... STOP" |
| 253 |
STOP |
| 254 |
END IF |
| 255 |
END IF |
| 256 |
|
| 257 |
if (debug) WRITE(*,*) 'Back from Calc_zmat' |
| 258 |
IF (.NOT.test_zmat(nat,IndZmat0)) THEN |
| 259 |
WRITE(IOOUT,*) "I cannot generate a valid Zmat... help" |
| 260 |
STOP |
| 261 |
END IF |
| 262 |
|
| 263 |
! The IndZmat0 generated by Calc_zmat refers to the order of the input x,y,z |
| 264 |
! However, we need it with the new order so that we can use the zmat |
| 265 |
! coordinates to generate cartesian coordinates. |
| 266 |
! So, we have to reorder it... |
| 267 |
DO I=1,Nat |
| 268 |
Order(IndZmat0(I,1))=I |
| 269 |
OrderInv(I)=IndZmat0(I,1) |
| 270 |
! I let X0 being the Cartesian coordinates of the reference geometry. Before it was |
| 271 |
! those of the First geometry (which was also the reference one). This might change! |
| 272 |
X0(i)=X(IndZmat0(i,1)) |
| 273 |
Y0(i)=Y(IndZmat0(i,1)) |
| 274 |
Z0(i)=Z(IndZmat0(i,1)) |
| 275 |
END DO |
| 276 |
IndZmat(1,1)=Order(IndZmat0(1,1)) |
| 277 |
IndZmat(2,1)=Order(IndZmat0(2,1)) |
| 278 |
IndZmat(2,2)=Order(IndZmat0(2,2)) |
| 279 |
IndZmat(3,1)=Order(IndZmat0(3,1)) |
| 280 |
IndZmat(3,2)=Order(IndZmat0(3,2)) |
| 281 |
IndZmat(3,3)=Order(IndZmat0(3,3)) |
| 282 |
DO I=4,Nat |
| 283 |
DO J=1,4 |
| 284 |
IndZmat(I,J)=Order(IndZmat0(I,J)) |
| 285 |
END DO |
| 286 |
end do |
| 287 |
IF (DEBUG) THEN |
| 288 |
WRITE(IOOUT,*) "DBG PathCreate : IndZmat" |
| 289 |
DO I=1,Nat |
| 290 |
WRITE(IOOUT,*) (IndZmat(I,J),J=1,5) |
| 291 |
END DO |
| 292 |
WRITE(IOOUT,*) "DBG PathCreate : IndZmat0" |
| 293 |
DO I=1,Nat |
| 294 |
WRITE(IOOUT,*) (IndZmat0(I,J),J=1,5) |
| 295 |
END DO |
| 296 |
|
| 297 |
END IF |
| 298 |
|
| 299 |
! It is the first call, we have to create all internal coordinates |
| 300 |
if (debug) WrITE(*,*) "DBG PathCreate L302: First Call, we generate internal coords" |
| 301 |
DO igeom=1,NgeomI |
| 302 |
x(1:Nat) = XyzGeomI(IGeom,1,1:Nat) |
| 303 |
y(1:Nat) = XyzGeomI(IGeom,2,1:Nat) |
| 304 |
z(1:Nat) = XyzGeomI(IGeom,3,1:Nat) |
| 305 |
|
| 306 |
if (debug) WRITE(*,*) "DBG PathCreate L308: we generate internal coords for geom",IGeom |
| 307 |
|
| 308 |
Call ConvXyzZmat(Nat,x,y,z,IndZmat0,val_zmatTmp) |
| 309 |
IntCoordI(IGeom,1)=val_zmatTmp(2,1) |
| 310 |
IntCoordI(IGeom,2)=val_zmatTmp(3,1) |
| 311 |
IntCoordI(IGeom,3)=val_zmatTmp(3,2)*Pi/180. |
| 312 |
Idx=4 |
| 313 |
DO i=4,nat |
| 314 |
IntCoordI(IGeom,Idx)=val_zmatTmp(i,1) |
| 315 |
Idx=Idx+1 |
| 316 |
IntCoordI(IGeom,Idx)=val_zmatTmp(i,2)*Pi/180. |
| 317 |
Idx=Idx+1 |
| 318 |
|
| 319 |
! Some tests to check that the dihedral angles are similar... this is |
| 320 |
! important if they are close to Pi. |
| 321 |
Delta=0. |
| 322 |
|
| 323 |
if (abs(val_zmatTMP(i,3)-val_zmat(i,3))>=180.) THEN |
| 324 |
if ((val_zmatTMP(i,3)-val_zmat(i,3))<=-180.) THEN |
| 325 |
Delta=-1.0d0*TwoPi |
| 326 |
ELSE |
| 327 |
Delta=TwoPi |
| 328 |
END IF |
| 329 |
if (debug) THEN |
| 330 |
WRITE(*,*) Nom(atome(i)), & |
| 331 |
abs(val_zmatTMP(i,3)-val_zmat(i,3)), & |
| 332 |
val_zmatTMP(i,3),val_zmat(i,3),Delta, & |
| 333 |
val_zmatTMP(i,3)-Delta |
| 334 |
END IF |
| 335 |
END IF |
| 336 |
IntCoordI(IGeom,Idx)=(val_zmatTmp(i,3)-Delta)/180.*Pi |
| 337 |
Idx=Idx+1 |
| 338 |
END DO |
| 339 |
END DO ! End Loop on Igeom |
| 340 |
|
| 341 |
CASE ('MIXED')
|
| 342 |
! IN case we are using mixed coordinate system, we have to |
| 343 |
! we generate the internal coordinates with a Z-Matrix |
| 344 |
Renum=.TRUE. |
| 345 |
! |
| 346 |
call Calc_mixed_frag(Nat,atome,IndZmat0,val_zmat,x,y,z, & |
| 347 |
r_cov,fact,frozen,cart,ncart) |
| 348 |
|
| 349 |
if (debug) WRITE(*,*) 'Back from Calc_Mixed' |
| 350 |
|
| 351 |
! How to test this partial zmat ? it must be good as it was automatically generated... |
| 352 |
! IF (.NOT.test_zmat(nat,IndZmat0)) THEN |
| 353 |
! WRITE(IOOUT,*) "I cannot generate a valid Zmat... help" |
| 354 |
! STOP |
| 355 |
! END IF |
| 356 |
|
| 357 |
! The IndZmat0 generated by Calc_zmat refers to the order of the input x,y,z |
| 358 |
! However, we need it with the new order so that we can use the zmat |
| 359 |
! coordinates to generate cartesian coordinates. |
| 360 |
! So, we have to reorder it... |
| 361 |
DO I=1,Nat |
| 362 |
Order(IndZmat0(I,1))=I |
| 363 |
OrderInv(I)=IndZmat0(I,1) |
| 364 |
! I let X0 being the Cartesian coordinates of the reference geometry. Before it was |
| 365 |
! those of the First geometry (which was also the reference one). This might change! |
| 366 |
X0(i)=X(IndZmat0(i,1)) |
| 367 |
Y0(i)=Y(IndZmat0(i,1)) |
| 368 |
Z0(i)=Z(IndZmat0(i,1)) |
| 369 |
END DO |
| 370 |
IndZmat=0 |
| 371 |
IndZmat(1:NCart,:)=-1 |
| 372 |
|
| 373 |
DO I=1,Nat |
| 374 |
IndZmat(I,1)=Order(IndZmat0(I,1)) |
| 375 |
END DO |
| 376 |
|
| 377 |
SELECT CASE (NCart) |
| 378 |
CASE (1) |
| 379 |
IndZmat(2,2)=Order(IndZmat0(2,2)) |
| 380 |
IndZmat(3,2)=Order(IndZmat0(3,2)) |
| 381 |
IndZmat(3,3)=Order(IndZmat0(3,3)) |
| 382 |
IdX=4 |
| 383 |
CASE (2) |
| 384 |
IndZmat(3,2)=Order(IndZmat0(3,2)) |
| 385 |
IndZmat(3,3)=Order(IndZmat0(3,3)) |
| 386 |
Idx=4 |
| 387 |
CASE DEFAULT |
| 388 |
Idx=NCart+1 |
| 389 |
END SELECT |
| 390 |
|
| 391 |
DO I=Idx,Nat |
| 392 |
DO J=1,4 |
| 393 |
IndZmat(I,J)=Order(IndZmat0(I,J)) |
| 394 |
END DO |
| 395 |
end do |
| 396 |
IF (DEBUG) THEN |
| 397 |
WRITE(IOOUT,*) "DBG PathCreate : IndZmat - Mixed" |
| 398 |
DO I=1,Nat |
| 399 |
WRITE(IOOUT,*) (IndZmat(I,J),J=1,5) |
| 400 |
END DO |
| 401 |
END IF |
| 402 |
|
| 403 |
! It is the first call, we have to create all internal coordinates |
| 404 |
! Idx=1 |
| 405 |
! DO I=1,NCart |
| 406 |
! IntCoordI(1,Idx)=val_zmat(I,1) |
| 407 |
! IntCoordI(1,Idx+1)=val_zmat(I,2) |
| 408 |
! IntCoordI(1,Idx+2)=val_zmat(I,3) |
| 409 |
! Idx=Idx+3 |
| 410 |
! END DO |
| 411 |
! SELECT CASE (NCART) |
| 412 |
! CASE (1) |
| 413 |
! IntCoordI(1,Idx)=val_zmat(2,1) |
| 414 |
! IntCoordI(1,Idx+1)=val_zmat(3,1) |
| 415 |
! IntCoordI(1,Idx+2)=val_zmat(3,2)*Pi/180. |
| 416 |
! Idx=Idx+3 |
| 417 |
! IBeg=4 |
| 418 |
! CASE (2) |
| 419 |
! IntCoordI(1,Idx)=val_zmat(3,1) |
| 420 |
! IntCoordI(1,Idx+1)=val_zmat(3,2)*Pi/180. |
| 421 |
! Idx=Idx+2 |
| 422 |
! IBeg=4 |
| 423 |
! CASE DEFAULT |
| 424 |
! IBeg=NCart+1 |
| 425 |
! END SELECT |
| 426 |
! DO i=iBeg,Nat |
| 427 |
! IntCoordI(1,Idx)=val_zmat(i,1) |
| 428 |
! Idx=Idx+1 |
| 429 |
! DO j=2,3 |
| 430 |
! IntCoordI(1,Idx)=val_zmat(i,j)*Pi/180. |
| 431 |
! Idx=Idx+1 |
| 432 |
! END DO |
| 433 |
! END DO |
| 434 |
|
| 435 |
! If (debug) WRITE(*,*) "Idx, NCoord",Idx-1,NCoord |
| 436 |
|
| 437 |
DO Igeom=1,NgeomI |
| 438 |
x(1:Nat) = XyzGeomI(IGeom,1,1:Nat) |
| 439 |
y(1:Nat) = XyzGeomI(IGeom,2,1:Nat) |
| 440 |
z(1:Nat) = XyzGeomI(IGeom,3,1:Nat) |
| 441 |
|
| 442 |
Call ConvXyzMixed(Nat,Ncart,x,y,z,IndZmat0,val_zmatTmp(1,1)) |
| 443 |
Idx=1 |
| 444 |
DO I=1,NCart |
| 445 |
IntCoordI(IGeom,Idx)=val_zmatTmp(I,1) |
| 446 |
IntCoordI(IGeom,Idx+1)=val_zmatTmp(I,2) |
| 447 |
IntCoordI(IGeom,Idx+2)=val_zmatTmp(I,3) |
| 448 |
Idx=Idx+3 |
| 449 |
END DO |
| 450 |
|
| 451 |
SELECT CASE (NCART) |
| 452 |
CASE (1) |
| 453 |
IntCoordI(IGeom,Idx)=val_zmatTmp(2,1) |
| 454 |
Idx=Idx+1 |
| 455 |
IntCoordI(IGeom,Idx)=val_zmatTmp(3,1) |
| 456 |
IntCoordI(IGeom,Idx+1)=val_zmatTmp(3,2)*Pi/180. |
| 457 |
Idx=Idx+2 |
| 458 |
IBeg=4 |
| 459 |
CASE (2) |
| 460 |
IntCoordI(IGeom,Idx)=val_zmatTmp(3,1) |
| 461 |
IntCoordI(IGeom,Idx+1)=val_zmatTmp(3,2)*Pi/180. |
| 462 |
Idx=Idx+2 |
| 463 |
IBeg=4 |
| 464 |
CASE DEFAULT |
| 465 |
Ibeg=Ncart+1 |
| 466 |
END SELECT |
| 467 |
DO i=IBeg,Nat |
| 468 |
IntCoordI(IGeom,Idx)=val_zmatTmp(i,1) |
| 469 |
Idx=Idx+1 |
| 470 |
IntCoordI(IGeom,Idx)=val_zmatTmp(i,2)*Pi/180. |
| 471 |
Idx=Idx+1 |
| 472 |
|
| 473 |
! Some tests to check that the dihedral angles are similar... this is |
| 474 |
! important if they are close to Pi. |
| 475 |
Delta=0. |
| 476 |
|
| 477 |
if (abs(val_zmatTMP(i,3)-val_zmat(i,3))>=180.) THEN |
| 478 |
if ((val_zmatTMP(i,3)-val_zmat(i,3))<=-180.) THEN |
| 479 |
Delta=-1.0d0*TwoPi |
| 480 |
ELSE |
| 481 |
Delta=TwoPi |
| 482 |
END IF |
| 483 |
if (debug) THEN |
| 484 |
WRITE(*,*) Nom(atome(i)), & |
| 485 |
abs(val_zmatTMP(i,3)-val_zmat(i,3)), & |
| 486 |
val_zmatTMP(i,3),val_zmat(i,3),Delta, & |
| 487 |
val_zmatTMP(i,3)-Delta |
| 488 |
END IF |
| 489 |
END IF |
| 490 |
IntCoordI(IGeom,Idx)=(val_zmatTmp(i,3)-Delta)/180.*Pi |
| 491 |
Idx=Idx+1 |
| 492 |
END DO |
| 493 |
|
| 494 |
END DO |
| 495 |
CASE ('CART')
|
| 496 |
DO I=1,Nat |
| 497 |
Order(I)=I |
| 498 |
OrderInv(I)=I |
| 499 |
END DO |
| 500 |
X0=X |
| 501 |
Y0=y |
| 502 |
Z0=z |
| 503 |
END SELECT |
| 504 |
|
| 505 |
ELSE ! First iteration of the optimization. Match at L616 |
| 506 |
|
| 507 |
IGeom=1 |
| 508 |
x(1:Nat) = XyzGeomI(IGeom,1,1:Nat) |
| 509 |
y(1:Nat) = XyzGeomI(IGeom,2,1:Nat) |
| 510 |
z(1:Nat) = XyzGeomI(IGeom,3,1:Nat) |
| 511 |
|
| 512 |
SELECT CASE (COORD) |
| 513 |
CASE ('HYBRID')
|
| 514 |
IndZmat0=IndZmat |
| 515 |
Call ConvXyzZmat(Nat,x,y,z,IndZmat,val_zmat(1,1)) |
| 516 |
CASE ('ZMAT')
|
| 517 |
IndZmat0=IndZmat |
| 518 |
val_zmat=0.d0 |
| 519 |
val_zmat(2,1)=IntCoordI(1,1) |
| 520 |
val_zmat(3,1)=IntCoordI(1,2) |
| 521 |
val_zmat(3,2)=IntCoordI(1,3)*180./Pi |
| 522 |
|
| 523 |
Idx=4 |
| 524 |
DO iat=4,Nat |
| 525 |
val_zmat(iat,1)=IntCoordI(1,idx) |
| 526 |
Idx=Idx+1 |
| 527 |
do j=2,3 |
| 528 |
val_zmat(iat,J)=IntCoordI(1,idx)*180./Pi |
| 529 |
Idx=Idx+1 |
| 530 |
END DO |
| 531 |
END DO |
| 532 |
|
| 533 |
CASE ('MIXED')
|
| 534 |
IndZmat0=IndZmat |
| 535 |
val_zmat=0.d0 |
| 536 |
Idx=1 |
| 537 |
DO I=1,NCart |
| 538 |
DO J=1,3 |
| 539 |
val_zmat(i,j)= IntCoordI(1,Idx) |
| 540 |
Idx=Idx+1 |
| 541 |
END DO |
| 542 |
END DO |
| 543 |
SELECT CASE (NCart) |
| 544 |
CASE(1) |
| 545 |
val_zmat(2,1)=IntCoordI(1,Idx) |
| 546 |
val_zmat(3,1)=IntCoordI(1,Idx+1) |
| 547 |
val_zmat(3,2)=IntCoordI(1,Idx+2)*180./Pi |
| 548 |
Idx=Idx+3 |
| 549 |
IBeg=4 |
| 550 |
CASE(2) |
| 551 |
val_zmat(3,1)=IntCoordI(1,Idx) |
| 552 |
val_zmat(3,2)=IntCoordI(1,Idx)*180./Pi |
| 553 |
Idx=Idx+2 |
| 554 |
IBeg=4 |
| 555 |
CASE DEFAULT |
| 556 |
IBeg=NCart+1 |
| 557 |
END SELECT |
| 558 |
|
| 559 |
DO Iat=IBeg,Nat |
| 560 |
val_zmat(iat,1)=IntCoordI(1,idx) |
| 561 |
Idx=Idx+1 |
| 562 |
do j=2,3 |
| 563 |
val_zmat(iat,J)=IntCoordI(1,idx)*180./Pi |
| 564 |
Idx=Idx+1 |
| 565 |
END DO |
| 566 |
END DO |
| 567 |
CASE ('BAKER')
|
| 568 |
! Nothing to be done here. |
| 569 |
CASE ('CART')
|
| 570 |
! Nothing to be done here. |
| 571 |
CASE DEFAULT |
| 572 |
WRITE(*,*) "Coord=",TRIM(COORD)," not recognized in PathCreate.L554.STOP" |
| 573 |
STOP |
| 574 |
END SELECT |
| 575 |
X0=x |
| 576 |
y0=y |
| 577 |
z0=z |
| 578 |
END IF ! First |
| 579 |
|
| 580 |
! Now that we have a zmat, we will generate all the IntCoodI corresponding... |
| 581 |
! First one |
| 582 |
IF (COORD.EQ.'HYBRID') THEN ! Matches at L680 |
| 583 |
DO IGeom=1,NGeomI |
| 584 |
x(1:Nat) = XyzGeomI(IGeom,1,1:Nat) |
| 585 |
y(1:Nat) = XyzGeomI(IGeom,2,1:Nat) |
| 586 |
z(1:Nat) = XyzGeomI(IGeom,3,1:Nat) |
| 587 |
|
| 588 |
Call ConvXyzZmat(Nat,x,y,z,IndZmat0,val_zmatTmp(1,1)) |
| 589 |
IntCoordI(IGeom,1)=val_zmatTmp(2,1) |
| 590 |
IntCoordI(IGeom,2)=val_zmatTmp(3,1) |
| 591 |
IntCoordI(IGeom,3)=val_zmatTmp(3,2)*Pi/180. |
| 592 |
Idx=4 |
| 593 |
DO i=4,nat |
| 594 |
IntCoordI(IGeom,Idx)=val_zmatTmp(i,1) |
| 595 |
Idx=Idx+1 |
| 596 |
IntCoordI(IGeom,Idx)=val_zmatTmp(i,2)*Pi/180. |
| 597 |
Idx=Idx+1 |
| 598 |
|
| 599 |
! Some tests to check that the dihedral angles are similar... this is |
| 600 |
! important if they are close to Pi. |
| 601 |
Delta=0. |
| 602 |
|
| 603 |
if (abs(val_zmatTMP(i,3)-val_zmat(i,3))>=180.) THEN |
| 604 |
if ((val_zmatTMP(i,3)-val_zmat(i,3))<=-180.) THEN |
| 605 |
Delta=-1.0d0*TwoPi |
| 606 |
ELSE |
| 607 |
Delta=TwoPi |
| 608 |
END IF |
| 609 |
if (debug) THEN |
| 610 |
WRITE(*,*) Nom(atome(i)), & |
| 611 |
abs(val_zmatTMP(i,3)-val_zmat(i,3)), & |
| 612 |
val_zmatTMP(i,3),val_zmat(i,3),Delta, & |
| 613 |
val_zmatTMP(i,3)-Delta |
| 614 |
END IF |
| 615 |
END IF |
| 616 |
IntCoordI(IGeom,Idx)=(val_zmatTmp(i,3)-Delta)/180.*Pi |
| 617 |
Idx=Idx+1 |
| 618 |
END DO |
| 619 |
END DO |
| 620 |
END IF ! Matches Coord=Hybrid |
| 621 |
|
| 622 |
! PFL 24 Nov 2008 -> |
| 623 |
! This should not be necessary... |
| 624 |
! ! if we have frozen atoms, we make sure that they do not move between geometries |
| 625 |
! IF (IntFroz.NE.0) THEN |
| 626 |
! if (debug) WRITE(*,*) 'DBG PathCreate L641: Number of frozen coordinates=', IntFroz |
| 627 |
! DO IGeom=2,NGeomI ! For IOpt .GT. 0, NGeomI is equal to NGeomF |
| 628 |
! IntCoordI(IGeom,1:IntFroz)=IntCoordI(1,1:IntFroz) |
| 629 |
! END DO |
| 630 |
! END IF |
| 631 |
! -> PFL 24 Nov 2008 |
| 632 |
|
| 633 |
Idx=min(9,NCoord) |
| 634 |
|
| 635 |
IF (DEBUG.AND.(COORD.NE.'CART')) THEN |
| 636 |
WRITE(*,*) "DBG PathCreate. L685 IntCoordI(IGeom,:)" |
| 637 |
DO I=1,NGeomI |
| 638 |
WRITE(*,'("Geom:",I5,9(1X,F10.4))') I,IntCoordI(I,1:Idx)
|
| 639 |
END DO |
| 640 |
! We write it also in terms of Zmat |
| 641 |
IF ((COORD.EQ.'ZMAT').OR.(COORD.EQ.'HYBRID')) THEN |
| 642 |
DO I=1,NGeomI |
| 643 |
WRITE(*,*) 'Zmat for geom ',I,'/',NGeomI,'Xgeom=',Xgeom(I) |
| 644 |
WRITE(*,'(1X,A5,3(1X,I5,1X,F11.6))') Nom(Atome(IndZmat0(1,1))) |
| 645 |
WRITE(*,'(1X,A5,3(1X,I5,1X,F11.6))') Nom(Atome(IndZmat0(2,1))), & |
| 646 |
IndZmat(2,2),IntCoordI(I,1) |
| 647 |
WRITE(*,'(1X,A5,3(1X,I5,1X,F11.6))') Nom(Atome(IndZmat0(3,1))), & |
| 648 |
IndZmat(3,2),IntCoordI(I,2),IndZmat(3,3),IntCoordI(I,3)*180./Pi |
| 649 |
Idx=4 |
| 650 |
DO J=4,Nat |
| 651 |
WRITE(*,'(1X,A5,3(1X,I5,1X,F11.6))') Nom(Atome(IndZmat0(J,1))), & |
| 652 |
IndZmat(J,2),IntCoordI(I,Idx),IndZmat(J,3), & |
| 653 |
IntCoordI(I,Idx+1)*180./Pi, & |
| 654 |
IndZmat(J,4),IntCoordI(I,Idx+2)*180./Pi |
| 655 |
Idx=Idx+3 |
| 656 |
END DO |
| 657 |
|
| 658 |
XyzTmp2=0. |
| 659 |
! We convert it into Cartesian coordinates |
| 660 |
XyzTmp2(2,1)=IntCoordI(I,1) |
| 661 |
d=IntCoordI(I,2) |
| 662 |
a_val=IntCoordI(I,3) |
| 663 |
if (Nat.GE.3) THEN |
| 664 |
if (IndZmat(3,2).EQ.1) THEN |
| 665 |
XyzTmp2(3,1)=XYzTmp2(1,1)+d*cos(a_val) |
| 666 |
ELSE |
| 667 |
XyzTmp2(3,1)=XyzTmp2(2,1)-d*cos(a_val) |
| 668 |
ENDIF |
| 669 |
XyzTmp2(3,2)=d*sin(a_val) |
| 670 |
ENDIF |
| 671 |
|
| 672 |
Idx=4 |
| 673 |
DO iat=4,Nat |
| 674 |
val_zmatTMP(iat,1)=IntCoordI(I,idx) |
| 675 |
Idx=Idx+1 |
| 676 |
DO j=2,3 |
| 677 |
val_zmatTMP(iat,J)=IntCoordI(I,idx)*180./Pi |
| 678 |
Idx=Idx+1 |
| 679 |
END DO |
| 680 |
END DO |
| 681 |
DO iat=4,Nat |
| 682 |
call ConvertZmat_cart(iat,IndZmat,val_zmatTMP, & |
| 683 |
XYzTMP2(1,1), XYzTMP2(1,2),XYzTMP2(1,3)) |
| 684 |
END DO |
| 685 |
DO Iat=1,nat |
| 686 |
WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(IndZmat0(Iat,1))),& |
| 687 |
XyzTmp2(iat,1:3) |
| 688 |
END DO |
| 689 |
|
| 690 |
END DO |
| 691 |
END IF |
| 692 |
IF (COORD.EQ.'MIXED') THEN |
| 693 |
DO I=1,NGeomI |
| 694 |
WRITE(*,*) 'Cart+Zmat for geom ',I,'/',NGeomI,'Xgeom=',Xgeom(I) |
| 695 |
Idx=1 |
| 696 |
XyzTmp2=0. |
| 697 |
DO J=1,NCART |
| 698 |
WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(IndZmat0(1,1))), & |
| 699 |
IntCoordI(I,Idx:Idx+2) |
| 700 |
XyzTmp2(J,1:3)=IntCoordI(I,Idx:Idx+2) |
| 701 |
Idx=Idx+3 |
| 702 |
END DO |
| 703 |
SELECT CASE (NCart) |
| 704 |
CASE (1) |
| 705 |
J=2 |
| 706 |
WRITE(*,'(1X,A5,3(I5,F11.6))') Nom(Atome(IndZmat0(J,1))), & |
| 707 |
IndZmat(J,2),IntCoordI(I,Idx) |
| 708 |
Idx=Idx+1 |
| 709 |
J=3 |
| 710 |
WRITE(*,'(1X,A5,3(I5,F11.6))') Nom(Atome(IndZmat0(J,1))), & |
| 711 |
IndZmat(J,2),IntCoordI(I,Idx),IndZmat(J,3), & |
| 712 |
IntCoordI(I,Idx+1)*180./Pi |
| 713 |
Idx=Idx+2 |
| 714 |
Ibeg=4 |
| 715 |
CASE (2) |
| 716 |
J=3 |
| 717 |
WRITE(*,'(1X,A5,3(I5,F11.6))') Nom(Atome(IndZmat0(J,1))), & |
| 718 |
IndZmat(J,2),IntCoordI(I,Idx),IndZmat(J,3), & |
| 719 |
IntCoordI(I,Idx+1)*180./Pi |
| 720 |
Idx=Idx+2 |
| 721 |
Ibeg=4 |
| 722 |
CASE DEFAULT |
| 723 |
IBeg=NCart+1 |
| 724 |
END SELECT |
| 725 |
DO J=IBeg,Nat |
| 726 |
IF (J.EQ.2) & |
| 727 |
WRITE(*,'(1X,A5,3(I5,F11.6))') Nom(Atome(IndZmat0(J,1))), & |
| 728 |
IndZmat(J,2),IntCoordI(I,Idx),IndZmat(J,3), & |
| 729 |
IntCoordI(I,Idx+1)*180./Pi, & |
| 730 |
IndZmat(J,4),IntCoordI(I,Idx+2)*180./Pi |
| 731 |
Idx=Idx+3 |
| 732 |
END DO |
| 733 |
|
| 734 |
! We convert it into Cartesian coordinates |
| 735 |
IntCoordTmp=IntCoordI(I,1:NCoord) |
| 736 |
Call Mixed2cart(Nat,IndZmat,IntCoordTmp,XyzTmp2) |
| 737 |
|
| 738 |
DO Iat=1,nat |
| 739 |
WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(IndZmat0(Iat,1))),& |
| 740 |
XyzTmp2(iat,1:3) |
| 741 |
END DO |
| 742 |
|
| 743 |
END DO |
| 744 |
END IF |
| 745 |
END IF ! matches IF (DEBUG.AND.(COORD.NE.'CART')) THEN |
| 746 |
|
| 747 |
if (debug) WRITE(*,*) "Before interpolation, PathCreate.f90, L740, IOpt=",IOpt, & |
| 748 |
"ISpline=", ISpline |
| 749 |
! Now comes the Interpolation: |
| 750 |
IF ((NGeomI>2).AND.(IOpt.GE.ISpline)) THEN |
| 751 |
Linear=.FALSE. |
| 752 |
! We have at least three geometries so we can apply cubic spline |
| 753 |
SELECT CASE (COORD) |
| 754 |
CASE ('ZMAT','HYBRID','MIXED')
|
| 755 |
DO I=1,NCoord |
| 756 |
! We compute the spline coefficients |
| 757 |
call spline(xGeom,IntCoordI(1,I),NGeomI,Inf,Inf, Coef(1,I)) |
| 758 |
if (debug) THEN |
| 759 |
WRITE(*,*) 'Coef Spline for coord',I |
| 760 |
WRITE(*,*) Coef(1:NGeomI,I) |
| 761 |
END IF |
| 762 |
END DO |
| 763 |
CASE ('BAKER')
|
| 764 |
! We compute the spline coefficients |
| 765 |
! xGeom(NGeomI), IntCoordI(NGeomI,3*Nat-6) declared in Path_module.f90 |
| 766 |
! can also be used for the Baker's internal coordinates. |
| 767 |
! we need to get Baker's internal coordinates from cartesian coordinates. |
| 768 |
! as we have subroutine ConvXyzmat(...) in Z matrix case. |
| 769 |
! Coef(NGeomI,NCoord) or (NGeomI,N3at) has INTENT(OUT) |
| 770 |
DO I=1,NCoord ! NCoord=3*Nat-6-symmetry_eliminated. |
| 771 |
call spline(xGeom,IntCoordI(1,I),NGeomI,Inf,Inf,Coef(1,I)) |
| 772 |
! IF (debug) THEN |
| 773 |
! WRITE(*,*) 'Coef Spline for coord',I |
| 774 |
! WRITE(*,*) Coef(1:NGeomI,I) |
| 775 |
! END IF |
| 776 |
END DO |
| 777 |
CASE ('CART')
|
| 778 |
|
| 779 |
!! PFL 2011 June 22 -> |
| 780 |
!! The alignment procedure from Extrapol_cart has been moved |
| 781 |
!! here, before computation of the spline coefficients |
| 782 |
|
| 783 |
! XyzTmp2=Reshape(XyzGeomI(1,:,:),(/Nat,3/),ORDER=(/2,1/)) |
| 784 |
|
| 785 |
if (debug) THEN |
| 786 |
WRITE(*,*) "DBG PathCreate - Calc Spline coeff CART- Initial geometries" |
| 787 |
DO IGeom=1,NGeomI |
| 788 |
WRITE(*,*) 'XyzGeomI, IGeom=',IGeom |
| 789 |
DO I=1,Nat |
| 790 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)), & |
| 791 |
(XyzGeomI(IGeom,J,I),J=1,3) |
| 792 |
END DO |
| 793 |
END DO |
| 794 |
END IF |
| 795 |
|
| 796 |
|
| 797 |
! In order to mesure only the relevant distance between two points |
| 798 |
! we align all geometries on the original one |
| 799 |
|
| 800 |
DO IGeom=1,NGeomI |
| 801 |
|
| 802 |
XyzTmp2=Reshape(XyzGeomI(IGeom,:,:),(/Nat,3/),ORDER=(/2,1/)) |
| 803 |
! We align this geometry with the original one |
| 804 |
! PFL 17/July/2006: only if we have more than 4 atoms. |
| 805 |
! IF (Nat.GT.4) THEN |
| 806 |
! PFL 24 Nov 2008 -> |
| 807 |
! If we have frozen atoms we align only those ones. |
| 808 |
! PFL 8 Feb 2011 -> |
| 809 |
! I add a flag to see if we should align or not. |
| 810 |
! For small systems, it might be better to let the user align himself |
| 811 |
IF (Align) THEN |
| 812 |
if (NFroz.GT.0) THEN |
| 813 |
Call AlignPartial(Nat,x0,y0,z0, & |
| 814 |
xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3), & |
| 815 |
FrozAtoms,MRot) |
| 816 |
ELSE |
| 817 |
Call CalcRmsd(Nat, x0,y0,z0, & |
| 818 |
xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3), & |
| 819 |
MRot,rmsd,.TRUE.,.TRUE.) |
| 820 |
END IF |
| 821 |
! <- PFL 24 Nov 2008 |
| 822 |
END IF |
| 823 |
! -> PFL 8 Feb 2011 |
| 824 |
! END IF |
| 825 |
|
| 826 |
XyzGeomI(IGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/)) |
| 827 |
END DO |
| 828 |
|
| 829 |
if (debug) THEN |
| 830 |
WRITE(*,*) "DBG PathCreate - Calc Spline coeff CART- Aligned geometries" |
| 831 |
DO J=1, NGeomI |
| 832 |
WRITE(IOOUT,*) Nat |
| 833 |
WRITE(IOOUT,*) " Aligned geometry ",J,"/",NGeomI |
| 834 |
DO i=1,Nat |
| 835 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)), & |
| 836 |
XyzGeomI(J,1:3,I) |
| 837 |
END DO |
| 838 |
END DO |
| 839 |
END IF |
| 840 |
|
| 841 |
!! <- PFL 2011 June 22 |
| 842 |
|
| 843 |
DO I=1,Nat |
| 844 |
! We compute the spline coefficients |
| 845 |
call spline(xGeom,XyzGeomI(1,1,I),NGeomI,Inf,Inf, Coef(1,3*I-2)) |
| 846 |
call spline(xGeom,XyzGeomI(1,2,I),NGeomI,Inf,Inf, Coef(1,3*I-1)) |
| 847 |
call spline(xGeom,XyzGeomI(1,3,I),NGeomI,Inf,Inf, Coef(1,3*I)) |
| 848 |
if (debug) THEN |
| 849 |
WRITE(*,*) 'Coef Spline for coord',i |
| 850 |
WRITE(*,*) Coef(1:NGeomI,I) |
| 851 |
END IF |
| 852 |
END DO |
| 853 |
CASE DEFAULT |
| 854 |
WRITE(*,*) "Coord=",TRIM(COORD)," not recognized in PathCreate.L783.STOP" |
| 855 |
STOP |
| 856 |
END SELECT |
| 857 |
ELSE ! matches IF ((NGeomI>2).AND.(Iopt.Ge.ISpline)) THEN |
| 858 |
! On n'a que deux images. On fera une interpolation lineaire, |
| 859 |
! qui est un cas particulier avec Coef=0 |
| 860 |
if (debug.AND.(NGeomI.EQ.2)) WRITE(*,*) "DBG : Only 2 starting geometries" |
| 861 |
if (debug.AND.(Iopt.LE.ISpline)) WRITE(*,*) "DBG : Not enough path -> linear int" |
| 862 |
Coef=0.d0 |
| 863 |
Linear=.TRUE. |
| 864 |
END IF ! matches IF ((NGeomI>2).AND.(Iopt.Ge.ISpline)) THEN |
| 865 |
! Shall we redistribute the points along the path ? |
| 866 |
if (debug) WRITE(*,*) "PathCreate.f90, L795, IOpt=", IOpt, "IReparam=", IReparam |
| 867 |
|
| 868 |
IF (MOD(IOpt,IReparam).EQ.0) THEN |
| 869 |
! We generate the Path, in two steps: |
| 870 |
! i) we calculate the length of the mass weighted (MW) path |
| 871 |
! ii) we sample the path to get the geometries |
| 872 |
|
| 873 |
NGeomS=NGeomI |
| 874 |
SELECT CASE (COORD) |
| 875 |
CASE ('ZMAT','HYBRID')
|
| 876 |
! We call the extrapolation once to get the path length |
| 877 |
dist=Inf |
| 878 |
Call ExtraPol_int(IOpt,s,dist,x0,y0,z0,xgeom,Coef,XgeomF) |
| 879 |
! we have the length, we calculate the distance between two points |
| 880 |
|
| 881 |
if (s.LE.1e-6) THEN |
| 882 |
IF (OptGeom.LE.0) THEN |
| 883 |
WRITE(*,*) "Length of the path is 0 and you are not doing Geometry Optimization." |
| 884 |
WRITE(*,*) "ERROR !!! Stop !" |
| 885 |
STOP |
| 886 |
END IF |
| 887 |
ELSE |
| 888 |
! we have the length, we calculate the distance between two points |
| 889 |
dist=s/Real(NGeomf-1) |
| 890 |
if (debug) WRITE(*,*) 'Dbg PathCreate ZMAT s, dist:',s,dist |
| 891 |
! we call it again to obtain the geometries ! |
| 892 |
Call ExtraPol_int(iopt,s,dist,x0,y0,z0,xgeom,Coef,XgeomF) |
| 893 |
END IF |
| 894 |
CASE ('BAKER')
|
| 895 |
! We generate the Path, in two steps: |
| 896 |
! i) we calculate the length of the mass weighted (MW) path |
| 897 |
! ii) we sample the path to get the geometries |
| 898 |
|
| 899 |
! We call the extrapolation first time to get the path length |
| 900 |
! iopt: Number of the cycles for the optimization. |
| 901 |
! s: a real number and has INTENT(OUT), probably returns the |
| 902 |
! length of the path. |
| 903 |
! dist=Inf=> ExtraPol_baker has to calculate the length of the path. |
| 904 |
! X0(Nat),Y0(Nat),Z0(Nat): reference geometry. |
| 905 |
! Xgeom: Xgeom(NGeomI) has INTENT(IN) |
| 906 |
! Coef(NGeomI,NCoord) is obtained from spline interpolation subroutine. |
| 907 |
! XgeomF: XGeomF(NGeomF) has INTENT(OUT) |
| 908 |
! Which reference coordinate geometry X0, Y0, Z0 to use??? |
| 909 |
dist=Inf |
| 910 |
!if (debug) WRITE(*,*) "Before the call of ExtraPol_baker in redistribution & |
| 911 |
!of the points, in PathCreate.f90, L836" |
| 912 |
!Print *, 'Before ExtraPol_baker, PathCreate.90, L848, IntCoordI=' |
| 913 |
!Print *, IntCoordI |
| 914 |
Call ExtraPol_baker(s,dist,x0,y0,z0,xgeom,Coef,XgeomF) |
| 915 |
!Print *, 'After ExtraPol_baker, PathCreate.90, L848, IntCoordI=' |
| 916 |
!Print *, IntCoordI |
| 917 |
!if (debug) WRITE(*,*) "After the call of ExtraPol_baker in the redistribution & |
| 918 |
! of the points, in PathCreate.f90, L843" |
| 919 |
|
| 920 |
! we have the lenght, we calculate the distance between two points |
| 921 |
!Print *, 'After first call of ExtraPol_baker in PathCreate.f90, s=', s |
| 922 |
|
| 923 |
if (s.LE.1e-6) THEN |
| 924 |
IF (OptGeom.LE.0) THEN |
| 925 |
WRITE(*,*) "Length of the path is 0 and you are not doing Geometry Optimization." |
| 926 |
WRITE(*,*) "ERROR !!! Stop !" |
| 927 |
STOP |
| 928 |
END IF |
| 929 |
ELSE |
| 930 |
|
| 931 |
dist=s/Real(NGeomf-1) |
| 932 |
!if (debug) WRITE(*,*) 'Dbg PathCreate ZMAT s, dist:',s,dist |
| 933 |
|
| 934 |
! we call it again to obtain the geometries ! |
| 935 |
Call ExtraPol_baker(s,dist,x0,y0,z0,xgeom,Coef,XgeomF) |
| 936 |
WRITE(*,*) "At the end of Baker case in the redistribution of the points, in PathCreate.f90, L966" |
| 937 |
END IF |
| 938 |
|
| 939 |
DO IGeom=1,NGeomF |
| 940 |
WRITE(*,*) "UMatF for IGeom=",IGeom |
| 941 |
DO I=1,3*Nat-6 |
| 942 |
WRITE(*,'(50(1X,F12.8))') UMatF(IGeom,:,I) |
| 943 |
END DO |
| 944 |
END DO |
| 945 |
|
| 946 |
CASE ('MIXED')
|
| 947 |
! WRITE(*,*) "IOIOIOIOIOIOIOI" |
| 948 |
! We call the extrapolation once to get the path length |
| 949 |
Dist=Inf |
| 950 |
Call ExtraPol_Mixed(s,dist,x0,y0,z0,xgeom,Coef) |
| 951 |
|
| 952 |
if (s.LE.1e-6) THEN |
| 953 |
IF (OptGeom.LE.0) THEN |
| 954 |
WRITE(*,*) "Length of the path is 0 and you are not doing Geometry Optimization." |
| 955 |
WRITE(*,*) "ERROR !!! Stop !" |
| 956 |
STOP |
| 957 |
END IF |
| 958 |
ELSE |
| 959 |
|
| 960 |
! we have the length, we calculate the distance between two points |
| 961 |
dist=s/Real(NGeomf-1) |
| 962 |
if (debug) WRITE(*,*) 'Dbg PathCreate Mixed s, dist:',s,dist |
| 963 |
|
| 964 |
! we call it again to obtain the geometries ! |
| 965 |
Call ExtraPol_Mixed(s,dist,x0,y0,z0,xgeom,Coef) |
| 966 |
|
| 967 |
IF (debug) THEN |
| 968 |
DO I=1,NGeomF |
| 969 |
WRITE(*,'(1X,A,12(1X,F10.5))') "IntTangent:",IntTangent(I,1:NCoord) |
| 970 |
END DO |
| 971 |
END IF |
| 972 |
END IF |
| 973 |
CASE ('CART')
|
| 974 |
! We call the extrapolation once to get the path length |
| 975 |
Dist=Inf |
| 976 |
Call ExtraPol_cart(iopt,s,dist,x0,y0,z0,xgeom,Coef) |
| 977 |
|
| 978 |
if (s.LE.1e-6) THEN |
| 979 |
IF (OptGeom.LE.0) THEN |
| 980 |
WRITE(*,*) "Length of the path is 0 and you are not doing Geometry Optimization." |
| 981 |
WRITE(*,*) "ERROR !!! Stop !" |
| 982 |
STOP |
| 983 |
END IF |
| 984 |
ELSE |
| 985 |
! we have the lenght, we calculate the distance between two points |
| 986 |
dist=s/Real(NGeomf-1) |
| 987 |
if (debug) WRITE(*,*) 'Debug s, dist:',s,dist |
| 988 |
|
| 989 |
! we call it again to obtain the geometries ! |
| 990 |
Call ExtraPol_cart(iopt,s,dist,x0,y0,z0,xgeom,Coef) |
| 991 |
END IF |
| 992 |
END SELECT |
| 993 |
ELSE |
| 994 |
! PFL 3 Jan 2008 -> |
| 995 |
! Tangents are not recalculated if the points are not reparameterized |
| 996 |
! PFL 6 Apr 2008 -> |
| 997 |
! Unless user has asked to reparameterized them ! |
| 998 |
IF (mod(Iopt,iReparamT).EQ.0) THEN |
| 999 |
XGeomF=XGeom |
| 1000 |
NGeomS=NGeomI |
| 1001 |
Call CalcTangent(XgeomF,NGeomS,xgeom,Coef) |
| 1002 |
! |
| 1003 |
END IF |
| 1004 |
! <- PFL 3 Jan 2008 / 6 Apr 2008 |
| 1005 |
END IF ! if (mod(Iop,iReparam).EQ.0) |
| 1006 |
if (debug) WRITE(*,*) "PathCreate.f90, L885" |
| 1007 |
|
| 1008 |
! PFL 22.Nov.2007 -> |
| 1009 |
! We do not write tangents for baker coordinates because they are hard to |
| 1010 |
! interpret for a chemist. |
| 1011 |
|
| 1012 |
IF (debug.AND.(COORD.NE."BAKER")) THEN |
| 1013 |
! we write the tangents :-) |
| 1014 |
DO I=1,NGeomF |
| 1015 |
SELECT CASE(Coord) |
| 1016 |
CASE ('ZMAT','MIXED')
|
| 1017 |
IntCoordTmp=IntTangent(I,:) |
| 1018 |
WRITE(*,'(1X,A,12(1X,F10.5))') "IntCoordTmp:",IntCoordTmp(1:NCoord) |
| 1019 |
WRITE(*,'(1X,A,12(1X,F10.5))') "IntTangent:",IntTangent(I,1:NCoord) |
| 1020 |
CASE ('CART','HYBRID')
|
| 1021 |
IntCoordTmp=XyzTangent(I,:) |
| 1022 |
CASE DEFAULT |
| 1023 |
WRITE(*,*) "Coord=",TRIM(COORD)," not recognized in PathCreate. STOP" |
| 1024 |
STOP |
| 1025 |
END SELECT |
| 1026 |
WRITE(Title,"('Tangents for geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomF
|
| 1027 |
Call PrintGeom(Title,Nat,Ncoord,IntCoordTmp,Coord,6,Atome,Order,OrderInv,IndZmat) |
| 1028 |
END DO |
| 1029 |
END IF |
| 1030 |
|
| 1031 |
|
| 1032 |
IF (DEBUG.AND.(COORD.NE.'CART')) THEN |
| 1033 |
Idx=min(12,NCoord) |
| 1034 |
WRITE(*,*) "DBG PathCreate. IntCoordF(IGeom,:)" |
| 1035 |
DO I=1,NGeomF |
| 1036 |
WRITE(*,'("Geom:",I5,12(1X,F10.4))') I,IntCoordF(I,1:Idx)
|
| 1037 |
END DO |
| 1038 |
END IF |
| 1039 |
|
| 1040 |
DEALLOCATE(Coef,val_zmat,val_zmatTMP) |
| 1041 |
DEALLOCATE(X0,Y0,Z0,Indzmat0) |
| 1042 |
DEALLOCATE(X,Y,Z,Xgeom,XgeomF) |
| 1043 |
DEALLOCATE(XyzTmp,XyzTmp2) |
| 1044 |
|
| 1045 |
if (debug) Call header("PathCreate over")
|
| 1046 |
|
| 1047 |
END SUBROUTINE PathCreate |
| 1048 |
|