Statistiques
| Révision :

root / src / CalcTangent.f90

Historique | Voir | Annoter | Télécharger (7,28 ko)

1
!This programs reads a set of geometries, and print the tangent
2
! to the path they form
3

    
4
SUBROUTINE CalcTangent(XgeomF,NGeomS,XGeom,Coef)
5

    
6
!----------------------------------------------------------------------
7
!  Copyright 2003-2014 Ecole Normale Supérieure de Lyon, 
8
!  Centre National de la Recherche Scientifique,
9
!  Université Claude Bernard Lyon 1. All rights reserved.
10
!
11
!  This work is registered with the Agency for the Protection of Programs 
12
!  as IDDN.FR.001.100009.000.S.P.2014.000.30625
13
!
14
!  Authors: P. Fleurat-Lessard, P. Dayal
15
!  Contact: optnpath@gmail.com
16
!
17
! This file is part of "Opt'n Path".
18
!
19
!  "Opt'n Path" is free software: you can redistribute it and/or modify
20
!  it under the terms of the GNU Affero General Public License as
21
!  published by the Free Software Foundation, either version 3 of the License,
22
!  or (at your option) any later version.
23
!
24
!  "Opt'n Path" is distributed in the hope that it will be useful,
25
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
26
!
27
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
!  GNU Affero General Public License for more details.
29
!
30
!  You should have received a copy of the GNU Affero General Public License
31
!  along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>.
32
!
33
! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr,
34
! for commercial licensing opportunities.
35
!----------------------------------------------------------------------
36

    
37
  use Path_module, only: IntCoordI, Nat, Coord, XyzGeomI, Atome, Order, &
38
                         OrderInv, IndZmat, NMaxPtPath, IntTangent, XyzTangent, &
39
             NGeomF, NCoord
40
  use Io_module, ONly : IoTmp,PathName, Kint,KReal
41
  use VarTypes
42

    
43
  IMPLICIT NONE
44
  ! NGeomS: number of geometries.
45
  INTEGER(KINT), INTENT(IN) :: NGeomS
46
  REAL(KREAL), INTENT(IN) :: XGeomF(NGeomF),Xgeom(NGeomS),Coef(NGeomS,NCoord)
47
  
48
  REAL(KREAL), ALLOCATABLE :: Path(:,:) ! NGeomS,NCoord
49
  REAL(KREAL), ALLOCATABLE :: PathTan(:,:) ! NGeomF,NCoord
50
  REAL(KREAL), ALLOCATABLE :: DbgTgt(:),GeomTmp(:) ! NCoord
51

    
52
  INTEGER(KINT) :: i, j, n3at, k
53
  INTEGER(KINT), SAVE :: icall=-1
54
  INTEGER(KINT) :: NMaxPt
55
!  REAL(KREAL), PARAMETER :: Inf=1e32, h=0.001d0
56
  CHARACTER(120) :: Line,File
57
  CHARACTER(LCHARS) :: TITLE
58
  LOGICAL :: Debug=.False.
59
  REAL(KREAL) :: utmp
60

    
61
  LOGICAL, EXTERNAL :: valid
62

    
63
  debug=valid('calctangent')
64

    
65
  if (debug) WRITE(*,*) "======================================== Entering CalcTangen ============================"
66
  n3at=3*nat
67

    
68
  ALLOCATE(Path(NGeomS,Ncoord),PathTan(NGeomF,NCoord),GeomTMP(NCoord))
69

    
70
 icall=icall+2
71
 write(Line,'(I5)') icall
72
 File=TRIM(adjustl(PathName)) // '_dbgtgt_' // TRIM(adjustl(Line)) // '.dat'
73
 OPEN(IOTMP,File=File)
74

    
75
  ! We construct path, depending on COORD:
76
  ! Path(NGeomS,Ncoord), NGeoms is equal to NGeomI
77
  ! IntCoordI(:,:) ! (NGeomI,3*Nat-6)
78
 SELECT CASE(Coord)
79
    CASE ('ZMAT','MIXED')
80
     Path(:,:)=IntCoordI(:,:)
81
  CASE ('CART','HYBRID')
82
     Path=reshape(XyzGeomI,(/NGeomS,NCoord/))
83
  CASE ('BAKER')
84
   Path(:,:)=IntCoordI(:,:)
85
  CASE DEFAULT
86
     WRITE(*,*) "Coord=",TRIM(COORD)," not recognized in CalcTangent. STOP"
87
     STOP
88
  END SELECT
89

    
90

    
91
  if (debug) THEN
92
     WRITE(*,*) 'DBG CalcTangent. Geometries from Path'
93
     DO I=1,NGeomS
94
        GeomTmp=Path(I,1:NCoord)
95
        WRITE(Title,"('Geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomS
96
        Call PrintGeom(Title,Nat,Ncoord,GeomTmp,Coord,6,Atome,Order,OrderInv,IndZmat)
97
!         IF (COORD.EQ.'ZMAT') THEN
98
!            WRITE(*,"('Geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomS
99
!            WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(1,1))))
100
!            WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(2,1)))), &
101
!                 Nom(Atome(OrderInv(indzmat(2,2)))),Path(I,1)
102
!            WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(3,1)))), &
103
!                 Nom(Atome(OrderInv(indzmat(3,2)))),Path(I,2), &
104
!                 Nom(Atome(OrderInv(indzmat(3,3)))),Path(I,3)
105
!            Idx=4
106
!            DO Iat=4,Nat
107
!               WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), &
108
!                    Nom(Atome(OrderInv(indzmat(iat,2)))),Path(I,Idx), &
109
!                    Nom(Atome(OrderInv(indzmat(iat,3)))),Path(I,Idx+1), &
110
!                    Nom(Atome(OrderInv(indzmat(iat,4)))),Path(I,Idx+2)
111
!               Idx=Idx+3
112
!            END DO
113
!         ELSE
114
!            WRITE(*,*) Nat
115
!            WRITE(*,"('Geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomF
116
!            DO Iat=1,Nat
117
!               WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), &
118
!                    Path(I,3*Iat-2:3*Iat)
119
!            END DO
120
!         END IF
121
     END DO
122
  END IF
123

    
124
!Debug info
125
 IF (debug.AND.(COORD.EQ.'ZMAT')) THEN
126
     ALLOCATE(DbgTgt(NCoord))
127
     WRITE(*,*) 'DBG CalcTangent. Path written in ' // TRIM(File)
128
     WRITE(*,'(A,12(1X,F10.5))') "DBG CalcTangent, XgeomF:",XGeomF
129

    
130
     NMaxPt=min(200,NMaxPtPath)-1
131
    DO K=0,NMaxPt
132
       utmp=K*Xgeom(NGeomS)/NMaxPt
133
       DO J=1,NCoord
134
       Call Splint(utmp,DbgTgt(J),NGeomS,Xgeom,Path(1,J),Coef(1,J))
135
       END DO
136
       WRITE(IOTMP,'(12(1X,F10.5))') utmp,DbgTgt
137
    END DO
138
    DEALLOCATE(DbgTgt)
139
 END IF
140

    
141
!We construct the derivatives
142
DO I=1,NGeomF
143
  DO J=1,NCoord
144
        Call SplinDer(XgeomF(I),PathTan(I,J),NGeomS,Xgeom,Path(1,J),Coef(1,J))
145
  END DO
146
END DO
147

    
148
 SELECT CASE(Coord)
149
    CASE ('ZMAT','MIXED')
150
     IntTangent=PathTan
151
  CASE ('CART','HYBRID')
152
     XyzTangent=Pathtan
153
  END SELECT
154

    
155

    
156
  if (debug) THEN
157
     WRITE(*,*) 'DBG CalcTangent. Tangents'
158
     DO I=1,NGeomF
159
        GeomTmp=PathTan(I,1:NCoord)
160
        WRITE(Title,"('Tangents for geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomF
161
        Call PrintGeom(Title,Nat,Ncoord,GeomTmp,Coord,6,Atome,Order,OrderInv,IndZmat)
162

    
163
        WRITe(*,'(A,12(1X,F10.6))') "Test:",GeomTmp(1:NCoord)
164

    
165
!         IF (COORD.EQ.'ZMAT') THEN
166
!            WRITE(*,"('Tangent for Geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomF
167
!            WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(1,1))))
168
!            WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(2,1)))), &
169
!                 Nom(Atome(OrderInv(indzmat(2,2)))),IntTangent(I,1)
170
!            WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(3,1)))), &
171
!                 Nom(Atome(OrderInv(indzmat(3,2)))),IntTangent(I,2), &
172
!                 Nom(Atome(OrderInv(indzmat(3,3)))),IntTangent(I,3)
173
!            Idx=4
174
!            DO Iat=4,Nat
175
!               WRITE(*,'(1X,A5,3(1X,A4,1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), &
176
!                    Nom(Atome(OrderInv(indzmat(iat,2)))),IntTangent(I,Idx), &
177
!                    Nom(Atome(OrderInv(indzmat(iat,3)))),IntTangent(I,Idx+1), &
178
!                    Nom(Atome(OrderInv(indzmat(iat,4)))),IntTangent(I,Idx+2)
179
!               Idx=Idx+3
180
!            END DO
181
!         ELSE
182
!            WRITE(*,*) Nat
183
!            WRITE(*,"('Tangent for Geometry ',I3,'/',I3,' for iteration ',I3)") I,NgeomF
184
!            DO Iat=1,Nat
185
!               WRITE(*,'(1X,A5,3(1X,F11.6))') Nom(Atome(OrderInv(indzmat(iat,1)))), &
186
!                    XyzTangent(I,3*Iat-2:3*Iat)
187
!            END DO
188
!         END IF
189
     END DO
190
  END IF
191

    
192

    
193
DeALLOCATE(Path) 
194

    
195
 CLOSE(IOTMP)
196
  if (debug) WRITE(*,*) "======================================== Ending CalcTangent ============================"
197

    
198
END SUBROUTINE CalcTangent
199