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_ElecCSTab_VdwLJ_GeomW3P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwLJ_GeomW3P1_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
74 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
82 jindex = nlist->jindex;
84 shiftidx = nlist->shift;
86 shiftvec = fr->shift_vec[0];
87 fshift = fr->fshift[0];
89 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 vftab = kernel_data->table_elec->data;
95 vftabscale = kernel_data->table_elec->scale;
97 /* Setup water-specific parameters */
99 iq0 = facel*charge[inr+0];
100 iq1 = facel*charge[inr+1];
101 iq2 = facel*charge[inr+2];
102 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
107 /* Start outer loop over neighborlists */
108 for(iidx=0; iidx<nri; iidx++)
110 /* Load shift vector for this list */
111 i_shift_offset = DIM*shiftidx[iidx];
112 shX = shiftvec[i_shift_offset+XX];
113 shY = shiftvec[i_shift_offset+YY];
114 shZ = shiftvec[i_shift_offset+ZZ];
116 /* Load limits for loop over neighbors */
117 j_index_start = jindex[iidx];
118 j_index_end = jindex[iidx+1];
120 /* Get outer coordinate index */
122 i_coord_offset = DIM*inr;
124 /* Load i particle coords and add shift vector */
125 ix0 = shX + x[i_coord_offset+DIM*0+XX];
126 iy0 = shY + x[i_coord_offset+DIM*0+YY];
127 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
128 ix1 = shX + x[i_coord_offset+DIM*1+XX];
129 iy1 = shY + x[i_coord_offset+DIM*1+YY];
130 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
131 ix2 = shX + x[i_coord_offset+DIM*2+XX];
132 iy2 = shY + x[i_coord_offset+DIM*2+YY];
133 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
145 /* Reset potential sums */
149 /* Start inner kernel loop */
150 for(jidx=j_index_start; jidx<j_index_end; jidx++)
152 /* Get j neighbor index, and coordinate index */
154 j_coord_offset = DIM*jnr;
156 /* load j atom coordinates */
157 jx0 = x[j_coord_offset+DIM*0+XX];
158 jy0 = x[j_coord_offset+DIM*0+YY];
159 jz0 = x[j_coord_offset+DIM*0+ZZ];
161 /* Calculate displacement vector */
172 /* Calculate squared distance and things based on it */
173 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
174 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
175 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
177 rinv00 = gmx_invsqrt(rsq00);
178 rinv10 = gmx_invsqrt(rsq10);
179 rinv20 = gmx_invsqrt(rsq20);
181 rinvsq00 = rinv00*rinv00;
183 /* Load parameters for j particles */
185 vdwjidx0 = 2*vdwtype[jnr+0];
187 /**************************
188 * CALCULATE INTERACTIONS *
189 **************************/
194 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
195 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
197 /* Calculate table index by multiplying r with table scale and truncate to integer */
203 /* CUBIC SPLINE TABLE ELECTROSTATICS */
206 Geps = vfeps*vftab[vfitab+2];
207 Heps2 = vfeps*vfeps*vftab[vfitab+3];
211 FF = Fp+Geps+2.0*Heps2;
212 felec = -qq00*FF*vftabscale*rinv00;
214 /* LENNARD-JONES DISPERSION/REPULSION */
216 rinvsix = rinvsq00*rinvsq00*rinvsq00;
217 vvdw6 = c6_00*rinvsix;
218 vvdw12 = c12_00*rinvsix*rinvsix;
219 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
220 fvdw = (vvdw12-vvdw6)*rinvsq00;
222 /* Update potential sums from outer loop */
228 /* Calculate temporary vectorial force */
233 /* Update vectorial force */
237 f[j_coord_offset+DIM*0+XX] -= tx;
238 f[j_coord_offset+DIM*0+YY] -= ty;
239 f[j_coord_offset+DIM*0+ZZ] -= tz;
241 /**************************
242 * CALCULATE INTERACTIONS *
243 **************************/
249 /* Calculate table index by multiplying r with table scale and truncate to integer */
255 /* CUBIC SPLINE TABLE ELECTROSTATICS */
258 Geps = vfeps*vftab[vfitab+2];
259 Heps2 = vfeps*vfeps*vftab[vfitab+3];
263 FF = Fp+Geps+2.0*Heps2;
264 felec = -qq10*FF*vftabscale*rinv10;
266 /* Update potential sums from outer loop */
271 /* Calculate temporary vectorial force */
276 /* Update vectorial force */
280 f[j_coord_offset+DIM*0+XX] -= tx;
281 f[j_coord_offset+DIM*0+YY] -= ty;
282 f[j_coord_offset+DIM*0+ZZ] -= tz;
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
292 /* Calculate table index by multiplying r with table scale and truncate to integer */
298 /* CUBIC SPLINE TABLE ELECTROSTATICS */
301 Geps = vfeps*vftab[vfitab+2];
302 Heps2 = vfeps*vfeps*vftab[vfitab+3];
306 FF = Fp+Geps+2.0*Heps2;
307 felec = -qq20*FF*vftabscale*rinv20;
309 /* Update potential sums from outer loop */
314 /* Calculate temporary vectorial force */
319 /* Update vectorial force */
323 f[j_coord_offset+DIM*0+XX] -= tx;
324 f[j_coord_offset+DIM*0+YY] -= ty;
325 f[j_coord_offset+DIM*0+ZZ] -= tz;
327 /* Inner loop uses 139 flops */
329 /* End of innermost loop */
332 f[i_coord_offset+DIM*0+XX] += fix0;
333 f[i_coord_offset+DIM*0+YY] += fiy0;
334 f[i_coord_offset+DIM*0+ZZ] += fiz0;
338 f[i_coord_offset+DIM*1+XX] += fix1;
339 f[i_coord_offset+DIM*1+YY] += fiy1;
340 f[i_coord_offset+DIM*1+ZZ] += fiz1;
344 f[i_coord_offset+DIM*2+XX] += fix2;
345 f[i_coord_offset+DIM*2+YY] += fiy2;
346 f[i_coord_offset+DIM*2+ZZ] += fiz2;
350 fshift[i_shift_offset+XX] += tx;
351 fshift[i_shift_offset+YY] += ty;
352 fshift[i_shift_offset+ZZ] += tz;
355 /* Update potential energies */
356 kernel_data->energygrp_elec[ggid] += velecsum;
357 kernel_data->energygrp_vdw[ggid] += vvdwsum;
359 /* Increment number of inner iterations */
360 inneriter += j_index_end - j_index_start;
362 /* Outer loop uses 32 flops */
365 /* Increment number of outer iterations */
368 /* Update outer/inner flops */
370 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*139);
373 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW3P1_F_c
374 * Electrostatics interaction: CubicSplineTable
375 * VdW interaction: LennardJones
376 * Geometry: Water3-Particle
377 * Calculate force/pot: Force
380 nb_kernel_ElecCSTab_VdwLJ_GeomW3P1_F_c
381 (t_nblist * gmx_restrict nlist,
382 rvec * gmx_restrict xx,
383 rvec * gmx_restrict ff,
384 t_forcerec * gmx_restrict fr,
385 t_mdatoms * gmx_restrict mdatoms,
386 nb_kernel_data_t * gmx_restrict kernel_data,
387 t_nrnb * gmx_restrict nrnb)
389 int i_shift_offset,i_coord_offset,j_coord_offset;
390 int j_index_start,j_index_end;
391 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
392 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
393 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
394 real *shiftvec,*fshift,*x,*f;
396 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
398 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
400 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
402 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
403 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
404 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
405 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
406 real velec,felec,velecsum,facel,crf,krf,krf2;
409 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
413 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
421 jindex = nlist->jindex;
423 shiftidx = nlist->shift;
425 shiftvec = fr->shift_vec[0];
426 fshift = fr->fshift[0];
428 charge = mdatoms->chargeA;
429 nvdwtype = fr->ntype;
431 vdwtype = mdatoms->typeA;
433 vftab = kernel_data->table_elec->data;
434 vftabscale = kernel_data->table_elec->scale;
436 /* Setup water-specific parameters */
437 inr = nlist->iinr[0];
438 iq0 = facel*charge[inr+0];
439 iq1 = facel*charge[inr+1];
440 iq2 = facel*charge[inr+2];
441 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
446 /* Start outer loop over neighborlists */
447 for(iidx=0; iidx<nri; iidx++)
449 /* Load shift vector for this list */
450 i_shift_offset = DIM*shiftidx[iidx];
451 shX = shiftvec[i_shift_offset+XX];
452 shY = shiftvec[i_shift_offset+YY];
453 shZ = shiftvec[i_shift_offset+ZZ];
455 /* Load limits for loop over neighbors */
456 j_index_start = jindex[iidx];
457 j_index_end = jindex[iidx+1];
459 /* Get outer coordinate index */
461 i_coord_offset = DIM*inr;
463 /* Load i particle coords and add shift vector */
464 ix0 = shX + x[i_coord_offset+DIM*0+XX];
465 iy0 = shY + x[i_coord_offset+DIM*0+YY];
466 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
467 ix1 = shX + x[i_coord_offset+DIM*1+XX];
468 iy1 = shY + x[i_coord_offset+DIM*1+YY];
469 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
470 ix2 = shX + x[i_coord_offset+DIM*2+XX];
471 iy2 = shY + x[i_coord_offset+DIM*2+YY];
472 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
484 /* Start inner kernel loop */
485 for(jidx=j_index_start; jidx<j_index_end; jidx++)
487 /* Get j neighbor index, and coordinate index */
489 j_coord_offset = DIM*jnr;
491 /* load j atom coordinates */
492 jx0 = x[j_coord_offset+DIM*0+XX];
493 jy0 = x[j_coord_offset+DIM*0+YY];
494 jz0 = x[j_coord_offset+DIM*0+ZZ];
496 /* Calculate displacement vector */
507 /* Calculate squared distance and things based on it */
508 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
509 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
510 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
512 rinv00 = gmx_invsqrt(rsq00);
513 rinv10 = gmx_invsqrt(rsq10);
514 rinv20 = gmx_invsqrt(rsq20);
516 rinvsq00 = rinv00*rinv00;
518 /* Load parameters for j particles */
520 vdwjidx0 = 2*vdwtype[jnr+0];
522 /**************************
523 * CALCULATE INTERACTIONS *
524 **************************/
529 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
530 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
532 /* Calculate table index by multiplying r with table scale and truncate to integer */
538 /* CUBIC SPLINE TABLE ELECTROSTATICS */
540 Geps = vfeps*vftab[vfitab+2];
541 Heps2 = vfeps*vfeps*vftab[vfitab+3];
543 FF = Fp+Geps+2.0*Heps2;
544 felec = -qq00*FF*vftabscale*rinv00;
546 /* LENNARD-JONES DISPERSION/REPULSION */
548 rinvsix = rinvsq00*rinvsq00*rinvsq00;
549 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
553 /* Calculate temporary vectorial force */
558 /* Update vectorial force */
562 f[j_coord_offset+DIM*0+XX] -= tx;
563 f[j_coord_offset+DIM*0+YY] -= ty;
564 f[j_coord_offset+DIM*0+ZZ] -= tz;
566 /**************************
567 * CALCULATE INTERACTIONS *
568 **************************/
574 /* Calculate table index by multiplying r with table scale and truncate to integer */
580 /* CUBIC SPLINE TABLE ELECTROSTATICS */
582 Geps = vfeps*vftab[vfitab+2];
583 Heps2 = vfeps*vfeps*vftab[vfitab+3];
585 FF = Fp+Geps+2.0*Heps2;
586 felec = -qq10*FF*vftabscale*rinv10;
590 /* Calculate temporary vectorial force */
595 /* Update vectorial force */
599 f[j_coord_offset+DIM*0+XX] -= tx;
600 f[j_coord_offset+DIM*0+YY] -= ty;
601 f[j_coord_offset+DIM*0+ZZ] -= tz;
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
611 /* Calculate table index by multiplying r with table scale and truncate to integer */
617 /* CUBIC SPLINE TABLE ELECTROSTATICS */
619 Geps = vfeps*vftab[vfitab+2];
620 Heps2 = vfeps*vfeps*vftab[vfitab+3];
622 FF = Fp+Geps+2.0*Heps2;
623 felec = -qq20*FF*vftabscale*rinv20;
627 /* Calculate temporary vectorial force */
632 /* Update vectorial force */
636 f[j_coord_offset+DIM*0+XX] -= tx;
637 f[j_coord_offset+DIM*0+YY] -= ty;
638 f[j_coord_offset+DIM*0+ZZ] -= tz;
640 /* Inner loop uses 122 flops */
642 /* End of innermost loop */
645 f[i_coord_offset+DIM*0+XX] += fix0;
646 f[i_coord_offset+DIM*0+YY] += fiy0;
647 f[i_coord_offset+DIM*0+ZZ] += fiz0;
651 f[i_coord_offset+DIM*1+XX] += fix1;
652 f[i_coord_offset+DIM*1+YY] += fiy1;
653 f[i_coord_offset+DIM*1+ZZ] += fiz1;
657 f[i_coord_offset+DIM*2+XX] += fix2;
658 f[i_coord_offset+DIM*2+YY] += fiy2;
659 f[i_coord_offset+DIM*2+ZZ] += fiz2;
663 fshift[i_shift_offset+XX] += tx;
664 fshift[i_shift_offset+YY] += ty;
665 fshift[i_shift_offset+ZZ] += tz;
667 /* Increment number of inner iterations */
668 inneriter += j_index_end - j_index_start;
670 /* Outer loop uses 30 flops */
673 /* Increment number of outer iterations */
676 /* Update outer/inner flops */
678 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*122);