source: enyshe_p.f@ e40e335

Last change on this file since e40e335 was e40e335, checked in by baerbaer <baerbaer@…>, 16 years ago

Initial import to BerliOS corresponding to 3.0.4

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

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