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_ElecRFCut_VdwBhamSw_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_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;
61 real velec,felec,velecsum,facel,crf,krf,krf2;
64 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
67 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
74 jindex = nlist->jindex;
76 shiftidx = nlist->shift;
78 shiftvec = fr->shift_vec[0];
79 fshift = fr->fshift[0];
81 charge = mdatoms->chargeA;
87 vdwtype = mdatoms->typeA;
89 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
90 rcutoff = fr->rcoulomb;
91 rcutoff2 = rcutoff*rcutoff;
93 rswitch = fr->rvdw_switch;
94 /* Setup switch parameters */
97 swV4 = 15.0/(d*d*d*d);
98 swV5 = -6.0/(d*d*d*d*d);
100 swF3 = 60.0/(d*d*d*d);
101 swF4 = -30.0/(d*d*d*d*d);
106 /* Start outer loop over neighborlists */
107 for(iidx=0; iidx<nri; iidx++)
109 /* Load shift vector for this list */
110 i_shift_offset = DIM*shiftidx[iidx];
111 shX = shiftvec[i_shift_offset+XX];
112 shY = shiftvec[i_shift_offset+YY];
113 shZ = shiftvec[i_shift_offset+ZZ];
115 /* Load limits for loop over neighbors */
116 j_index_start = jindex[iidx];
117 j_index_end = jindex[iidx+1];
119 /* Get outer coordinate index */
121 i_coord_offset = DIM*inr;
123 /* Load i particle coords and add shift vector */
124 ix0 = shX + x[i_coord_offset+DIM*0+XX];
125 iy0 = shY + x[i_coord_offset+DIM*0+YY];
126 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
132 /* Load parameters for i particles */
133 iq0 = facel*charge[inr+0];
134 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
136 /* Reset potential sums */
140 /* Start inner kernel loop */
141 for(jidx=j_index_start; jidx<j_index_end; jidx++)
143 /* Get j neighbor index, and coordinate index */
145 j_coord_offset = DIM*jnr;
147 /* load j atom coordinates */
148 jx0 = x[j_coord_offset+DIM*0+XX];
149 jy0 = x[j_coord_offset+DIM*0+YY];
150 jz0 = x[j_coord_offset+DIM*0+ZZ];
152 /* Calculate displacement vector */
157 /* Calculate squared distance and things based on it */
158 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
160 rinv00 = gmx_invsqrt(rsq00);
162 rinvsq00 = rinv00*rinv00;
164 /* Load parameters for j particles */
166 vdwjidx0 = 3*vdwtype[jnr+0];
168 /**************************
169 * CALCULATE INTERACTIONS *
170 **************************/
178 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
179 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
180 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
182 /* REACTION-FIELD ELECTROSTATICS */
183 velec = qq00*(rinv00+krf*rsq00-crf);
184 felec = qq00*(rinv00*rinvsq00-krf2);
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 */
212 /* Calculate temporary vectorial force */
217 /* Update vectorial force */
221 f[j_coord_offset+DIM*0+XX] -= tx;
222 f[j_coord_offset+DIM*0+YY] -= ty;
223 f[j_coord_offset+DIM*0+ZZ] -= tz;
227 /* Inner loop uses 89 flops */
229 /* End of innermost loop */
232 f[i_coord_offset+DIM*0+XX] += fix0;
233 f[i_coord_offset+DIM*0+YY] += fiy0;
234 f[i_coord_offset+DIM*0+ZZ] += fiz0;
238 fshift[i_shift_offset+XX] += tx;
239 fshift[i_shift_offset+YY] += ty;
240 fshift[i_shift_offset+ZZ] += tz;
243 /* Update potential energies */
244 kernel_data->energygrp_elec[ggid] += velecsum;
245 kernel_data->energygrp_vdw[ggid] += vvdwsum;
247 /* Increment number of inner iterations */
248 inneriter += j_index_end - j_index_start;
250 /* Outer loop uses 15 flops */
253 /* Increment number of outer iterations */
256 /* Update outer/inner flops */
258 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*89);
261 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomP1P1_F_c
262 * Electrostatics interaction: ReactionField
263 * VdW interaction: Buckingham
264 * Geometry: Particle-Particle
265 * Calculate force/pot: Force
268 nb_kernel_ElecRFCut_VdwBhamSw_GeomP1P1_F_c
269 (t_nblist * gmx_restrict nlist,
270 rvec * gmx_restrict xx,
271 rvec * gmx_restrict ff,
272 t_forcerec * gmx_restrict fr,
273 t_mdatoms * gmx_restrict mdatoms,
274 nb_kernel_data_t * gmx_restrict kernel_data,
275 t_nrnb * gmx_restrict nrnb)
277 int i_shift_offset,i_coord_offset,j_coord_offset;
278 int j_index_start,j_index_end;
279 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
280 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
281 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
282 real *shiftvec,*fshift,*x,*f;
284 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
286 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
287 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
288 real velec,felec,velecsum,facel,crf,krf,krf2;
291 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
294 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
301 jindex = nlist->jindex;
303 shiftidx = nlist->shift;
305 shiftvec = fr->shift_vec[0];
306 fshift = fr->fshift[0];
308 charge = mdatoms->chargeA;
312 nvdwtype = fr->ntype;
314 vdwtype = mdatoms->typeA;
316 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
317 rcutoff = fr->rcoulomb;
318 rcutoff2 = rcutoff*rcutoff;
320 rswitch = fr->rvdw_switch;
321 /* Setup switch parameters */
323 swV3 = -10.0/(d*d*d);
324 swV4 = 15.0/(d*d*d*d);
325 swV5 = -6.0/(d*d*d*d*d);
326 swF2 = -30.0/(d*d*d);
327 swF3 = 60.0/(d*d*d*d);
328 swF4 = -30.0/(d*d*d*d*d);
333 /* Start outer loop over neighborlists */
334 for(iidx=0; iidx<nri; iidx++)
336 /* Load shift vector for this list */
337 i_shift_offset = DIM*shiftidx[iidx];
338 shX = shiftvec[i_shift_offset+XX];
339 shY = shiftvec[i_shift_offset+YY];
340 shZ = shiftvec[i_shift_offset+ZZ];
342 /* Load limits for loop over neighbors */
343 j_index_start = jindex[iidx];
344 j_index_end = jindex[iidx+1];
346 /* Get outer coordinate index */
348 i_coord_offset = DIM*inr;
350 /* Load i particle coords and add shift vector */
351 ix0 = shX + x[i_coord_offset+DIM*0+XX];
352 iy0 = shY + x[i_coord_offset+DIM*0+YY];
353 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
359 /* Load parameters for i particles */
360 iq0 = facel*charge[inr+0];
361 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
363 /* Start inner kernel loop */
364 for(jidx=j_index_start; jidx<j_index_end; jidx++)
366 /* Get j neighbor index, and coordinate index */
368 j_coord_offset = DIM*jnr;
370 /* load j atom coordinates */
371 jx0 = x[j_coord_offset+DIM*0+XX];
372 jy0 = x[j_coord_offset+DIM*0+YY];
373 jz0 = x[j_coord_offset+DIM*0+ZZ];
375 /* Calculate displacement vector */
380 /* Calculate squared distance and things based on it */
381 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
383 rinv00 = gmx_invsqrt(rsq00);
385 rinvsq00 = rinv00*rinv00;
387 /* Load parameters for j particles */
389 vdwjidx0 = 3*vdwtype[jnr+0];
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
401 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
402 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
403 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
405 /* REACTION-FIELD ELECTROSTATICS */
406 felec = qq00*(rinv00*rinvsq00-krf2);
408 /* BUCKINGHAM DISPERSION/REPULSION */
409 rinvsix = rinvsq00*rinvsq00*rinvsq00;
410 vvdw6 = c6_00*rinvsix;
412 vvdwexp = cexp1_00*exp(-br);
413 vvdw = vvdwexp - vvdw6*(1.0/6.0);
414 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
417 d = (d>0.0) ? d : 0.0;
419 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
421 dsw = d2*(swF2+d*(swF3+d*swF4));
423 /* Evaluate switch function */
424 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
425 fvdw = fvdw*sw - rinv00*vvdw*dsw;
429 /* Calculate temporary vectorial force */
434 /* Update vectorial force */
438 f[j_coord_offset+DIM*0+XX] -= tx;
439 f[j_coord_offset+DIM*0+YY] -= ty;
440 f[j_coord_offset+DIM*0+ZZ] -= tz;
444 /* Inner loop uses 82 flops */
446 /* End of innermost loop */
449 f[i_coord_offset+DIM*0+XX] += fix0;
450 f[i_coord_offset+DIM*0+YY] += fiy0;
451 f[i_coord_offset+DIM*0+ZZ] += fiz0;
455 fshift[i_shift_offset+XX] += tx;
456 fshift[i_shift_offset+YY] += ty;
457 fshift[i_shift_offset+ZZ] += tz;
459 /* Increment number of inner iterations */
460 inneriter += j_index_end - j_index_start;
462 /* Outer loop uses 13 flops */
465 /* Increment number of outer iterations */
468 /* Update outer/inner flops */
470 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*82);