2 C This source code is part of
6 C Copyright (c) 1991-2000, University of Groningen, The Netherlands.
7 C Copyright (c) 2001-2009, The GROMACS Development Team
9 C Gromacs is a library for molecular simulation and trajectory analysis,
10 C written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
11 C a full list of developers and information, check out http://www.gromacs.org
13 C This program is free software; you can redistribute it and/or modify it under
14 C the terms of the GNU Lesser General Public License as published by the Free
15 C Software Foundation; either version 2 of the License, or (at your option) any
17 C As a special exception, you may use this file as part of a free software
18 C library without restriction. Specifically, if other files instantiate
19 C templates or use macros or inline functions from this file, or you compile
20 C this file and link it with other files to produce an executable, this
21 C file does not by itself cause the resulting executable to be covered by
22 C the GNU Lesser General Public License.
24 C In plain-speak: do not worry about classes/macros/templates either - only
25 C changes to the library have to be LGPL, not an application linking with it.
27 C To help fund GROMACS development, we humbly ask that you cite
28 C the papers people have written on it - you can find them on the website!
36 # define gmxreal real*8
38 # define gmxreal real*4
44 C Gromacs nonbonded kernel pwr6kernel420
45 C Coulomb interaction: Generalized-Born
46 C VdW interaction: Buckingham
47 C water optimization: No
48 C Calculate forces: yes
50 subroutine pwr6kernel420(
83 integer*4 nri,iinr(*),jindex(*),jjnr(*),shift(*)
84 gmxreal shiftvec(*),fshift(*),pos(*),faction(*)
85 integer*4 gid(*),type(*),ntype
86 gmxreal charge(*),facel,krf,crf,Vc(*),vdwparam(*)
87 gmxreal Vvdw(*),tabscale,VFtab(*)
88 gmxreal invsqrta(*),dvda(*),gbtabscale,GBtab(*)
89 integer*4 nthreads,count,mtx,outeriter,inneriter
92 integer*4 n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid
93 integer*4 nn0,nn1,nouter,ninner
95 gmxreal fscal,tx,ty,tz
98 gmxreal qq,vcoul,vctot
102 gmxreal Vvdw6,Vvdwtot
103 gmxreal r,rt,eps,eps2
105 gmxreal Y,F,Geps,Heps2,Fp,VV
108 gmxreal isai,isaj,isaprod,gbscale,vgb
109 gmxreal dvdasum,dvdatmp,dvdaj,fgb
111 gmxreal ix1,iy1,iz1,fix1,fiy1,fiz1
113 gmxreal dx11,dy11,dz11,rsq11,rinv11
114 gmxreal c6,cexp1,cexp2
117 C Reset outer and inner iteration counters
121 C Loop over thread workunits
122 10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
123 if(nn1.gt.nri) nn1=nri
125 C Start outer loop over neighborlists
129 C Load shift vector for this list
132 shY = shiftvec(is3+1)
133 shZ = shiftvec(is3+2)
135 C Load limits for loop over neighbors
139 C Get outer coordinate index
143 C Load i atom data, add shift vector
144 ix1 = shX + pos(ii3+0)
145 iy1 = shY + pos(ii3+1)
146 iz1 = shZ + pos(ii3+2)
148 C Load parameters for i atom
149 iq = facel*charge(ii)
151 nti = 3*ntype*type(ii)
153 C Zero the potential energy for this list
158 C Clear i atom forces
165 C Get j neighbor index, and coordinate index
169 C load j atom coordinates
178 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11
180 C Calculate 1/r and 1/r2
182 C PowerPC intrinsics 1/sqrt lookup table
184 rinv11 = frsqrtes(rsq11)
186 rinv11 = frsqrte(dble(rsq11))
188 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
191 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
195 C Load parameters for j atom
202 gbscale = isaprod*gbtabscale
203 tj = nti+3*type(jnr)+1
205 cexp1 = vdwparam(tj+1)
206 cexp2 = vdwparam(tj+2)
207 rinvsq = rinv11*rinv11
209 C Tabulated Generalized-Born interaction
213 C Calculate table index
221 Geps = eps*GBtab(nnn+2)
222 Heps2 = eps2*GBtab(nnn+3)
225 FF = Fp+Geps+2.0*Heps2
228 dvdatmp = -0.5*(vgb+fijC*r)
229 dvdasum = dvdasum + dvdatmp
230 dvda(jnr) = dvdaj+dvdatmp*isaj*isaj
231 vctot = vctot + vcoul
233 C Buckingham interaction
234 rinvsix = rinvsq*rinvsq*rinvsq
236 br = cexp2*rsq11*rinv11
237 Vvdwexp = cexp1*exp(-br)
238 Vvdwtot = Vvdwtot+Vvdwexp-Vvdw6
239 fscal = (br*Vvdwexp-6.0*Vvdw6)*rinvsq
240 & -(fijC-fscal)*rinv11
242 C Calculate temporary vectorial force
247 C Increment i atom force
252 C Decrement j atom force
253 faction(j3+0) = faction(j3+0) - tx
254 faction(j3+1) = faction(j3+1) - ty
255 faction(j3+2) = faction(j3+2) - tz
257 C Inner loop uses 89 flops/iteration
261 C Add i forces to mem and shifted force list
262 faction(ii3+0) = faction(ii3+0) + fix1
263 faction(ii3+1) = faction(ii3+1) + fiy1
264 faction(ii3+2) = faction(ii3+2) + fiz1
265 fshift(is3) = fshift(is3)+fix1
266 fshift(is3+1) = fshift(is3+1)+fiy1
267 fshift(is3+2) = fshift(is3+2)+fiz1
269 C Add potential energies to the group for this list
271 Vc(ggid) = Vc(ggid) + vctot
272 Vvdw(ggid) = Vvdw(ggid) + Vvdwtot
273 dvda(ii) = dvda(ii) + dvdasum*isai*isai
275 C Increment number of inner iterations
276 ninner = ninner + nj1 - nj0
278 C Outer loop uses 13 flops/iteration
282 C Increment number of outer iterations
283 nouter = nouter + nn1 - nn0
284 if(nn1.lt.nri) goto 10
286 C Write outer/inner iteration count to pointers
298 C Gromacs nonbonded kernel pwr6kernel420nf
299 C Coulomb interaction: Generalized-Born
300 C VdW interaction: Buckingham
301 C water optimization: No
302 C Calculate forces: no
304 subroutine pwr6kernel420nf(
337 integer*4 nri,iinr(*),jindex(*),jjnr(*),shift(*)
338 gmxreal shiftvec(*),fshift(*),pos(*),faction(*)
339 integer*4 gid(*),type(*),ntype
340 gmxreal charge(*),facel,krf,crf,Vc(*),vdwparam(*)
341 gmxreal Vvdw(*),tabscale,VFtab(*)
342 gmxreal invsqrta(*),dvda(*),gbtabscale,GBtab(*)
343 integer*4 nthreads,count,mtx,outeriter,inneriter
346 integer*4 n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid
347 integer*4 nn0,nn1,nouter,ninner
351 gmxreal qq,vcoul,vctot
355 gmxreal Vvdw6,Vvdwtot
356 gmxreal r,rt,eps,eps2
358 gmxreal Y,F,Geps,Heps2,Fp,VV
359 gmxreal isai,isaj,isaprod,gbscale,vgb
363 gmxreal dx11,dy11,dz11,rsq11,rinv11
364 gmxreal c6,cexp1,cexp2
367 C Reset outer and inner iteration counters
371 C Loop over thread workunits
372 10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
373 if(nn1.gt.nri) nn1=nri
375 C Start outer loop over neighborlists
379 C Load shift vector for this list
382 shY = shiftvec(is3+1)
383 shZ = shiftvec(is3+2)
385 C Load limits for loop over neighbors
389 C Get outer coordinate index
393 C Load i atom data, add shift vector
394 ix1 = shX + pos(ii3+0)
395 iy1 = shY + pos(ii3+1)
396 iz1 = shZ + pos(ii3+2)
398 C Load parameters for i atom
399 iq = facel*charge(ii)
401 nti = 3*ntype*type(ii)
403 C Zero the potential energy for this list
407 C Clear i atom forces
411 C Get j neighbor index, and coordinate index
415 C load j atom coordinates
424 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11
426 C Calculate 1/r and 1/r2
428 C PowerPC intrinsics 1/sqrt lookup table
430 rinv11 = frsqrtes(rsq11)
432 rinv11 = frsqrte(dble(rsq11))
434 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
437 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
441 C Load parameters for j atom
447 gbscale = isaprod*gbtabscale
448 tj = nti+3*type(jnr)+1
450 cexp1 = vdwparam(tj+1)
451 cexp2 = vdwparam(tj+2)
452 rinvsq = rinv11*rinv11
454 C Tabulated Generalized-Born interaction
457 C Calculate table index
465 Geps = eps*GBtab(nnn+2)
466 Heps2 = eps2*GBtab(nnn+3)
470 vctot = vctot + vcoul
472 C Buckingham interaction
473 rinvsix = rinvsq*rinvsq*rinvsq
475 br = cexp2*rsq11*rinv11
476 Vvdwexp = cexp1*exp(-br)
477 Vvdwtot = Vvdwtot+Vvdwexp-Vvdw6
479 C Inner loop uses 65 flops/iteration
483 C Add i forces to mem and shifted force list
485 C Add potential energies to the group for this list
487 Vc(ggid) = Vc(ggid) + vctot
488 Vvdw(ggid) = Vvdw(ggid) + Vvdwtot
490 C Increment number of inner iterations
491 ninner = ninner + nj1 - nj0
493 C Outer loop uses 6 flops/iteration
497 C Increment number of outer iterations
498 nouter = nouter + nn1 - nn0
499 if(nn1.lt.nri) goto 10
501 C Write outer/inner iteration count to pointers