2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source 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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_VF_c
49 * Electrostatics interaction: None
50 * VdW interaction: Buckingham
51 * Geometry: Particle-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
76 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
79 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
86 jindex = nlist->jindex;
88 shiftidx = nlist->shift;
90 shiftvec = fr->shift_vec[0];
91 fshift = fr->fshift[0];
94 vdwtype = mdatoms->typeA;
97 rcutoff2 = rcutoff*rcutoff;
99 rswitch = fr->rvdw_switch;
100 /* Setup switch parameters */
102 swV3 = -10.0/(d*d*d);
103 swV4 = 15.0/(d*d*d*d);
104 swV5 = -6.0/(d*d*d*d*d);
105 swF2 = -30.0/(d*d*d);
106 swF3 = 60.0/(d*d*d*d);
107 swF4 = -30.0/(d*d*d*d*d);
112 /* Start outer loop over neighborlists */
113 for(iidx=0; iidx<nri; iidx++)
115 /* Load shift vector for this list */
116 i_shift_offset = DIM*shiftidx[iidx];
117 shX = shiftvec[i_shift_offset+XX];
118 shY = shiftvec[i_shift_offset+YY];
119 shZ = shiftvec[i_shift_offset+ZZ];
121 /* Load limits for loop over neighbors */
122 j_index_start = jindex[iidx];
123 j_index_end = jindex[iidx+1];
125 /* Get outer coordinate index */
127 i_coord_offset = DIM*inr;
129 /* Load i particle coords and add shift vector */
130 ix0 = shX + x[i_coord_offset+DIM*0+XX];
131 iy0 = shY + x[i_coord_offset+DIM*0+YY];
132 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
138 /* Load parameters for i particles */
139 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
141 /* Reset potential sums */
144 /* Start inner kernel loop */
145 for(jidx=j_index_start; jidx<j_index_end; jidx++)
147 /* Get j neighbor index, and coordinate index */
149 j_coord_offset = DIM*jnr;
151 /* load j atom coordinates */
152 jx0 = x[j_coord_offset+DIM*0+XX];
153 jy0 = x[j_coord_offset+DIM*0+YY];
154 jz0 = x[j_coord_offset+DIM*0+ZZ];
156 /* Calculate displacement vector */
161 /* Calculate squared distance and things based on it */
162 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
164 rinv00 = gmx_invsqrt(rsq00);
166 rinvsq00 = rinv00*rinv00;
168 /* Load parameters for j particles */
169 vdwjidx0 = 3*vdwtype[jnr+0];
171 /**************************
172 * CALCULATE INTERACTIONS *
173 **************************/
180 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
181 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
182 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
184 /* BUCKINGHAM DISPERSION/REPULSION */
185 rinvsix = rinvsq00*rinvsq00*rinvsq00;
186 vvdw6 = c6_00*rinvsix;
188 vvdwexp = cexp1_00*exp(-br);
189 vvdw = vvdwexp - vvdw6*(1.0/6.0);
190 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
193 d = (d>0.0) ? d : 0.0;
195 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
197 dsw = d2*(swF2+d*(swF3+d*swF4));
199 /* Evaluate switch function */
200 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
201 fvdw = fvdw*sw - rinv00*vvdw*dsw;
204 /* Update potential sums from outer loop */
209 /* Calculate temporary vectorial force */
214 /* Update vectorial force */
218 f[j_coord_offset+DIM*0+XX] -= tx;
219 f[j_coord_offset+DIM*0+YY] -= ty;
220 f[j_coord_offset+DIM*0+ZZ] -= tz;
224 /* Inner loop uses 79 flops */
226 /* End of innermost loop */
229 f[i_coord_offset+DIM*0+XX] += fix0;
230 f[i_coord_offset+DIM*0+YY] += fiy0;
231 f[i_coord_offset+DIM*0+ZZ] += fiz0;
235 fshift[i_shift_offset+XX] += tx;
236 fshift[i_shift_offset+YY] += ty;
237 fshift[i_shift_offset+ZZ] += tz;
240 /* Update potential energies */
241 kernel_data->energygrp_vdw[ggid] += vvdwsum;
243 /* Increment number of inner iterations */
244 inneriter += j_index_end - j_index_start;
246 /* Outer loop uses 13 flops */
249 /* Increment number of outer iterations */
252 /* Update outer/inner flops */
254 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*79);
257 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_F_c
258 * Electrostatics interaction: None
259 * VdW interaction: Buckingham
260 * Geometry: Particle-Particle
261 * Calculate force/pot: Force
264 nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_F_c
265 (t_nblist * gmx_restrict nlist,
266 rvec * gmx_restrict xx,
267 rvec * gmx_restrict ff,
268 t_forcerec * gmx_restrict fr,
269 t_mdatoms * gmx_restrict mdatoms,
270 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
271 t_nrnb * gmx_restrict nrnb)
273 int i_shift_offset,i_coord_offset,j_coord_offset;
274 int j_index_start,j_index_end;
275 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
276 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
277 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
278 real *shiftvec,*fshift,*x,*f;
280 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
282 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
283 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
285 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
288 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
295 jindex = nlist->jindex;
297 shiftidx = nlist->shift;
299 shiftvec = fr->shift_vec[0];
300 fshift = fr->fshift[0];
301 nvdwtype = fr->ntype;
303 vdwtype = mdatoms->typeA;
306 rcutoff2 = rcutoff*rcutoff;
308 rswitch = fr->rvdw_switch;
309 /* Setup switch parameters */
311 swV3 = -10.0/(d*d*d);
312 swV4 = 15.0/(d*d*d*d);
313 swV5 = -6.0/(d*d*d*d*d);
314 swF2 = -30.0/(d*d*d);
315 swF3 = 60.0/(d*d*d*d);
316 swF4 = -30.0/(d*d*d*d*d);
321 /* Start outer loop over neighborlists */
322 for(iidx=0; iidx<nri; iidx++)
324 /* Load shift vector for this list */
325 i_shift_offset = DIM*shiftidx[iidx];
326 shX = shiftvec[i_shift_offset+XX];
327 shY = shiftvec[i_shift_offset+YY];
328 shZ = shiftvec[i_shift_offset+ZZ];
330 /* Load limits for loop over neighbors */
331 j_index_start = jindex[iidx];
332 j_index_end = jindex[iidx+1];
334 /* Get outer coordinate index */
336 i_coord_offset = DIM*inr;
338 /* Load i particle coords and add shift vector */
339 ix0 = shX + x[i_coord_offset+DIM*0+XX];
340 iy0 = shY + x[i_coord_offset+DIM*0+YY];
341 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
347 /* Load parameters for i particles */
348 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
350 /* Start inner kernel loop */
351 for(jidx=j_index_start; jidx<j_index_end; jidx++)
353 /* Get j neighbor index, and coordinate index */
355 j_coord_offset = DIM*jnr;
357 /* load j atom coordinates */
358 jx0 = x[j_coord_offset+DIM*0+XX];
359 jy0 = x[j_coord_offset+DIM*0+YY];
360 jz0 = x[j_coord_offset+DIM*0+ZZ];
362 /* Calculate displacement vector */
367 /* Calculate squared distance and things based on it */
368 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
370 rinv00 = gmx_invsqrt(rsq00);
372 rinvsq00 = rinv00*rinv00;
374 /* Load parameters for j particles */
375 vdwjidx0 = 3*vdwtype[jnr+0];
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
386 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
387 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
388 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
390 /* BUCKINGHAM DISPERSION/REPULSION */
391 rinvsix = rinvsq00*rinvsq00*rinvsq00;
392 vvdw6 = c6_00*rinvsix;
394 vvdwexp = cexp1_00*exp(-br);
395 vvdw = vvdwexp - vvdw6*(1.0/6.0);
396 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
399 d = (d>0.0) ? d : 0.0;
401 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
403 dsw = d2*(swF2+d*(swF3+d*swF4));
405 /* Evaluate switch function */
406 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
407 fvdw = fvdw*sw - rinv00*vvdw*dsw;
411 /* Calculate temporary vectorial force */
416 /* Update vectorial force */
420 f[j_coord_offset+DIM*0+XX] -= tx;
421 f[j_coord_offset+DIM*0+YY] -= ty;
422 f[j_coord_offset+DIM*0+ZZ] -= tz;
426 /* Inner loop uses 77 flops */
428 /* End of innermost loop */
431 f[i_coord_offset+DIM*0+XX] += fix0;
432 f[i_coord_offset+DIM*0+YY] += fiy0;
433 f[i_coord_offset+DIM*0+ZZ] += fiz0;
437 fshift[i_shift_offset+XX] += tx;
438 fshift[i_shift_offset+YY] += ty;
439 fshift[i_shift_offset+ZZ] += tz;
441 /* Increment number of inner iterations */
442 inneriter += j_index_end - j_index_start;
444 /* Outer loop uses 12 flops */
447 /* Increment number of outer iterations */
450 /* Update outer/inner flops */
452 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*77);