hdiff output

r30234/djwgr1.f90 2016-04-05 15:30:23.249116998 +0100 r30233/djwgr1.f90 2016-04-05 15:30:23.841124842 +0100
 28: INTEGER NATOMS, J1, J2, J3, J4, NPOS1, NPOS2 28: INTEGER NATOMS, J1, J2, J3, J4, NPOS1, NPOS2
 29: DOUBLE PRECISION X(3*NATOMS), V(3*NATOMS), ENERGY, DUMMY2, DUMMY3, DUMMY, DIST, SIGMA, XDUMM, RHO, RDIST, RAD, EPSEFF 29: DOUBLE PRECISION X(3*NATOMS), V(3*NATOMS), ENERGY, DUMMY2, DUMMY3, DUMMY, DIST, SIGMA, XDUMM, RHO, RDIST, RAD, EPSEFF
 30: DOUBLE PRECISION FATT, DFATT, DDFATT, FREP, DFREP, DDFREP 30: DOUBLE PRECISION FATT, DFATT, DDFATT, FREP, DFREP, DDFREP
 31:  31: 
 32: ! 32: !
 33: ! Derivatives of the pairwise site-site terms in terms of distance 33: ! Derivatives of the pairwise site-site terms in terms of distance
 34: ! 34: !
 35: FATT(RHO,XDUMM)=-1.0D0 + (1.0D0 - EXP(RHO*(1.0D0 - XDUMM)))**2 35: FATT(RHO,XDUMM)=-1.0D0 + (1.0D0 - EXP(RHO*(1.0D0 - XDUMM)))**2
 36: DFATT(RHO,XDUMM)=2.0D0*(-EXP(2.0D0*RHO*(1.0D0-XDUMM)) + EXP(RHO*(1.0D0-XDUMM)))*RHO 36: DFATT(RHO,XDUMM)=2.0D0*(-EXP(2.0D0*RHO*(1.0D0-XDUMM)) + EXP(RHO*(1.0D0-XDUMM)))*RHO
 37: DDFATT(RHO,XDUMM)=-2.0D0*(-2.0D0*EXP(2.0D0*RHO*(1.0D0-XDUMM)) + EXP(RHO*(1.0D0-XDUMM)))*RHO**2 37: DDFATT(RHO,XDUMM)=-2.0D0*(-2.0D0*EXP(2.0D0*RHO*(1.0D0-XDUMM)) + EXP(RHO*(1.0D0-XDUMM)))*RHO**2
  38: ! FATT(RHO,XDUMM)=0.0D0
  39: ! DFATT(RHO,XDUMM)=0.0D0
  40: ! DDFATT(RHO,XDUMM)=0.0D0
 38: FREP(SIGMA,XDUMM)=(SIGMA/XDUMM)**12 41: FREP(SIGMA,XDUMM)=(SIGMA/XDUMM)**12
 39: DFREP(SIGMA,XDUMM)=-12.0D0*(SIGMA/XDUMM)**12/XDUMM 42: DFREP(SIGMA,XDUMM)=-12.0D0*(SIGMA/XDUMM)**12/XDUMM
 40: DDFREP(SIGMA,XDUMM)=156.0D0*(SIGMA/XDUMM)**12/XDUMM**2 43: DDFREP(SIGMA,XDUMM)=156.0D0*(SIGMA/XDUMM)**12/XDUMM**2
  44: ! FREP(SIGMA,XDUMM)=0.0D0
  45: ! DFREP(SIGMA,XDUMM)=0.0D0
  46: ! DDFREP(SIGMA,XDUMM)=0.0D0
 41:  47: 
 42: ENERGY=0.0D0 48: ENERGY=0.0D0
 43: IF (GTEST) V(1:3*NATOMS)=0.0D0 49: IF (GTEST) V(1:3*NATOMS)=0.0D0
 44: IF (SECT) HESS(1:3*NATOMS,1:3*NATOMS)=0.0D0 50: IF (SECT) HESS(1:3*NATOMS,1:3*NATOMS)=0.0D0
 45:  51: 
 46: ! 52: !
 47: ! 5 Morse plus two axial site pentamers from 53: ! 5 Morse plus two axial site pentamers from
 48: ! S.N. Fejer, T. James, J. Hernandez-Rojas and D.J. Wales, Phys. Chem. Chem. Phys., 11, 2098-2104 (2009).  54: ! S.N. Fejer, T. James, J. Hernandez-Rojas and D.J. Wales, Phys. Chem. Chem. Phys., 11, 2098-2104 (2009). 
 49: ! Energy Landscapes for Shells Assembled from Pentagonal and Hexagonal Pyramids  55: ! Energy Landscapes for Shells Assembled from Pentagonal and Hexagonal Pyramids 
 50: ! 56: !
 58: ! 64: !
 59: ! Three different sorts of axial repulsion 65: ! Three different sorts of axial repulsion
 60: ! 66: !
 61:       NPOS1=RIGIDGROUPS(NSITEPERBODY(J1)-1,J1) 67:       NPOS1=RIGIDGROUPS(NSITEPERBODY(J1)-1,J1)
 62:       NPOS2=RIGIDGROUPS(NSITEPERBODY(J2)-1,J2) 68:       NPOS2=RIGIDGROUPS(NSITEPERBODY(J2)-1,J2)
 63:       DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2) 69:       DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2)
 64:       ENERGY=ENERGY+EPSEFF*FREP(SIGMA,DIST)  ! axial-axial repulsive term 70:       ENERGY=ENERGY+EPSEFF*FREP(SIGMA,DIST)  ! axial-axial repulsive term
 65:       IF (GTEST) THEN 71:       IF (GTEST) THEN
 66:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST) 72:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)
 67:          RDIST=1.0D0/DIST 73:          RDIST=1.0D0/DIST
 68:          CALL DJWGR1GRAD(NATOMS,NPOS1,NPOS2,DUMMY2,RDIST,X,V) 74:          V(3*(NPOS1-1)+1)=V(3*(NPOS1-1)+1)+DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
  75:          V(3*(NPOS1-1)+2)=V(3*(NPOS1-1)+2)+DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
  76:          V(3*(NPOS1-1)+3)=V(3*(NPOS1-1)+3)+DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
  77:          V(3*(NPOS2-1)+1)=V(3*(NPOS2-1)+1)-DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
  78:          V(3*(NPOS2-1)+2)=V(3*(NPOS2-1)+2)-DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
  79:          V(3*(NPOS2-1)+3)=V(3*(NPOS2-1)+3)-DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
 69:       ENDIF 80:       ENDIF
 70:       IF (SECT) THEN 81:       IF (SECT) THEN
 71:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST) 82:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)
 72:          DUMMY3=EPSEFF*DDFREP(SIGMA,DIST) 83:          DUMMY3=EPSEFF*DDFREP(SIGMA,DIST)
 73:          RDIST=1.0D0/DIST 84:          RDIST=1.0D0/DIST
 74:          CALL DJWGR1SEC(NATOMS,NPOS1,NPOS2,DUMMY3,DUMMY2,RDIST,X) 85: ! same rigid body, same Cartesian component
  86:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)+ &
  87:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
  88:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)+ &
  89:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
  90:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)+ &
  91:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
  92:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)+ &
  93:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
  94:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)+ &
  95:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
  96:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)+ &
  97:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
  98: ! same rigid body, different Cartesian component
  99:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)+ &
 100:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 101:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)+ &
 102:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 103:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)+ &
 104:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 105:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)+ &
 106:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 107:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)+ &
 108:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 109:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)+ &
 110:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 111:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)+ &
 112:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 113:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)+ &
 114:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 115:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)+ &
 116:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 117:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)+ &
 118:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 119:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)+ &
 120:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 121:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)+ &
 122:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 123: ! different rigid body, same Cartesian component
 124:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)- &
 125:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 126:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)- &
 127:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 128:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)- &
 129:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 130:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)- &
 131:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 132:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)- &
 133:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 134:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)- &
 135:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 136: ! different rigid body, different Cartesian component
 137:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)- &
 138:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 139:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)- &
 140:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 141:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)- &
 142:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 143:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)- &
 144:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 145:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)- &
 146:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 147:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)- &
 148:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 149:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)- &
 150:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 151:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)- &
 152:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 153:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)- &
 154:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 155:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)- &
 156:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 157:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)- &
 158:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 159:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)- &
 160:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 75:       ENDIF161:       ENDIF
 76:  
 77:       NPOS1=RIGIDGROUPS(NSITEPERBODY(J1)-1,J1)162:       NPOS1=RIGIDGROUPS(NSITEPERBODY(J1)-1,J1)
 78:       NPOS2=RIGIDGROUPS(NSITEPERBODY(J2),J2)163:       NPOS2=RIGIDGROUPS(NSITEPERBODY(J2),J2)
 79:       DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2)164:       DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2)
 80:       ENERGY=ENERGY+EPSEFF*FREP(SIGMA,DIST)  ! axial-axial repulsive term165:       ENERGY=ENERGY+EPSEFF*FREP(SIGMA,DIST)  ! axial-axial repulsive term
 81:       IF (GTEST) THEN166:       IF (GTEST) THEN
 82:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)167:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)
 83:          RDIST=1.0D0/DIST168:          RDIST=1.0D0/DIST
 84:          CALL DJWGR1GRAD(NATOMS,NPOS1,NPOS2,DUMMY2,RDIST,X,V)169:          V(3*(NPOS1-1)+1)=V(3*(NPOS1-1)+1)+DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
 170:          V(3*(NPOS1-1)+2)=V(3*(NPOS1-1)+2)+DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
 171:          V(3*(NPOS1-1)+3)=V(3*(NPOS1-1)+3)+DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
 172:          V(3*(NPOS2-1)+1)=V(3*(NPOS2-1)+1)-DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
 173:          V(3*(NPOS2-1)+2)=V(3*(NPOS2-1)+2)-DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
 174:          V(3*(NPOS2-1)+3)=V(3*(NPOS2-1)+3)-DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
 85:       ENDIF175:       ENDIF
 86:       IF (SECT) THEN176:       IF (SECT) THEN
 87:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)177:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)
 88:          DUMMY3=EPSEFF*DDFREP(SIGMA,DIST)178:          DUMMY3=EPSEFF*DDFREP(SIGMA,DIST)
 89:          RDIST=1.0D0/DIST179:          RDIST=1.0D0/DIST
 90:          CALL DJWGR1SEC(NATOMS,NPOS1,NPOS2,DUMMY3,DUMMY2,RDIST,X)180: ! same rigid body, same Cartesian component
 181:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)+ &
 182:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
 183:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)+ &
 184:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 185:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)+ &
 186:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 187:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)+ &
 188:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
 189:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)+ &
 190:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 191:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)+ &
 192:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 193: ! same rigid body, different Cartesian component
 194:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)+ &
 195:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 196:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)+ &
 197:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 198:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)+ &
 199:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 200:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)+ &
 201:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 202:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)+ &
 203:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 204:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)+ &
 205:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 206:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)+ &
 207:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 208:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)+ &
 209:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 210:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)+ &
 211:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 212:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)+ &
 213:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 214:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)+ &
 215:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 216:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)+ &
 217:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 218: ! different rigid body, same Cartesian component
 219:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)- &
 220:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 221:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)- &
 222:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 223:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)- &
 224:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 225:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)- &
 226:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 227:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)- &
 228:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 229:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)- &
 230:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 231: ! different rigid body, different Cartesian component
 232:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)- &
 233:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 234:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)- &
 235:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 236:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)- &
 237:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 238:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)- &
 239:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 240:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)- &
 241:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 242:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)- &
 243:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 244:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)- &
 245:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 246:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)- &
 247:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 248:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)- &
 249:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 250:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)- &
 251:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 252:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)- &
 253:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 254:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)- &
 255:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 91:       ENDIF256:       ENDIF
 92:  
 93:       NPOS1=RIGIDGROUPS(NSITEPERBODY(J1),J1)257:       NPOS1=RIGIDGROUPS(NSITEPERBODY(J1),J1)
 94:       NPOS2=RIGIDGROUPS(NSITEPERBODY(J2)-1,J2)258:       NPOS2=RIGIDGROUPS(NSITEPERBODY(J2)-1,J2)
 95:       DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2)259:       DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2)
 96:       ENERGY=ENERGY+EPSEFF*FREP(SIGMA,DIST)  ! axial 2-axial repulsive term260:       ENERGY=ENERGY+EPSEFF*FREP(SIGMA,DIST)  ! axial 2-axial repulsive term
 97:       IF (GTEST) THEN261:       IF (GTEST) THEN
 98:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)262:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)
 99:          RDIST=1.0D0/DIST263:          RDIST=1.0D0/DIST
100:          CALL DJWGR1GRAD(NATOMS,NPOS1,NPOS2,DUMMY2,RDIST,X,V)264:          V(3*(NPOS1-1)+1)=V(3*(NPOS1-1)+1)+DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
 265:          V(3*(NPOS1-1)+2)=V(3*(NPOS1-1)+2)+DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
 266:          V(3*(NPOS1-1)+3)=V(3*(NPOS1-1)+3)+DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
 267:          V(3*(NPOS2-1)+1)=V(3*(NPOS2-1)+1)-DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
 268:          V(3*(NPOS2-1)+2)=V(3*(NPOS2-1)+2)-DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
 269:          V(3*(NPOS2-1)+3)=V(3*(NPOS2-1)+3)-DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
101:       ENDIF270:       ENDIF
102:       IF (SECT) THEN271:       IF (SECT) THEN
103:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)272:          DUMMY2=EPSEFF*DFREP(SIGMA,DIST)
104:          DUMMY3=EPSEFF*DDFREP(SIGMA,DIST)273:          DUMMY3=EPSEFF*DDFREP(SIGMA,DIST)
105:          RDIST=1.0D0/DIST274:          RDIST=1.0D0/DIST
106:          CALL DJWGR1SEC(NATOMS,NPOS1,NPOS2,DUMMY3,DUMMY2,RDIST,X)275: ! same rigid body, same Cartesian component
 276:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)+ &
 277:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
 278:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)+ &
 279:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 280:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)+ &
 281:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 282:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)+ &
 283:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
 284:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)+ &
 285:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 286:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)+ &
 287:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 288: ! same rigid body, different Cartesian component
 289:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)+ &
 290:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 291:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)+ &
 292:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 293:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)+ &
 294:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 295:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)+ &
 296:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 297:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)+ &
 298:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 299:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)+ &
 300:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 301:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)+ &
 302:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 303:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)+ &
 304:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 305:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)+ &
 306:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 307:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)+ &
 308:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 309:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)+ &
 310:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 311:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)+ &
 312:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 313: ! different rigid body, same Cartesian component
 314:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)- &
 315:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 316:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)- &
 317:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 318:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)- &
 319:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 320:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)- &
 321:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 322:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)- &
 323:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 324:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)- &
 325:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 326: ! different rigid body, different Cartesian component
 327:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)- &
 328:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 329:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)- &
 330:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 331:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)- &
 332:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 333:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)- &
 334:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 335:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)- &
 336:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 337:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)- &
 338:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 339:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)- &
 340:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 341:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)- &
 342:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 343:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)- &
 344:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 345:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)- &
 346:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 347:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)- &
 348:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 349:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)- &
 350:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
107:       ENDIF351:       ENDIF
108: !352: !
109: ! Sum over the attractive sites353: ! Sum over the attractive sites
110: !354: !
111:       DO J3=1,NSITEPERBODY(J1)-2     ! # Morse sites in rb J1 NSITEPERBODY(J1)355:       DO J3=1,NSITEPERBODY(J1)-2     ! # Morse sites in rb J1 NSITEPERBODY(J1)
112:          NPOS1=RIGIDGROUPS(J3,J1)    ! where is this site in the list?356:          NPOS1=RIGIDGROUPS(J3,J1)    ! where is this site in the list?
113:          DO J4=1,NSITEPERBODY(J2)-2  ! # Morse sites in rb J2 NSITEPERBODY(J2)357:          DO J4=1,NSITEPERBODY(J2)-2  ! # Morse sites in rb J2 NSITEPERBODY(J2)
114:             NPOS2=RIGIDGROUPS(J4,J2) ! where is this site in the list?358:             NPOS2=RIGIDGROUPS(J4,J2) ! where is this site in the list?
115:             DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+ &359:             DIST=SQRT((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))**2+(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))**2+(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2)
116:   &                   (X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))**2) 
117:             ENERGY=ENERGY+FATT(RHO,DIST) 360:             ENERGY=ENERGY+FATT(RHO,DIST) 
118:             IF (GTEST) THEN361:             IF (GTEST) THEN
119:                DUMMY2=DFATT(RHO,DIST)362:                DUMMY2=DFATT(RHO,DIST)
120:                RDIST=1.0D0/DIST363:                RDIST=1.0D0/DIST
121:                CALL DJWGR1GRAD(NATOMS,NPOS1,NPOS2,DUMMY2,RDIST,X,V)364:                V(3*(NPOS1-1)+1)=V(3*(NPOS1-1)+1)+DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
 365:                V(3*(NPOS1-1)+2)=V(3*(NPOS1-1)+2)+DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
 366:                V(3*(NPOS1-1)+3)=V(3*(NPOS1-1)+3)+DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
 367:                V(3*(NPOS2-1)+1)=V(3*(NPOS2-1)+1)-DUMMY2*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST
 368:                V(3*(NPOS2-1)+2)=V(3*(NPOS2-1)+2)-DUMMY2*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST
 369:                V(3*(NPOS2-1)+3)=V(3*(NPOS2-1)+3)-DUMMY2*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST
122:             ENDIF370:             ENDIF
123:             IF (SECT) THEN371:             IF (SECT) THEN
124:                DUMMY2=DFATT(RHO,DIST)372:                DUMMY2=DFATT(RHO,DIST)
125:                DUMMY3=DDFATT(RHO,DIST)373:                DUMMY3=DDFATT(RHO,DIST)
126:                RDIST=1.0D0/DIST374:                RDIST=1.0D0/DIST
127:                CALL DJWGR1SEC(NATOMS,NPOS1,NPOS2,DUMMY3,DUMMY2,RDIST,X)375: ! same rigid body, same Cartesian component
 376:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+1)+ &
 377:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
 378:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+2)+ &
 379:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 380:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+3)+ &
 381:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 382:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+1)+ &
 383:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST  
 384:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+2)+ &
 385:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 386:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+3)+ &
 387:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)+DUMMY2*RDIST
 388: ! same rigid body, different Cartesian component
 389:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+2)+ &
 390:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 391:          HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS1-1)+3)+ &
 392:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 393:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+1)+ &
 394:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 395:          HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS1-1)+3)+ &
 396:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 397:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+1)+ &
 398:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 399:          HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS1-1)+2)+ &
 400:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 401:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+2)+ &
 402:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 403:          HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS2-1)+3)+ &
 404:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 405:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+1)+ &
 406:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 407:          HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS2-1)+3)+ &
 408:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 409:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+1)+ &
 410:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 411:          HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS2-1)+2)+ &
 412:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 413: ! different rigid body, same Cartesian component
 414:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+1)- &
 415:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 416:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+2)- &
 417:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 418:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+3)- &
 419:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 420:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+1)- &
 421:   &                                  ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 422:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+2)- &
 423:   &                                  ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 424:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+3)- &
 425:   &                                  ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*RDIST)**2*(DUMMY3-DUMMY2*RDIST)-DUMMY2*RDIST
 426: ! different rigid body, different Cartesian component
 427:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+2)- &
 428:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 429:          HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+1,3*(NPOS2-1)+3)- &
 430:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 431:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+1)- &
 432:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 433:          HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)=HESS(3*(NPOS1-1)+2,3*(NPOS2-1)+3)- &
 434:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 435:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+1)- &
 436:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 437:          HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)=HESS(3*(NPOS1-1)+3,3*(NPOS2-1)+2)- &
 438:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 439:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+2)- &
 440:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)   
 441:          HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+1,3*(NPOS1-1)+3)- &
 442:   &                         ((X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 443:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+1)- &
 444:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 445:          HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)=HESS(3*(NPOS2-1)+2,3*(NPOS1-1)+3)- &
 446:   &                         ((X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2))*(X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 447:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+1)- &
 448:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+1)-X(3*(NPOS2-1)+1)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
 449:          HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)=HESS(3*(NPOS2-1)+3,3*(NPOS1-1)+2)- &
 450:   &                         ((X(3*(NPOS1-1)+3)-X(3*(NPOS2-1)+3))*(X(3*(NPOS1-1)+2)-X(3*(NPOS2-1)+2)))*RDIST**2*(DUMMY3-DUMMY2*RDIST)
128:             ENDIF451:             ENDIF
129:          ENDDO452:          ENDDO
130:       ENDDO453:       ENDDO
131:    ENDDO454:    ENDDO
132: ENDDO455: ENDDO
133: 456: 
134: END SUBROUTINE DJWGR1457: END SUBROUTINE DJWGR1
135:  
136: SUBROUTINE DJWGR1SEC(NATOMS,NPOS1,NPOS2,DUMMY3,DUMMY2,RDIST,X) 
137: USE MODHESS 
138: IMPLICIT NONE 
139: INTEGER NPOS1, NPOS2, NATOMS, J1, J2, J3, J4 
140: DOUBLE PRECISION X(3*NATOMS), DUMMY2, DUMMY3, RDIST, DUMMY4, DUMMY5 
141:  
142: DUMMY4=(DUMMY3-DUMMY2*RDIST)*RDIST**2 
143: J3=3*(NPOS1-1) 
144: J4=3*(NPOS2-1) 
145:  
146: DO J1=1,3 
147:    DO J2=1,3 
148:       DUMMY5=((X(J3+J1)-X(J4+J1))*(X(J3+J2)-X(J4+J2)))*DUMMY4 
149:       HESS(J3+J1,J3+J2)=HESS(J3+J1,J3+J2)+DUMMY5 
150:       HESS(J4+J1,J4+J2)=HESS(J4+J1,J4+J2)+DUMMY5 
151:       HESS(J3+J1,J4+J2)=HESS(J3+J1,J4+J2)-DUMMY5 
152:       HESS(J4+J1,J3+J2)=HESS(J4+J1,J3+J2)-DUMMY5 
153:    ENDDO 
154:    DUMMY5=DUMMY2*RDIST 
155:    HESS(J3+J1,J3+J1)=HESS(J3+J1,J3+J1)+DUMMY5 
156:    HESS(J4+J1,J4+J1)=HESS(J4+J1,J4+J1)+DUMMY5 
157:    HESS(J3+J1,J4+J1)=HESS(J3+J1,J4+J1)-DUMMY5 
158:    HESS(J4+J1,J3+J1)=HESS(J4+J1,J3+J1)-DUMMY5 
159: ENDDO 
160:  
161: END SUBROUTINE DJWGR1SEC 
162:  
163: SUBROUTINE DJWGR1GRAD(NATOMS,NPOS1,NPOS2,DUMMY2,RDIST,X,V) 
164: USE MODHESS 
165: IMPLICIT NONE 
166: INTEGER NPOS1, NPOS2, NATOMS, J1, J2, J3, J4 
167: DOUBLE PRECISION X(3*NATOMS), DUMMY2, RDIST, DUMMY4, DUMMY5, V(3*NATOMS) 
168:  
169: DUMMY4=DUMMY2*RDIST 
170: J3=3*(NPOS1-1) 
171: J4=3*(NPOS2-1) 
172:  
173: DO J1=1,3 
174:    DUMMY5=DUMMY4*(X(J3+J1)-X(J4+J1)) 
175:    V(J3+J1)=V(J3+J1)+DUMMY5 
176:    V(J4+J1)=V(J4+J1)-DUMMY5 
177: ENDDO 
178:  
179: END SUBROUTINE DJWGR1GRAD 
180:  


r30234/keywords.f 2016-04-05 15:30:23.449119625 +0100 r30233/keywords.f 2016-04-05 15:30:24.037127446 +0100
677:          MODEDOWNT=.FALSE.677:          MODEDOWNT=.FALSE.
678:          NOINVERSION=.FALSE.678:          NOINVERSION=.FALSE.
679:          PMPATHT=.FALSE.679:          PMPATHT=.FALSE.
680:          PMPATHINR=6680:          PMPATHINR=6
681:          AAORIENTT=.FALSE.681:          AAORIENTT=.FALSE.
682:          KAA=1.0D0682:          KAA=1.0D0
683:          SIGMAAA=0.0D0683:          SIGMAAA=0.0D0
684:          MULTIJOBT=.FALSE.684:          MULTIJOBT=.FALSE.
685:          MULTISTART=''685:          MULTISTART=''
686:          MULTIFINISH=''686:          MULTIFINISH=''
687:          DJWRBT=.FALSE. 
688:          ! 687:          ! 
689:          ! General mixed LJ systems688:          ! General mixed LJ systems
690:          ! 689:          ! 
691:          GLJT=.FALSE.690:          GLJT=.FALSE.
692:          NGLJ=1 ! number of atom types691:          NGLJ=1 ! number of atom types
693:          ! 692:          ! 
694:          ! ds656> substrate field(s)693:          ! ds656> substrate field(s)
695:          MIEFT=.FALSE.694:          MIEFT=.FALSE.
696:          MIEF_PBCT=.FALSE.695:          MIEF_PBCT=.FALSE.
697:          MIEF_CUTT=.FALSE.696:          MIEF_CUTT=.FALSE.
2254:             ENDIF2253:             ENDIF
2255: 2254: 
2256:             NRBSITES = 32255:             NRBSITES = 3
2257:             ALLOCATE(RBSITE(NRBSITES,3))2256:             ALLOCATE(RBSITE(NRBSITES,3))
2258: 2257: 
2259:             NTSITES = (NATOMS/2-1)*NRBSITES + 42258:             NTSITES = (NATOMS/2-1)*NRBSITES + 4
2260: 2259: 
2261:          ELSE IF (WORD.EQ.'DJWRB') THEN2260:          ELSE IF (WORD.EQ.'DJWRB') THEN
2262:             DJWRBT=.TRUE.2261:             DJWRBT=.TRUE.
2263:             CALL READI(DJWRBID)2262:             CALL READI(DJWRBID)
2264:             IF (.NOT.ALLOCATED(ATMASS)) ALLOCATE(ATMASS(NATOMS)) 
2265:             ATMASS(1:NATOMS)=1.0D0 
2266:             IF (DJWRBID /= 1) THEN2263:             IF (DJWRBID /= 1) THEN
2267:                PRINT *, 'DJWRB id ',DJWRBID,' unknown'2264:                PRINT *, 'DJWRB id ',DJWRBID,' unknown'
2268:                STOP2265:                STOP
2269:             ENDIF2266:             ENDIF
2270: 2267: 
2271: ! 2268: ! 
2272: ! DCHECK  turns ON/OFF warnings about short interatomic distances2269: ! DCHECK  turns ON/OFF warnings about short interatomic distances
2273: ! default ON2270: ! default ON
2274: ! 2271: ! 
2275:          ELSE IF (WORD.EQ.'DMBLPY') THEN2272:          ELSE IF (WORD.EQ.'DMBLPY') THEN


r30234/potential.f 2016-04-05 15:30:23.645122229 +0100 r30233/potential.f 2016-04-05 15:30:24.277130659 +0100
1630:             CALL MULTISITEPY2 (COORDS, VNEW, ENERGY, GTEST)1630:             CALL MULTISITEPY2 (COORDS, VNEW, ENERGY, GTEST)
1631:             IF (SSTEST) THEN1631:             IF (SSTEST) THEN
1632:                CALL MULTISITEPYSECDER(COORDS,SSTEST)1632:                CALL MULTISITEPYSECDER(COORDS,SSTEST)
1633:             END IF1633:             END IF
1634:             IF (PTEST) THEN1634:             IF (PTEST) THEN
1635:                WRITE(*,10) ' potential> Energy for last cycle=',ENERGY,'         '1635:                WRITE(*,10) ' potential> Energy for last cycle=',ENERGY,'         '
1636:                WRITE(ESTRING,10) 'Energy for last cycle=',ENERGY,'         '1636:                WRITE(ESTRING,10) 'Energy for last cycle=',ENERGY,'         '
1637:             END IF1637:             END IF
1638:          ELSE IF (DJWRBT) THEN1638:          ELSE IF (DJWRBT) THEN
1639:             IF (DJWRBID.EQ.1) THEN1639:             IF (DJWRBID.EQ.1) THEN
1640:                CALL DJWGR1(NATOMS,COORDS,VNEW,ENERGY,GTEST,SSTEST)1640: !              CALL DJWGR1(NATOMS,COORDS,VNEW,ENERGY,GTEST,SSTEST)
1641: 1641: 
1642: !               DIFF=1.0D-41642:                DIFF=1.0D-4
1643: !               PRINT*,'analytic and numerical gradients:'1643:                PRINT*,'analytic and numerical gradients:'
1644: !               IF (.NOT.(ALLOCATED(HESS))) ALLOCATE(HESS(3*NATOMS,3*NATOMS))1644:                IF (.NOT.(ALLOCATED(HESS))) ALLOCATE(HESS(3*NATOMS,3*NATOMS))
1645: !               CALL DJWGR1(NATOMS,COORDS, VNEW, ENERGY, .TRUE., .TRUE.)1645:                CALL DJWGR1(NATOMS,COORDS, VNEW, ENERGY, .TRUE., .TRUE.)
1646: !               PRINT '(A,I8)','SIZE(HESS)=',SIZE(HESS)1646:                PRINT '(A,I8)','SIZE(HESS)=',SIZE(HESS)
1647: !               HESSDUM(1:3*NATOMS,1:3*NATOMS)=HESS(1:3*NATOMS,1:3*NATOMS)1647:                HESSDUM(1:3*NATOMS,1:3*NATOMS)=HESS(1:3*NATOMS,1:3*NATOMS)
1648: !               DO J1=1,3*NATOMS1648:                DO J1=1,3*NATOMS
1649: !                  COORDS(J1)=COORDS(J1)+DIFF1649:                   COORDS(J1)=COORDS(J1)+DIFF
1650: !                  CALL DJWGR1(NATOMS,COORDS,VPLUS,EPLUS,.FALSE.,.FALSE.)1650:                   CALL DJWGR1(NATOMS,COORDS,VPLUS,EPLUS,.FALSE.,.FALSE.)
1651: !                  COORDS(J1)=COORDS(J1)-2.0D0*DIFF1651:                   COORDS(J1)=COORDS(J1)-2.0D0*DIFF
1652: !                  CALL DJWGR1(NATOMS,COORDS,VMINUS,EMINUS,.FALSE.,.FALSE.)1652:                   CALL DJWGR1(NATOMS,COORDS,VMINUS,EMINUS,.FALSE.,.FALSE.)
1653: !                  COORDS(J1)=COORDS(J1)+DIFF1653:                   COORDS(J1)=COORDS(J1)+DIFF
1654: !                  WRITE(*,'(I5,2F20.10)') J1,VNEW(J1),(EPLUS-EMINUS)/(2.0D0*DIFF)1654:                   WRITE(*,'(I5,2F20.10)') J1,VNEW(J1),(EPLUS-EMINUS)/(2.0D0*DIFF)
1655: !               ENDDO1655:                ENDDO
1656: !               PRINT*,'analytic and numerical second derivatives:'1656:                PRINT*,'analytic and numerical second derivatives:'
1657: !               DO J1=1,3*NATOMS1657:                DO J1=1,3*NATOMS
1658: !                  COORDS(J1)=COORDS(J1)+DIFF1658:                   COORDS(J1)=COORDS(J1)+DIFF
1659: !                  CALL DJWGR1(NATOMS,COORDS,VPLUS,EPLUS,.TRUE.,.FALSE.)1659:                   CALL DJWGR1(NATOMS,COORDS,VPLUS,EPLUS,.TRUE.,.FALSE.)
1660: !                  COORDS(J1)=COORDS(J1)-2.0D0*DIFF1660:                   COORDS(J1)=COORDS(J1)-2.0D0*DIFF
1661: !                  CALL DJWGR1(NATOMS,COORDS,VMINUS,EMINUS,.TRUE.,.FALSE.)1661:                   CALL DJWGR1(NATOMS,COORDS,VMINUS,EMINUS,.TRUE.,.FALSE.)
1662: !                  COORDS(J1)=COORDS(J1)+DIFF1662:                   COORDS(J1)=COORDS(J1)+DIFF
1663: !                  DO J2=1,3*NATOMS1663:                   DO J2=1,3*NATOMS
1664: !                     DUMMY1=(VPLUS(J2)-VMINUS(J2))/(2.0D0*DIFF)1664:                      DUMMY1=(VPLUS(J2)-VMINUS(J2))/(2.0D0*DIFF)
1665: !                     IF ((ABS(DUMMY1).GT.1.0D-10).AND. 1665:                      IF ((ABS(DUMMY1).GT.1.0D-10).AND. 
1666: !     &                   (ABS(100.0D0*(HESS(J1,J2)-DUMMY1)/DUMMY1).GT.1.0D0)) THEN1666:      &                   (ABS(100.0D0*(HESS(J1,J2)-DUMMY1)/DUMMY1).GT.1.0D0)) THEN
1667: !                     WRITE(*,'(2I5,2G20.10,A)') J1,J2,HESS(J1,J2),DUMMY1,'   X'1667:                      WRITE(*,'(2I5,2G20.10,A)') J1,J2,HESS(J1,J2),DUMMY1,'   X'
1668: !                     ELSE1668:                      ELSE
1669: !                        WRITE(*,'(2I5,2G20.10,A)') J1,J2,HESS(J1,J2),DUMMY11669:                         WRITE(*,'(2I5,2G20.10,A)') J1,J2,HESS(J1,J2),DUMMY1
1670: !                     ENDIF1670:                      ENDIF
1671: !                  ENDDO1671:                   ENDDO
1672: !               ENDDO1672:                ENDDO
1673: !               STOP1673:                STOP
1674: 1674:             ENDIF
1675:              ENDIF 
1676:             IF (PTEST) THEN1675:             IF (PTEST) THEN
1677:                WRITE(*,10) ' potential> Energy for last cycle=',ENERGY,'         '1676:                WRITE(*,10) ' potential> Energy for last cycle=',ENERGY,'         '
1678:                WRITE(ESTRING,10) 'Energy for last cycle=',ENERGY,'         '1677:                WRITE(ESTRING,10) 'Energy for last cycle=',ENERGY,'         '
1679:             ENDIF1678:             ENDIF
1680:          ELSE IF (NCAPT) THEN1679:          ELSE IF (NCAPT) THEN
1681:             CALL NEWCAPSID (COORDS,VNEW,ENERGY,GTEST,SSTEST)1680:             CALL NEWCAPSID (COORDS,VNEW,ENERGY,GTEST,SSTEST)
1682:             IF (PTEST) THEN1681:             IF (PTEST) THEN
1683:                WRITE(*,10) ' potential> Energy for last cycle=',ENERGY,'         '1682:                WRITE(*,10) ' potential> Energy for last cycle=',ENERGY,'         '
1684:                WRITE(ESTRING,10) 'Energy for last cycle=',ENERGY,'         '1683:                WRITE(ESTRING,10) 'Energy for last cycle=',ENERGY,'         '
1685:             END IF1684:             END IF


legend
Lines Added 
Lines changed
 Lines Removed

hdiff - version: 2.1.0