root / src / Calc_Xprim.f90 @ 3
Historique | Voir | Annoter | Télécharger (6,66 ko)
| 1 | 1 | pfleura2 | SUBROUTINE Calc_Xprim(nat,x,y,z,Coordinate,NPrim,XPrimitive,XPrimRef) |
|---|---|---|---|
| 2 | 1 | pfleura2 | ! |
| 3 | 1 | pfleura2 | ! This subroutine uses the description of a list of Coordinates |
| 4 | 1 | pfleura2 | ! to compute the values of the coordinates for a given geometry. |
| 5 | 1 | pfleura2 | ! |
| 6 | 1 | pfleura2 | !!!!!!!!!! |
| 7 | 1 | pfleura2 | ! Input: |
| 8 | 1 | pfleura2 | ! Na: INTEGER, Number of atoms |
| 9 | 1 | pfleura2 | ! x,y,z(Na): REAL, cartesian coordinates of the considered geometry |
| 10 | 1 | pfleura2 | ! Coordinate (Pointer(ListCoord)): description of the wanted coordiantes |
| 11 | 1 | pfleura2 | ! NPrim, INTEGER: Number of coordinates to compute |
| 12 | 1 | pfleura2 | ! |
| 13 | 1 | pfleura2 | ! Optional: XPrimRef(NPrim) REAL: array that contains coordinates values for |
| 14 | 1 | pfleura2 | ! a former geometry. Useful for Dihedral angles evolution... |
| 15 | 1 | pfleura2 | |
| 16 | 1 | pfleura2 | !!!!!!!!!!! |
| 17 | 1 | pfleura2 | ! Output: |
| 18 | 1 | pfleura2 | ! XPrimimite(NPrim) REAL: array that will contain the values of the coordinates |
| 19 | 1 | pfleura2 | ! |
| 20 | 1 | pfleura2 | !!!!!!!!! |
| 21 | 1 | pfleura2 | |
| 22 | 1 | pfleura2 | Use VarTypes |
| 23 | 1 | pfleura2 | Use Io_module |
| 24 | 1 | pfleura2 | Use Path_module, only : pi |
| 25 | 1 | pfleura2 | |
| 26 | 1 | pfleura2 | IMPLICIT NONE |
| 27 | 1 | pfleura2 | |
| 28 | 1 | pfleura2 | Type (ListCoord), POINTER :: Coordinate |
| 29 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: Nat,NPrim |
| 30 | 1 | pfleura2 | REAL(KREAL), INTENT(IN) :: x(Nat), y(Nat), z(Nat) |
| 31 | 1 | pfleura2 | REAL(KREAL), INTENT(IN), OPTIONAL :: XPrimRef(NPrim) |
| 32 | 1 | pfleura2 | REAL(KREAL), INTENT(OUT) :: XPrimitive(NPrim) |
| 33 | 1 | pfleura2 | |
| 34 | 1 | pfleura2 | |
| 35 | 1 | pfleura2 | Type (ListCoord), POINTER :: ScanCoord |
| 36 | 1 | pfleura2 | |
| 37 | 1 | pfleura2 | real(KREAL) :: vx1,vy1,vz1,norm1 |
| 38 | 1 | pfleura2 | real(KREAL) :: vx2,vy2,vz2,norm2 |
| 39 | 1 | pfleura2 | real(KREAL) :: vx3,vy3,vz3,norm3 |
| 40 | 1 | pfleura2 | real(KREAL) :: vx4,vy4,vz4,norm4 |
| 41 | 1 | pfleura2 | real(KREAL) :: vx5,vy5,vz5,norm5 |
| 42 | 1 | pfleura2 | |
| 43 | 2 | pfleura2 | INTEGER(KINT) :: I |
| 44 | 1 | pfleura2 | |
| 45 | 1 | pfleura2 | REAL(KREAL) :: DiheTmp |
| 46 | 1 | pfleura2 | |
| 47 | 1 | pfleura2 | LOGICAL :: debug, debugPFL |
| 48 | 1 | pfleura2 | |
| 49 | 1 | pfleura2 | INTERFACE |
| 50 | 1 | pfleura2 | function valid(string) result (isValid) |
| 51 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 52 | 1 | pfleura2 | logical :: isValid |
| 53 | 1 | pfleura2 | END function VALID |
| 54 | 1 | pfleura2 | |
| 55 | 1 | pfleura2 | FUNCTION angle(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2) |
| 56 | 1 | pfleura2 | use Path_module, only : Pi,KINT, KREAL |
| 57 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
| 58 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
| 59 | 1 | pfleura2 | real(KREAL) :: angle |
| 60 | 1 | pfleura2 | END FUNCTION ANGLE |
| 61 | 1 | pfleura2 | |
| 62 | 1 | pfleura2 | FUNCTION SinAngle(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2) |
| 63 | 1 | pfleura2 | use Path_module, only : Pi,KINT, KREAL |
| 64 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
| 65 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
| 66 | 1 | pfleura2 | real(KREAL) :: SinAngle |
| 67 | 1 | pfleura2 | END FUNCTION SINANGLE |
| 68 | 1 | pfleura2 | |
| 69 | 1 | pfleura2 | |
| 70 | 1 | pfleura2 | FUNCTION angle_d(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2,v3x,v3y,v3z,norm3) |
| 71 | 1 | pfleura2 | use Path_module, only : Pi,KINT, KREAL |
| 72 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
| 73 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
| 74 | 1 | pfleura2 | real(KREAL) :: v3x,v3y,v3z,norm3 |
| 75 | 1 | pfleura2 | real(KREAL) :: angle_d,ca,sa |
| 76 | 1 | pfleura2 | END FUNCTION ANGLE_D |
| 77 | 1 | pfleura2 | |
| 78 | 1 | pfleura2 | END INTERFACE |
| 79 | 1 | pfleura2 | |
| 80 | 1 | pfleura2 | |
| 81 | 1 | pfleura2 | debug=valid("Calc_Xprim")
|
| 82 | 1 | pfleura2 | debugPFL=valid("BakerPFL")
|
| 83 | 1 | pfleura2 | if (debug) WRITE(*,*) "============= Entering Cal_XPrim ==============" |
| 84 | 1 | pfleura2 | |
| 85 | 1 | pfleura2 | |
| 86 | 1 | pfleura2 | IF (debug) THEN |
| 87 | 1 | pfleura2 | WRITE(*,*) "DBG Calc_Xprim, geom" |
| 88 | 1 | pfleura2 | DO I=1,Nat |
| 89 | 1 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F15.3))') I,X(I),y(i),z(i) |
| 90 | 1 | pfleura2 | END DO |
| 91 | 1 | pfleura2 | WRITE(*,*) "XPrimRef" |
| 92 | 1 | pfleura2 | WRITE(*,'(15(1X,F10.6))') XPrimRef |
| 93 | 1 | pfleura2 | END IF |
| 94 | 1 | pfleura2 | |
| 95 | 1 | pfleura2 | |
| 96 | 1 | pfleura2 | ! WRITE(*,*) "Coordinate:",associated(Coordinate) |
| 97 | 1 | pfleura2 | |
| 98 | 1 | pfleura2 | ScanCoord=>Coordinate |
| 99 | 1 | pfleura2 | |
| 100 | 1 | pfleura2 | ! WRITE(*,*) "ScanCoord:",associated(ScanCoord),ScanCoord%Type |
| 101 | 1 | pfleura2 | |
| 102 | 1 | pfleura2 | ! WRITE(*,*) "coucou" |
| 103 | 1 | pfleura2 | I=0 ! index for the NPrim (NPrim is the number of primitive coordinates). |
| 104 | 1 | pfleura2 | DO WHILE (Associated(ScanCoord%next)) |
| 105 | 1 | pfleura2 | I=I+1 |
| 106 | 1 | pfleura2 | ! WRITE(*,*) i |
| 107 | 1 | pfleura2 | SELECT CASE (ScanCoord%Type) |
| 108 | 1 | pfleura2 | CASE ('BOND')
|
| 109 | 1 | pfleura2 | Call vecteur(ScanCoord%At2,ScanCoord%At1,x,y,z,vx2,vy2,vz2,Norm2) |
| 110 | 1 | pfleura2 | Xprimitive(I) = Norm2 |
| 111 | 1 | pfleura2 | CASE ('ANGLE')
|
| 112 | 1 | pfleura2 | Call vecteur(ScanCoord%At2,ScanCoord%At3,x,y,z,vx1,vy1,vz1,Norm1) |
| 113 | 1 | pfleura2 | Call vecteur(ScanCoord%At2,ScanCoord%At1,x,y,z,vx2,vy2,vz2,Norm2) |
| 114 | 1 | pfleura2 | Xprimitive(I) = angle(vx1,vy1,vz1,Norm1,vx2,vy2,vz2,Norm2)*Pi/180. |
| 115 | 1 | pfleura2 | CASE ('DIHEDRAL')
|
| 116 | 1 | pfleura2 | Call vecteur(ScanCoord%At2,ScanCoord%At1,x,y,z,vx1,vy1,vz1,Norm1) |
| 117 | 1 | pfleura2 | Call vecteur(ScanCoord%At2,ScanCoord%At3,x,y,z,vx2,vy2,vz2,Norm2) |
| 118 | 1 | pfleura2 | Call vecteur(ScanCoord%At3,ScanCoord%At4,x,y,z,vx3,vy3,vz3,Norm3) |
| 119 | 2 | pfleura2 | Call produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, & |
| 120 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
| 121 | 2 | pfleura2 | Call produit_vect(vx3,vy3,vz3,vx2,vy2,vz2, & |
| 122 | 1 | pfleura2 | vx5,vy5,vz5,norm5) |
| 123 | 1 | pfleura2 | |
| 124 | 1 | pfleura2 | DiheTmp= angle_d(vx4,vy4,vz4,norm4,vx5,vy5,vz5,norm5, & |
| 125 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
| 126 | 1 | pfleura2 | Xprimitive(I) = DiheTmp*Pi/180. |
| 127 | 1 | pfleura2 | ! PFL 15th March 2008 -> |
| 128 | 1 | pfleura2 | ! I think that the test on changes less than Pi should be enough |
| 129 | 1 | pfleura2 | !! We treat large dihedral angles differently as +180=-180 mathematically and physically |
| 130 | 1 | pfleura2 | !! but this causes lots of troubles when converting baker to cart. |
| 131 | 1 | pfleura2 | !! So we ensure that large dihedral angles always have the same sign |
| 132 | 1 | pfleura2 | ! if (abs(ScanCoord%SignDihedral).NE.1) THEN |
| 133 | 1 | pfleura2 | ! ScanCoord%SignDihedral=Int(Sign(1.D0,DiheTmp)) |
| 134 | 1 | pfleura2 | ! ELSE |
| 135 | 1 | pfleura2 | ! If ((abs(DiheTmp).GE.170.D0).AND.(Sign(1.,DiheTmp)*ScanCoord%SignDihedral<0)) THEN |
| 136 | 1 | pfleura2 | ! Xprimitive(I) = DiheTmp*Pi/180.+ ScanCoord%SignDihedral*2.*Pi |
| 137 | 1 | pfleura2 | ! END IF |
| 138 | 1 | pfleura2 | ! END IF |
| 139 | 1 | pfleura2 | !!!! <- PFL 15th March 2008 |
| 140 | 1 | pfleura2 | ! Another test... will all this be consistent ??? |
| 141 | 1 | pfleura2 | ! We want the shortest path, so we check that the change in dihedral angles is less than Pi: |
| 142 | 1 | pfleura2 | IF (Present(XPrimRef)) THEN |
| 143 | 1 | pfleura2 | IF (abs(Xprimitive(I)-XPrimRef(I)).GE.Pi) THEN |
| 144 | 1 | pfleura2 | if (debug) THEN |
| 145 | 1 | pfleura2 | WRITE(*,*) "Pb dihedral, i,Xprimivite,XPrimref=",i,XPrimitive(I),XPrimRef(I) |
| 146 | 1 | pfleura2 | WRITE(*,*) "In deg Xprimivite,XPrimref=",XPrimitive(I)*180./Pi,XPrimRef(I)*180/Pi |
| 147 | 1 | pfleura2 | END IF |
| 148 | 1 | pfleura2 | if ((Xprimitive(I)-XPrimRef(I)).GE.Pi) THEN |
| 149 | 1 | pfleura2 | Xprimitive(I)=Xprimitive(I)-2.d0*Pi |
| 150 | 1 | pfleura2 | ELSE |
| 151 | 1 | pfleura2 | Xprimitive(I)=Xprimitive(I)+2.d0*Pi |
| 152 | 1 | pfleura2 | END IF |
| 153 | 1 | pfleura2 | END IF |
| 154 | 1 | pfleura2 | if (debug) WRITE(*,*) " New Xprimivite",XPrimitive(I),XPrimitive(I)*180./Pi |
| 155 | 1 | pfleura2 | END IF |
| 156 | 1 | pfleura2 | END SELECT |
| 157 | 1 | pfleura2 | ScanCoord => ScanCoord%next |
| 158 | 1 | pfleura2 | END DO ! matches DO WHILE (Associated(ScanCoord%next)) |
| 159 | 1 | pfleura2 | |
| 160 | 1 | pfleura2 | |
| 161 | 1 | pfleura2 | |
| 162 | 1 | pfleura2 | IF (debug) THEN |
| 163 | 1 | pfleura2 | WRITE(*,*) "DBG Calc_Xprim Values" |
| 164 | 1 | pfleura2 | |
| 165 | 1 | pfleura2 | ScanCoord=>Coordinate |
| 166 | 1 | pfleura2 | I=0 ! index for the NPrim (NPrim is the number of primitive coordinates). |
| 167 | 1 | pfleura2 | DO WHILE (Associated(ScanCoord%next)) |
| 168 | 1 | pfleura2 | I=I+1 |
| 169 | 1 | pfleura2 | SELECT CASE (ScanCoord%Type) |
| 170 | 1 | pfleura2 | CASE ('BOND')
|
| 171 | 1 | pfleura2 | WRITE(*,'(1X,I3,":",I5," - ",I5," = ",F15.6)') I,ScanCoord%At1,ScanCoord%At2,Xprimitive(I) |
| 172 | 1 | pfleura2 | CASE ('ANGLE')
|
| 173 | 1 | pfleura2 | WRITE(*,'(1X,I3,":",I5," - ",I5," - ",I5," = ",F15.6)') I,ScanCoord%At1, & |
| 174 | 1 | pfleura2 | ScanCoord%At2, ScanCoord%At3,Xprimitive(I)*180./Pi |
| 175 | 1 | pfleura2 | CASE ('DIHEDRAL')
|
| 176 | 1 | pfleura2 | WRITE(*,'(1X,I3,":",I5," - ",I5," - ",I5," - ",I5," = ",F15.6)') I,ScanCoord%At1,& |
| 177 | 1 | pfleura2 | ScanCoord%At2, ScanCoord%At3,ScanCoord%At4,Xprimitive(I)*180./Pi |
| 178 | 1 | pfleura2 | END SELECT |
| 179 | 1 | pfleura2 | ScanCoord => ScanCoord%next |
| 180 | 1 | pfleura2 | END DO ! matches DO WHILE (Associated(ScanCoord%next)) |
| 181 | 1 | pfleura2 | END IF |
| 182 | 1 | pfleura2 | if (debug) WRITE(*,*) "============= Cal_XPrim OVER ==============" |
| 183 | 1 | pfleura2 | END SUBROUTINE Calc_Xprim |