Statistiques
| Révision :

root / src / Extrapol_mixed.f90 @ 4

Historique | Voir | Annoter | Télécharger (6,41 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, v
29
  REAL(KREAL) :: a_val, d
30

    
31
  REAL(KREAL), ALLOCATABLE :: XyzTmp(:,:), XyzTmp2(:,:) ! (Nat,3)
32
  REAL(KREAL), ALLOCATABLE :: IntCoordTmp(:),DerInt(:) ! (NCoord)
33

    
34

    
35
  LOGICAL ::  debug, print
36
  LOGICAL, EXTERNAL :: valid
37

    
38
  !We will calculate the length of the path, in MW coordinates...
39
  ! this is done is a stupid way: we interpolate the zmatrix values,
40
  ! convert them into cartesian, weight the cartesian
41
  ! and calculate the evolution of the distance ! 
42
  ! We have to follow the same procedure for every geometry
43
  ! so even for the first one, we have to convert it from zmat
44
  ! to cartesian !
45

    
46
  debug=valid("pathcreate")
47
  print=valid("printgeom")
48

    
49
  if (debug) Call Header("Entering Extrapol_mixed")
50
  if (debug) WRITE(*,*) "NFroz,NCart",NFroz,NCart
51
  ALLOCATE(XyzTmp(Nat,3),XyzTmp2(Nat,3),IntCoordTmp(NCoord),DerInt(NCoord))
52
  IdxGeom=1
53
  
54
  IntCoordTmp=IntCoordI(1,1:NCoord)
55
  call Mixed2Cart(Nat,IndZmat,IntCoordTmp,XyzTmp2(1,1))
56

    
57
  XyzTmp=XyzTmp2
58

    
59
! We align this geometry with the original one
60
! PFL 01/feb/2007: useless when dealing with more than three cartesian atoms 
61
! PFL 17/July/2006: only if we have more than 4 atoms.
62
  IF ((NCart.LT.3).AND.(Nat.GT.4)) THEN
63
!  IF (Nat.GT.4) THEN
64
     Call  CalcRmsd(Nat, x0,y0,z0,                              &
65
          xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3),       &
66
          MRot,rmsd,FRot,FAlign)
67
  END IF
68

    
69
  XyzGeomF(IdxGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/))
70
  IntCoordF(IdxGeom,:)=IntCoordI(1,:)
71

    
72
  if (print.AND.(Dist.LE.1e20)) THEN
73
     WRITE(IOOUT,'(1X,I5)') Nat
74
     WRITE(IOOUT,*) "# Cartesian Coordinates for geom",IdxGeom
75
     DO i=1,Nat
76
        If (Renum) THEN
77
           WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)),      &
78
                (XyzTmp2(Order(I),J),J=1,3)
79
        ELSE
80
           WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(OrderInv(I))),      &
81
                (XyzTmp2(I,J),J=1,3)
82
        END IF
83
     END DO
84
  END IF
85

    
86
! Calculate tangents for first geometry
87
  u=0.d0
88
     DO Idx=1,NCoord
89
           call splintder(u,IntCoordTmp(Idx),DerInt(Idx),NGeomI,xgeom(1),IntCoordI(1,Idx),Coef(1,Idx))
90
     END DO
91
     IntTangent(IdxGeom,:)=DerInt
92

    
93

    
94
! First geometry already initialized
95

    
96
  s=0.
97
!  valzmat=0.d0
98

    
99
  DO K=1,NMaxPtPath
100
     u=real(K)/NMaxPtPath*(NGeomI-1.)
101

    
102
     XYZTmp2=0.
103

    
104
! We generate the interpolated  coordinates
105
     DO Idx=1,NCoord
106
           call splintder(u,IntCoordTmp(Idx),DerInt(Idx),NGeomI,xgeom(1),IntCoordI(1,Idx),Coef(1,Idx))
107
     END DO
108

    
109
! We convert it into Cartesian coordinates
110
  call Mixed2Cart(Nat,IndZmat,IntCoordTmp,XyzTmp2(1,1))
111

    
112
! We calculate ds
113
     ds=0.
114
     DO I=1,Nat
115
        DO J=1,3
116
           ds=ds+MassAt(I)*(XYZTMp2(I,J)-XYZTmp(I,J))**2
117
           XYZTmp(I,J)=XyzTMP2(I,J)
118
        ENDDO
119
     ENDDO
120
     s=s+sqrt(ds)
121

    
122
!         if (debug) WRITE(*,*) "Debug u,s,dist",u,s,dist
123
     if (s>=dist) THEN
124
        s=s-dist
125
        IdxGeom=IdxGeom+1
126
        XyzGeomF(IdxGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/))
127

    
128
        IntCoordF(IdxGeom,:)=IntCoordTmp
129
        IntTangent(IdxGeom,:)=DerInt
130

    
131
        if (print) THEN
132
           WRITE(IOOUT,'(1X,A,12(1X,F10.5))') "#Internal Coord",IntCoordTmp(1:NCoord)
133
           WRITE(IOOUT,'(1X,A,12(1X,F10.5))') "#Internal tan",IntTangent(IdxGeom,1:NCoord)
134
           WRITE(IOOUT,'(1X,I5)') Nat
135
           WRITE(IOOUT,*) "# Cartesian coord for Geometry ",IdxGeom,K,u,Xgeom(NGeomI)
136

    
137
! PFL 01/feb/2007: useless when dealing with more than three cartesian atoms 
138
! PFL 17/July/2006: only if we have more than 4 atoms.
139
           IF ((NCart.LT.3).AND.(Nat.GT.4)) THEN
140
!           IF (Nat.GT.4) THEN
141
              Call  CalcRmsd(Nat, x0,y0,z0,                               &
142
                   xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3),   &
143
                   MRot,rmsd,FRot,FAlign)
144
           END IF
145

    
146
           DO i=1,Nat
147
              If (Renum) THEN
148
                 WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)),   &
149
                      (XyzTmp2(Order(I),J),J=1,3)
150
              ELSE
151
                 WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(OrderInv(I))),    &
152
                      (XyzTmp2(I,J),J=1,3)
153
              END IF
154
           END DO
155

    
156
        END IF
157
     END IF
158
  ENDDO
159

    
160

    
161
  if ((s>=0.1*dist).AND.(IdxGeom.EQ.NGeomF)) THEN
162
     WRITE(*,*) "** PathCreate ***"
163
     WRITE(*,*) "Distribution of points along the path is wrong."
164
     WRITE(*,*) "Increase value of NMaxPtPath in the input file"
165
     WRITE(*,*) "Present value is:", NMaxPtPath
166
     STOP
167
  END IF
168

    
169
  IdxGeom=NGeomF
170

    
171
! We have to add the last geometry. We copy the last geom of Initial geometries.
172
     IntCoordF(IdxGeom,:)=IntCoordI(NGeomI,:)
173
     IntTangent(IdxGeom,:)=DerInt
174

    
175
! we convert it to cartesian geom
176
  call Mixed2Cart(Nat,IndZmat,IntCoordF(IdxGeom,1),XyzTmp2(1,1))
177
  XyzGeomF(IdxGeom,:,:)=Reshape(XyzTmp2(:,:),(/3,Nat/),ORDER=(/2,1/))
178

    
179
     if (print) THEN
180
        WRITE(IOOUT,'(1X,I5)') Nat
181
        WRITE(IOOUT,*) "# Cartesian coord for last Geometry ",IdxGeom,K,u,Xgeom(NGeomI)
182
! PFL 01/feb/2007: useless when dealing with more than three cartesian atoms 
183
! PFL 17/July/2006: only if we have more than 4 atoms.
184
        IF ((NCART.LT.3).AND.(Nat.GT.4)) THEN
185
!       IF (Nat.GT.4) THEN
186
           Call  CalcRmsd(Nat, x0,y0,z0,                          &
187
                xyzTmp2(1,1),xyzTmp2(1,2),xyzTMP2(1,3),    &
188
                MRot,rmsd,FRot,FAlign)
189
        END IF
190

    
191
        DO i=1,Nat
192
           If (Renum) THEN
193
              WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(I)),    &
194
                   (XyzTmp2(Order(I),J),J=1,3)
195
           ELSE
196
              WRITE(IOOUT,'(1X,A2,3(1X,F15.6))') Nom(Atome(OrderInv(I))),     &
197
                   (XyzTmp2(I,J),J=1,3)
198
           END IF
199
        END DO
200
     END IF
201

    
202

    
203
  if (debug) WRITE(*,*) 's final =',s
204

    
205
  DEALLOCATE(XyzTmp,XyzTmp2)
206

    
207
  if (debug) Call Header("Extrapol_Mixed Over")
208

    
209
 
210
END SUBROUTINE EXTRAPOL_MIXED