[bd2278d] | 1 | ! **************************************************************
|
---|
| 2 | !
|
---|
[32289cd] | 3 | ! This file contains the subroutines: enyshe
|
---|
[bd2278d] | 4 | !
|
---|
| 5 | ! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
[32289cd] | 6 | ! Shura Hayryan, Chin-Ku
|
---|
[bd2278d] | 7 | ! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
| 8 | ! Jan H. Meinke, Sandipan Mohanty
|
---|
| 9 | !
|
---|
| 10 | ! **************************************************************
|
---|
[e40e335] | 11 |
|
---|
| 12 |
|
---|
| 13 | real*8 function enyshe(nml)
|
---|
| 14 |
|
---|
[3fbbfbb] | 15 | !> PURPOSE: Calculate internal energy of molecule 'nml' with ECEPP parameters
|
---|
| 16 | !!
|
---|
| 17 | !! CALLS: none
|
---|
| 18 | !!
|
---|
| 19 | !! The function loops over all moving sets within the molecule. Within
|
---|
| 20 | !! this loop it loops over the van-der-Waals domains of each atom in the
|
---|
| 21 | !! moving set and finally over the atoms that belong to the 1-4 interaction
|
---|
| 22 | !! set.
|
---|
| 23 | !< ............................................................................
|
---|
[e40e335] | 24 |
|
---|
| 25 | include 'INCL.H'
|
---|
| 26 | include 'mpif.h'
|
---|
| 27 | ! include 'VT.inc'
|
---|
| 28 |
|
---|
| 29 |
|
---|
[bd2278d] | 30 | ! If nml == 0 calculate the interaction between all pairs.
|
---|
[32289cd] | 31 | double precision eysmsum, teysm, teyel, teyvw, teyhb, teyvr
|
---|
| 32 | double precision startwtime, e0, vr, cqi, xi, yi, zi, xij, yij
|
---|
| 33 | double precision zij, rij2, rij4, rij6, rij, sr, ep, endwtime
|
---|
| 34 |
|
---|
| 35 | integer nml, ntlvr, ifivr, i1s, iend, istart, loopcounter, io, iv
|
---|
| 36 | integer ia, it, ic, i2s, ims, i1, i2, i, ity, ivw, j, jty, i14
|
---|
| 37 | integer ierror
|
---|
| 38 |
|
---|
[e40e335] | 39 | if (nml.eq.0) then
|
---|
| 40 | ntlvr = nvr
|
---|
| 41 | else
|
---|
| 42 | ntlvr=nvrml(nml)
|
---|
| 43 | endif
|
---|
[32289cd] | 44 |
|
---|
[e40e335] | 45 | if (ntlvr.eq.0) then
|
---|
[38d77eb] | 46 | write (logString, '(a,i4)')
|
---|
[bd2278d] | 47 | & ' enyshe> No variables defined in molecule #',nml
|
---|
[e40e335] | 48 | return
|
---|
| 49 | endif
|
---|
| 50 |
|
---|
| 51 | ! call mpi_comm_size(my_mpi_comm,no,ierr)
|
---|
| 52 |
|
---|
| 53 | eysmsum = 0.0
|
---|
| 54 | enyshe=0.0
|
---|
| 55 | teysm = 0.0
|
---|
| 56 | teyel=0.0
|
---|
| 57 | teyvw=0.0
|
---|
| 58 | teyhb=0.0
|
---|
| 59 | teyvr=0.0
|
---|
| 60 |
|
---|
| 61 | if (nml.eq.0) then
|
---|
| 62 | ifivr = ivrml1(1)
|
---|
| 63 | i1s = imsml1(ntlml) + nmsml(ntlml)
|
---|
[32289cd] | 64 | else
|
---|
[bd2278d] | 65 | ! Index of first variable in molecule.
|
---|
[e40e335] | 66 | ifivr=ivrml1(nml)
|
---|
[bd2278d] | 67 | ! Index of last moving set in molecule
|
---|
[e40e335] | 68 | i1s=imsml1(nml)+nmsml(nml)
|
---|
| 69 | endif
|
---|
[32289cd] | 70 | ! Loop over variables in reverse order
|
---|
[bd2278d] | 71 | ! This is the first loop to parallize. We'll just split the moving sets
|
---|
| 72 | ! over the number of available processors and sum the energy up in the end.
|
---|
[e40e335] | 73 |
|
---|
[bd2278d] | 74 | ! Number of moving sets per processor
|
---|
[e40e335] | 75 | iend = ifivr
|
---|
| 76 | istart = ifivr + ntlvr - 1
|
---|
| 77 |
|
---|
| 78 | startwtime = MPI_Wtime()
|
---|
| 79 | loopcounter = 0
|
---|
[32289cd] | 80 | ! do io=ifivr+ntlvr-1,ifivr,-1
|
---|
| 81 | do io = workPerProcessor(nml, myrank) - 1,
|
---|
[e40e335] | 82 | & workPerProcessor(nml, myrank+1), -1
|
---|
| 83 | if (io.lt.istart) then
|
---|
| 84 | i1s = imsvr1(iorvr(io + 1))
|
---|
| 85 | endif
|
---|
[bd2278d] | 86 | ! The array iorvr contains the variables in an "apropriate" order.
|
---|
[32289cd] | 87 | iv=iorvr(io)
|
---|
[bd2278d] | 88 | ! Index of the primary moving atom for the variable with index iv
|
---|
[32289cd] | 89 | ia=iatvr(iv)
|
---|
[bd2278d] | 90 | ! Get the type of variable iv (valence length, valence angle, dihedral angle)
|
---|
[32289cd] | 91 | it=ityvr(iv)
|
---|
[bd2278d] | 92 | ! Class of variable iv's potential (Q: What are they)
|
---|
[32289cd] | 93 | ic=iclvr(iv)
|
---|
[bd2278d] | 94 | ! If iv is a dihedral angle ...
|
---|
[32289cd] | 95 | if (it.eq.3) then
|
---|
[bd2278d] | 96 | ! Barrier height * 1/2 of the potential of iv.
|
---|
[e40e335] | 97 | e0=e0to(ic)
|
---|
[bd2278d] | 98 | ! Calculate the periodic potential term. sgto is the sign of the barrier, rnto is
|
---|
| 99 | ! the periodicity and toat is torsion angle(?) associate with atom ia.
|
---|
[32289cd] | 100 | if (e0.ne.0.)
|
---|
[bd2278d] | 101 | & teyvr=teyvr+e0*(1.0+sgto(ic)*cos(toat(ia)*rnto(ic)))
|
---|
| 102 | ! else if iv is a valence angle ...
|
---|
[32289cd] | 103 | elseif (it.eq.2) then
|
---|
[bd2278d] | 104 | ! vr is the valence angle of ia
|
---|
[e40e335] | 105 | vr=baat(ia)
|
---|
[bd2278d] | 106 | ! else if iv is a valence length...
|
---|
[32289cd] | 107 | elseif (it.eq.1) then
|
---|
[bd2278d] | 108 | ! vr is the length of the valence bond
|
---|
[e40e335] | 109 | vr=blat(ia)
|
---|
| 110 | endif
|
---|
| 111 |
|
---|
[bd2278d] | 112 | ! ============================================ Energies & Atomic forces
|
---|
| 113 | ! index of next to last moving set
|
---|
[e40e335] | 114 | i2s=i1s-1
|
---|
[bd2278d] | 115 | ! index of first moving set associated with iv
|
---|
[32289cd] | 116 | i1s=imsvr1(iv)
|
---|
[bd2278d] | 117 | ! Loop over all moving sets starting from the one associated with vr to the end.
|
---|
[32289cd] | 118 | do ims=i1s,i2s
|
---|
[bd2278d] | 119 | ! First atom of the current moving set
|
---|
[e40e335] | 120 | i1=latms1(ims)
|
---|
[bd2278d] | 121 | ! Last atom of the current moving set
|
---|
[e40e335] | 122 | i2=latms2(ims)
|
---|
[bd2278d] | 123 | ! Loop over all atoms of the current moving set.
|
---|
[32289cd] | 124 | do i=i1,i2
|
---|
[bd2278d] | 125 | ! Atom class of current atom
|
---|
[e40e335] | 126 | ity=ityat(i)
|
---|
[bd2278d] | 127 | ! Point charge at current atom
|
---|
[e40e335] | 128 | cqi=conv*cgat(i)
|
---|
[bd2278d] | 129 | ! Cartesian coordinates of current atom
|
---|
[e40e335] | 130 | xi=xat(i)
|
---|
| 131 | yi=yat(i)
|
---|
| 132 | zi=zat(i)
|
---|
[bd2278d] | 133 | ! Loop over the atoms of the van der Waals domain belonging to atom i
|
---|
[32289cd] | 134 | do ivw=ivwat1(i),ivwat2(i)
|
---|
| 135 | ! Loop over the atoms of the van der Waals domain of the atoms of the
|
---|
[bd2278d] | 136 | ! van der Waals domain of atom i
|
---|
| 137 | ! Q: Which atoms are in these domains?
|
---|
[32289cd] | 138 | do j=lvwat1(ivw),lvwat2(ivw)
|
---|
[e40e335] | 139 |
|
---|
| 140 | loopcounter = loopcounter + 1
|
---|
[bd2278d] | 141 | ! Atom type of partner
|
---|
[e40e335] | 142 | jty=ityat(j)
|
---|
[bd2278d] | 143 | ! Differences in cartesian coordinates
|
---|
[e40e335] | 144 | xij=xat(j)-xi
|
---|
| 145 | yij=yat(j)-yi
|
---|
| 146 | zij=zat(j)-zi
|
---|
[bd2278d] | 147 | ! Cartesian distance and higher powers
|
---|
[e40e335] | 148 | rij2=xij*xij+yij*yij+zij*zij
|
---|
| 149 | rij4=rij2*rij2
|
---|
| 150 | rij6=rij4*rij2
|
---|
| 151 | rij=sqrt(rij2)
|
---|
[bd2278d] | 152 | ! Are we using a distance dependent dielectric constant?
|
---|
[e40e335] | 153 | if(epsd) then
|
---|
| 154 | sr=slp*rij
|
---|
| 155 | ep=plt-(sr*sr+2.0*sr+2.0)*(plt-1.0)*exp(-sr)/2.0
|
---|
| 156 | else
|
---|
| 157 | ep = 1.0d0
|
---|
| 158 | end if
|
---|
[bd2278d] | 159 | ! Coulomb interaction
|
---|
[e40e335] | 160 | teyel=teyel+cqi*cgat(j)/(rij*ep)
|
---|
[bd2278d] | 161 | ! If the two atoms cannot form a hydrogen bond use 6-12 Lennard-Jones potential
|
---|
[e40e335] | 162 | if (ihbty(ity,jty).eq.0) then
|
---|
| 163 | teyvw=teyvw+aij(ity,jty)/(rij6*rij6)
|
---|
[bd2278d] | 164 | & -cij(ity,jty)/rij6
|
---|
[e40e335] | 165 | else
|
---|
[bd2278d] | 166 | ! For hydrogen bonding use 10-12 Lennard-Jones potential
|
---|
[e40e335] | 167 | teyhb=teyhb+ahb(ity,jty)/(rij6*rij6)
|
---|
[bd2278d] | 168 | & -chb(ity,jty)/(rij6*rij4)
|
---|
[e40e335] | 169 | endif
|
---|
| 170 |
|
---|
[32289cd] | 171 | enddo
|
---|
| 172 | enddo
|
---|
| 173 |
|
---|
[bd2278d] | 174 | ! Loop over 1-4 interaction partners
|
---|
| 175 | ! The interactions between atoms that are three bonds apart in the protein are
|
---|
| 176 | ! dominated by quantum mechanical effects. They are treated separately.
|
---|
[32289cd] | 177 | do i14=i14at1(i),i14at2(i)
|
---|
[e40e335] | 178 | loopcounter = loopcounter + 1
|
---|
| 179 | j=l14at(i14)
|
---|
| 180 |
|
---|
| 181 | jty=ityat(j)
|
---|
| 182 |
|
---|
| 183 | xij=xat(j)-xi
|
---|
| 184 | yij=yat(j)-yi
|
---|
| 185 | zij=zat(j)-zi
|
---|
| 186 | rij2=xij*xij+yij*yij+zij*zij
|
---|
| 187 | rij4=rij2*rij2
|
---|
| 188 | rij6=rij4*rij2
|
---|
| 189 | rij = sqrt(rij2)
|
---|
[bd2278d] | 190 | ! Are we using a distance dependent dielectric constant?
|
---|
[e40e335] | 191 | if(epsd) then
|
---|
| 192 | sr=slp*rij
|
---|
| 193 | ep=plt-(sr*sr+2.0*sr+2.0)*(plt-1.0)*exp(-sr)/2.0
|
---|
| 194 | else
|
---|
| 195 | ep=1.0d0
|
---|
| 196 | end if
|
---|
| 197 |
|
---|
| 198 | teyel=teyel+cqi*cgat(j)/(rij*ep)
|
---|
[bd2278d] | 199 | ! If hydrogen bonding is not possible use 6-12 Lennard-Jones potential.
|
---|
[e40e335] | 200 | if (ihbty(ity,jty).eq.0) then
|
---|
| 201 | teyvw=teyvw+a14(ity,jty)/(rij6*rij6)
|
---|
[bd2278d] | 202 | & -cij(ity,jty)/rij6
|
---|
[e40e335] | 203 | else
|
---|
[bd2278d] | 204 | ! Use 10-12 Lennard-Jones potential for hydrogen bonds.
|
---|
[e40e335] | 205 | teyhb=teyhb+ahb(ity,jty)/(rij6*rij6)
|
---|
[bd2278d] | 206 | & -chb(ity,jty)/(rij6*rij4)
|
---|
[e40e335] | 207 | endif
|
---|
| 208 | enddo ! ... 1-4-partners of i
|
---|
| 209 | enddo ! ... atoms i
|
---|
| 210 | enddo ! ... m.s.
|
---|
| 211 | enddo ! ... variables
|
---|
| 212 |
|
---|
| 213 | teysm = teyel + teyvw + teyhb + teyvr
|
---|
| 214 |
|
---|
| 215 | endwtime = MPI_Wtime()
|
---|
| 216 |
|
---|
[bd2278d] | 217 | ! Collect energies from all nodes and sum them up
|
---|
[32289cd] | 218 | call MPI_ALLREDUCE(teysm, eysmsum, 1, MPI_DOUBLE_PRECISION,
|
---|
[e40e335] | 219 | & MPI_SUM, my_mpi_comm, ierror)
|
---|
| 220 | call MPI_ALLREDUCE(teyel, eyel, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
| 221 | & my_mpi_comm, ierror)
|
---|
[32289cd] | 222 | call MPI_ALLREDUCE(teyvw, eyvw, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
[e40e335] | 223 | & my_mpi_comm, ierror)
|
---|
[32289cd] | 224 | call MPI_ALLREDUCE(teyhb, eyhb, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
[e40e335] | 225 | & my_mpi_comm, ierror)
|
---|
[32289cd] | 226 | call MPI_ALLREDUCE(teyvr, eyvr, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
[e40e335] | 227 | & my_mpi_comm, ierror)
|
---|
| 228 |
|
---|
| 229 | enyshe=eysmsum
|
---|
| 230 | ! call VTEnd(101, ierr)
|
---|
| 231 | return
|
---|
| 232 | end
|
---|
| 233 |
|
---|