source: enyshe_p.f@ bd2278d

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

Reformatting comments and continuation marks.

Fortran 90 and higher use ! to mark comments no matter where they are in the
code. The only valid continuation marker is &.
I also added the SMMP.kdevelop.filelist to the repository to make it easier
to use kdevelop.

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

  • Property mode set to 100644
File size: 8.0 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 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
59! Index of first variable in molecule.
60 ifivr=ivrml1(nml)
61! Index of last moving set in molecule
62 i1s=imsml1(nml)+nmsml(nml)
63 endif
64! Loop over variables in reverse order
65! This is the first loop to parallize. We'll just split the moving sets
66! over the number of available processors and sum the energy up in the end.
67
68! Number of moving sets per processor
69 iend = ifivr
70 istart = ifivr + ntlvr - 1
71
72 startwtime = MPI_Wtime()
73 loopcounter = 0
74! 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
80! The array iorvr contains the variables in an "apropriate" order.
81 iv=iorvr(io)
82! Index of the primary moving atom for the variable with index iv
83 ia=iatvr(iv)
84! Get the type of variable iv (valence length, valence angle, dihedral angle)
85 it=ityvr(iv)
86! Class of variable iv's potential (Q: What are they)
87 ic=iclvr(iv)
88! If iv is a dihedral angle ...
89 if (it.eq.3) then
90! Barrier height * 1/2 of the potential of iv.
91 e0=e0to(ic)
92! Calculate the periodic potential term. sgto is the sign of the barrier, rnto is
93! 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)))
96! else if iv is a valence angle ...
97 elseif (it.eq.2) then
98! vr is the valence angle of ia
99 vr=baat(ia)
100! else if iv is a valence length...
101 elseif (it.eq.1) then
102! vr is the length of the valence bond
103 vr=blat(ia)
104 endif
105
106! ============================================ Energies & Atomic forces
107! index of next to last moving set
108 i2s=i1s-1
109! index of first moving set associated with iv
110 i1s=imsvr1(iv)
111! Loop over all moving sets starting from the one associated with vr to the end.
112 do ims=i1s,i2s
113! First atom of the current moving set
114 i1=latms1(ims)
115! Last atom of the current moving set
116 i2=latms2(ims)
117! Loop over all atoms of the current moving set.
118 do i=i1,i2
119! Atom class of current atom
120 ity=ityat(i)
121! Point charge at current atom
122 cqi=conv*cgat(i)
123! Cartesian coordinates of current atom
124 xi=xat(i)
125 yi=yat(i)
126 zi=zat(i)
127! Loop over the atoms of the van der Waals domain belonging to atom i
128 do ivw=ivwat1(i),ivwat2(i)
129! Loop over the atoms of the van der Waals domain of the atoms of the
130! van der Waals domain of atom i
131! Q: Which atoms are in these domains?
132 do j=lvwat1(ivw),lvwat2(ivw)
133
134 loopcounter = loopcounter + 1
135! Atom type of partner
136 jty=ityat(j)
137! Differences in cartesian coordinates
138 xij=xat(j)-xi
139 yij=yat(j)-yi
140 zij=zat(j)-zi
141! 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)
146! 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
153! Coulomb interaction
154 teyel=teyel+cqi*cgat(j)/(rij*ep)
155! 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
160! 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
168! Loop over 1-4 interaction partners
169! The interactions between atoms that are three bonds apart in the protein are
170! 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)
184! 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)
193! 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
198! 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
211! 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.