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