root / src / Extrapol_mixed.f90 @ 3
Historique | Voir | Annoter | Télécharger (6,39 ko)
| 1 |
SUBROUTINE Extrapol_mixed(s,dist,x0,y0,z0,xgeom,Coef) |
|---|---|
| 2 |
|
| 3 |
! This subroutine constructs the path, and if dist<>Infinity, it samples |
| 4 |
! the path to obtain geometries. |
| 5 |
! Basically, you call it twice: i) dist=infinity, it will calculate the |
| 6 |
! length of the path |
| 7 |
! ii) dist finite, it will give you the images you want along the path. |
| 8 |
! |
| 9 |
! For now, it gives equidistant geometries |
| 10 |
!!!!!!!!!!!!!!!! |
| 11 |
! |
| 12 |
! v2.0 |
| 13 |
! Uses Mix2cart for conversions. |
| 14 |
|
| 15 |
|
| 16 |
use Path_module |
| 17 |
use Io_module |
| 18 |
|
| 19 |
|
| 20 |
IMPLICIT NONE |
| 21 |
|
| 22 |
|
| 23 |
REAL(KREAL), INTENT(OUT) :: s |
| 24 |
REAL(KREAL), INTENT(IN) :: dist,X0(Nat),Y0(Nat),Z0(Nat) |
| 25 |
REAL(KREAL), INTENT(IN) :: Xgeom(NGeomI),Coef(NGeomI,NCoord) |
| 26 |
|
| 27 |
INTEGER(KINT) :: IdxGeom, I, J, K, Idx |
| 28 |
REAL(KREAL) :: Rmsd, MRot(3, 3), ds, u |
| 29 |
|
| 30 |
REAL(KREAL), ALLOCATABLE :: XyzTmp(:,:), XyzTmp2(:,:) ! (Nat,3) |
| 31 |
REAL(KREAL), ALLOCATABLE :: IntCoordTmp(:),DerInt(:) ! (NCoord) |
| 32 |
|
| 33 |
|
| 34 |
LOGICAL :: debug, print |
| 35 |
LOGICAL, EXTERNAL :: valid |
| 36 |
|
| 37 |
!We will calculate the length of the path, in MW coordinates... |
| 38 |
! this is done is a stupid way: we interpolate the zmatrix values, |
| 39 |
! convert them into cartesian, weight the cartesian |
| 40 |
! and calculate the evolution of the distance ! |
| 41 |
! We have to follow the same procedure for every geometry |
| 42 |
! so even for the first one, we have to convert it from zmat |
| 43 |
! to cartesian ! |
| 44 |
|
| 45 |
debug=valid("pathcreate")
|
| 46 |
print=valid("printgeom")
|
| 47 |
|
| 48 |
if (debug) Call Header("Entering Extrapol_mixed")
|
| 49 |
if (debug) WRITE(*,*) "NFroz,NCart",NFroz,NCart |
| 50 |
ALLOCATE(XyzTmp(Nat,3),XyzTmp2(Nat,3),IntCoordTmp(NCoord),DerInt(NCoord)) |
| 51 |
IdxGeom=1 |
| 52 |
|
| 53 |
IntCoordTmp=IntCoordI(1,1:NCoord) |
| 54 |
call Mixed2Cart(Nat,IndZmat,IntCoordTmp,XyzTmp2(1,1)) |
| 55 |
|
| 56 |
XyzTmp=XyzTmp2 |
| 57 |
|
| 58 |
! We align this geometry with the original one |
| 59 |
! PFL 01/feb/2007: useless when dealing with more than three cartesian atoms |
| 60 |
! PFL 17/July/2006: only if we have more than 4 atoms. |
| 61 |
IF ((NCart.LT.3).AND.(Nat.GT.4)) THEN |
| 62 |
! IF (Nat.GT.4) THEN |
| 63 |
Call CalcRmsd(Nat, x0,y0,z0, & |
| 64 |
xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3), & |
| 65 |
MRot,rmsd,FRot,FAlign) |
| 66 |
END IF |
| 67 |
|
| 68 |
XyzGeomF(IdxGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/)) |
| 69 |
IntCoordF(IdxGeom,:)=IntCoordI(1,:) |
| 70 |
|
| 71 |
if (print.AND.(Dist.LE.1e20)) THEN |
| 72 |
WRITE(IOOUT,'(1X,I5)') Nat |
| 73 |
WRITE(IOOUT,*) "# Cartesian Coordinates for geom",IdxGeom |
| 74 |
DO i=1,Nat |
| 75 |
If (Renum) THEN |
| 76 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)), & |
| 77 |
(XyzTmp2(Order(I),J),J=1,3) |
| 78 |
ELSE |
| 79 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(OrderInv(I))), & |
| 80 |
(XyzTmp2(I,J),J=1,3) |
| 81 |
END IF |
| 82 |
END DO |
| 83 |
END IF |
| 84 |
|
| 85 |
! Calculate tangents for first geometry |
| 86 |
u=0.d0 |
| 87 |
DO Idx=1,NCoord |
| 88 |
call splintder(u,IntCoordTmp(Idx),DerInt(Idx),NGeomI,xgeom(1),IntCoordI(1,Idx),Coef(1,Idx)) |
| 89 |
END DO |
| 90 |
IntTangent(IdxGeom,:)=DerInt |
| 91 |
|
| 92 |
|
| 93 |
! First geometry already initialized |
| 94 |
|
| 95 |
s=0. |
| 96 |
! valzmat=0.d0 |
| 97 |
|
| 98 |
DO K=1,NMaxPtPath |
| 99 |
u=real(K)/NMaxPtPath*(NGeomI-1.) |
| 100 |
|
| 101 |
XYZTmp2=0. |
| 102 |
|
| 103 |
! We generate the interpolated coordinates |
| 104 |
DO Idx=1,NCoord |
| 105 |
call splintder(u,IntCoordTmp(Idx),DerInt(Idx),NGeomI,xgeom(1),IntCoordI(1,Idx),Coef(1,Idx)) |
| 106 |
END DO |
| 107 |
|
| 108 |
! We convert it into Cartesian coordinates |
| 109 |
call Mixed2Cart(Nat,IndZmat,IntCoordTmp,XyzTmp2(1,1)) |
| 110 |
|
| 111 |
! We calculate ds |
| 112 |
ds=0. |
| 113 |
DO I=1,Nat |
| 114 |
DO J=1,3 |
| 115 |
ds=ds+MassAt(I)*(XYZTMp2(I,J)-XYZTmp(I,J))**2 |
| 116 |
XYZTmp(I,J)=XyzTMP2(I,J) |
| 117 |
ENDDO |
| 118 |
ENDDO |
| 119 |
s=s+sqrt(ds) |
| 120 |
|
| 121 |
! if (debug) WRITE(*,*) "Debug u,s,dist",u,s,dist |
| 122 |
if (s>=dist) THEN |
| 123 |
s=s-dist |
| 124 |
IdxGeom=IdxGeom+1 |
| 125 |
XyzGeomF(IdxGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/)) |
| 126 |
|
| 127 |
IntCoordF(IdxGeom,:)=IntCoordTmp |
| 128 |
IntTangent(IdxGeom,:)=DerInt |
| 129 |
|
| 130 |
if (print) THEN |
| 131 |
WRITE(IOOUT,'(1X,A,12(1X,F10.5))') "#Internal Coord",IntCoordTmp(1:NCoord) |
| 132 |
WRITE(IOOUT,'(1X,A,12(1X,F10.5))') "#Internal tan",IntTangent(IdxGeom,1:NCoord) |
| 133 |
WRITE(IOOUT,'(1X,I5)') Nat |
| 134 |
WRITE(IOOUT,*) "# Cartesian coord for Geometry ",IdxGeom,K,u,Xgeom(NGeomI) |
| 135 |
|
| 136 |
! PFL 01/feb/2007: useless when dealing with more than three cartesian atoms |
| 137 |
! PFL 17/July/2006: only if we have more than 4 atoms. |
| 138 |
IF ((NCart.LT.3).AND.(Nat.GT.4)) THEN |
| 139 |
! IF (Nat.GT.4) THEN |
| 140 |
Call CalcRmsd(Nat, x0,y0,z0, & |
| 141 |
xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3), & |
| 142 |
MRot,rmsd,FRot,FAlign) |
| 143 |
END IF |
| 144 |
|
| 145 |
DO i=1,Nat |
| 146 |
If (Renum) THEN |
| 147 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)), & |
| 148 |
(XyzTmp2(Order(I),J),J=1,3) |
| 149 |
ELSE |
| 150 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(OrderInv(I))), & |
| 151 |
(XyzTmp2(I,J),J=1,3) |
| 152 |
END IF |
| 153 |
END DO |
| 154 |
|
| 155 |
END IF |
| 156 |
END IF |
| 157 |
ENDDO |
| 158 |
|
| 159 |
|
| 160 |
if ((s>=0.1*dist).AND.(IdxGeom.EQ.NGeomF)) THEN |
| 161 |
WRITE(*,*) "** PathCreate ***" |
| 162 |
WRITE(*,*) "Distribution of points along the path is wrong." |
| 163 |
WRITE(*,*) "Increase value of NMaxPtPath in the input file" |
| 164 |
WRITE(*,*) "Present value is:", NMaxPtPath |
| 165 |
STOP |
| 166 |
END IF |
| 167 |
|
| 168 |
IdxGeom=NGeomF |
| 169 |
|
| 170 |
! We have to add the last geometry. We copy the last geom of Initial geometries. |
| 171 |
IntCoordF(IdxGeom,:)=IntCoordI(NGeomI,:) |
| 172 |
IntTangent(IdxGeom,:)=DerInt |
| 173 |
|
| 174 |
! we convert it to cartesian geom |
| 175 |
call Mixed2Cart(Nat,IndZmat,IntCoordF(IdxGeom,1),XyzTmp2(1,1)) |
| 176 |
XyzGeomF(IdxGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/)) |
| 177 |
|
| 178 |
if (print) THEN |
| 179 |
WRITE(IOOUT,'(1X,I5)') Nat |
| 180 |
WRITE(IOOUT,*) "# Cartesian coord for last Geometry ",IdxGeom,K,u,Xgeom(NGeomI) |
| 181 |
! PFL 01/feb/2007: useless when dealing with more than three cartesian atoms |
| 182 |
! PFL 17/July/2006: only if we have more than 4 atoms. |
| 183 |
IF ((NCART.LT.3).AND.(Nat.GT.4)) THEN |
| 184 |
! IF (Nat.GT.4) THEN |
| 185 |
Call CalcRmsd(Nat, x0,y0,z0, & |
| 186 |
xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3), & |
| 187 |
MRot,rmsd,FRot,FAlign) |
| 188 |
END IF |
| 189 |
|
| 190 |
DO i=1,Nat |
| 191 |
If (Renum) THEN |
| 192 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)), & |
| 193 |
(XyzTmp2(Order(I),J),J=1,3) |
| 194 |
ELSE |
| 195 |
WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(OrderInv(I))), & |
| 196 |
(XyzTmp2(I,J),J=1,3) |
| 197 |
END IF |
| 198 |
END DO |
| 199 |
END IF |
| 200 |
|
| 201 |
|
| 202 |
if (debug) WRITE(*,*) 's final =',s |
| 203 |
|
| 204 |
DEALLOCATE(XyzTmp,XyzTmp2) |
| 205 |
|
| 206 |
if (debug) Call Header("Extrapol_Mixed Over")
|
| 207 |
|
| 208 |
|
| 209 |
END SUBROUTINE EXTRAPOL_MIXED |