2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_VF_c
51 * Electrostatics interaction: None
52 * VdW interaction: Buckingham
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
78 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
81 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
88 jindex = nlist->jindex;
90 shiftidx = nlist->shift;
92 shiftvec = fr->shift_vec[0];
93 fshift = fr->fshift[0];
96 vdwtype = mdatoms->typeA;
99 rcutoff2 = rcutoff*rcutoff;
101 rswitch = fr->rvdw_switch;
102 /* Setup switch parameters */
104 swV3 = -10.0/(d*d*d);
105 swV4 = 15.0/(d*d*d*d);
106 swV5 = -6.0/(d*d*d*d*d);
107 swF2 = -30.0/(d*d*d);
108 swF3 = 60.0/(d*d*d*d);
109 swF4 = -30.0/(d*d*d*d*d);
114 /* Start outer loop over neighborlists */
115 for(iidx=0; iidx<nri; iidx++)
117 /* Load shift vector for this list */
118 i_shift_offset = DIM*shiftidx[iidx];
119 shX = shiftvec[i_shift_offset+XX];
120 shY = shiftvec[i_shift_offset+YY];
121 shZ = shiftvec[i_shift_offset+ZZ];
123 /* Load limits for loop over neighbors */
124 j_index_start = jindex[iidx];
125 j_index_end = jindex[iidx+1];
127 /* Get outer coordinate index */
129 i_coord_offset = DIM*inr;
131 /* Load i particle coords and add shift vector */
132 ix0 = shX + x[i_coord_offset+DIM*0+XX];
133 iy0 = shY + x[i_coord_offset+DIM*0+YY];
134 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
140 /* Load parameters for i particles */
141 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
143 /* Reset potential sums */
146 /* Start inner kernel loop */
147 for(jidx=j_index_start; jidx<j_index_end; jidx++)
149 /* Get j neighbor index, and coordinate index */
151 j_coord_offset = DIM*jnr;
153 /* load j atom coordinates */
154 jx0 = x[j_coord_offset+DIM*0+XX];
155 jy0 = x[j_coord_offset+DIM*0+YY];
156 jz0 = x[j_coord_offset+DIM*0+ZZ];
158 /* Calculate displacement vector */
163 /* Calculate squared distance and things based on it */
164 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
166 rinv00 = gmx_invsqrt(rsq00);
168 rinvsq00 = rinv00*rinv00;
170 /* Load parameters for j particles */
171 vdwjidx0 = 3*vdwtype[jnr+0];
173 /**************************
174 * CALCULATE INTERACTIONS *
175 **************************/
182 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
183 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
184 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
186 /* BUCKINGHAM DISPERSION/REPULSION */
187 rinvsix = rinvsq00*rinvsq00*rinvsq00;
188 vvdw6 = c6_00*rinvsix;
190 vvdwexp = cexp1_00*exp(-br);
191 vvdw = vvdwexp - vvdw6*(1.0/6.0);
192 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
195 d = (d>0.0) ? d : 0.0;
197 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
199 dsw = d2*(swF2+d*(swF3+d*swF4));
201 /* Evaluate switch function */
202 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
203 fvdw = fvdw*sw - rinv00*vvdw*dsw;
206 /* Update potential sums from outer loop */
211 /* Calculate temporary vectorial force */
216 /* Update vectorial force */
220 f[j_coord_offset+DIM*0+XX] -= tx;
221 f[j_coord_offset+DIM*0+YY] -= ty;
222 f[j_coord_offset+DIM*0+ZZ] -= tz;
226 /* Inner loop uses 79 flops */
228 /* End of innermost loop */
231 f[i_coord_offset+DIM*0+XX] += fix0;
232 f[i_coord_offset+DIM*0+YY] += fiy0;
233 f[i_coord_offset+DIM*0+ZZ] += fiz0;
237 fshift[i_shift_offset+XX] += tx;
238 fshift[i_shift_offset+YY] += ty;
239 fshift[i_shift_offset+ZZ] += tz;
242 /* Update potential energies */
243 kernel_data->energygrp_vdw[ggid] += vvdwsum;
245 /* Increment number of inner iterations */
246 inneriter += j_index_end - j_index_start;
248 /* Outer loop uses 13 flops */
251 /* Increment number of outer iterations */
254 /* Update outer/inner flops */
256 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*79);
259 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_F_c
260 * Electrostatics interaction: None
261 * VdW interaction: Buckingham
262 * Geometry: Particle-Particle
263 * Calculate force/pot: Force
266 nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_F_c
267 (t_nblist * gmx_restrict nlist,
268 rvec * gmx_restrict xx,
269 rvec * gmx_restrict ff,
270 t_forcerec * gmx_restrict fr,
271 t_mdatoms * gmx_restrict mdatoms,
272 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
273 t_nrnb * gmx_restrict nrnb)
275 int i_shift_offset,i_coord_offset,j_coord_offset;
276 int j_index_start,j_index_end;
277 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
278 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
279 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
280 real *shiftvec,*fshift,*x,*f;
282 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
284 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
285 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
287 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
290 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
297 jindex = nlist->jindex;
299 shiftidx = nlist->shift;
301 shiftvec = fr->shift_vec[0];
302 fshift = fr->fshift[0];
303 nvdwtype = fr->ntype;
305 vdwtype = mdatoms->typeA;
308 rcutoff2 = rcutoff*rcutoff;
310 rswitch = fr->rvdw_switch;
311 /* Setup switch parameters */
313 swV3 = -10.0/(d*d*d);
314 swV4 = 15.0/(d*d*d*d);
315 swV5 = -6.0/(d*d*d*d*d);
316 swF2 = -30.0/(d*d*d);
317 swF3 = 60.0/(d*d*d*d);
318 swF4 = -30.0/(d*d*d*d*d);
323 /* Start outer loop over neighborlists */
324 for(iidx=0; iidx<nri; iidx++)
326 /* Load shift vector for this list */
327 i_shift_offset = DIM*shiftidx[iidx];
328 shX = shiftvec[i_shift_offset+XX];
329 shY = shiftvec[i_shift_offset+YY];
330 shZ = shiftvec[i_shift_offset+ZZ];
332 /* Load limits for loop over neighbors */
333 j_index_start = jindex[iidx];
334 j_index_end = jindex[iidx+1];
336 /* Get outer coordinate index */
338 i_coord_offset = DIM*inr;
340 /* Load i particle coords and add shift vector */
341 ix0 = shX + x[i_coord_offset+DIM*0+XX];
342 iy0 = shY + x[i_coord_offset+DIM*0+YY];
343 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
349 /* Load parameters for i particles */
350 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
352 /* Start inner kernel loop */
353 for(jidx=j_index_start; jidx<j_index_end; jidx++)
355 /* Get j neighbor index, and coordinate index */
357 j_coord_offset = DIM*jnr;
359 /* load j atom coordinates */
360 jx0 = x[j_coord_offset+DIM*0+XX];
361 jy0 = x[j_coord_offset+DIM*0+YY];
362 jz0 = x[j_coord_offset+DIM*0+ZZ];
364 /* Calculate displacement vector */
369 /* Calculate squared distance and things based on it */
370 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
372 rinv00 = gmx_invsqrt(rsq00);
374 rinvsq00 = rinv00*rinv00;
376 /* Load parameters for j particles */
377 vdwjidx0 = 3*vdwtype[jnr+0];
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
388 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
389 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
390 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
392 /* BUCKINGHAM DISPERSION/REPULSION */
393 rinvsix = rinvsq00*rinvsq00*rinvsq00;
394 vvdw6 = c6_00*rinvsix;
396 vvdwexp = cexp1_00*exp(-br);
397 vvdw = vvdwexp - vvdw6*(1.0/6.0);
398 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
401 d = (d>0.0) ? d : 0.0;
403 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
405 dsw = d2*(swF2+d*(swF3+d*swF4));
407 /* Evaluate switch function */
408 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
409 fvdw = fvdw*sw - rinv00*vvdw*dsw;
413 /* Calculate temporary vectorial force */
418 /* Update vectorial force */
422 f[j_coord_offset+DIM*0+XX] -= tx;
423 f[j_coord_offset+DIM*0+YY] -= ty;
424 f[j_coord_offset+DIM*0+ZZ] -= tz;
428 /* Inner loop uses 77 flops */
430 /* End of innermost loop */
433 f[i_coord_offset+DIM*0+XX] += fix0;
434 f[i_coord_offset+DIM*0+YY] += fiy0;
435 f[i_coord_offset+DIM*0+ZZ] += fiz0;
439 fshift[i_shift_offset+XX] += tx;
440 fshift[i_shift_offset+YY] += ty;
441 fshift[i_shift_offset+ZZ] += tz;
443 /* Increment number of inner iterations */
444 inneriter += j_index_end - j_index_start;
446 /* Outer loop uses 12 flops */
449 /* Increment number of outer iterations */
452 /* Update outer/inner flops */
454 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*77);