2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_VF_c
35 * Electrostatics interaction: None
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
60 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
62 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
65 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
72 jindex = nlist->jindex;
74 shiftidx = nlist->shift;
76 shiftvec = fr->shift_vec[0];
77 fshift = fr->fshift[0];
80 vdwtype = mdatoms->typeA;
83 rcutoff2 = rcutoff*rcutoff;
85 rswitch = fr->rvdw_switch;
86 /* Setup switch parameters */
89 swV4 = 15.0/(d*d*d*d);
90 swV5 = -6.0/(d*d*d*d*d);
92 swF3 = 60.0/(d*d*d*d);
93 swF4 = -30.0/(d*d*d*d*d);
98 /* Start outer loop over neighborlists */
99 for(iidx=0; iidx<nri; iidx++)
101 /* Load shift vector for this list */
102 i_shift_offset = DIM*shiftidx[iidx];
103 shX = shiftvec[i_shift_offset+XX];
104 shY = shiftvec[i_shift_offset+YY];
105 shZ = shiftvec[i_shift_offset+ZZ];
107 /* Load limits for loop over neighbors */
108 j_index_start = jindex[iidx];
109 j_index_end = jindex[iidx+1];
111 /* Get outer coordinate index */
113 i_coord_offset = DIM*inr;
115 /* Load i particle coords and add shift vector */
116 ix0 = shX + x[i_coord_offset+DIM*0+XX];
117 iy0 = shY + x[i_coord_offset+DIM*0+YY];
118 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
124 /* Load parameters for i particles */
125 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
127 /* Reset potential sums */
130 /* Start inner kernel loop */
131 for(jidx=j_index_start; jidx<j_index_end; jidx++)
133 /* Get j neighbor index, and coordinate index */
135 j_coord_offset = DIM*jnr;
137 /* load j atom coordinates */
138 jx0 = x[j_coord_offset+DIM*0+XX];
139 jy0 = x[j_coord_offset+DIM*0+YY];
140 jz0 = x[j_coord_offset+DIM*0+ZZ];
142 /* Calculate displacement vector */
147 /* Calculate squared distance and things based on it */
148 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
150 rinv00 = gmx_invsqrt(rsq00);
152 rinvsq00 = rinv00*rinv00;
154 /* Load parameters for j particles */
155 vdwjidx0 = 3*vdwtype[jnr+0];
157 /**************************
158 * CALCULATE INTERACTIONS *
159 **************************/
166 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
167 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
168 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
170 /* BUCKINGHAM DISPERSION/REPULSION */
171 rinvsix = rinvsq00*rinvsq00*rinvsq00;
172 vvdw6 = c6_00*rinvsix;
174 vvdwexp = cexp1_00*exp(-br);
175 vvdw = vvdwexp - vvdw6*(1.0/6.0);
176 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
179 d = (d>0.0) ? d : 0.0;
181 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
183 dsw = d2*(swF2+d*(swF3+d*swF4));
185 /* Evaluate switch function */
186 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
187 fvdw = fvdw*sw - rinv00*vvdw*dsw;
190 /* Update potential sums from outer loop */
195 /* Calculate temporary vectorial force */
200 /* Update vectorial force */
204 f[j_coord_offset+DIM*0+XX] -= tx;
205 f[j_coord_offset+DIM*0+YY] -= ty;
206 f[j_coord_offset+DIM*0+ZZ] -= tz;
210 /* Inner loop uses 79 flops */
212 /* End of innermost loop */
215 f[i_coord_offset+DIM*0+XX] += fix0;
216 f[i_coord_offset+DIM*0+YY] += fiy0;
217 f[i_coord_offset+DIM*0+ZZ] += fiz0;
221 fshift[i_shift_offset+XX] += tx;
222 fshift[i_shift_offset+YY] += ty;
223 fshift[i_shift_offset+ZZ] += tz;
226 /* Update potential energies */
227 kernel_data->energygrp_vdw[ggid] += vvdwsum;
229 /* Increment number of inner iterations */
230 inneriter += j_index_end - j_index_start;
232 /* Outer loop uses 13 flops */
235 /* Increment number of outer iterations */
238 /* Update outer/inner flops */
240 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*79);
243 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_F_c
244 * Electrostatics interaction: None
245 * VdW interaction: Buckingham
246 * Geometry: Particle-Particle
247 * Calculate force/pot: Force
250 nb_kernel_ElecNone_VdwBhamSw_GeomP1P1_F_c
251 (t_nblist * gmx_restrict nlist,
252 rvec * gmx_restrict xx,
253 rvec * gmx_restrict ff,
254 t_forcerec * gmx_restrict fr,
255 t_mdatoms * gmx_restrict mdatoms,
256 nb_kernel_data_t * gmx_restrict kernel_data,
257 t_nrnb * gmx_restrict nrnb)
259 int i_shift_offset,i_coord_offset,j_coord_offset;
260 int j_index_start,j_index_end;
261 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
262 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
263 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
264 real *shiftvec,*fshift,*x,*f;
266 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
268 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
269 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
271 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
274 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
281 jindex = nlist->jindex;
283 shiftidx = nlist->shift;
285 shiftvec = fr->shift_vec[0];
286 fshift = fr->fshift[0];
287 nvdwtype = fr->ntype;
289 vdwtype = mdatoms->typeA;
292 rcutoff2 = rcutoff*rcutoff;
294 rswitch = fr->rvdw_switch;
295 /* Setup switch parameters */
297 swV3 = -10.0/(d*d*d);
298 swV4 = 15.0/(d*d*d*d);
299 swV5 = -6.0/(d*d*d*d*d);
300 swF2 = -30.0/(d*d*d);
301 swF3 = 60.0/(d*d*d*d);
302 swF4 = -30.0/(d*d*d*d*d);
307 /* Start outer loop over neighborlists */
308 for(iidx=0; iidx<nri; iidx++)
310 /* Load shift vector for this list */
311 i_shift_offset = DIM*shiftidx[iidx];
312 shX = shiftvec[i_shift_offset+XX];
313 shY = shiftvec[i_shift_offset+YY];
314 shZ = shiftvec[i_shift_offset+ZZ];
316 /* Load limits for loop over neighbors */
317 j_index_start = jindex[iidx];
318 j_index_end = jindex[iidx+1];
320 /* Get outer coordinate index */
322 i_coord_offset = DIM*inr;
324 /* Load i particle coords and add shift vector */
325 ix0 = shX + x[i_coord_offset+DIM*0+XX];
326 iy0 = shY + x[i_coord_offset+DIM*0+YY];
327 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
333 /* Load parameters for i particles */
334 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
336 /* Start inner kernel loop */
337 for(jidx=j_index_start; jidx<j_index_end; jidx++)
339 /* Get j neighbor index, and coordinate index */
341 j_coord_offset = DIM*jnr;
343 /* load j atom coordinates */
344 jx0 = x[j_coord_offset+DIM*0+XX];
345 jy0 = x[j_coord_offset+DIM*0+YY];
346 jz0 = x[j_coord_offset+DIM*0+ZZ];
348 /* Calculate displacement vector */
353 /* Calculate squared distance and things based on it */
354 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
356 rinv00 = gmx_invsqrt(rsq00);
358 rinvsq00 = rinv00*rinv00;
360 /* Load parameters for j particles */
361 vdwjidx0 = 3*vdwtype[jnr+0];
363 /**************************
364 * CALCULATE INTERACTIONS *
365 **************************/
372 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
373 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
374 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
376 /* BUCKINGHAM DISPERSION/REPULSION */
377 rinvsix = rinvsq00*rinvsq00*rinvsq00;
378 vvdw6 = c6_00*rinvsix;
380 vvdwexp = cexp1_00*exp(-br);
381 vvdw = vvdwexp - vvdw6*(1.0/6.0);
382 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
385 d = (d>0.0) ? d : 0.0;
387 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
389 dsw = d2*(swF2+d*(swF3+d*swF4));
391 /* Evaluate switch function */
392 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
393 fvdw = fvdw*sw - rinv00*vvdw*dsw;
397 /* Calculate temporary vectorial force */
402 /* Update vectorial force */
406 f[j_coord_offset+DIM*0+XX] -= tx;
407 f[j_coord_offset+DIM*0+YY] -= ty;
408 f[j_coord_offset+DIM*0+ZZ] -= tz;
412 /* Inner loop uses 77 flops */
414 /* End of innermost loop */
417 f[i_coord_offset+DIM*0+XX] += fix0;
418 f[i_coord_offset+DIM*0+YY] += fiy0;
419 f[i_coord_offset+DIM*0+ZZ] += fiz0;
423 fshift[i_shift_offset+XX] += tx;
424 fshift[i_shift_offset+YY] += ty;
425 fshift[i_shift_offset+ZZ] += tz;
427 /* Increment number of inner iterations */
428 inneriter += j_index_end - j_index_start;
430 /* Outer loop uses 12 flops */
433 /* Increment number of outer iterations */
436 /* Update outer/inner flops */
438 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*77);