1 | ! **************************************************************
|
---|
2 | !
|
---|
3 | ! This file contains the subroutines: enyshe
|
---|
4 | !
|
---|
5 | ! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
6 | ! Shura Hayryan, Chin-Ku
|
---|
7 | ! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
8 | ! Jan H. Meinke, Sandipan Mohanty
|
---|
9 | !
|
---|
10 | ! **************************************************************
|
---|
11 |
|
---|
12 |
|
---|
13 | real*8 function enyshe(nml)
|
---|
14 |
|
---|
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 | !< ............................................................................
|
---|
24 |
|
---|
25 | include 'INCL.H'
|
---|
26 | include 'mpif.h'
|
---|
27 | ! include 'VT.inc'
|
---|
28 |
|
---|
29 |
|
---|
30 | ! If nml == 0 calculate the interaction between all pairs.
|
---|
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 |
|
---|
39 | if (nml.eq.0) then
|
---|
40 | ntlvr = nvr
|
---|
41 | else
|
---|
42 | ntlvr=nvrml(nml)
|
---|
43 | endif
|
---|
44 |
|
---|
45 | if (ntlvr.eq.0) then
|
---|
46 | write (logString, '(a,i4)')
|
---|
47 | & ' enyshe> No variables defined in molecule #',nml
|
---|
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)
|
---|
64 | else
|
---|
65 | ! Index of first variable in molecule.
|
---|
66 | ifivr=ivrml1(nml)
|
---|
67 | ! Index of last moving set in molecule
|
---|
68 | i1s=imsml1(nml)+nmsml(nml)
|
---|
69 | endif
|
---|
70 | ! Loop over variables in reverse order
|
---|
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.
|
---|
73 |
|
---|
74 | ! Number of moving sets per processor
|
---|
75 | iend = ifivr
|
---|
76 | istart = ifivr + ntlvr - 1
|
---|
77 |
|
---|
78 | startwtime = MPI_Wtime()
|
---|
79 | loopcounter = 0
|
---|
80 | ! do io=ifivr+ntlvr-1,ifivr,-1
|
---|
81 | do io = workPerProcessor(nml, myrank) - 1,
|
---|
82 | & workPerProcessor(nml, myrank+1), -1
|
---|
83 | if (io.lt.istart) then
|
---|
84 | i1s = imsvr1(iorvr(io + 1))
|
---|
85 | endif
|
---|
86 | ! The array iorvr contains the variables in an "apropriate" order.
|
---|
87 | iv=iorvr(io)
|
---|
88 | ! Index of the primary moving atom for the variable with index iv
|
---|
89 | ia=iatvr(iv)
|
---|
90 | ! Get the type of variable iv (valence length, valence angle, dihedral angle)
|
---|
91 | it=ityvr(iv)
|
---|
92 | ! Class of variable iv's potential (Q: What are they)
|
---|
93 | ic=iclvr(iv)
|
---|
94 | ! If iv is a dihedral angle ...
|
---|
95 | if (it.eq.3) then
|
---|
96 | ! Barrier height * 1/2 of the potential of iv.
|
---|
97 | e0=e0to(ic)
|
---|
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.
|
---|
100 | if (e0.ne.0.)
|
---|
101 | & teyvr=teyvr+e0*(1.0+sgto(ic)*cos(toat(ia)*rnto(ic)))
|
---|
102 | ! else if iv is a valence angle ...
|
---|
103 | elseif (it.eq.2) then
|
---|
104 | ! vr is the valence angle of ia
|
---|
105 | vr=baat(ia)
|
---|
106 | ! else if iv is a valence length...
|
---|
107 | elseif (it.eq.1) then
|
---|
108 | ! vr is the length of the valence bond
|
---|
109 | vr=blat(ia)
|
---|
110 | endif
|
---|
111 |
|
---|
112 | ! ============================================ Energies & Atomic forces
|
---|
113 | ! index of next to last moving set
|
---|
114 | i2s=i1s-1
|
---|
115 | ! index of first moving set associated with iv
|
---|
116 | i1s=imsvr1(iv)
|
---|
117 | ! Loop over all moving sets starting from the one associated with vr to the end.
|
---|
118 | do ims=i1s,i2s
|
---|
119 | ! First atom of the current moving set
|
---|
120 | i1=latms1(ims)
|
---|
121 | ! Last atom of the current moving set
|
---|
122 | i2=latms2(ims)
|
---|
123 | ! Loop over all atoms of the current moving set.
|
---|
124 | do i=i1,i2
|
---|
125 | ! Atom class of current atom
|
---|
126 | ity=ityat(i)
|
---|
127 | ! Point charge at current atom
|
---|
128 | cqi=conv*cgat(i)
|
---|
129 | ! Cartesian coordinates of current atom
|
---|
130 | xi=xat(i)
|
---|
131 | yi=yat(i)
|
---|
132 | zi=zat(i)
|
---|
133 | ! Loop over the atoms of the van der Waals domain belonging to atom i
|
---|
134 | do ivw=ivwat1(i),ivwat2(i)
|
---|
135 | ! Loop over the atoms of the van der Waals domain of the atoms of the
|
---|
136 | ! van der Waals domain of atom i
|
---|
137 | ! Q: Which atoms are in these domains?
|
---|
138 | do j=lvwat1(ivw),lvwat2(ivw)
|
---|
139 |
|
---|
140 | loopcounter = loopcounter + 1
|
---|
141 | ! Atom type of partner
|
---|
142 | jty=ityat(j)
|
---|
143 | ! Differences in cartesian coordinates
|
---|
144 | xij=xat(j)-xi
|
---|
145 | yij=yat(j)-yi
|
---|
146 | zij=zat(j)-zi
|
---|
147 | ! Cartesian distance and higher powers
|
---|
148 | rij2=xij*xij+yij*yij+zij*zij
|
---|
149 | rij4=rij2*rij2
|
---|
150 | rij6=rij4*rij2
|
---|
151 | rij=sqrt(rij2)
|
---|
152 | ! Are we using a distance dependent dielectric constant?
|
---|
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
|
---|
159 | ! Coulomb interaction
|
---|
160 | teyel=teyel+cqi*cgat(j)/(rij*ep)
|
---|
161 | ! If the two atoms cannot form a hydrogen bond use 6-12 Lennard-Jones potential
|
---|
162 | if (ihbty(ity,jty).eq.0) then
|
---|
163 | teyvw=teyvw+aij(ity,jty)/(rij6*rij6)
|
---|
164 | & -cij(ity,jty)/rij6
|
---|
165 | else
|
---|
166 | ! For hydrogen bonding use 10-12 Lennard-Jones potential
|
---|
167 | teyhb=teyhb+ahb(ity,jty)/(rij6*rij6)
|
---|
168 | & -chb(ity,jty)/(rij6*rij4)
|
---|
169 | endif
|
---|
170 |
|
---|
171 | enddo
|
---|
172 | enddo
|
---|
173 |
|
---|
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.
|
---|
177 | do i14=i14at1(i),i14at2(i)
|
---|
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)
|
---|
190 | ! Are we using a distance dependent dielectric constant?
|
---|
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)
|
---|
199 | ! If hydrogen bonding is not possible use 6-12 Lennard-Jones potential.
|
---|
200 | if (ihbty(ity,jty).eq.0) then
|
---|
201 | teyvw=teyvw+a14(ity,jty)/(rij6*rij6)
|
---|
202 | & -cij(ity,jty)/rij6
|
---|
203 | else
|
---|
204 | ! Use 10-12 Lennard-Jones potential for hydrogen bonds.
|
---|
205 | teyhb=teyhb+ahb(ity,jty)/(rij6*rij6)
|
---|
206 | & -chb(ity,jty)/(rij6*rij4)
|
---|
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 |
|
---|
217 | ! Collect energies from all nodes and sum them up
|
---|
218 | call MPI_ALLREDUCE(teysm, eysmsum, 1, MPI_DOUBLE_PRECISION,
|
---|
219 | & MPI_SUM, my_mpi_comm, ierror)
|
---|
220 | call MPI_ALLREDUCE(teyel, eyel, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
221 | & my_mpi_comm, ierror)
|
---|
222 | call MPI_ALLREDUCE(teyvw, eyvw, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
223 | & my_mpi_comm, ierror)
|
---|
224 | call MPI_ALLREDUCE(teyhb, eyhb, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
225 | & my_mpi_comm, ierror)
|
---|
226 | call MPI_ALLREDUCE(teyvr, eyvr, 1, MPI_DOUBLE_PRECISION, MPI_SUM,
|
---|
227 | & my_mpi_comm, ierror)
|
---|
228 |
|
---|
229 | enyshe=eysmsum
|
---|
230 | ! call VTEnd(101, ierr)
|
---|
231 | return
|
---|
232 | end
|
---|
233 |
|
---|