root / src / AnaPath.f90
Historique | Voir | Annoter | Télécharger (7,33 ko)
1 | 7 | pfleura2 | !================================================================ |
---|---|---|---|
2 | 7 | pfleura2 | ! |
3 | 7 | pfleura2 | ! This subroutine analyzes the geometries along a path |
4 | 7 | pfleura2 | ! and prints it to FileUnit |
5 | 7 | pfleura2 | !================================================================ |
6 | 7 | pfleura2 | |
7 | 7 | pfleura2 | SUBROUTINE AnaPath(IOpt,FileUnit) |
8 | 7 | pfleura2 | |
9 | 12 | pfleura2 | !---------------------------------------------------------------------- |
10 | 12 | pfleura2 | ! Copyright 2003-2014 Ecole Normale Supérieure de Lyon, |
11 | 12 | pfleura2 | ! Centre National de la Recherche Scientifique, |
12 | 12 | pfleura2 | ! Université Claude Bernard Lyon 1. All rights reserved. |
13 | 12 | pfleura2 | ! |
14 | 12 | pfleura2 | ! This work is registered with the Agency for the Protection of Programs |
15 | 12 | pfleura2 | ! as IDDN.FR.001.100009.000.S.P.2014.000.30625 |
16 | 12 | pfleura2 | ! |
17 | 12 | pfleura2 | ! Authors: P. Fleurat-Lessard, P. Dayal |
18 | 12 | pfleura2 | ! Contact: optnpath@gmail.com |
19 | 12 | pfleura2 | ! |
20 | 12 | pfleura2 | ! This file is part of "Opt'n Path". |
21 | 12 | pfleura2 | ! |
22 | 12 | pfleura2 | ! "Opt'n Path" is free software: you can redistribute it and/or modify |
23 | 12 | pfleura2 | ! it under the terms of the GNU Affero General Public License as |
24 | 12 | pfleura2 | ! published by the Free Software Foundation, either version 3 of the License, |
25 | 12 | pfleura2 | ! or (at your option) any later version. |
26 | 12 | pfleura2 | ! |
27 | 12 | pfleura2 | ! "Opt'n Path" is distributed in the hope that it will be useful, |
28 | 12 | pfleura2 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of |
29 | 12 | pfleura2 | ! |
30 | 12 | pfleura2 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 | 12 | pfleura2 | ! GNU Affero General Public License for more details. |
32 | 12 | pfleura2 | ! |
33 | 12 | pfleura2 | ! You should have received a copy of the GNU Affero General Public License |
34 | 12 | pfleura2 | ! along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>. |
35 | 12 | pfleura2 | ! |
36 | 12 | pfleura2 | ! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr, |
37 | 12 | pfleura2 | ! for commercial licensing opportunities. |
38 | 12 | pfleura2 | !---------------------------------------------------------------------- |
39 | 7 | pfleura2 | |
40 | 7 | pfleura2 | use Io_module |
41 | 8 | pfleura2 | use Path_module, only : Nat, NGeomF, XyzGeomF, SGeom,MassAt, & |
42 | 8 | pfleura2 | IReparam,NbVar, FormAna, Energies,Order, & |
43 | 7 | pfleura2 | Renum, PrintGeomFactor, & |
44 | 8 | pfleura2 | Align, NFroz, FrozAtoms, AnaFile,NbVar |
45 | 7 | pfleura2 | |
46 | 7 | pfleura2 | |
47 | 7 | pfleura2 | IMPLICIT NONE |
48 | 7 | pfleura2 | |
49 | 8 | pfleura2 | ! Input |
50 | 8 | pfleura2 | ! Iteration number |
51 | 7 | pfleura2 | INTEGER(KINT), INTENT(IN) :: IOpt |
52 | 8 | pfleura2 | ! Unit file to print |
53 | 7 | pfleura2 | INTEGER(KINT), INTENT(IN) :: FileUnit |
54 | 7 | pfleura2 | |
55 | 7 | pfleura2 | |
56 | 7 | pfleura2 | INTERFACE |
57 | 7 | pfleura2 | function valid(string) result (isValid) |
58 | 7 | pfleura2 | CHARACTER(*), intent(in) :: string |
59 | 7 | pfleura2 | logical :: isValid |
60 | 7 | pfleura2 | END function VALID |
61 | 7 | pfleura2 | |
62 | 7 | pfleura2 | FUNCTION test_zmat(na,ind_zmat) |
63 | 7 | pfleura2 | |
64 | 7 | pfleura2 | USE Path_module |
65 | 7 | pfleura2 | |
66 | 7 | pfleura2 | logical :: test_zmat |
67 | 7 | pfleura2 | integer(KINT) :: na |
68 | 7 | pfleura2 | integer(KINT) :: ind_zmat(Na,5) |
69 | 7 | pfleura2 | END FUNCTION TEST_ZMAT |
70 | 7 | pfleura2 | |
71 | 7 | pfleura2 | |
72 | 8 | pfleura2 | SUBROUTINE die(routine, msg, file, line, unit) |
73 | 7 | pfleura2 | |
74 | 8 | pfleura2 | Use VarTypes |
75 | 8 | pfleura2 | Use io_module |
76 | 7 | pfleura2 | |
77 | 8 | pfleura2 | implicit none |
78 | 7 | pfleura2 | |
79 | 8 | pfleura2 | character(len=*), intent(in) :: routine, msg |
80 | 8 | pfleura2 | character(len=*), intent(in), optional :: file |
81 | 8 | pfleura2 | integer(KINT), intent(in), optional :: line, unit |
82 | 7 | pfleura2 | |
83 | 8 | pfleura2 | END SUBROUTINE die |
84 | 7 | pfleura2 | |
85 | 8 | pfleura2 | SUBROUTINE Warning(routine, msg, file, line, unit) |
86 | 7 | pfleura2 | |
87 | 8 | pfleura2 | Use VarTypes |
88 | 8 | pfleura2 | Use io_module |
89 | 7 | pfleura2 | |
90 | 8 | pfleura2 | implicit none |
91 | 7 | pfleura2 | |
92 | 8 | pfleura2 | character(len=*), intent(in) :: routine, msg |
93 | 8 | pfleura2 | character(len=*), intent(in), optional :: file |
94 | 8 | pfleura2 | integer(KINT), intent(in), optional :: line, unit |
95 | 7 | pfleura2 | |
96 | 8 | pfleura2 | END SUBROUTINE Warning |
97 | 7 | pfleura2 | |
98 | 7 | pfleura2 | END INTERFACE |
99 | 7 | pfleura2 | |
100 | 7 | pfleura2 | LOGICAL :: Debug, CalcDist |
101 | 7 | pfleura2 | INTEGER(KINT) :: I,J,K,Iat |
102 | 7 | pfleura2 | REAL(KREAL), ALLOCATABLE :: GeomCart(:,:),GeomCartPrec(:,:) ! Nat,3 |
103 | 7 | pfleura2 | REAL(KREAL), ALLOCATABLE :: xRef(:),yRef(:),zRef(:) ! Nat |
104 | 7 | pfleura2 | REAL(KREAL), ALLOCATABLE :: Values(:) ! NbVar |
105 | 7 | pfleura2 | REAL(KREAL) :: ds |
106 | 7 | pfleura2 | REAL(KREAL) :: MRot(3,3), Rmsd |
107 | 8 | pfleura2 | CHARACTER(SCHARS) :: Plot="plot" |
108 | 7 | pfleura2 | |
109 | 7 | pfleura2 | debug=valid("AnaPath") |
110 | 7 | pfleura2 | |
111 | 7 | pfleura2 | if (debug) Call header("Entering AnaPath") |
112 | 7 | pfleura2 | |
113 | 8 | pfleura2 | ! if (debug) WRITE(*,*) "DBG AnaPaht PrintGeomFactor:",PrintGeomFactor |
114 | 7 | pfleura2 | ALLOCATE(GeomCart(Nat,3)) |
115 | 8 | pfleura2 | If (NbVar>0) THEN |
116 | 8 | pfleura2 | ALLOCATE(Values(NbVar)) |
117 | 8 | pfleura2 | END IF |
118 | 7 | pfleura2 | |
119 | 7 | pfleura2 | CalcDist=.FALSE. |
120 | 7 | pfleura2 | |
121 | 7 | pfleura2 | WRITE(FileUnit,'("# Iteration ",I5)') Iopt |
122 | 7 | pfleura2 | |
123 | 7 | pfleura2 | DO J=1,Nat |
124 | 7 | pfleura2 | Iat=J |
125 | 7 | pfleura2 | IF (renum) Iat=Order(J) |
126 | 7 | pfleura2 | GeomCart(J,:)=XyzGeomF(1,:,Iat) |
127 | 7 | pfleura2 | END DO |
128 | 7 | pfleura2 | |
129 | 7 | pfleura2 | |
130 | 8 | pfleura2 | ! Do we know the curvilinear values ? |
131 | 7 | pfleura2 | IF (MOD(IOpt,IReparam)/=0) THEN |
132 | 7 | pfleura2 | CalcDist=.TRUE. |
133 | 7 | pfleura2 | SGeom=0. |
134 | 7 | pfleura2 | ALLOCATE(xRef(Nat),yRef(Nat),zref(Nat),GeomCartPrec(Nat,3)) |
135 | 7 | pfleura2 | xRef=GeomCart(:,1) |
136 | 7 | pfleura2 | yRef=GeomCart(:,2) |
137 | 7 | pfleura2 | zRef=GeomCart(:,3) |
138 | 7 | pfleura2 | GeomCartPrec=GeomCart |
139 | 7 | pfleura2 | END IF |
140 | 7 | pfleura2 | |
141 | 7 | pfleura2 | if (debug) THEN |
142 | 7 | pfleura2 | WRITE(*,*) "AnaPath - GeomCart - I=",1 |
143 | 7 | pfleura2 | DO K=1,Nat |
144 | 7 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F15.8))') K,GeomCart(K,1:3) |
145 | 7 | pfleura2 | END DO |
146 | 7 | pfleura2 | WRITE(*,*) "AnaPath - XYzGeomF(I,:,:) - I=",1 |
147 | 7 | pfleura2 | DO K=1,Nat |
148 | 7 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F15.8))') K,XyzGeomF(1,:,K) |
149 | 7 | pfleura2 | END DO |
150 | 7 | pfleura2 | END IF |
151 | 7 | pfleura2 | |
152 | 8 | pfleura2 | If (NbVar>0) THEN |
153 | 8 | pfleura2 | Call AnalyzeGeom(GeomCart,Values) |
154 | 8 | pfleura2 | WRITE(FileUnit,FormAna) SGeom(1),Values*PrintGeomFactor,0.d0,Energies(1) |
155 | 8 | pfleura2 | if (debug) WRITE(*,FormAna) SGeom(1),Values*PrintGeomFactor,0.d0,Energies(1) |
156 | 8 | pfleura2 | ELSE |
157 | 8 | pfleura2 | WRITE(FileUnit,FormAna) SGeom(1),0.d0,Energies(1) |
158 | 8 | pfleura2 | if (debug) WRITE(*,FormAna) SGeom(1),0.d0,Energies(1) |
159 | 8 | pfleura2 | END IF |
160 | 7 | pfleura2 | |
161 | 7 | pfleura2 | DO I=2,NGeomF |
162 | 7 | pfleura2 | DO J=1,Nat |
163 | 7 | pfleura2 | Iat=J |
164 | 7 | pfleura2 | IF (renum) Iat=Order(J) |
165 | 7 | pfleura2 | GeomCart(J,:)=XyzGeomF(I,:,Iat) |
166 | 7 | pfleura2 | END DO |
167 | 7 | pfleura2 | |
168 | 7 | pfleura2 | If (CalcDist) THEN |
169 | 8 | pfleura2 | ! PFL 2013 Feb 26 |
170 | 8 | pfleura2 | ! For now, I do _NOT_ align the geometries |
171 | 7 | pfleura2 | if (debug) THEN |
172 | 7 | pfleura2 | WRITE(*,*) "AnaPath - GeomCart avant align - I=",I |
173 | 7 | pfleura2 | DO K=1,Nat |
174 | 7 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F15.8))') K,GeomCart(K,1:3) |
175 | 7 | pfleura2 | END DO |
176 | 7 | pfleura2 | END IF |
177 | 7 | pfleura2 | |
178 | 7 | pfleura2 | IF ((Nat.GE.4).OR.Align) THEN |
179 | 8 | pfleura2 | if (debug) WRITE(*,*) "DBG AnaPath: Aglin 2 geoms" |
180 | 7 | pfleura2 | |
181 | 8 | pfleura2 | ! If we have frozen atoms we align only those ones. |
182 | 7 | pfleura2 | if (NFroz.GT.0) THEN |
183 | 7 | pfleura2 | Call AlignPartial(Nat,xRef,yRef,zRef, & |
184 | 7 | pfleura2 | GeomCart(1,1),GeomCart(1,2),GeomCart(1,3), & |
185 | 7 | pfleura2 | FrozAtoms,MRot) |
186 | 7 | pfleura2 | ELSE |
187 | 7 | pfleura2 | Call CalcRmsd(Nat, xRef,yRef,zRef, & |
188 | 7 | pfleura2 | GeomCart(1,1),GeomCart(1,2),GeomCart(1,3), & |
189 | 7 | pfleura2 | MRot,rmsd,.TRUE.,.TRUE.) |
190 | 7 | pfleura2 | END IF |
191 | 8 | pfleura2 | ! <- PFL 24 Nov 2008 |
192 | 8 | pfleura2 | |
193 | 7 | pfleura2 | END IF |
194 | 7 | pfleura2 | |
195 | 7 | pfleura2 | if (debug) WRITE(*,*) "Mass:",MassAt(1:Nat) |
196 | 7 | pfleura2 | ds=0. |
197 | 7 | pfleura2 | DO J=1,Nat |
198 | 7 | pfleura2 | Iat=J |
199 | 8 | pfleura2 | ! IF (renum) Iat=Order(J) |
200 | 7 | pfleura2 | if (debug) WRITE(*,*) "Mass(J):",J,MassAt(Iat) |
201 | 8 | pfleura2 | |
202 | 7 | pfleura2 | do K=1,3 |
203 | 7 | pfleura2 | ds=ds+MassAt(Iat)*(GeomCartPrec(J,K)-GeomCart(J,K))**2 |
204 | 7 | pfleura2 | END DO |
205 | 7 | pfleura2 | if (debug) WRITE(*,*) "DBG DS:",J,ds |
206 | 7 | pfleura2 | END DO |
207 | 8 | pfleura2 | ds=sqrt(ds) |
208 | 7 | pfleura2 | if (debug) THEN |
209 | 7 | pfleura2 | WRITE(*,*) "AnaPath - GeomCartPrec - I=",I |
210 | 7 | pfleura2 | DO K=1,Nat |
211 | 7 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F15.8))') K,GeomCartPrec(K,1:3) |
212 | 7 | pfleura2 | END DO |
213 | 7 | pfleura2 | WRITE(*,*) "DBG Anapaht, ds=",ds |
214 | 7 | pfleura2 | END IF |
215 | 7 | pfleura2 | |
216 | 7 | pfleura2 | SGeom(I)=SGeom(I-1)+ds |
217 | 7 | pfleura2 | GeomCartPrec=GeomCart |
218 | 7 | pfleura2 | xRef=GeomCart(:,1) |
219 | 7 | pfleura2 | yRef=GeomCart(:,2) |
220 | 7 | pfleura2 | zRef=GeomCart(:,3) |
221 | 8 | pfleura2 | |
222 | 7 | pfleura2 | END IF |
223 | 7 | pfleura2 | |
224 | 7 | pfleura2 | if (debug) THEN |
225 | 7 | pfleura2 | WRITE(*,*) "AnaPath - GeomCart - I=",I |
226 | 7 | pfleura2 | DO K=1,Nat |
227 | 7 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F15.8))') K,GeomCart(K,1:3) |
228 | 7 | pfleura2 | END DO |
229 | 7 | pfleura2 | END IF |
230 | 7 | pfleura2 | |
231 | 8 | pfleura2 | If (NbVar>0) THEN |
232 | 8 | pfleura2 | Call AnalyzeGeom(GeomCart,Values) |
233 | 8 | pfleura2 | WRITE(FileUnit,FormAna) SGeom(i),Values*PrintGeomFactor,(Energies(i)-Energies(1))*ConvE,Energies(i) |
234 | 8 | pfleura2 | IF (Debug) WRITE(*,FormAna) SGeom(i),Values*PrintGeomFactor,(Energies(i)-Energies(1))*ConvE,Energies(i) |
235 | 8 | pfleura2 | ELSE |
236 | 8 | pfleura2 | WRITE(FileUnit,FormAna) SGeom(i),(Energies(i)-Energies(1))*ConvE,Energies(i) |
237 | 8 | pfleura2 | If (debug) WRITE(*,FormAna) SGeom(i),(Energies(i)-Energies(1))*ConvE,Energies(i) |
238 | 8 | pfleura2 | END IF |
239 | 7 | pfleura2 | END DO |
240 | 7 | pfleura2 | |
241 | 7 | pfleura2 | WRITE(FileUnit,*) "" |
242 | 7 | pfleura2 | WRITE(FileUnit,*) "" |
243 | 7 | pfleura2 | |
244 | 8 | pfleura2 | DeAllocate(GeomCart) |
245 | 8 | pfleura2 | If (NbVar>0) DeAllocate(Values) |
246 | 7 | pfleura2 | If (CalcDist) Deallocate(GeomCartPrec,xRef,yRef,zRef) |
247 | 7 | pfleura2 | |
248 | 8 | pfleura2 | Write(IoGplot,'(A,I5,A)') TRIM(Plot) // ' "' // TRIM(AnaFile) // '" i ',Iopt," u xcol:Ecol w lp " |
249 | 8 | pfleura2 | Plot="replot" |
250 | 8 | pfleura2 | |
251 | 7 | pfleura2 | if (debug) Call header("AnaPath over") |
252 | 7 | pfleura2 | |
253 | 7 | pfleura2 | END SUBROUTINE AnaPath |