source: enyshe_p.f@ 32289cd

Last change on this file since 32289cd was 32289cd, checked in by baerbaer <baerbaer@…>, 14 years ago

Explicitly declare variables.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@33 26dc1dd8-5c4e-0410-9ffe-d298b4865968

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