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_ElecEw_VdwCSTab_GeomW3P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwCSTab_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;
77 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
85 jindex = nlist->jindex;
87 shiftidx = nlist->shift;
89 shiftvec = fr->shift_vec[0];
90 fshift = fr->fshift[0];
92 charge = mdatoms->chargeA;
95 vdwtype = mdatoms->typeA;
97 vftab = kernel_data->table_vdw->data;
98 vftabscale = kernel_data->table_vdw->scale;
100 sh_ewald = fr->ic->sh_ewald;
101 ewtab = fr->ic->tabq_coul_FDV0;
102 ewtabscale = fr->ic->tabq_scale;
103 ewtabhalfspace = 0.5/ewtabscale;
105 /* Setup water-specific parameters */
106 inr = nlist->iinr[0];
107 iq0 = facel*charge[inr+0];
108 iq1 = facel*charge[inr+1];
109 iq2 = facel*charge[inr+2];
110 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
115 /* Start outer loop over neighborlists */
116 for(iidx=0; iidx<nri; iidx++)
118 /* Load shift vector for this list */
119 i_shift_offset = DIM*shiftidx[iidx];
120 shX = shiftvec[i_shift_offset+XX];
121 shY = shiftvec[i_shift_offset+YY];
122 shZ = shiftvec[i_shift_offset+ZZ];
124 /* Load limits for loop over neighbors */
125 j_index_start = jindex[iidx];
126 j_index_end = jindex[iidx+1];
128 /* Get outer coordinate index */
130 i_coord_offset = DIM*inr;
132 /* Load i particle coords and add shift vector */
133 ix0 = shX + x[i_coord_offset+DIM*0+XX];
134 iy0 = shY + x[i_coord_offset+DIM*0+YY];
135 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
136 ix1 = shX + x[i_coord_offset+DIM*1+XX];
137 iy1 = shY + x[i_coord_offset+DIM*1+YY];
138 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
139 ix2 = shX + x[i_coord_offset+DIM*2+XX];
140 iy2 = shY + x[i_coord_offset+DIM*2+YY];
141 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
153 /* Reset potential sums */
157 /* Start inner kernel loop */
158 for(jidx=j_index_start; jidx<j_index_end; jidx++)
160 /* Get j neighbor index, and coordinate index */
162 j_coord_offset = DIM*jnr;
164 /* load j atom coordinates */
165 jx0 = x[j_coord_offset+DIM*0+XX];
166 jy0 = x[j_coord_offset+DIM*0+YY];
167 jz0 = x[j_coord_offset+DIM*0+ZZ];
169 /* Calculate displacement vector */
180 /* Calculate squared distance and things based on it */
181 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
182 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
183 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
185 rinv00 = gmx_invsqrt(rsq00);
186 rinv10 = gmx_invsqrt(rsq10);
187 rinv20 = gmx_invsqrt(rsq20);
189 rinvsq00 = rinv00*rinv00;
190 rinvsq10 = rinv10*rinv10;
191 rinvsq20 = rinv20*rinv20;
193 /* Load parameters for j particles */
195 vdwjidx0 = 2*vdwtype[jnr+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
204 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
205 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
207 /* Calculate table index by multiplying r with table scale and truncate to integer */
213 /* EWALD ELECTROSTATICS */
215 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
216 ewrt = r00*ewtabscale;
220 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
221 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
222 felec = qq00*rinv00*(rinvsq00-felec);
224 /* CUBIC SPLINE TABLE DISPERSION */
228 Geps = vfeps*vftab[vfitab+2];
229 Heps2 = vfeps*vfeps*vftab[vfitab+3];
233 FF = Fp+Geps+2.0*Heps2;
236 /* CUBIC SPLINE TABLE REPULSION */
239 Geps = vfeps*vftab[vfitab+6];
240 Heps2 = vfeps*vfeps*vftab[vfitab+7];
244 FF = Fp+Geps+2.0*Heps2;
247 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
249 /* Update potential sums from outer loop */
255 /* Calculate temporary vectorial force */
260 /* Update vectorial force */
264 f[j_coord_offset+DIM*0+XX] -= tx;
265 f[j_coord_offset+DIM*0+YY] -= ty;
266 f[j_coord_offset+DIM*0+ZZ] -= tz;
268 /**************************
269 * CALCULATE INTERACTIONS *
270 **************************/
276 /* EWALD ELECTROSTATICS */
278 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
279 ewrt = r10*ewtabscale;
283 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
284 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
285 felec = qq10*rinv10*(rinvsq10-felec);
287 /* Update potential sums from outer loop */
292 /* Calculate temporary vectorial force */
297 /* Update vectorial force */
301 f[j_coord_offset+DIM*0+XX] -= tx;
302 f[j_coord_offset+DIM*0+YY] -= ty;
303 f[j_coord_offset+DIM*0+ZZ] -= tz;
305 /**************************
306 * CALCULATE INTERACTIONS *
307 **************************/
313 /* EWALD ELECTROSTATICS */
315 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
316 ewrt = r20*ewtabscale;
320 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
321 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
322 felec = qq20*rinv20*(rinvsq20-felec);
324 /* Update potential sums from outer loop */
329 /* Calculate temporary vectorial force */
334 /* Update vectorial force */
338 f[j_coord_offset+DIM*0+XX] -= tx;
339 f[j_coord_offset+DIM*0+YY] -= ty;
340 f[j_coord_offset+DIM*0+ZZ] -= tz;
342 /* Inner loop uses 156 flops */
344 /* End of innermost loop */
347 f[i_coord_offset+DIM*0+XX] += fix0;
348 f[i_coord_offset+DIM*0+YY] += fiy0;
349 f[i_coord_offset+DIM*0+ZZ] += fiz0;
353 f[i_coord_offset+DIM*1+XX] += fix1;
354 f[i_coord_offset+DIM*1+YY] += fiy1;
355 f[i_coord_offset+DIM*1+ZZ] += fiz1;
359 f[i_coord_offset+DIM*2+XX] += fix2;
360 f[i_coord_offset+DIM*2+YY] += fiy2;
361 f[i_coord_offset+DIM*2+ZZ] += fiz2;
365 fshift[i_shift_offset+XX] += tx;
366 fshift[i_shift_offset+YY] += ty;
367 fshift[i_shift_offset+ZZ] += tz;
370 /* Update potential energies */
371 kernel_data->energygrp_elec[ggid] += velecsum;
372 kernel_data->energygrp_vdw[ggid] += vvdwsum;
374 /* Increment number of inner iterations */
375 inneriter += j_index_end - j_index_start;
377 /* Outer loop uses 32 flops */
380 /* Increment number of outer iterations */
383 /* Update outer/inner flops */
385 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*156);
388 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3P1_F_c
389 * Electrostatics interaction: Ewald
390 * VdW interaction: CubicSplineTable
391 * Geometry: Water3-Particle
392 * Calculate force/pot: Force
395 nb_kernel_ElecEw_VdwCSTab_GeomW3P1_F_c
396 (t_nblist * gmx_restrict nlist,
397 rvec * gmx_restrict xx,
398 rvec * gmx_restrict ff,
399 t_forcerec * gmx_restrict fr,
400 t_mdatoms * gmx_restrict mdatoms,
401 nb_kernel_data_t * gmx_restrict kernel_data,
402 t_nrnb * gmx_restrict nrnb)
404 int i_shift_offset,i_coord_offset,j_coord_offset;
405 int j_index_start,j_index_end;
406 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
407 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
408 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
409 real *shiftvec,*fshift,*x,*f;
411 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
413 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
415 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
417 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
419 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
420 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
421 real velec,felec,velecsum,facel,crf,krf,krf2;
424 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
428 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
431 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
439 jindex = nlist->jindex;
441 shiftidx = nlist->shift;
443 shiftvec = fr->shift_vec[0];
444 fshift = fr->fshift[0];
446 charge = mdatoms->chargeA;
447 nvdwtype = fr->ntype;
449 vdwtype = mdatoms->typeA;
451 vftab = kernel_data->table_vdw->data;
452 vftabscale = kernel_data->table_vdw->scale;
454 sh_ewald = fr->ic->sh_ewald;
455 ewtab = fr->ic->tabq_coul_F;
456 ewtabscale = fr->ic->tabq_scale;
457 ewtabhalfspace = 0.5/ewtabscale;
459 /* Setup water-specific parameters */
460 inr = nlist->iinr[0];
461 iq0 = facel*charge[inr+0];
462 iq1 = facel*charge[inr+1];
463 iq2 = facel*charge[inr+2];
464 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
469 /* Start outer loop over neighborlists */
470 for(iidx=0; iidx<nri; iidx++)
472 /* Load shift vector for this list */
473 i_shift_offset = DIM*shiftidx[iidx];
474 shX = shiftvec[i_shift_offset+XX];
475 shY = shiftvec[i_shift_offset+YY];
476 shZ = shiftvec[i_shift_offset+ZZ];
478 /* Load limits for loop over neighbors */
479 j_index_start = jindex[iidx];
480 j_index_end = jindex[iidx+1];
482 /* Get outer coordinate index */
484 i_coord_offset = DIM*inr;
486 /* Load i particle coords and add shift vector */
487 ix0 = shX + x[i_coord_offset+DIM*0+XX];
488 iy0 = shY + x[i_coord_offset+DIM*0+YY];
489 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
490 ix1 = shX + x[i_coord_offset+DIM*1+XX];
491 iy1 = shY + x[i_coord_offset+DIM*1+YY];
492 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
493 ix2 = shX + x[i_coord_offset+DIM*2+XX];
494 iy2 = shY + x[i_coord_offset+DIM*2+YY];
495 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
507 /* Start inner kernel loop */
508 for(jidx=j_index_start; jidx<j_index_end; jidx++)
510 /* Get j neighbor index, and coordinate index */
512 j_coord_offset = DIM*jnr;
514 /* load j atom coordinates */
515 jx0 = x[j_coord_offset+DIM*0+XX];
516 jy0 = x[j_coord_offset+DIM*0+YY];
517 jz0 = x[j_coord_offset+DIM*0+ZZ];
519 /* Calculate displacement vector */
530 /* Calculate squared distance and things based on it */
531 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
532 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
533 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
535 rinv00 = gmx_invsqrt(rsq00);
536 rinv10 = gmx_invsqrt(rsq10);
537 rinv20 = gmx_invsqrt(rsq20);
539 rinvsq00 = rinv00*rinv00;
540 rinvsq10 = rinv10*rinv10;
541 rinvsq20 = rinv20*rinv20;
543 /* Load parameters for j particles */
545 vdwjidx0 = 2*vdwtype[jnr+0];
547 /**************************
548 * CALCULATE INTERACTIONS *
549 **************************/
554 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
555 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
557 /* Calculate table index by multiplying r with table scale and truncate to integer */
563 /* EWALD ELECTROSTATICS */
565 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
566 ewrt = r00*ewtabscale;
569 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
570 felec = qq00*rinv00*(rinvsq00-felec);
572 /* CUBIC SPLINE TABLE DISPERSION */
576 Geps = vfeps*vftab[vfitab+2];
577 Heps2 = vfeps*vfeps*vftab[vfitab+3];
579 FF = Fp+Geps+2.0*Heps2;
582 /* CUBIC SPLINE TABLE REPULSION */
585 Geps = vfeps*vftab[vfitab+6];
586 Heps2 = vfeps*vfeps*vftab[vfitab+7];
588 FF = Fp+Geps+2.0*Heps2;
590 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
594 /* Calculate temporary vectorial force */
599 /* Update vectorial force */
603 f[j_coord_offset+DIM*0+XX] -= tx;
604 f[j_coord_offset+DIM*0+YY] -= ty;
605 f[j_coord_offset+DIM*0+ZZ] -= tz;
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
615 /* EWALD ELECTROSTATICS */
617 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
618 ewrt = r10*ewtabscale;
621 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
622 felec = qq10*rinv10*(rinvsq10-felec);
626 /* Calculate temporary vectorial force */
631 /* Update vectorial force */
635 f[j_coord_offset+DIM*0+XX] -= tx;
636 f[j_coord_offset+DIM*0+YY] -= ty;
637 f[j_coord_offset+DIM*0+ZZ] -= tz;
639 /**************************
640 * CALCULATE INTERACTIONS *
641 **************************/
647 /* EWALD ELECTROSTATICS */
649 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
650 ewrt = r20*ewtabscale;
653 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
654 felec = qq20*rinv20*(rinvsq20-felec);
658 /* Calculate temporary vectorial force */
663 /* Update vectorial force */
667 f[j_coord_offset+DIM*0+XX] -= tx;
668 f[j_coord_offset+DIM*0+YY] -= ty;
669 f[j_coord_offset+DIM*0+ZZ] -= tz;
671 /* Inner loop uses 127 flops */
673 /* End of innermost loop */
676 f[i_coord_offset+DIM*0+XX] += fix0;
677 f[i_coord_offset+DIM*0+YY] += fiy0;
678 f[i_coord_offset+DIM*0+ZZ] += fiz0;
682 f[i_coord_offset+DIM*1+XX] += fix1;
683 f[i_coord_offset+DIM*1+YY] += fiy1;
684 f[i_coord_offset+DIM*1+ZZ] += fiz1;
688 f[i_coord_offset+DIM*2+XX] += fix2;
689 f[i_coord_offset+DIM*2+YY] += fiy2;
690 f[i_coord_offset+DIM*2+ZZ] += fiz2;
694 fshift[i_shift_offset+XX] += tx;
695 fshift[i_shift_offset+YY] += ty;
696 fshift[i_shift_offset+ZZ] += tz;
698 /* Increment number of inner iterations */
699 inneriter += j_index_end - j_index_start;
701 /* Outer loop uses 30 flops */
704 /* Increment number of outer iterations */
707 /* Update outer/inner flops */
709 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*127);