Revision 6
utils/Xyz2Path.f (revision 6) | ||
---|---|---|
1 |
program Xyz2Path |
|
2 |
! This programs reads a XYZ file and converts it into distances, |
|
3 |
! valence angle and dihedral angles. |
|
4 |
! It prints them as a function of the irc distance... |
|
5 |
!----------------------------------------------- |
|
6 |
! Input: name of the XYZ File |
|
7 |
! it also needs a file call list which has the following structure: |
|
8 |
! one line contains the type of the value you want to follow, it can be |
|
9 |
! b for a Bond distance |
|
10 |
! a for an angle |
|
11 |
! d for a dihedral |
|
12 |
! this descriptor is followed by the number of the atoms involved ! |
|
13 |
! a typical file can be: |
|
14 |
! b 1 2 |
|
15 |
! b 2 3 |
|
16 |
! a 1 2 3 |
|
17 |
!---------------------------------------------- |
|
18 |
! Ouput: A files call Scan.dat |
|
19 |
! wich contains in the first lines the input file (as a reminder) |
|
20 |
! and then for each step the wanted values |
|
21 |
!------------------------------------------------ |
|
22 |
! Second version also reads the energy (as to be written after E= on |
|
23 |
! the comment line) |
|
24 |
!------------------------------------------------ |
|
25 |
! Third version contains a new command: c for Center of Mass |
|
26 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
27 |
! v 3.1 the c command now creates the center of mass... and allows |
|
28 |
! people to do whatever they want with it... |
|
29 |
! Syntax: c NbAt ListAt |
|
30 |
|
|
31 |
|
|
32 |
IMPLICIT NONE |
|
33 |
|
|
34 |
INCLUDE "Xyz2Path.param" |
|
35 |
|
|
36 |
character*40 f1 |
|
37 |
REAL*8 geos(3,maxnat), geos1(3,maxnat) |
|
38 |
character*33 fmt |
|
39 |
character*3 atoms(maxnat) |
|
40 |
character*5 Type |
|
41 |
Character*120 line |
|
42 |
INTEGER*4 NbPrint |
|
43 |
REAL*8 AU2PS,Pi |
|
44 |
REAL*8 Mass(MaxNat), Ener, Conv, Ds, s |
|
45 |
REAL*8 MassAt(0:86) |
|
46 |
INTEGER*4 At1,At2,At3,At4,IOOUT,Iat |
|
47 |
INTEGER*4 IArg, I, NNN, Ng, J |
|
48 |
|
|
49 |
INTEGER*4 Nat,NbDist, NbAngle, NbDie,NbCOM |
|
50 |
INTEGER*4 At1B(MaxNat),At2B(MaxNat) |
|
51 |
INTEGER*4 At1A(MaxNat),At2A(MaxNat),At3A(MaxNat) |
|
52 |
INTEGER*4 At1D(MaxNat),At2D(MaxNat),At3D(MaxNat),At4D(MaxNat) |
|
53 |
INTEGER*4 AtCom(0:MaxNat,MaxNat) |
|
54 |
REAL*8 VB(MaxNat),VA(MaxNat),VD(MaxNat),VCOM(MaxNat) |
|
55 |
|
|
56 |
REAL*8 MRot(3,3), Rmsd |
|
57 |
LOGICAL FExist,FRot,FAlign,Debug |
|
58 |
|
|
59 |
INTEGER*4 ConvertNumAt |
|
60 |
external ConvertNumAt |
|
61 |
|
|
62 |
COMMON /Indices/Nat,NbDist,NbAngle,NbDie,NbCom, At1B,At2B, |
|
63 |
& At1A,At2A,At3A,At1D,At2D,At3D,At4D,AtCom |
|
64 |
COMMON /Values/VB,VA,VD,VCom |
|
65 |
COMMON /Const/AU2ps,Pi |
|
66 |
|
|
67 |
DATA MassAt/0.0D0, |
|
68 |
$ 1.0078D0, 4.0026D0, |
|
69 |
$ 7.0160D0, 9.0122D0,11.0093D0, |
|
70 |
$ 12.0000D0,14.0031D0,15.9949D0,18.9984D0,19.9924D0, |
|
71 |
$ 22.9898D0,23.9850D0,26.9815D0, |
|
72 |
$ 27.9769D0,30.9738D0,31.9721D0,34.9688D0,39.9624D0, |
|
73 |
$ 39.0983D0,40.08D0, |
|
74 |
$ 44.9559D0, 47.88D0, 50.9415D0, 51.996D0, 54.9380D0, |
|
75 |
$ 55.847D0, 58.9332D0, 58.69D0, 63.546D0, 65.39D0, |
|
76 |
$ 69.72D0,72.59D0,74.9216D0,78.96D0,79.904D0,83.80D0, |
|
77 |
$ 85.4678D0,87.62D0,88.9059D0,91.224D0,92.9064D0, |
|
78 |
$ 95.94D0,98D0,101.07D0,102.906D0,106.42D0,107.868D0,112.41D0, |
|
79 |
$ 114.82D0,118.71D0,121.75D0,127.60D0,126.905D0,131.29D0, |
|
80 |
! 6 'CS','BA', |
|
81 |
$ 132.905,137.34, |
|
82 |
! 6 'LA', |
|
83 |
! 'CE','PR','ND','PM','SM','EU','GD', |
|
84 |
! 'TB','DY','HO', 'ER','TM','YB','LU', |
|
85 |
$ 138.91, |
|
86 |
$ 140.12, 130.91, 144.24,147.,150.35, 151.96,157.25, |
|
87 |
$ 158.924, 162.50, 164.93, 167.26,168.93,173.04,174.97, |
|
88 |
! 6 'HF','TA',' W','RE','OS','IR','PT', |
|
89 |
! 'AU','HG', |
|
90 |
! 6 'TL','PB','BI','PO','AT','RN'/ |
|
91 |
$ 178.49, 180.95, 183.85, 186.2, 190.2, 192.2, 195.09, |
|
92 |
$ 196.97, 200.59, |
|
93 |
$ 204.37, 207.19,208.98,210.,210.,222. / |
|
94 |
|
|
95 |
|
|
96 |
AU2PS=1./41341.37 |
|
97 |
NbPrint=100 |
|
98 |
Pi=dacos(-1.d0) |
|
99 |
IOOUT=13 |
|
100 |
Conv=1. |
|
101 |
FRot=.TRUE. |
|
102 |
FAlign=.TRUE. |
|
103 |
Debug=.FALSE. |
|
104 |
NbDist=0 |
|
105 |
NbAngle=0 |
|
106 |
NbDie=0 |
|
107 |
|
|
108 |
iarg=command_argument_count() |
|
109 |
if (iarg.lt.1) then |
|
110 |
write(*,*) 'XYZ filename:' |
|
111 |
read(*,'(a)') f1 |
|
112 |
else |
|
113 |
call getarg(1,f1) |
|
114 |
endif |
|
115 |
|
|
116 |
open(13,file='Scan.dat') |
|
117 |
|
|
118 |
INQUIRE(File='list',Exist=FExist) |
|
119 |
if (.NOT.FExist) THEN |
|
120 |
WRITE(*,*) "No file 'list', just printing Energy" |
|
121 |
END IF |
|
122 |
|
|
123 |
open(11,file=f1) |
|
124 |
call rtraitem(11,nnn,ener,geos1,atoms) |
|
125 |
close(11) |
|
126 |
|
|
127 |
DO I=1,nnn |
|
128 |
Iat=ConvertNumAt(atoms(I)) |
|
129 |
Mass(I)=MassAt(Iat) |
|
130 |
! write(*,*) I,Atoms(I),Mass(I),geos1(:,I) |
|
131 |
END DO |
|
132 |
|
|
133 |
Nat=nnn |
|
134 |
|
|
135 |
if (FExist) THEN |
|
136 |
open(14,file='list') |
|
137 |
Type="d" |
|
138 |
DO WHILE (Type.ne."E") |
|
139 |
CALL READLINE(14,Type,Line) |
|
140 |
! WRITE(*,*) Line,Type |
|
141 |
if (Type.eq."b") THEN |
|
142 |
NbDist=NbDist+1 |
|
143 |
READ(Line,*) At1,At2 |
|
144 |
At1B(NbDist)=At1 |
|
145 |
At2B(NbDist)=At2 |
|
146 |
WRITE(13,'("# b ",2(A3,I3))') Atoms(At1),At1,Atoms(At2),At2 |
|
147 |
WRITE(*,'("# b ",2(A3,I3))') Atoms(At1),At1,Atoms(At2),At2 |
|
148 |
END IF |
|
149 |
if (Type.eq."a") THEN |
|
150 |
NbAngle=NbAngle+1 |
|
151 |
READ(Line,*) At1,At2,At3 |
|
152 |
At1A(NbAngle)=At1 |
|
153 |
At2A(NbAngle)=At2 |
|
154 |
At3A(NbAngle)=At3 |
|
155 |
WRITE(13,'("# a ",3(A3,I3))') Atoms(At1),At1,Atoms(At2), |
|
156 |
& At2, Atoms(At3),At3 |
|
157 |
WRITE(*,'("# a ",3(A3,I3))') Atoms(At1),At1,Atoms(At2), |
|
158 |
& At2, Atoms(At3),At3 |
|
159 |
END IF |
|
160 |
if (Type.eq."d") THEN |
|
161 |
NbDie=NbDie+1 |
|
162 |
READ(Line,*) At1,At2,At3,At4 |
|
163 |
At1D(NbDie)=At1 |
|
164 |
At2D(NbDie)=At2 |
|
165 |
At3D(NbDie)=At3 |
|
166 |
At4D(NbDie)=At4 |
|
167 |
WRITE(13,'("# d ",4(A3,I3))') Atoms(At1),At1,Atoms(At2),At2, |
|
168 |
& Atoms(At3),At3,Atoms(At4),At4 |
|
169 |
WRITE(*,'("# d ",4(A3,I3))') Atoms(At1),At1,Atoms(At2),At2, |
|
170 |
& Atoms(At3),At3,Atoms(At4),At4 |
|
171 |
|
|
172 |
END IF |
|
173 |
if (Type.eq."c") THEN |
|
174 |
NbCOM=NbCOM+1 |
|
175 |
READ(Line,*) At1,(AtCom(j,NbCOM),j=1,At1) |
|
176 |
AtCom(0,NbCOM)=At1 |
|
177 |
Atoms(nat+NbCom)="G" |
|
178 |
WRITE(13,'("# c ",I4,20(A3,I3))') At1, |
|
179 |
& (Atoms(AtCom(i,NbCoM)),AtCom(i,NbCOM),i=1,At1) |
|
180 |
WRITE(*,'("# c ",I4,20(A3,I3))') At1, |
|
181 |
& (Atoms(AtCom(i,NbCoM)),AtCom(i,NbCOM),i=1,At1) |
|
182 |
END IF |
|
183 |
|
|
184 |
END DO |
|
185 |
END IF |
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
fmt='( (1X,F12.5),1X,F15.6)' |
|
190 |
write(fmt(2:4),'(i3)') NbDist+NbAngle+NbDie+1 |
|
191 |
! write(*,*) nat3 |
|
192 |
! write(*,*) 'fmt:',fmt |
|
193 |
|
|
194 |
ng=1 |
|
195 |
|
|
196 |
s=0. |
|
197 |
|
|
198 |
open(11,file=f1) |
|
199 |
|
|
200 |
10 call rtraitem(11,nnn,ener,geos,atoms) |
|
201 |
! WRITE(*,*) nnn |
|
202 |
if (nnn.gt.0) then |
|
203 |
|
|
204 |
call CalcRmsd(nnn, geos1, geos,MRot,rmsd,FRot,FAlign,debug) |
|
205 |
ds=0. |
|
206 |
DO I=1,nnn |
|
207 |
DO J=1,3 |
|
208 |
ds=ds+mass(I)*(geos(J,I)-geos1(J,I))**2 |
|
209 |
! write(*,*) I,J,geos(J,I),Geos1(J,I),ds |
|
210 |
geos1(J,I)=Geos(J,I) |
|
211 |
END DO |
|
212 |
END DO |
|
213 |
s=s+sqrt(ds) |
|
214 |
|
|
215 |
! We convert coordinates in a0 into Angstroem |
|
216 |
! write(*,*) "Analyse !" |
|
217 |
if (FExist) THEN |
|
218 |
Call Analyse(geos) |
|
219 |
|
|
220 |
write(IOOUT,fmt) s,(VB(j)/Conv,j=1,NbDist), |
|
221 |
& (VA(j),j=1,NbAngle), |
|
222 |
& (VD(j),j=1,NbDie),ener |
|
223 |
write(*,fmt) s,(VB(j)/Conv,j=1,NbDist), |
|
224 |
& (VA(j),j=1,NbAngle), |
|
225 |
& (VD(j),j=1,NbDie),ener |
|
226 |
ELSE |
|
227 |
write(IOOUT,fmt) s,ener |
|
228 |
write(*,fmt) s,ener |
|
229 |
END IF |
|
230 |
ng=ng+1 |
|
231 |
goto 10 |
|
232 |
endif |
|
233 |
WRITE(*,*) 'Found ',ng-1,' geometries' |
|
234 |
close(11) |
|
235 |
end |
|
236 |
|
|
237 |
!-------------------------------------------------------------- |
|
238 |
subroutine rtraitem(ifil,nnn,E,tab,atoms) |
|
239 |
! implicit real*8 (a-h,o-z) |
|
240 |
IMPLICIT NONE |
|
241 |
character*120 line |
|
242 |
character*3 Atoms(*) |
|
243 |
integer*4 nnn, IFil, Idx, I, J |
|
244 |
REAL*8 Tab(3,*), E |
|
245 |
|
|
246 |
|
|
247 |
read(ifil,*,err=99,end=99) nnn |
|
248 |
read(ifil,'(A)') line |
|
249 |
idx=index(line,'E') |
|
250 |
! WRITE(*,*) 'idx,line',idx,line |
|
251 |
if (idx/=0) THEN |
|
252 |
line=line(idx+2:) |
|
253 |
idx=index(line,"=") |
|
254 |
if (idx/=0) line=line(idx+1:) |
|
255 |
idx=index(line,":") |
|
256 |
if (idx/=0) line=line(idx+1:) |
|
257 |
read(line,*) E |
|
258 |
ELSE |
|
259 |
E=0. |
|
260 |
END IF |
|
261 |
|
|
262 |
! write(*,*) 'coucou',line |
|
263 |
do i=1,nnn |
|
264 |
read(ifil,'(A)',err=99,end=99) Line |
|
265 |
do while (line(1:1)==' ') |
|
266 |
line=line(2:) |
|
267 |
end do |
|
268 |
atoms(i)=line(1:3) |
|
269 |
! write(*,*) 'coucou atoms',atoms(i) |
|
270 |
do while (line(1:1).ne.' ') |
|
271 |
line=line(2:) |
|
272 |
end do |
|
273 |
! WRITE(*,*) 'coucou2:',i,line |
|
274 |
read(line,*) (tab(j,i),j=1,3) |
|
275 |
end do |
|
276 |
! WRITE(*,*) 'coucou:',nnn,tab(1,1) |
|
277 |
return |
|
278 |
99 nnn=0 |
|
279 |
! WRITE(*,*) 'Erreur lecture',ifil,nnn |
|
280 |
return |
|
281 |
end |
|
282 |
|
|
283 |
!-------------------------------------------------------------- |
|
284 |
|
|
285 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
286 |
! READLINE |
|
287 |
! This subroutine reads a line for a file, and converts |
|
288 |
! the first field into a character variable, and the rest into 4 integers |
|
289 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
290 |
|
|
291 |
SUBROUTINE READLINE(IOIN,Type,Line) |
|
292 |
|
|
293 |
IMPLICIT NONE |
|
294 |
CHARACTER Type*5,LINE*120 |
|
295 |
INTEGER i,IOIN |
|
296 |
READ(IOIN,'(A120)',ERR=999,END=999) LINE |
|
297 |
! WRITE(*,*) Line |
|
298 |
DO WHILE (LINE(1:1).eq.' ') |
|
299 |
LINE=LINE(2:) |
|
300 |
END DO |
|
301 |
|
|
302 |
i=1 |
|
303 |
DO WHILE (LINE(i:i).ne.' ') |
|
304 |
i=i+1 |
|
305 |
END DO |
|
306 |
|
|
307 |
if (i.ge.6) THEN |
|
308 |
WRITE(*,*) 'Pb with READLINE:',LINE |
|
309 |
GOTO 999 |
|
310 |
END IF |
|
311 |
Type=LINE(1:i-1) |
|
312 |
LINE=LINE(i:120) // " 0 0 0 0" |
|
313 |
|
|
314 |
RETURN |
|
315 |
999 Type="E" |
|
316 |
END |
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
SUBROUTINE Analyse(geos) |
|
321 |
|
|
322 |
IMPLICIT NONE |
|
323 |
INCLUDE "Xyz2Path.param" |
|
324 |
|
|
325 |
REAL*8 geos(3,maxnat) |
|
326 |
REAL*8 AU2PS,Pi |
|
327 |
INTEGER*4 i,j,k |
|
328 |
REAL*8 V1x,V1y,V1z,V2x,V2y,V2z,V3x,V3y,V3z |
|
329 |
REAL*8 d1,d2,ca,sa |
|
330 |
REAL*8 V4x,v4y,v4z,v5x,v5y,v5z |
|
331 |
REAL*8 COG(3) |
|
332 |
|
|
333 |
INTEGER*4 Nat,NbDist, NbAngle, NbDie,NbCOM |
|
334 |
INTEGER*4 At1B(MaxNat),At2B(MaxNat) |
|
335 |
INTEGER*4 At1A(MaxNat),At2A(MaxNat),At3A(MaxNat) |
|
336 |
INTEGER*4 At1D(MaxNat),At2D(MaxNat),At3D(MaxNat),At4D(MaxNat) |
|
337 |
INTEGER*4 AtCom(0:MaxNat,MaxNat) |
|
338 |
REAL*8 VB(MaxNat),VA(MaxNat),VD(MaxNat),VCOM(MaxNat) |
|
339 |
|
|
340 |
COMMON /Indices/Nat,NbDist,NbAngle,NbDie,NbCom, |
|
341 |
& At1B,At2B,At1A,At2A,At3A,At1D,At2D,At3D,At4D,AtCom |
|
342 |
COMMON /Values/VB,VA,VD,VCom |
|
343 |
COMMON /Const/AU2ps,Pi |
|
344 |
|
|
345 |
DO I=1,Nat |
|
346 |
WRITE(*,'(1X,I3,3(1X,F15.6))') i,(geos(j,i),j=1,3) |
|
347 |
END DO |
|
348 |
|
|
349 |
! First, we create the Centre of Mass atoms |
|
350 |
DO i=1,NbCOM |
|
351 |
COG(1)=0. |
|
352 |
COG(2)=0. |
|
353 |
COG(3)=0. |
|
354 |
DO j=1,AtCOm(0,i) |
|
355 |
DO k=1,3 |
|
356 |
COG(k)=COG(k)+geos(k,AtCom(j,i)) |
|
357 |
END DO |
|
358 |
END DO |
|
359 |
DO k=1,3 |
|
360 |
COG(k)=COG(k)/AtCOM(0,i) |
|
361 |
geos(k,Nat+i)=COG(k) |
|
362 |
END DO |
|
363 |
END DO |
|
364 |
|
|
365 |
|
|
366 |
DO i=1,NbDist |
|
367 |
VB(i)=sqrt((geos(1,At1B(i))-geos(1,At2B(i)))**2+ |
|
368 |
& (geos(2,At1B(i))-geos(2,At2B(i)))**2+ |
|
369 |
& (geos(3,At1B(i))-geos(3,At2B(i)))**2) |
|
370 |
END DO |
|
371 |
DO i=1,NbAngle |
|
372 |
v1x=geos(1,At1A(i))-geos(1,At2A(i)) |
|
373 |
v1y=geos(2,At1A(i))-geos(2,At2A(i)) |
|
374 |
v1z=geos(3,At1A(i))-geos(3,At2A(i)) |
|
375 |
d1=sqrt(v1x**2+v1y**2+v1z**2) |
|
376 |
v2x=geos(1,At3A(i))-geos(1,At2A(i)) |
|
377 |
v2y=geos(2,At3A(i))-geos(2,At2A(i)) |
|
378 |
v2z=geos(3,At3A(i))-geos(3,At2A(i)) |
|
379 |
d2=sqrt(v2x**2+v2y**2+v2z**2) |
|
380 |
VA(i)=acos((v1x*v2x+v1y*v2y+v1z*v2z)/(d1*d2))*180./Pi |
|
381 |
END DO |
|
382 |
DO i=1,NbDie |
|
383 |
! WRITE(*,*) At1D(i),At2D(i),At3D(i),At4D(i) |
|
384 |
! WRITE(*,*) geos(1,At1D(i)),geos(2,At1D(i)),geos(3,At1D(i)) |
|
385 |
! WRITE(*,*) geos(1,At2D(i)),geos(2,At2D(i)),geos(3,At2D(i)) |
|
386 |
v1x=geos(1,At1D(i))-geos(1,At2D(i)) |
|
387 |
v1y=geos(2,At1D(i))-geos(2,At2D(i)) |
|
388 |
v1z=geos(3,At1D(i))-geos(3,At2D(i)) |
|
389 |
v2x=geos(1,At3D(i))-geos(1,At2D(i)) |
|
390 |
v2y=geos(2,At3D(i))-geos(2,At2D(i)) |
|
391 |
v2z=geos(3,At3D(i))-geos(3,At2D(i)) |
|
392 |
v3x=geos(1,At4D(i))-geos(1,At3D(i)) |
|
393 |
v3y=geos(2,At4D(i))-geos(2,At3D(i)) |
|
394 |
v3z=geos(3,At4D(i))-geos(3,At3D(i)) |
|
395 |
|
|
396 |
v4x=v1y*v2z-v1z*v2y |
|
397 |
v4y=v1z*v2x-v1x*v2z |
|
398 |
v4z=v1x*v2y-v1y*v2x |
|
399 |
d1=sqrt(v4x**2+v4y**2+v4z**2) |
|
400 |
v5x=-v2y*v3z+v2z*v3y |
|
401 |
v5y=-v2z*v3x+v2x*v3z |
|
402 |
v5z=-v2x*v3y+v2y*v3x |
|
403 |
d2=sqrt(v5x**2+v5y**2+v5z**2) |
|
404 |
ca=(v4x*v5x+v4y*v5y+v4z*v5z)/(d1*d2) |
|
405 |
sa=v1x*v5x+v1y*v5y+v1z*v5z |
|
406 |
VD(i)=acos(ca)*180./Pi |
|
407 |
if (sa<0.) VD(i)=-VD(i) |
|
408 |
! WRITE(*,*) "Dihe",v5x,v5y,v5z,v4x,v4y,v4z,d1,d2, |
|
409 |
! &(v4x*v5x+v4y*v5y+v4z*v5z)/(d1*d2),pi |
|
410 |
!!!!!!!!! Another solution, more elegant ? |
|
411 |
! norm2=sqrt(v2x**2+v2y**2+v2z**2) |
|
412 |
! sa=(v4x*(v5y*v2z-v5z*v2y) |
|
413 |
! * -v4y*(v5x*v2z-v5z*v2x) |
|
414 |
! * +v4z*(v5x*v2y-v5y*v2x)) |
|
415 |
! * /(d1*norm2*d2) |
|
416 |
! angle_d=datan2(sa,ca)*180./Pi |
|
417 |
! WRITE(*,*) sa,ca,angle_d,d1,d2,norm2 |
|
418 |
! WRITE(*,*) VD(i),angle_d |
|
419 |
END DO |
|
420 |
|
|
421 |
END |
|
422 |
|
|
423 |
C================================================================ |
|
424 |
C Convertit un nom d'atome (2 lettres) en nombre de masse (entier) |
|
425 |
C cette fonction a ete modifiee pour pouvoir convertir un nom |
|
426 |
C d'atome avec un numero a la fin... |
|
427 |
C================================================================ |
|
428 |
|
|
429 |
FUNCTION ConvertNumAt(ATOM) |
|
430 |
|
|
431 |
|
|
432 |
IMPLICIT NONE |
|
433 |
|
|
434 |
INTEGER*4 I,Long,ConvertNumAt,IC |
|
435 |
character*2 ATOM*2,ATOME*3,L_Atom*2 |
|
436 |
INTEGER*4 Max_Z |
|
437 |
PARAMETER (Max_Z=86) |
|
438 |
CHARACTER*2 Nom(0:Max_Z) |
|
439 |
|
|
440 |
DATA NOM/ ' X',' H', 'HE', |
|
441 |
$ 'LI','BE', ' B',' C',' N',' O',' F','NE', |
|
442 |
$ 'NA','MG', 'AL','SI',' P',' S','CL','AR', |
|
443 |
$ ' K','CA', |
|
444 |
$ 'SC','TI',' V','CR','MN','FE','CO','NI','CU','ZN', |
|
445 |
$ 'GA','GE','AS','SE','BR','KR', |
|
446 |
$ 'RB','SR', |
|
447 |
$ ' Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD', |
|
448 |
$ 'IN','SN','SB','TE',' I','XE', |
|
449 |
$ 'CS','BA', |
|
450 |
$ 'LA', |
|
451 |
$ 'CE','PR','ND','PM','SM','EU','GD','TB','DY','HO', |
|
452 |
$ 'ER','TM','YB','LU', |
|
453 |
$ 'HF','TA',' W','RE','OS','IR','PT','AU','HG', |
|
454 |
$ 'TL','PB','BI','PO','AT','RN'/ |
|
455 |
|
|
456 |
|
|
457 |
C Verifie qu'il n'y a que des lettres et des espaces dans ATOM |
|
458 |
! WRITE(*,*) 'DBG CNVNUMAT, ATOM:',ATOM |
|
459 |
|
|
460 |
L_atom=Atom |
|
461 |
IF (ATOM(1:1).LT.'A') L_ATOM(1:1)=' ' |
|
462 |
IC=Ichar(ATOM(1:1)) |
|
463 |
IF ((ic.le.123).AND.(ic.ge.97)) L_ATOM(1:1)=CHAr(IC-32) |
|
464 |
IF (ATOM(2:2).LT.'A') L_ATOM(2:2)=' ' |
|
465 |
IC=Ichar(ATOM(2:2)) |
|
466 |
IF ((ic.le.123).AND.(ic.ge.97)) L_ATOM(2:2)=CHAr(IC-32) |
|
467 |
C Justifie le nom sur la droite (et non sur la gauche comme souvent...) |
|
468 |
Long=INDEX(L_ATOM,' ')-1 |
|
469 |
ATOME=' ' // L_ATOM |
|
470 |
IF (Long.EQ.1) L_ATOM=ATOME(1:2) |
|
471 |
! WRITE(*,*) 'DBG CNVNUMAT, L_ATOM:',L_ATOM |
|
472 |
I=max_Z |
|
473 |
DO WHILE ((nom(I).NE.L_ATOM) .AND. (I.GT.0)) |
|
474 |
I=I-1 |
|
475 |
END DO |
|
476 |
ConvertNumAT=I |
|
477 |
END |
|
478 |
! This subroutine calculates RMSD using quaternions. |
|
479 |
! It is based on the F90 routine bu E. Coutsias |
|
480 |
! http://www.math.unm.edu/~vageli/homepage.html |
|
481 |
! I (PFL) have just translated it, and I have changed the diagonalization |
|
482 |
! subroutine. |
|
483 |
! I also made some changes to make it suitable for Cart package. |
|
484 |
!---------------------------------------------------------------------- |
|
485 |
!---------------------------------------------------------------------- |
|
486 |
! Copyright (C) 2004, 2005 Chaok Seok, Evangelos Coutsias and Ken Dill |
|
487 |
! UCSF, Univeristy of New Mexico, Seoul National University |
|
488 |
! Witten by Chaok Seok and Evangelos Coutsias 2004. |
|
489 |
|
|
490 |
! This library is free software; you can redistribute it and/or |
|
491 |
! modify it under the terms of the GNU Lesser General Public |
|
492 |
! License as published by the Free Software Foundation; either |
|
493 |
! version 2.1 of the License, or (at your option) any later version. |
|
494 |
! |
|
495 |
|
|
496 |
! This library is distributed in the hope that it will be useful, |
|
497 |
! but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
498 |
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
499 |
! Lesser General Public License for more details. |
|
500 |
! |
|
501 |
|
|
502 |
! You should have received a copy of the GNU Lesser General Public |
|
503 |
! License along with this library; if not, write to the Free Software |
|
504 |
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
505 |
!---------------------------------------------------------------------------- |
|
506 |
|
|
507 |
subroutine CalcRmsd(na, geom,geom2,U,rmsd,FRot,FAlign,debug) |
|
508 |
!----------------------------------------------------------------------- |
|
509 |
! This subroutine calculates the least square rmsd of two coordinate |
|
510 |
! sets coord1(3,n) and coord2(3,n) using a method based on quaternion. |
|
511 |
! It then calculate the rotation matrix U and the centers of coord, and uses |
|
512 |
! them to align the two molecules. |
|
513 |
!----------------------------------------------------------------------- |
|
514 |
|
|
515 |
|
|
516 |
IMPLICIT NONE |
|
517 |
|
|
518 |
INCLUDE "Xyz2Path.param" |
|
519 |
|
|
520 |
INTEGER*4 IOIN, IOOUT, IOSCRN, IOPRNT, IOTAMP |
|
521 |
COMMON/IODEFS/IOIN,IOOUT,IOSCRN,IOPRNT,IOTAMP |
|
522 |
|
|
523 |
integer*4 na |
|
524 |
real*8 geom(3,MaxNAt), Geom2(3,MaxNAt) |
|
525 |
real*8 U(3,3), rmsd |
|
526 |
LOGICAL FRot,FAlign,Debug |
|
527 |
|
|
528 |
REAL*8 Coord1(3,MaxNAt), Coord2(3,MaxNAt) |
|
529 |
real*8 xc1,yc1,zc1, xc2,yc2,zc2 |
|
530 |
|
|
531 |
|
|
532 |
integer*4 i, j, ia |
|
533 |
real*8 x_norm, y_norm, lambda |
|
534 |
real*8 Rmatrix(3,3) |
|
535 |
real*8 S(4,4) |
|
536 |
real*8 EigVec(4,4), EigVal(4) |
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
! calculate the barycenters, centroidal coordinates, and the norms |
|
541 |
x_norm = 0.0d0 |
|
542 |
y_norm = 0.0d0 |
|
543 |
xc1=0. |
|
544 |
yc1=0. |
|
545 |
zc1=0. |
|
546 |
xc2=0. |
|
547 |
yc2=0. |
|
548 |
zc2=0. |
|
549 |
do ia=1,na |
|
550 |
xc1=xc1+geom(1,ia) |
|
551 |
xc2=xc2+geom2(1,ia) |
|
552 |
yc1=yc1+geom(2,ia) |
|
553 |
yc2=yc2+geom2(2,ia) |
|
554 |
zc1=zc1+geom(3,ia) |
|
555 |
zc2=zc2+geom2(3,ia) |
|
556 |
! if (debug) WRITE(*,'(A,I5,4(1X,F10.4))') 'ia...',ia,x(ia), |
|
557 |
! & x2(ia),xc1,xc2 |
|
558 |
END DO |
|
559 |
xc1=xc1/dble(na) |
|
560 |
yc1=yc1/dble(na) |
|
561 |
zc1=zc1/dble(na) |
|
562 |
xc2=xc2/dble(na) |
|
563 |
yc2=yc2/dble(na) |
|
564 |
zc2=zc2/dble(na) |
|
565 |
|
|
566 |
IF (debug) WRITE(*,'(1X,A,3(1X,F10.4))') 'Center1',xc1,yc1,zc1 |
|
567 |
IF (debug) WRITE(*,'(1X,A,3(1X,F10.4))') 'Center2',xc2,yc2,zc2 |
|
568 |
do i=1,na |
|
569 |
Coord1(1,i)=geom(1,i)-xc1 |
|
570 |
Coord1(2,i)=geom(2,i)-yc1 |
|
571 |
Coord1(3,i)=geom(3,i)-zc1 |
|
572 |
Coord2(1,i)=geom2(1,i)-xc2 |
|
573 |
Coord2(2,i)=geom2(2,i)-yc2 |
|
574 |
Coord2(3,i)=geom2(3,i)-zc2 |
|
575 |
x_norm=x_norm+Coord1(1,i)**2+Coord1(2,i)**2+Coord1(3,i)**2 |
|
576 |
y_norm=y_norm+Coord2(1,i)**2+Coord2(2,i)**2+Coord2(3,i)**2 |
|
577 |
end do |
|
578 |
|
|
579 |
IF (debug) THEN |
|
580 |
WRITE(*,*) "R matrix" |
|
581 |
DO I=1,3 |
|
582 |
WRITE(*,*) (RMatrix(I,j),j=1,3) |
|
583 |
END DO |
|
584 |
END IF |
|
585 |
|
|
586 |
! calculate the R matrix |
|
587 |
do i = 1, 3 |
|
588 |
do j = 1, 3 |
|
589 |
Rmatrix(i,j)=0. |
|
590 |
do ia=1,na |
|
591 |
Rmatrix(i,j) = Rmatrix(i,j)+Coord1(i,ia)*Coord2(j,ia) |
|
592 |
END DO |
|
593 |
end do |
|
594 |
end do |
|
595 |
|
|
596 |
IF (debug) THEN |
|
597 |
WRITE(*,*) "R matrix" |
|
598 |
DO I=1,3 |
|
599 |
WRITE(*,*) (RMatrix(I,j),j=1,3) |
|
600 |
END DO |
|
601 |
END IF |
|
602 |
|
|
603 |
|
|
604 |
! S matrix |
|
605 |
S(1, 1) = Rmatrix(1, 1) + Rmatrix(2, 2) + Rmatrix(3, 3) |
|
606 |
S(2, 1) = Rmatrix(2, 3) - Rmatrix(3, 2) |
|
607 |
S(3, 1) = Rmatrix(3, 1) - Rmatrix(1, 3) |
|
608 |
S(4, 1) = Rmatrix(1, 2) - Rmatrix(2, 1) |
|
609 |
|
|
610 |
S(1, 2) = S(2, 1) |
|
611 |
S(2, 2) = Rmatrix(1, 1) - Rmatrix(2, 2) - Rmatrix(3, 3) |
|
612 |
S(3, 2) = Rmatrix(1, 2) + Rmatrix(2, 1) |
|
613 |
S(4, 2) = Rmatrix(1, 3) + Rmatrix(3, 1) |
|
614 |
|
|
615 |
S(1, 3) = S(3, 1) |
|
616 |
S(2, 3) = S(3, 2) |
|
617 |
S(3, 3) =-Rmatrix(1, 1) + Rmatrix(2, 2) - Rmatrix(3, 3) |
|
618 |
S(4, 3) = Rmatrix(2, 3) + Rmatrix(3, 2) |
|
619 |
|
|
620 |
S(1, 4) = S(4, 1) |
|
621 |
S(2, 4) = S(4, 2) |
|
622 |
S(3, 4) = S(4, 3) |
|
623 |
S(4, 4) =-Rmatrix(1, 1) - Rmatrix(2, 2) + Rmatrix(3, 3) |
|
624 |
|
|
625 |
|
|
626 |
! PFL : I use my usual Jacobi diagonalisation |
|
627 |
! Calculate eigenvalues and eigenvectors, and |
|
628 |
! take the maximum eigenvalue lambda and the corresponding eigenvector q. |
|
629 |
|
|
630 |
IF (debug) THEN |
|
631 |
WRITE(*,*) "S matrix" |
|
632 |
DO I=1,4 |
|
633 |
WRITE(*,*) (S(I,j),j=1,4) |
|
634 |
END DO |
|
635 |
END IF |
|
636 |
|
|
637 |
Call Jacobi(S,4,EigVal,EigVec,4) |
|
638 |
|
|
639 |
Call Trie(4,EigVal,EigVec,4) |
|
640 |
|
|
641 |
Lambda=EigVal(4) |
|
642 |
|
|
643 |
! RMS Deviation |
|
644 |
rmsd=sqrt(max(0.0d0,((x_norm+y_norm)-2.0d0*lambda))/dble(na)) |
|
645 |
|
|
646 |
if (FRot.OR.FAlign) Call rotation_matrix(EigVec(1,4),U) |
|
647 |
IF (FAlign) THEN |
|
648 |
DO I=1,na |
|
649 |
geom2(1,i)=Coord2(1,i)*U(1,1)+Coord2(2,i)*U(2,1) |
|
650 |
& +Coord2(3,i)*U(3,1) +xc1 |
|
651 |
geom2(2,i)=Coord2(1,i)*U(1,2)+Coord2(2,i)*U(2,2) |
|
652 |
& +Coord2(3,i)*U(3,2) +yc1 |
|
653 |
geom2(3,i)=Coord2(1,i)*U(1,3)+Coord2(2,i)*U(2,3) |
|
654 |
& +Coord2(3,i)*U(3,3) +zc1 |
|
655 |
END DO |
|
656 |
END IF |
|
657 |
|
|
658 |
END |
|
659 |
|
|
660 |
|
|
661 |
!----------------------------------------------------------------------- |
|
662 |
subroutine rotation_matrix(q, U) |
|
663 |
!----------------------------------------------------------------------- |
|
664 |
! This subroutine constructs rotation matrix U from quaternion q. |
|
665 |
!----------------------------------------------------------------------- |
|
666 |
! This subroutine calculates RMSD using quaternions. |
|
667 |
! It is based on the F90 routine bu E. Coutsias |
|
668 |
! http://www.math.unm.edu/~vageli/homepage.html |
|
669 |
! I (PFL) have just translated it, and I have changed the diagonalization |
|
670 |
! subroutine. |
|
671 |
! I also made some changes to make it suitable for Cart package. |
|
672 |
!---------------------------------------------------------------------- |
|
673 |
!---------------------------------------------------------------------- |
|
674 |
! Copyright (C) 2004, 2005 Chaok Seok, Evangelos Coutsias and Ken Dill |
|
675 |
! UCSF, Univeristy of New Mexico, Seoul National University |
|
676 |
! Witten by Chaok Seok and Evangelos Coutsias 2004. |
|
677 |
|
|
678 |
! This library is free software; you can redistribute it and/or |
|
679 |
! modify it under the terms of the GNU Lesser General Public |
|
680 |
! License as published by the Free Software Foundation; either |
|
681 |
! version 2.1 of the License, or (at your option) any later version. |
|
682 |
! |
|
683 |
|
|
684 |
! This library is distributed in the hope that it will be useful, |
|
685 |
! but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
686 |
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
687 |
! Lesser General Public License for more details. |
|
688 |
! |
|
689 |
|
|
690 |
! You should have received a copy of the GNU Lesser General Public |
|
691 |
! License along with this library; if not, write to the Free Software |
|
692 |
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
693 |
!---------------------------------------------------------------------------- |
|
694 |
|
|
695 |
real*8 q(4) |
|
696 |
real*8 U(3,3) |
|
697 |
real*8 q0,q1,q2,q3,b0,b1,b2,b3,q00,q01,q02,q03 |
|
698 |
REAL*8 q11,q12,q13,q22,q23,q33 |
|
699 |
|
|
700 |
q0 = q(1) |
|
701 |
q1 = q(2) |
|
702 |
q2 = q(3) |
|
703 |
q3 = q(4) |
|
704 |
|
|
705 |
b0 = 2.0d0*q0 |
|
706 |
b1 = 2.0d0*q1 |
|
707 |
b2 = 2.0d0*q2 |
|
708 |
b3 = 2.0d0*q3 |
|
709 |
|
|
710 |
q00 = b0*q0-1.0d0 |
|
711 |
q01 = b0*q1 |
|
712 |
q02 = b0*q2 |
|
713 |
q03 = b0*q3 |
|
714 |
|
|
715 |
q11 = b1*q1 |
|
716 |
q12 = b1*q2 |
|
717 |
q13 = b1*q3 |
|
718 |
|
|
719 |
q22 = b2*q2 |
|
720 |
q23 = b2*q3 |
|
721 |
|
|
722 |
q33 = b3*q3 |
|
723 |
|
|
724 |
U(1,1) = q00+q11 |
|
725 |
U(1,2) = q12-q03 |
|
726 |
U(1,3) = q13+q02 |
|
727 |
|
|
728 |
U(2,1) = q12+q03 |
|
729 |
U(2,2) = q00+q22 |
|
730 |
U(2,3) = q23-q01 |
|
731 |
|
|
732 |
U(3,1) = q13-q02 |
|
733 |
U(3,2) = q23+q01 |
|
734 |
U(3,3) = q00+q33 |
|
735 |
|
|
736 |
end |
|
737 |
|
|
738 |
c============================================================ |
|
739 |
c |
|
740 |
c ++ diagonalisation par jacobi |
|
741 |
c vecteur propre i : V(i,i) |
|
742 |
c valeur propre i : D(i) |
|
743 |
c |
|
744 |
c============================================================ |
|
745 |
c |
|
746 |
SUBROUTINE JACOBI(A,N,D,V,max_N) |
|
747 |
IMPLICIT REAL*8 (A-H,O-Z) |
|
748 |
parameter (max_it=500) |
|
749 |
DIMENSION A(max_N,max_N),B(max_N),Z(max_N) |
|
750 |
DIMENSION V(max_N,max_N),D(max_N) |
|
751 |
|
|
752 |
|
|
753 |
DO 12 IP=1,N |
|
754 |
DO 11 IQ=1,N |
|
755 |
V(IP,IQ)=0. |
|
756 |
11 CONTINUE |
|
757 |
V(IP,IP)=1. |
|
758 |
12 CONTINUE |
|
759 |
DO 13 IP=1,N |
|
760 |
B(IP)=A(IP,IP) |
|
761 |
D(IP)=B(IP) |
|
762 |
Z(IP)=0. |
|
763 |
13 CONTINUE |
|
764 |
NROT=0 |
|
765 |
DO 24 I=1,max_it |
|
766 |
SM=0. |
|
767 |
DO 15 IP=1,N-1 |
|
768 |
DO 14 IQ=IP+1,N |
|
769 |
SM=SM+ABS(A(IP,IQ)) |
|
770 |
14 CONTINUE |
|
771 |
15 CONTINUE |
|
772 |
IF(SM.EQ.0.)RETURN |
|
773 |
IF(I.LT.4)THEN |
|
774 |
TRESH=0.2*SM/N**2 |
|
775 |
ELSE |
|
776 |
TRESH=0. |
|
777 |
ENDIF |
|
778 |
DO 22 IP=1,N-1 |
|
779 |
DO 21 IQ=IP+1,N |
|
780 |
G=100.*ABS(A(IP,IQ)) |
|
781 |
IF((I.GT.4).AND.(ABS(D(IP))+G.EQ.ABS(D(IP))) |
|
782 |
* .AND.(ABS(D(IQ))+G.EQ.ABS(D(IQ))))THEN |
|
783 |
A(IP,IQ)=0. |
|
784 |
ELSE IF(ABS(A(IP,IQ)).GT.TRESH)THEN |
|
785 |
H=D(IQ)-D(IP) |
|
786 |
IF(ABS(H)+G.EQ.ABS(H))THEN |
|
787 |
T=A(IP,IQ)/H |
|
788 |
ELSE |
|
789 |
THETA=0.5*H/A(IP,IQ) |
|
790 |
T=1./(ABS(THETA)+SQRT(1.+THETA**2)) |
|
791 |
IF(THETA.LT.0.)T=-T |
|
792 |
ENDIF |
|
793 |
C=1./SQRT(1+T**2) |
|
794 |
S=T*C |
|
795 |
TAU=S/(1.+C) |
|
796 |
H=T*A(IP,IQ) |
|
797 |
Z(IP)=Z(IP)-H |
|
798 |
Z(IQ)=Z(IQ)+H |
|
799 |
D(IP)=D(IP)-H |
|
800 |
D(IQ)=D(IQ)+H |
|
801 |
A(IP,IQ)=0. |
|
802 |
DO 16 J=1,IP-1 |
|
803 |
G=A(J,IP) |
|
804 |
H=A(J,IQ) |
|
805 |
A(J,IP)=G-S*(H+G*TAU) |
|
806 |
A(J,IQ)=H+S*(G-H*TAU) |
|
807 |
16 CONTINUE |
|
808 |
DO 17 J=IP+1,IQ-1 |
|
809 |
G=A(IP,J) |
|
810 |
H=A(J,IQ) |
|
811 |
A(IP,J)=G-S*(H+G*TAU) |
|
812 |
A(J,IQ)=H+S*(G-H*TAU) |
|
813 |
17 CONTINUE |
|
814 |
DO 18 J=IQ+1,N |
|
815 |
G=A(IP,J) |
|
816 |
H=A(IQ,J) |
|
817 |
A(IP,J)=G-S*(H+G*TAU) |
|
818 |
A(IQ,J)=H+S*(G-H*TAU) |
|
819 |
18 CONTINUE |
|
820 |
DO 19 J=1,N |
|
821 |
G=V(J,IP) |
|
822 |
H=V(J,IQ) |
|
823 |
V(J,IP)=G-S*(H+G*TAU) |
|
824 |
V(J,IQ)=H+S*(G-H*TAU) |
|
825 |
19 CONTINUE |
|
826 |
NROT=NROT+1 |
|
827 |
ENDIF |
|
828 |
21 CONTINUE |
|
829 |
22 CONTINUE |
|
830 |
DO 23 IP=1,N |
|
831 |
B(IP)=B(IP)+Z(IP) |
|
832 |
D(IP)=B(IP) |
|
833 |
Z(IP)=0. |
|
834 |
23 CONTINUE |
|
835 |
24 CONTINUE |
|
836 |
write(6,*) max_it,' iterations should never happen' |
|
837 |
STOP |
|
838 |
RETURN |
|
839 |
END |
|
840 |
c |
|
841 |
c============================================================ |
|
842 |
c |
|
843 |
c ++ trie des vecteur dans l'ordre croissant |
|
844 |
c |
|
845 |
c============================================================ |
|
846 |
c |
|
847 |
SUBROUTINE trie(nb_niv,ene,psi,max_niv) |
|
848 |
integer i,j,k,nb_niv,max_niv |
|
849 |
real*8 ene(max_niv),psi(max_niv,max_niv) |
|
850 |
real*8 a |
|
851 |
|
|
852 |
DO i=1,nb_niv |
|
853 |
DO j=i+1,nb_niv |
|
854 |
IF (ene(i) .GT. ene(j)) THEN |
|
855 |
c permutation |
|
856 |
a=ene(i) |
|
857 |
ene(i)=ene(j) |
|
858 |
ene(j)=a |
|
859 |
DO k=1,nb_niv |
|
860 |
a=psi(k,i) |
|
861 |
psi(k,i)=psi(k,j) |
|
862 |
psi(k,j)=a |
|
863 |
END DO |
|
864 |
END IF |
|
865 |
END DO |
|
866 |
END DO |
|
867 |
|
|
868 |
END |
|
869 |
|
utils/Xyz2Scan.f (revision 6) | ||
---|---|---|
1 |
program Xyz2irc |
|
2 |
! This programs reads a XYZ file and converts it into distances, |
|
3 |
! valence angle and dihedral angles. |
|
4 |
! It prints them as a function of the irc distance... |
|
5 |
!----------------------------------------------- |
|
6 |
! Input: name of the ROOT file of PAW |
|
7 |
! it also needs a file call list which has the following structure: |
|
8 |
! the first line gives the time when you want to start your analysis |
|
9 |
! one line contains the type of the value you want to follow, it can be |
|
10 |
! b for a Bond distance |
|
11 |
! a for an angle |
|
12 |
! d for a dihedral |
|
13 |
! this descriptor is followed by the number of the atoms involved ! |
|
14 |
! a typical file can be: |
|
15 |
! 3. |
|
16 |
! b 1 2 |
|
17 |
! b 2 3 |
|
18 |
! a 1 2 3 |
|
19 |
!---------------------------------------------- |
|
20 |
! Ouput: A files call Scan.dat |
|
21 |
! wich contains in the first lines the input file (as a reminder) |
|
22 |
! and then for each step the wanted values |
|
23 |
!------------------------------------------------ |
|
24 |
! Second version also reads the energy (as to be written after E= on |
|
25 |
! the comment line) |
|
26 |
!------------------------------------------------ |
|
27 |
! Third version contains a new command: c for Center of Mass |
|
28 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
29 |
! v 3.1 the c command now creates the center of mass... and allows |
|
30 |
! people to do whatever they want with it... |
|
31 |
! Syntax: c NbAt ListAt |
|
32 |
!! |
|
33 |
! v 3.2 |
|
34 |
! Added the p command that gives the oriented angle between two planes |
|
35 |
! Syntax: p At1 At2 At3 At4 At5 At6 |
|
36 |
! At1, At2, At3 define the first plane |
|
37 |
! At4, At5, At6 define the second plane |
|
38 |
! How it works: gives the angles between the normal of the two planes, defined by |
|
39 |
! the cross produc At2-At1 x At2-At3 etc. |
|
40 |
!!!! |
|
41 |
|
|
42 |
|
|
43 |
IMPLICIT NONE |
|
44 |
INTEGER*4 maxnat,MaxList |
|
45 |
Parameter (MaxNat=10000,MaxList=100) |
|
46 |
character*120 f1 |
|
47 |
REAL*8 geos(3,maxnat) |
|
48 |
character*33 fmt |
|
49 |
character*3 atoms(maxnat) |
|
50 |
character*5 Type |
|
51 |
Character*120 line |
|
52 |
INTEGER*4 NbPrint |
|
53 |
REAL*8 AU2PS,Pi |
|
54 |
! Mass is not used for now. |
|
55 |
! REAL*8 Mass(MaxNat) |
|
56 |
REAL*8 Ener, Conv |
|
57 |
INTEGER*4 At1,At2,At3,At4,At5,At6,IOOUT |
|
58 |
INTEGER*4 IArg, I, NNN, Ng, J |
|
59 |
|
|
60 |
INTEGER*4 Nat,NbDist, NbAngle, NbDie,NbP,NbCOM |
|
61 |
INTEGER*4 At1B(MaxList),At2B(MaxList) |
|
62 |
INTEGER*4 At1A(MaxList),At2A(MaxList),At3A(MaxList) |
|
63 |
INTEGER*4 At1D(MaxList),At2D(MaxList),At3D(MaxList), |
|
64 |
$ At4D(MaxList) |
|
65 |
INTEGER*4 At1p(MaxList),At2p(MaxList),At3p(MaxList), |
|
66 |
$ At4p(MaxList),At5p(MaxList),At6p(MaxList) |
|
67 |
INTEGER*4 AtCom(0:MaxList,MaxList) |
|
68 |
REAL*8 VB(MaxList),VA(MaxList),VD(MaxList),VCOM(MaxList) |
|
69 |
REAL*8 Vp(MaxList) |
|
70 |
LOGICAL FExist |
|
71 |
|
|
72 |
c INTEGER*4 iargc |
|
73 |
c external iargc |
|
74 |
|
|
75 |
COMMON /Indices/Nat,NbDist,NbAngle,NbDie,NbP,NbCom, At1B,At2B, |
|
76 |
& At1A,At2A,At3A,At1D,At2D,At3D,At4D,AtCom, |
|
77 |
& At1p,At2p,At3p,At4p,At5p,At6p |
|
78 |
COMMON /Values/VB,VA,VD,Vp,VCom |
|
79 |
COMMON /Const/AU2ps,Pi |
|
80 |
|
|
81 |
AU2PS=1./41341.37 |
|
82 |
NbPrint=100 |
|
83 |
Pi=dacos(-1.d0) |
|
84 |
IOOUT=13 |
|
85 |
Conv=1. |
|
86 |
iarg=iargc() |
|
87 |
if (iarg.lt.1) then |
|
88 |
WRITE(*,*) "==============================================" |
|
89 |
WRITE(*,*) "== ==" |
|
90 |
WRITE(*,*) "== Xyz2Scan: Xyz file to scan file ==" |
|
91 |
WRITE(*,*) "== ==" |
|
92 |
WRITE(*,*) "==============================================" |
|
93 |
WRITE(*,*) "Usage: xyz2scan XYZ_file " |
|
94 |
WRITE(*,*) "The XYZ file should follow the 'usual' format:" |
|
95 |
WRITE(*,*) "Number of atoms on the first line " |
|
96 |
WRITE(*,*) "Comment on the second line" |
|
97 |
WRITE(*,*) "The geometry is given in cartesian coordinates" |
|
98 |
WRITE(*,*) "with atom symbol and three coordinates:" |
|
99 |
WRITE(*,*) " C 0. 1. 0." |
|
100 |
WRITE(*,*) "" |
|
101 |
WRITE(*,*) " xyz2scan also needs a file called 'list' " |
|
102 |
WRITE(*,*) "which has the following structure:" |
|
103 |
WRITE(*,*) "Each line contains the type of the value you" |
|
104 |
WRITE(*,*) "want to follow, it can be:" |
|
105 |
WRITE(*,*) " - b for a Bond distance" |
|
106 |
WRITE(*,*) " - a for an angle" |
|
107 |
WRITE(*,*) " - d for a dihedral" |
|
108 |
WRITE(*,*) " - p for the oriented angle between two planes" |
|
109 |
WRITE(*,*) "This descriptor is followed by the number of" |
|
110 |
WRITE(*,*) "the atoms involved" |
|
111 |
WRITE(*,*) "One can also create 'barycenter' atoms that" |
|
112 |
WRITE(*,*) "can then be used as normal atoms." |
|
113 |
WRITE(*,*) "the descriptor is 'c' followed by the number" |
|
114 |
WRITE(*,*) "of atoms and the list of atoms:" |
|
115 |
WRITE(*,*) " c 2 1 5" |
|
116 |
WRITE(*,*) "A typical file can be:" |
|
117 |
WRITE(*,*) " b 1 2" |
|
118 |
WRITE(*,*) " b 2 3" |
|
119 |
WRITE(*,*) " a 1 2 3" |
|
120 |
WRITE(*,*) " " |
|
121 |
WRITE(*,*) "==============================================" |
|
122 |
write(*,*) 'XYZ filename:' |
|
123 |
read(*,'(a)') f1 |
|
124 |
else |
|
125 |
call getarg(1,f1) |
|
126 |
endif |
|
127 |
|
|
128 |
open(13,file='Scan.dat') |
|
129 |
|
|
130 |
INQUIRE(File='list',Exist=FExist) |
|
131 |
if (.NOT.FExist) THEN |
|
132 |
WRITE(*,*) "File *list* is missing" |
|
133 |
STOP |
|
134 |
END IF |
|
135 |
|
|
136 |
open(11,file=f1) |
|
137 |
READ(11,*) nnn |
|
138 |
close(11) |
|
139 |
|
|
140 |
|
|
141 |
if (nnn.GT.MaxNat) THEN |
|
142 |
WRITE(*,*) "Sorry but your system has too many atoms" |
|
143 |
WRITE(*,*) "Change the value of MaxNat in the source file" |
|
144 |
WRITE(*,*) "and then recompile." |
|
145 |
WRITE(*,*) "For information, now MaxNat=",MaxNat |
|
146 |
WRITE(*,*) "and you have ",nnn," atoms." |
|
147 |
STOP |
|
148 |
END IF |
|
149 |
|
|
150 |
Nat=nnn |
|
151 |
|
|
152 |
open(14,file='list') |
|
153 |
Type="d" |
|
154 |
DO WHILE (Type.ne."E") |
|
155 |
CALL READLINE(14,Type,Line) |
|
156 |
! WRITE(*,*) Line,Type |
|
157 |
if (Type.eq."b") THEN |
|
158 |
NbDist=NbDist+1 |
|
159 |
READ(Line,*) At1,At2 |
|
160 |
At1B(NbDist)=At1 |
|
161 |
At2B(NbDist)=At2 |
|
162 |
END IF |
|
163 |
if (Type.eq."a") THEN |
|
164 |
NbAngle=NbAngle+1 |
|
165 |
READ(Line,*) At1,At2,At3 |
|
166 |
At1A(NbAngle)=At1 |
|
167 |
At2A(NbAngle)=At2 |
|
168 |
At3A(NbAngle)=At3 |
|
169 |
END IF |
|
170 |
if (Type.eq."d") THEN |
|
171 |
NbDie=NbDie+1 |
|
172 |
READ(Line,*) At1,At2,At3,At4 |
|
173 |
At1D(NbDie)=At1 |
|
174 |
At2D(NbDie)=At2 |
|
175 |
At3D(NbDie)=At3 |
|
176 |
At4D(NbDie)=At4 |
|
177 |
! WRITE(13,'("# d ",4(A3,I3))') Atoms(At1),At1,Atoms(At2),At2, |
|
178 |
! & Atoms(At3),At3,Atoms(At4),At4 |
|
179 |
! WRITE(*,'("# d ",4(A3,I3))') Atoms(At1),At1,Atoms(At2),At2, |
|
180 |
! & Atoms(At3),At3,Atoms(At4),At4 |
|
181 |
|
|
182 |
END IF |
|
183 |
if (Type.eq."p") THEN |
|
184 |
NbP=NbP+1 |
|
185 |
READ(Line,*) At1,At2,At3,At4,At5,At6 |
|
186 |
At1p(NbP)=At1 |
|
187 |
At2p(NbP)=At2 |
|
188 |
At3p(NbP)=At3 |
|
189 |
At4p(NbP)=At4 |
|
190 |
At5p(NbP)=At5 |
|
191 |
At6p(NbP)=At6 |
|
192 |
END IF |
|
193 |
|
|
194 |
if (Type.eq."c") THEN |
|
195 |
NbCOM=NbCOM+1 |
|
196 |
READ(Line,*) At1,(AtCom(j,NbCOM),j=1,At1) |
|
197 |
AtCom(0,NbCOM)=At1 |
|
198 |
Atoms(nat+NbCom)="G" |
|
199 |
END IF |
|
200 |
|
|
201 |
END DO |
|
202 |
|
|
203 |
CLOSE(14) |
|
204 |
|
|
205 |
! We read one geoetry to get the atoms name |
|
206 |
open(11,file=f1) |
|
207 |
call rtraitem(11,nnn,ener,geos,atoms) |
|
208 |
close(11) |
|
209 |
|
|
210 |
|
|
211 |
! We write things |
|
212 |
! First NbCom |
|
213 |
if (NbCom.GE.1) THEN |
|
214 |
WRITE(*,*) "# Added center of mass" |
|
215 |
WRITE(IOOUT,*) "# Added center of mass" |
|
216 |
DO J=1,NbCom |
|
217 |
WRITE(IOOUT,'("# c ",I4,20(A3,I3))') AtCom(0,J), |
|
218 |
& (Atoms(AtCom(i,J)),AtCom(i,J),i=1,At1) |
|
219 |
WRITE(*,'("# c ",I4,20(A3,I3))') AtCom(0,J), |
|
220 |
& (Atoms(AtCom(i,J)),AtCom(i,J),i=1,At1) |
|
221 |
END DO |
|
222 |
END IF |
|
223 |
|
|
224 |
! Distances |
|
225 |
if (NbDist.GE.1) THEN |
|
226 |
WRITE(*,*) "# Bonds" |
|
227 |
WRITE(IOOUT,*) "# Bonds" |
|
228 |
DO J=1,NbDist |
|
229 |
At1= At1B(J) |
|
230 |
At2=At2B(J) |
|
231 |
WRITE(IOOUT,'("# b ",2(A3,I3))') Atoms(At1),At1, |
|
232 |
$ Atoms(At2),At2 |
|
233 |
WRITE(*,'("# b ",2(A3,I3))') Atoms(At1),At1,Atoms(At2),At2 |
|
234 |
END DO |
|
235 |
END IF |
|
236 |
|
|
237 |
! Angles |
|
238 |
if (NbAngle.GE.1) THEN |
|
239 |
WRITE(*,*) "# Angles" |
|
240 |
WRITE(IOOUT,*) "# Angles" |
|
241 |
DO J=1,NbAngle |
|
242 |
At1= At1A(J) |
|
243 |
At2= At2A(J) |
|
244 |
At3= At3A(J) |
|
245 |
WRITE(IOOUT,'("# a ",3(A3,I3))') Atoms(At1),At1,Atoms(At2), |
|
246 |
& At2, Atoms(At3),At3 |
|
247 |
WRITE(*,'("# a ",3(A3,I3))') Atoms(At1),At1,Atoms(At2), |
|
248 |
& At2, Atoms(At3),At3 |
|
249 |
|
|
250 |
END DO |
|
251 |
END IF |
|
252 |
|
|
253 |
|
|
254 |
! Dihedrals |
|
255 |
if (NbDie.GE.1) THEN |
|
256 |
WRITE(*,*) "# Dihedrals" |
|
257 |
WRITE(IOOUT,*) "# Dihedrals" |
|
258 |
DO J=1,NbDie |
|
259 |
At1= At1D(J) |
|
260 |
At2= At2D(J) |
|
261 |
At3= At3D(J) |
|
262 |
At4= At4D(J) |
|
263 |
WRITE(IOOUT,'("# d ",4(A3,I3))') Atoms(At1),At1,Atoms(At2) |
|
264 |
& ,At2,Atoms(At3),At3,Atoms(At4),At4 |
|
265 |
WRITE(*,'("# d ",4(A3,I3))') Atoms(At1),At1,Atoms(At2),At2, |
|
266 |
& Atoms(At3),At3,Atoms(At4),At4 |
|
267 |
END DO |
|
268 |
END IF |
|
269 |
|
|
270 |
! Planar angles |
|
271 |
if (NbP.GE.1) THEN |
|
272 |
WRITE(*,*) "# Planes angles" |
|
273 |
WRITE(IOOUT,*) "# Planes angles" |
|
274 |
DO J=1,NbP |
|
275 |
At1= At1p(J) |
|
276 |
At2= At2p(J) |
|
277 |
At3= At3p(J) |
|
278 |
At4= At4p(J) |
|
279 |
At5= At5p(J) |
|
280 |
At6= At6p(J) |
|
281 |
WRITE(IOOUT,'("# p ",8(A3,I3))') Atoms(At1),At1,Atoms(At2) |
|
282 |
& ,At2,Atoms(At3),At3,Atoms(At4),At4 |
|
283 |
& ,Atoms(At5),At5,Atoms(At6),At6 |
|
284 |
WRITE(*,'("# p ",8(A3,I3))') Atoms(At1),At1,Atoms(At2),At2, |
|
285 |
& Atoms(At3),At3,Atoms(At4),At4 |
|
286 |
& ,Atoms(At5),At5,Atoms(At6),At6 |
|
287 |
END DO |
|
288 |
END IF |
|
289 |
|
|
290 |
|
|
291 |
fmt='( (1X,F12.5),1X,F15.6)' |
|
292 |
write(fmt(2:4),'(i3)') NbDist+NbAngle+NbDie+NbP |
|
293 |
! write(*,*) nat3 |
|
294 |
! write(*,*) 'fmt:',fmt |
|
295 |
|
|
296 |
ng=1 |
|
297 |
|
|
298 |
open(11,file=f1) |
|
299 |
|
|
300 |
10 call rtraitem(11,nnn,ener,geos,atoms) |
|
301 |
! WRITE(*,*) nnn |
|
302 |
|
|
303 |
if (nnn.gt.0) then |
|
304 |
! We convert coordinates in a0 into Angstroem |
|
305 |
! write(*,*) "Analyse !" |
|
306 |
Call Analyse(geos) |
|
307 |
|
|
308 |
write(IOOUT,fmt) (VB(j)/Conv,j=1,NbDist), |
|
309 |
& (VA(j),j=1,NbAngle), |
|
310 |
& (VD(j),j=1,NbDie),(Vp(j),j=1,NbP),ener |
|
311 |
write(*,fmt) (VB(j)/Conv,j=1,NbDist), |
|
312 |
& (VA(j),j=1,NbAngle), |
|
313 |
& (VD(j),j=1,NbDie),(Vp(j),j=1,NbP),ener |
|
314 |
|
|
315 |
ng=ng+1 |
|
316 |
goto 10 |
|
317 |
endif |
|
318 |
WRITE(*,*) 'Found ',ng-1,' geometries' |
|
319 |
close(11) |
|
320 |
end |
|
321 |
|
|
322 |
!-------------------------------------------------------------- |
|
323 |
subroutine rtraitem(ifil,nnn,E,tab,atoms) |
|
324 |
! implicit real*8 (a-h,o-z) |
|
325 |
IMPLICIT NONE |
|
326 |
character*120 line |
|
327 |
character*3 Atoms(*) |
|
328 |
integer*4 nnn, IFil, Idx, I, J |
|
329 |
REAL*8 Tab(3,*), E |
|
330 |
|
|
331 |
|
|
332 |
read(ifil,*,err=99,end=99) nnn |
|
333 |
read(ifil,'(A)') line |
|
334 |
idx=index(line,'E') |
|
335 |
! WRITE(*,*) 'idx,line',idx,line |
|
336 |
if (idx/=0) THEN |
|
337 |
line=line(idx+2:) |
|
338 |
idx=index(line,"=") |
|
339 |
if (idx/=0) line=line(idx+1:) |
|
340 |
idx=index(line,":") |
|
341 |
if (idx/=0) line=line(idx+1:) |
|
342 |
read(line,*) E |
|
343 |
ELSE |
|
344 |
E=0. |
|
345 |
END IF |
|
346 |
|
|
347 |
! write(*,*) 'coucou',line |
|
348 |
do i=1,nnn |
|
349 |
read(ifil,'(A)',err=99,end=99) Line |
|
350 |
do while (line(1:1)==' ') |
|
351 |
line=line(2:) |
|
352 |
end do |
|
353 |
atoms(i)=line(1:3) |
|
354 |
! write(*,*) 'coucou atoms',atoms(i) |
|
355 |
do while (line(1:1).ne.' ') |
|
356 |
line=line(2:) |
|
357 |
end do |
|
358 |
! WRITE(*,*) 'coucou2:',i,line |
|
359 |
read(line,*) (tab(j,i),j=1,3) |
|
360 |
end do |
|
361 |
! WRITE(*,*) 'coucou:',nnn,tab(1,1) |
|
362 |
return |
|
363 |
99 nnn=0 |
|
364 |
! WRITE(*,*) 'Erreur lecture',ifil,nnn |
|
365 |
return |
|
366 |
end |
|
367 |
|
|
368 |
!-------------------------------------------------------------- |
|
369 |
|
|
370 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
371 |
! READLINE |
|
372 |
! This subroutine reads a line for a file, and converts |
|
373 |
! the first field into a character variable, and the rest into 4 integers |
|
374 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
375 |
|
|
376 |
SUBROUTINE READLINE(IOIN,Type,Line) |
|
377 |
|
|
378 |
IMPLICIT NONE |
|
379 |
CHARACTER Type*5,LINE*120 |
|
380 |
INTEGER i,IOIN |
|
381 |
READ(IOIN,'(A120)',ERR=999,END=999) LINE |
|
382 |
! WRITE(*,*) Line |
|
383 |
DO WHILE (LINE(1:1).eq.' ') |
|
384 |
LINE=LINE(2:) |
|
385 |
END DO |
|
386 |
|
|
387 |
i=1 |
|
388 |
DO WHILE (LINE(i:i).ne.' ') |
|
389 |
i=i+1 |
|
390 |
END DO |
|
391 |
|
|
392 |
if (i.ge.6) THEN |
|
393 |
WRITE(*,*) 'Pb with READLINE:',LINE |
|
394 |
GOTO 999 |
|
395 |
END IF |
|
396 |
Type=LINE(1:i-1) |
|
397 |
LINE=LINE(i:120) // " 0 0 0 0" |
|
398 |
|
|
399 |
RETURN |
|
400 |
999 Type="E" |
|
401 |
END |
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
SUBROUTINE Analyse(geos) |
|
406 |
|
|
407 |
IMPLICIT NONE |
|
408 |
INTEGER*4 MaxNat,MaxList |
|
409 |
parameter (maxnat=10000,MaxList=100) |
|
410 |
REAL*8 geos(3,maxnat) |
|
411 |
REAL*8 AU2PS,Pi |
|
412 |
INTEGER*4 i,j,k |
|
413 |
REAL*8 V1x,V1y,V1z,V2x,V2y,V2z,V3x,V3y,V3z |
|
414 |
REAL*8 d1,d2,ca,sa |
|
415 |
REAL*8 V4x,v4y,v4z,v5x,v5y,v5z |
|
416 |
REAL*8 COG(3) |
|
417 |
|
|
418 |
INTEGER*4 Nat,NbDist, NbAngle, NbDie,NbP,NbCOM |
|
419 |
INTEGER*4 At1B(MaxList),At2B(MaxList) |
|
420 |
INTEGER*4 At1A(MaxList),At2A(MaxList),At3A(MaxList) |
|
421 |
INTEGER*4 At1D(MaxList),At2D(MaxList),At3D(MaxList), |
|
422 |
$ At4D(MaxList) |
|
423 |
INTEGER*4 At1p(MaxList),At2p(MaxList),At3p(MaxList), |
|
424 |
$ At4p(MaxList),At5p(MaxList),At6p(MaxList) |
|
425 |
INTEGER*4 AtCom(0:MaxList,MaxList) |
|
426 |
REAL*8 VB(MaxList),VA(MaxList),VD(MaxList),VCOM(MaxList) |
|
427 |
REAL*8 Vp(MaxList) |
|
428 |
|
|
429 |
COMMON /Indices/Nat,NbDist,NbAngle,NbDie,NbP,NbCom, At1B,At2B, |
|
430 |
& At1A,At2A,At3A,At1D,At2D,At3D,At4D,AtCom, |
|
431 |
& At1p,At2p,At3p,At4p,At5p,At6p |
|
432 |
COMMON /Values/VB,VA,VD,Vp,VCom |
|
433 |
COMMON /Const/AU2ps,Pi |
|
434 |
|
|
435 |
DO I=1,Nat |
|
436 |
WRITE(*,'(1X,I3,3(1X,F15.6))') i,(geos(j,i),j=1,3) |
|
437 |
END DO |
|
438 |
|
|
439 |
! First, we create the Centre of Mass atoms |
|
440 |
DO i=1,NbCOM |
|
441 |
COG(1)=0. |
|
442 |
COG(2)=0. |
|
443 |
COG(3)=0. |
|
444 |
DO j=1,AtCOm(0,i) |
|
445 |
DO k=1,3 |
|
446 |
COG(k)=COG(k)+geos(k,AtCom(j,i)) |
|
447 |
END DO |
|
448 |
END DO |
|
449 |
DO k=1,3 |
|
450 |
COG(k)=COG(k)/AtCOM(0,i) |
|
451 |
geos(k,Nat+i)=COG(k) |
|
452 |
END DO |
|
453 |
END DO |
|
454 |
|
|
455 |
|
|
456 |
DO i=1,NbDist |
|
457 |
VB(i)=sqrt((geos(1,At1B(i))-geos(1,At2B(i)))**2+ |
|
458 |
& (geos(2,At1B(i))-geos(2,At2B(i)))**2+ |
|
459 |
& (geos(3,At1B(i))-geos(3,At2B(i)))**2) |
|
460 |
END DO |
|
461 |
DO i=1,NbAngle |
|
462 |
v1x=geos(1,At1A(i))-geos(1,At2A(i)) |
|
463 |
v1y=geos(2,At1A(i))-geos(2,At2A(i)) |
|
464 |
v1z=geos(3,At1A(i))-geos(3,At2A(i)) |
|
465 |
d1=sqrt(v1x**2+v1y**2+v1z**2) |
|
466 |
v2x=geos(1,At3A(i))-geos(1,At2A(i)) |
|
467 |
v2y=geos(2,At3A(i))-geos(2,At2A(i)) |
|
468 |
v2z=geos(3,At3A(i))-geos(3,At2A(i)) |
|
469 |
d2=sqrt(v2x**2+v2y**2+v2z**2) |
|
470 |
VA(i)=acos((v1x*v2x+v1y*v2y+v1z*v2z)/(d1*d2))*180./Pi |
|
471 |
END DO |
|
472 |
DO i=1,NbDie |
|
473 |
! WRITE(*,*) At1D(i),At2D(i),At3D(i),At4D(i) |
|
474 |
! WRITE(*,*) geos(1,At1D(i)),geos(2,At1D(i)),geos(3,At1D(i)) |
|
475 |
! WRITE(*,*) geos(1,At2D(i)),geos(2,At2D(i)),geos(3,At2D(i)) |
|
476 |
v1x=geos(1,At1D(i))-geos(1,At2D(i)) |
|
477 |
v1y=geos(2,At1D(i))-geos(2,At2D(i)) |
|
478 |
v1z=geos(3,At1D(i))-geos(3,At2D(i)) |
|
479 |
v2x=geos(1,At3D(i))-geos(1,At2D(i)) |
|
480 |
v2y=geos(2,At3D(i))-geos(2,At2D(i)) |
|
481 |
v2z=geos(3,At3D(i))-geos(3,At2D(i)) |
|
482 |
v3x=geos(1,At4D(i))-geos(1,At3D(i)) |
|
483 |
v3y=geos(2,At4D(i))-geos(2,At3D(i)) |
|
484 |
v3z=geos(3,At4D(i))-geos(3,At3D(i)) |
|
485 |
|
|
486 |
v4x=v1y*v2z-v1z*v2y |
|
487 |
v4y=v1z*v2x-v1x*v2z |
|
488 |
v4z=v1x*v2y-v1y*v2x |
|
489 |
d1=sqrt(v4x**2+v4y**2+v4z**2) |
|
490 |
v5x=-v2y*v3z+v2z*v3y |
|
491 |
v5y=-v2z*v3x+v2x*v3z |
|
492 |
v5z=-v2x*v3y+v2y*v3x |
|
493 |
d2=sqrt(v5x**2+v5y**2+v5z**2) |
|
494 |
if (d1<=1e-12) THEN |
|
495 |
WRITE(*,*) "WARNING: Dihedral, d1=0" |
|
496 |
ca=-1. |
|
497 |
sa=0. |
|
498 |
END IF |
|
499 |
if (d2<=1e-12) THEN |
|
500 |
WRITE(*,*) "WARNING: Dihedral, d2=0" |
|
501 |
ca=-1. |
|
502 |
sa=0. |
|
503 |
END IF |
|
504 |
ca=(v4x*v5x+v4y*v5y+v4z*v5z)/(d1*d2) |
|
505 |
sa=v1x*v5x+v1y*v5y+v1z*v5z |
|
506 |
if (abs(ca)>1.) ca=sign(1.d0,ca) |
|
507 |
VD(i)=acos(ca)*180./Pi |
|
508 |
if (sa<0.) VD(i)=-VD(i) |
|
509 |
! WRITE(*,*) "Dihe",v5x,v5y,v5z,v4x,v4y,v4z,d1,d2, |
|
510 |
! &(v4x*v5x+v4y*v5y+v4z*v5z)/(d1*d2),pi |
|
511 |
! WRITE(*,*) "Dihe ca,sa,d1,d2",ca,sa,d1,d2,acos(ca) |
|
512 |
|
|
513 |
|
|
514 |
!!!!!!!!! Another solution, more elegant ? |
|
515 |
! norm2=sqrt(v2x**2+v2y**2+v2z**2) |
|
516 |
! sa=(v4x*(v5y*v2z-v5z*v2y) |
|
517 |
! * -v4y*(v5x*v2z-v5z*v2x) |
|
518 |
! * +v4z*(v5x*v2y-v5y*v2x)) |
|
519 |
! * /(d1*norm2*d2) |
|
520 |
! angle_d=datan2(sa,ca)*180./Pi |
|
521 |
! WRITE(*,*) sa,ca,angle_d,d1,d2,norm2 |
|
522 |
! WRITE(*,*) VD(i),angle_d |
|
523 |
END DO |
|
524 |
|
|
525 |
DO i=1,NbP |
|
526 |
! v1= At2-At1 |
|
527 |
v1x=geos(1,At1p(i))-geos(1,At2p(i)) |
|
528 |
v1y=geos(2,At1p(i))-geos(2,At2p(i)) |
|
529 |
v1z=geos(3,At1p(i))-geos(3,At2p(i)) |
|
530 |
! v2=At2-At3 |
|
531 |
v2x=geos(1,At3p(i))-geos(1,At2p(i)) |
|
532 |
v2y=geos(2,At3p(i))-geos(2,At2p(i)) |
|
533 |
v2z=geos(3,At3p(i))-geos(3,At2p(i)) |
|
534 |
! v4 = v1 x v2 |
|
535 |
v4x=v1y*v2z-v1z*v2y |
|
536 |
v4y=v1z*v2x-v1x*v2z |
|
537 |
v4z=v1x*v2y-v1y*v2x |
|
538 |
d1=sqrt(v4x**2+v4y**2+v4z**2) |
|
539 |
|
|
540 |
! v3= At5-At4 |
|
541 |
v3x=geos(1,At4p(i))-geos(1,At5p(i)) |
|
542 |
v3y=geos(2,At4p(i))-geos(2,At5p(i)) |
|
543 |
v3z=geos(3,At4p(i))-geos(3,At5p(i)) |
|
544 |
! v2=At5-At6 |
|
545 |
v2x=geos(1,At6p(i))-geos(1,At5p(i)) |
|
546 |
v2y=geos(2,At6p(i))-geos(2,At5p(i)) |
|
547 |
v2z=geos(3,At6p(i))-geos(3,At5p(i)) |
|
548 |
|
|
549 |
! v5 = v3 x v2 |
|
550 |
v5x=v3y*v2z-v3z*v2y |
|
551 |
v5y=v3z*v2x-v3x*v2z |
|
552 |
v5z=v3x*v2y-v3y*v2x |
|
553 |
d2=sqrt(v5x**2+v5y**2+v5z**2) |
|
554 |
|
|
555 |
ca=(v4x*v5x+v4y*v5y+v4z*v5z)/(d1*d2) |
|
556 |
sa=v1x*v5x+v1y*v5y+v1z*v5z |
|
557 |
Vp(i)=acos(ca)*180./Pi |
|
558 |
if (sa<0.) Vp(i)=-Vp(i) |
|
559 |
! WRITE(*,*) "Dihe",v5x,v5y,v5z,v4x,v4y,v4z,d1,d2, |
|
560 |
! &(v4x*v5x+v4y*v5y+v4z*v5z)/(d1*d2),pi |
|
561 |
!!!!!!!!! Another solution, more elegant ? |
|
562 |
! See Dihedral routine |
|
563 |
END DO |
|
564 |
|
|
565 |
|
|
566 |
END |
utils/Xyz2Scan.f90 (revision 6) | ||
---|---|---|
1 |
program Xyz2irc |
|
2 |
! This programs reads a XYZ file and converts it into distances, |
|
3 |
! valence angle and dihedral angles. |
|
4 |
! It prints them as a function of the irc distance... |
|
5 |
!----------------------------------------------- |
|
6 |
! Input: name of the ROOT file of PAW |
|
7 |
! it also needs a file call list which has the following structure: |
|
8 |
! the first line gives the time when you want to start your analysis |
|
9 |
! one line contains the type of the value you want to follow, it can be |
|
10 |
! b for a Bond distance |
|
11 |
! a for an angle |
|
12 |
! d for a dihedral |
|
13 |
! this descriptor is followed by the number of the atoms involved ! |
|
14 |
! a typical file can be: |
|
15 |
! 3. |
|
16 |
! b 1 2 |
|
17 |
! b 2 3 |
|
18 |
! a 1 2 3 |
|
19 |
!---------------------------------------------- |
|
20 |
! Ouput: A files call Scan.dat |
|
21 |
! wich contains in the first lines the input file (as a reminder) |
|
22 |
! and then for each step the wanted values |
|
23 |
!------------------------------------------------ |
|
24 |
! Second version also reads the energy (as to be written after E= on |
|
25 |
! the comment line) |
|
26 |
!------------------------------------------------ |
|
27 |
! Third version contains a new command: c for Center of Mass |
|
28 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
29 |
! v 3.1 the c command now creates the center of mass... and allows |
|
30 |
! people to do whatever they want with it... |
|
31 |
! Syntax: c NbAt ListAt |
|
32 |
!! |
|
33 |
! v 3.2 |
|
34 |
! Added the p command that gives the oriented angle between two planes |
|
35 |
! Syntax: p At1 At2 At3 At4 At5 At6 |
|
36 |
! At1, At2, At3 define the first plane |
|
37 |
! At4, At5, At6 define the second plane |
|
38 |
! How it works: gives the angles between the normal of the two planes, defined by |
|
39 |
! the cross produc At2-At1 x At2-At3 etc. |
|
40 |
!!!! |
|
41 |
|
|
42 |
|
|
43 |
IMPLICIT NONE |
|
44 |
INTEGER(4), PARAMETER :: maxnat=10000,MaxList=100 |
|
45 |
|
|
46 |
CHARACTER(120) :: f1 |
|
47 |
REAL(8) :: geos(3,maxnat) |
|
48 |
CHARACTER(33) :: fmt |
|
49 |
CHARACTER(3) :: atoms(maxnat) |
|
50 |
character(5) :: Type |
|
51 |
CHARACTER(120) :: line |
Also available in: Unified diff