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_GeomW4P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwCSTab_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
66 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
67 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
68 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
69 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
70 real velec,felec,velecsum,facel,crf,krf,krf2;
73 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
77 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
80 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
88 jindex = nlist->jindex;
90 shiftidx = nlist->shift;
92 shiftvec = fr->shift_vec[0];
93 fshift = fr->fshift[0];
95 charge = mdatoms->chargeA;
98 vdwtype = mdatoms->typeA;
100 vftab = kernel_data->table_vdw->data;
101 vftabscale = kernel_data->table_vdw->scale;
103 sh_ewald = fr->ic->sh_ewald;
104 ewtab = fr->ic->tabq_coul_FDV0;
105 ewtabscale = fr->ic->tabq_scale;
106 ewtabhalfspace = 0.5/ewtabscale;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 iq3 = facel*charge[inr+3];
113 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
118 /* Start outer loop over neighborlists */
119 for(iidx=0; iidx<nri; iidx++)
121 /* Load shift vector for this list */
122 i_shift_offset = DIM*shiftidx[iidx];
123 shX = shiftvec[i_shift_offset+XX];
124 shY = shiftvec[i_shift_offset+YY];
125 shZ = shiftvec[i_shift_offset+ZZ];
127 /* Load limits for loop over neighbors */
128 j_index_start = jindex[iidx];
129 j_index_end = jindex[iidx+1];
131 /* Get outer coordinate index */
133 i_coord_offset = DIM*inr;
135 /* Load i particle coords and add shift vector */
136 ix0 = shX + x[i_coord_offset+DIM*0+XX];
137 iy0 = shY + x[i_coord_offset+DIM*0+YY];
138 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
139 ix1 = shX + x[i_coord_offset+DIM*1+XX];
140 iy1 = shY + x[i_coord_offset+DIM*1+YY];
141 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
142 ix2 = shX + x[i_coord_offset+DIM*2+XX];
143 iy2 = shY + x[i_coord_offset+DIM*2+YY];
144 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
145 ix3 = shX + x[i_coord_offset+DIM*3+XX];
146 iy3 = shY + x[i_coord_offset+DIM*3+YY];
147 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
162 /* Reset potential sums */
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end; jidx++)
169 /* Get j neighbor index, and coordinate index */
171 j_coord_offset = DIM*jnr;
173 /* load j atom coordinates */
174 jx0 = x[j_coord_offset+DIM*0+XX];
175 jy0 = x[j_coord_offset+DIM*0+YY];
176 jz0 = x[j_coord_offset+DIM*0+ZZ];
178 /* Calculate displacement vector */
192 /* Calculate squared distance and things based on it */
193 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
194 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
195 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
196 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
198 rinv00 = gmx_invsqrt(rsq00);
199 rinv10 = gmx_invsqrt(rsq10);
200 rinv20 = gmx_invsqrt(rsq20);
201 rinv30 = gmx_invsqrt(rsq30);
203 rinvsq10 = rinv10*rinv10;
204 rinvsq20 = rinv20*rinv20;
205 rinvsq30 = rinv30*rinv30;
207 /* Load parameters for j particles */
209 vdwjidx0 = 2*vdwtype[jnr+0];
211 /**************************
212 * CALCULATE INTERACTIONS *
213 **************************/
217 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
218 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
220 /* Calculate table index by multiplying r with table scale and truncate to integer */
226 /* CUBIC SPLINE TABLE DISPERSION */
230 Geps = vfeps*vftab[vfitab+2];
231 Heps2 = vfeps*vfeps*vftab[vfitab+3];
235 FF = Fp+Geps+2.0*Heps2;
238 /* CUBIC SPLINE TABLE REPULSION */
241 Geps = vfeps*vftab[vfitab+6];
242 Heps2 = vfeps*vfeps*vftab[vfitab+7];
246 FF = Fp+Geps+2.0*Heps2;
249 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
251 /* Update potential sums from outer loop */
256 /* Calculate temporary vectorial force */
261 /* Update vectorial force */
265 f[j_coord_offset+DIM*0+XX] -= tx;
266 f[j_coord_offset+DIM*0+YY] -= ty;
267 f[j_coord_offset+DIM*0+ZZ] -= tz;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
277 /* EWALD ELECTROSTATICS */
279 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
280 ewrt = r10*ewtabscale;
284 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
285 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
286 felec = qq10*rinv10*(rinvsq10-felec);
288 /* Update potential sums from outer loop */
293 /* Calculate temporary vectorial force */
298 /* Update vectorial force */
302 f[j_coord_offset+DIM*0+XX] -= tx;
303 f[j_coord_offset+DIM*0+YY] -= ty;
304 f[j_coord_offset+DIM*0+ZZ] -= tz;
306 /**************************
307 * CALCULATE INTERACTIONS *
308 **************************/
314 /* EWALD ELECTROSTATICS */
316 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
317 ewrt = r20*ewtabscale;
321 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
322 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
323 felec = qq20*rinv20*(rinvsq20-felec);
325 /* Update potential sums from outer loop */
330 /* Calculate temporary vectorial force */
335 /* Update vectorial force */
339 f[j_coord_offset+DIM*0+XX] -= tx;
340 f[j_coord_offset+DIM*0+YY] -= ty;
341 f[j_coord_offset+DIM*0+ZZ] -= tz;
343 /**************************
344 * CALCULATE INTERACTIONS *
345 **************************/
351 /* EWALD ELECTROSTATICS */
353 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
354 ewrt = r30*ewtabscale;
358 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
359 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
360 felec = qq30*rinv30*(rinvsq30-felec);
362 /* Update potential sums from outer loop */
367 /* Calculate temporary vectorial force */
372 /* Update vectorial force */
376 f[j_coord_offset+DIM*0+XX] -= tx;
377 f[j_coord_offset+DIM*0+YY] -= ty;
378 f[j_coord_offset+DIM*0+ZZ] -= tz;
380 /* Inner loop uses 178 flops */
382 /* End of innermost loop */
385 f[i_coord_offset+DIM*0+XX] += fix0;
386 f[i_coord_offset+DIM*0+YY] += fiy0;
387 f[i_coord_offset+DIM*0+ZZ] += fiz0;
391 f[i_coord_offset+DIM*1+XX] += fix1;
392 f[i_coord_offset+DIM*1+YY] += fiy1;
393 f[i_coord_offset+DIM*1+ZZ] += fiz1;
397 f[i_coord_offset+DIM*2+XX] += fix2;
398 f[i_coord_offset+DIM*2+YY] += fiy2;
399 f[i_coord_offset+DIM*2+ZZ] += fiz2;
403 f[i_coord_offset+DIM*3+XX] += fix3;
404 f[i_coord_offset+DIM*3+YY] += fiy3;
405 f[i_coord_offset+DIM*3+ZZ] += fiz3;
409 fshift[i_shift_offset+XX] += tx;
410 fshift[i_shift_offset+YY] += ty;
411 fshift[i_shift_offset+ZZ] += tz;
414 /* Update potential energies */
415 kernel_data->energygrp_elec[ggid] += velecsum;
416 kernel_data->energygrp_vdw[ggid] += vvdwsum;
418 /* Increment number of inner iterations */
419 inneriter += j_index_end - j_index_start;
421 /* Outer loop uses 41 flops */
424 /* Increment number of outer iterations */
427 /* Update outer/inner flops */
429 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*178);
432 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW4P1_F_c
433 * Electrostatics interaction: Ewald
434 * VdW interaction: CubicSplineTable
435 * Geometry: Water4-Particle
436 * Calculate force/pot: Force
439 nb_kernel_ElecEw_VdwCSTab_GeomW4P1_F_c
440 (t_nblist * gmx_restrict nlist,
441 rvec * gmx_restrict xx,
442 rvec * gmx_restrict ff,
443 t_forcerec * gmx_restrict fr,
444 t_mdatoms * gmx_restrict mdatoms,
445 nb_kernel_data_t * gmx_restrict kernel_data,
446 t_nrnb * gmx_restrict nrnb)
448 int i_shift_offset,i_coord_offset,j_coord_offset;
449 int j_index_start,j_index_end;
450 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
451 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
452 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
453 real *shiftvec,*fshift,*x,*f;
455 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
457 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
459 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
461 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
463 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
464 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
465 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
466 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
467 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
468 real velec,felec,velecsum,facel,crf,krf,krf2;
471 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
475 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
478 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
486 jindex = nlist->jindex;
488 shiftidx = nlist->shift;
490 shiftvec = fr->shift_vec[0];
491 fshift = fr->fshift[0];
493 charge = mdatoms->chargeA;
494 nvdwtype = fr->ntype;
496 vdwtype = mdatoms->typeA;
498 vftab = kernel_data->table_vdw->data;
499 vftabscale = kernel_data->table_vdw->scale;
501 sh_ewald = fr->ic->sh_ewald;
502 ewtab = fr->ic->tabq_coul_F;
503 ewtabscale = fr->ic->tabq_scale;
504 ewtabhalfspace = 0.5/ewtabscale;
506 /* Setup water-specific parameters */
507 inr = nlist->iinr[0];
508 iq1 = facel*charge[inr+1];
509 iq2 = facel*charge[inr+2];
510 iq3 = facel*charge[inr+3];
511 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
516 /* Start outer loop over neighborlists */
517 for(iidx=0; iidx<nri; iidx++)
519 /* Load shift vector for this list */
520 i_shift_offset = DIM*shiftidx[iidx];
521 shX = shiftvec[i_shift_offset+XX];
522 shY = shiftvec[i_shift_offset+YY];
523 shZ = shiftvec[i_shift_offset+ZZ];
525 /* Load limits for loop over neighbors */
526 j_index_start = jindex[iidx];
527 j_index_end = jindex[iidx+1];
529 /* Get outer coordinate index */
531 i_coord_offset = DIM*inr;
533 /* Load i particle coords and add shift vector */
534 ix0 = shX + x[i_coord_offset+DIM*0+XX];
535 iy0 = shY + x[i_coord_offset+DIM*0+YY];
536 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
537 ix1 = shX + x[i_coord_offset+DIM*1+XX];
538 iy1 = shY + x[i_coord_offset+DIM*1+YY];
539 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
540 ix2 = shX + x[i_coord_offset+DIM*2+XX];
541 iy2 = shY + x[i_coord_offset+DIM*2+YY];
542 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
543 ix3 = shX + x[i_coord_offset+DIM*3+XX];
544 iy3 = shY + x[i_coord_offset+DIM*3+YY];
545 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
560 /* Start inner kernel loop */
561 for(jidx=j_index_start; jidx<j_index_end; jidx++)
563 /* Get j neighbor index, and coordinate index */
565 j_coord_offset = DIM*jnr;
567 /* load j atom coordinates */
568 jx0 = x[j_coord_offset+DIM*0+XX];
569 jy0 = x[j_coord_offset+DIM*0+YY];
570 jz0 = x[j_coord_offset+DIM*0+ZZ];
572 /* Calculate displacement vector */
586 /* Calculate squared distance and things based on it */
587 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
588 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
589 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
590 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
592 rinv00 = gmx_invsqrt(rsq00);
593 rinv10 = gmx_invsqrt(rsq10);
594 rinv20 = gmx_invsqrt(rsq20);
595 rinv30 = gmx_invsqrt(rsq30);
597 rinvsq10 = rinv10*rinv10;
598 rinvsq20 = rinv20*rinv20;
599 rinvsq30 = rinv30*rinv30;
601 /* Load parameters for j particles */
603 vdwjidx0 = 2*vdwtype[jnr+0];
605 /**************************
606 * CALCULATE INTERACTIONS *
607 **************************/
611 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
612 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
614 /* Calculate table index by multiplying r with table scale and truncate to integer */
620 /* CUBIC SPLINE TABLE DISPERSION */
623 Geps = vfeps*vftab[vfitab+2];
624 Heps2 = vfeps*vfeps*vftab[vfitab+3];
626 FF = Fp+Geps+2.0*Heps2;
629 /* CUBIC SPLINE TABLE REPULSION */
631 Geps = vfeps*vftab[vfitab+6];
632 Heps2 = vfeps*vfeps*vftab[vfitab+7];
634 FF = Fp+Geps+2.0*Heps2;
636 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
640 /* Calculate temporary vectorial force */
645 /* Update vectorial force */
649 f[j_coord_offset+DIM*0+XX] -= tx;
650 f[j_coord_offset+DIM*0+YY] -= ty;
651 f[j_coord_offset+DIM*0+ZZ] -= tz;
653 /**************************
654 * CALCULATE INTERACTIONS *
655 **************************/
661 /* EWALD ELECTROSTATICS */
663 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
664 ewrt = r10*ewtabscale;
667 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
668 felec = qq10*rinv10*(rinvsq10-felec);
672 /* Calculate temporary vectorial force */
677 /* Update vectorial force */
681 f[j_coord_offset+DIM*0+XX] -= tx;
682 f[j_coord_offset+DIM*0+YY] -= ty;
683 f[j_coord_offset+DIM*0+ZZ] -= tz;
685 /**************************
686 * CALCULATE INTERACTIONS *
687 **************************/
693 /* EWALD ELECTROSTATICS */
695 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
696 ewrt = r20*ewtabscale;
699 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
700 felec = qq20*rinv20*(rinvsq20-felec);
704 /* Calculate temporary vectorial force */
709 /* Update vectorial force */
713 f[j_coord_offset+DIM*0+XX] -= tx;
714 f[j_coord_offset+DIM*0+YY] -= ty;
715 f[j_coord_offset+DIM*0+ZZ] -= tz;
717 /**************************
718 * CALCULATE INTERACTIONS *
719 **************************/
725 /* EWALD ELECTROSTATICS */
727 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
728 ewrt = r30*ewtabscale;
731 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
732 felec = qq30*rinv30*(rinvsq30-felec);
736 /* Calculate temporary vectorial force */
741 /* Update vectorial force */
745 f[j_coord_offset+DIM*0+XX] -= tx;
746 f[j_coord_offset+DIM*0+YY] -= ty;
747 f[j_coord_offset+DIM*0+ZZ] -= tz;
749 /* Inner loop uses 149 flops */
751 /* End of innermost loop */
754 f[i_coord_offset+DIM*0+XX] += fix0;
755 f[i_coord_offset+DIM*0+YY] += fiy0;
756 f[i_coord_offset+DIM*0+ZZ] += fiz0;
760 f[i_coord_offset+DIM*1+XX] += fix1;
761 f[i_coord_offset+DIM*1+YY] += fiy1;
762 f[i_coord_offset+DIM*1+ZZ] += fiz1;
766 f[i_coord_offset+DIM*2+XX] += fix2;
767 f[i_coord_offset+DIM*2+YY] += fiy2;
768 f[i_coord_offset+DIM*2+ZZ] += fiz2;
772 f[i_coord_offset+DIM*3+XX] += fix3;
773 f[i_coord_offset+DIM*3+YY] += fiy3;
774 f[i_coord_offset+DIM*3+ZZ] += fiz3;
778 fshift[i_shift_offset+XX] += tx;
779 fshift[i_shift_offset+YY] += ty;
780 fshift[i_shift_offset+ZZ] += tz;
782 /* Increment number of inner iterations */
783 inneriter += j_index_end - j_index_start;
785 /* Outer loop uses 39 flops */
788 /* Increment number of outer iterations */
791 /* Update outer/inner flops */
793 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*149);