2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
93 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
108 charge = mdatoms->chargeA;
112 nvdwtype = fr->ntype;
114 vdwtype = mdatoms->typeA;
116 vftab = kernel_data->table_vdw->data;
117 vftabscale = kernel_data->table_vdw->scale;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
123 iq3 = facel*charge[inr+3];
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
126 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
127 rcutoff = fr->rcoulomb;
128 rcutoff2 = rcutoff*rcutoff;
133 /* Start outer loop over neighborlists */
134 for(iidx=0; iidx<nri; iidx++)
136 /* Load shift vector for this list */
137 i_shift_offset = DIM*shiftidx[iidx];
138 shX = shiftvec[i_shift_offset+XX];
139 shY = shiftvec[i_shift_offset+YY];
140 shZ = shiftvec[i_shift_offset+ZZ];
142 /* Load limits for loop over neighbors */
143 j_index_start = jindex[iidx];
144 j_index_end = jindex[iidx+1];
146 /* Get outer coordinate index */
148 i_coord_offset = DIM*inr;
150 /* Load i particle coords and add shift vector */
151 ix0 = shX + x[i_coord_offset+DIM*0+XX];
152 iy0 = shY + x[i_coord_offset+DIM*0+YY];
153 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
154 ix1 = shX + x[i_coord_offset+DIM*1+XX];
155 iy1 = shY + x[i_coord_offset+DIM*1+YY];
156 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
157 ix2 = shX + x[i_coord_offset+DIM*2+XX];
158 iy2 = shY + x[i_coord_offset+DIM*2+YY];
159 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
160 ix3 = shX + x[i_coord_offset+DIM*3+XX];
161 iy3 = shY + x[i_coord_offset+DIM*3+YY];
162 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
177 /* Reset potential sums */
181 /* Start inner kernel loop */
182 for(jidx=j_index_start; jidx<j_index_end; jidx++)
184 /* Get j neighbor index, and coordinate index */
186 j_coord_offset = DIM*jnr;
188 /* load j atom coordinates */
189 jx0 = x[j_coord_offset+DIM*0+XX];
190 jy0 = x[j_coord_offset+DIM*0+YY];
191 jz0 = x[j_coord_offset+DIM*0+ZZ];
193 /* Calculate displacement vector */
207 /* Calculate squared distance and things based on it */
208 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
209 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
210 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
211 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
213 rinv00 = gmx_invsqrt(rsq00);
214 rinv10 = gmx_invsqrt(rsq10);
215 rinv20 = gmx_invsqrt(rsq20);
216 rinv30 = gmx_invsqrt(rsq30);
218 rinvsq10 = rinv10*rinv10;
219 rinvsq20 = rinv20*rinv20;
220 rinvsq30 = rinv30*rinv30;
222 /* Load parameters for j particles */
224 vdwjidx0 = 2*vdwtype[jnr+0];
226 /**************************
227 * CALCULATE INTERACTIONS *
228 **************************/
232 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
233 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
235 /* Calculate table index by multiplying r with table scale and truncate to integer */
241 /* CUBIC SPLINE TABLE DISPERSION */
245 Geps = vfeps*vftab[vfitab+2];
246 Heps2 = vfeps*vfeps*vftab[vfitab+3];
250 FF = Fp+Geps+2.0*Heps2;
253 /* CUBIC SPLINE TABLE REPULSION */
256 Geps = vfeps*vftab[vfitab+6];
257 Heps2 = vfeps*vfeps*vftab[vfitab+7];
261 FF = Fp+Geps+2.0*Heps2;
264 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
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 **************************/
293 /* REACTION-FIELD ELECTROSTATICS */
294 velec = qq10*(rinv10+krf*rsq10-crf);
295 felec = qq10*(rinv10*rinvsq10-krf2);
297 /* Update potential sums from outer loop */
302 /* Calculate temporary vectorial force */
307 /* Update vectorial force */
311 f[j_coord_offset+DIM*0+XX] -= tx;
312 f[j_coord_offset+DIM*0+YY] -= ty;
313 f[j_coord_offset+DIM*0+ZZ] -= tz;
317 /**************************
318 * CALCULATE INTERACTIONS *
319 **************************/
326 /* REACTION-FIELD ELECTROSTATICS */
327 velec = qq20*(rinv20+krf*rsq20-crf);
328 felec = qq20*(rinv20*rinvsq20-krf2);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*0+XX] -= tx;
345 f[j_coord_offset+DIM*0+YY] -= ty;
346 f[j_coord_offset+DIM*0+ZZ] -= tz;
350 /**************************
351 * CALCULATE INTERACTIONS *
352 **************************/
359 /* REACTION-FIELD ELECTROSTATICS */
360 velec = qq30*(rinv30+krf*rsq30-crf);
361 felec = qq30*(rinv30*rinvsq30-krf2);
363 /* Update potential sums from outer loop */
368 /* Calculate temporary vectorial force */
373 /* Update vectorial force */
377 f[j_coord_offset+DIM*0+XX] -= tx;
378 f[j_coord_offset+DIM*0+YY] -= ty;
379 f[j_coord_offset+DIM*0+ZZ] -= tz;
383 /* Inner loop uses 151 flops */
385 /* End of innermost loop */
388 f[i_coord_offset+DIM*0+XX] += fix0;
389 f[i_coord_offset+DIM*0+YY] += fiy0;
390 f[i_coord_offset+DIM*0+ZZ] += fiz0;
394 f[i_coord_offset+DIM*1+XX] += fix1;
395 f[i_coord_offset+DIM*1+YY] += fiy1;
396 f[i_coord_offset+DIM*1+ZZ] += fiz1;
400 f[i_coord_offset+DIM*2+XX] += fix2;
401 f[i_coord_offset+DIM*2+YY] += fiy2;
402 f[i_coord_offset+DIM*2+ZZ] += fiz2;
406 f[i_coord_offset+DIM*3+XX] += fix3;
407 f[i_coord_offset+DIM*3+YY] += fiy3;
408 f[i_coord_offset+DIM*3+ZZ] += fiz3;
412 fshift[i_shift_offset+XX] += tx;
413 fshift[i_shift_offset+YY] += ty;
414 fshift[i_shift_offset+ZZ] += tz;
417 /* Update potential energies */
418 kernel_data->energygrp_elec[ggid] += velecsum;
419 kernel_data->energygrp_vdw[ggid] += vvdwsum;
421 /* Increment number of inner iterations */
422 inneriter += j_index_end - j_index_start;
424 /* Outer loop uses 41 flops */
427 /* Increment number of outer iterations */
430 /* Update outer/inner flops */
432 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*151);
435 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_c
436 * Electrostatics interaction: ReactionField
437 * VdW interaction: CubicSplineTable
438 * Geometry: Water4-Particle
439 * Calculate force/pot: Force
442 nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_c
443 (t_nblist * gmx_restrict nlist,
444 rvec * gmx_restrict xx,
445 rvec * gmx_restrict ff,
446 t_forcerec * gmx_restrict fr,
447 t_mdatoms * gmx_restrict mdatoms,
448 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
449 t_nrnb * gmx_restrict nrnb)
451 int i_shift_offset,i_coord_offset,j_coord_offset;
452 int j_index_start,j_index_end;
453 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
454 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
455 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
456 real *shiftvec,*fshift,*x,*f;
458 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
460 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
462 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
464 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
466 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
467 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
468 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
469 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
470 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
471 real velec,felec,velecsum,facel,crf,krf,krf2;
474 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
478 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
486 jindex = nlist->jindex;
488 shiftidx = nlist->shift;
490 shiftvec = fr->shift_vec[0];
491 fshift = fr->fshift[0];
493 charge = mdatoms->chargeA;
497 nvdwtype = fr->ntype;
499 vdwtype = mdatoms->typeA;
501 vftab = kernel_data->table_vdw->data;
502 vftabscale = kernel_data->table_vdw->scale;
504 /* Setup water-specific parameters */
505 inr = nlist->iinr[0];
506 iq1 = facel*charge[inr+1];
507 iq2 = facel*charge[inr+2];
508 iq3 = facel*charge[inr+3];
509 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
511 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
512 rcutoff = fr->rcoulomb;
513 rcutoff2 = rcutoff*rcutoff;
518 /* Start outer loop over neighborlists */
519 for(iidx=0; iidx<nri; iidx++)
521 /* Load shift vector for this list */
522 i_shift_offset = DIM*shiftidx[iidx];
523 shX = shiftvec[i_shift_offset+XX];
524 shY = shiftvec[i_shift_offset+YY];
525 shZ = shiftvec[i_shift_offset+ZZ];
527 /* Load limits for loop over neighbors */
528 j_index_start = jindex[iidx];
529 j_index_end = jindex[iidx+1];
531 /* Get outer coordinate index */
533 i_coord_offset = DIM*inr;
535 /* Load i particle coords and add shift vector */
536 ix0 = shX + x[i_coord_offset+DIM*0+XX];
537 iy0 = shY + x[i_coord_offset+DIM*0+YY];
538 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
539 ix1 = shX + x[i_coord_offset+DIM*1+XX];
540 iy1 = shY + x[i_coord_offset+DIM*1+YY];
541 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
542 ix2 = shX + x[i_coord_offset+DIM*2+XX];
543 iy2 = shY + x[i_coord_offset+DIM*2+YY];
544 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
545 ix3 = shX + x[i_coord_offset+DIM*3+XX];
546 iy3 = shY + x[i_coord_offset+DIM*3+YY];
547 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
562 /* Start inner kernel loop */
563 for(jidx=j_index_start; jidx<j_index_end; jidx++)
565 /* Get j neighbor index, and coordinate index */
567 j_coord_offset = DIM*jnr;
569 /* load j atom coordinates */
570 jx0 = x[j_coord_offset+DIM*0+XX];
571 jy0 = x[j_coord_offset+DIM*0+YY];
572 jz0 = x[j_coord_offset+DIM*0+ZZ];
574 /* Calculate displacement vector */
588 /* Calculate squared distance and things based on it */
589 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
590 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
591 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
592 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
594 rinv00 = gmx_invsqrt(rsq00);
595 rinv10 = gmx_invsqrt(rsq10);
596 rinv20 = gmx_invsqrt(rsq20);
597 rinv30 = gmx_invsqrt(rsq30);
599 rinvsq10 = rinv10*rinv10;
600 rinvsq20 = rinv20*rinv20;
601 rinvsq30 = rinv30*rinv30;
603 /* Load parameters for j particles */
605 vdwjidx0 = 2*vdwtype[jnr+0];
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
613 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
614 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
616 /* Calculate table index by multiplying r with table scale and truncate to integer */
622 /* CUBIC SPLINE TABLE DISPERSION */
625 Geps = vfeps*vftab[vfitab+2];
626 Heps2 = vfeps*vfeps*vftab[vfitab+3];
628 FF = Fp+Geps+2.0*Heps2;
631 /* CUBIC SPLINE TABLE REPULSION */
633 Geps = vfeps*vftab[vfitab+6];
634 Heps2 = vfeps*vfeps*vftab[vfitab+7];
636 FF = Fp+Geps+2.0*Heps2;
638 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
642 /* Calculate temporary vectorial force */
647 /* Update vectorial force */
651 f[j_coord_offset+DIM*0+XX] -= tx;
652 f[j_coord_offset+DIM*0+YY] -= ty;
653 f[j_coord_offset+DIM*0+ZZ] -= tz;
655 /**************************
656 * CALCULATE INTERACTIONS *
657 **************************/
664 /* REACTION-FIELD ELECTROSTATICS */
665 felec = qq10*(rinv10*rinvsq10-krf2);
669 /* Calculate temporary vectorial force */
674 /* Update vectorial force */
678 f[j_coord_offset+DIM*0+XX] -= tx;
679 f[j_coord_offset+DIM*0+YY] -= ty;
680 f[j_coord_offset+DIM*0+ZZ] -= tz;
684 /**************************
685 * CALCULATE INTERACTIONS *
686 **************************/
693 /* REACTION-FIELD ELECTROSTATICS */
694 felec = qq20*(rinv20*rinvsq20-krf2);
698 /* Calculate temporary vectorial force */
703 /* Update vectorial force */
707 f[j_coord_offset+DIM*0+XX] -= tx;
708 f[j_coord_offset+DIM*0+YY] -= ty;
709 f[j_coord_offset+DIM*0+ZZ] -= tz;
713 /**************************
714 * CALCULATE INTERACTIONS *
715 **************************/
722 /* REACTION-FIELD ELECTROSTATICS */
723 felec = qq30*(rinv30*rinvsq30-krf2);
727 /* Calculate temporary vectorial force */
732 /* Update vectorial force */
736 f[j_coord_offset+DIM*0+XX] -= tx;
737 f[j_coord_offset+DIM*0+YY] -= ty;
738 f[j_coord_offset+DIM*0+ZZ] -= tz;
742 /* Inner loop uses 128 flops */
744 /* End of innermost loop */
747 f[i_coord_offset+DIM*0+XX] += fix0;
748 f[i_coord_offset+DIM*0+YY] += fiy0;
749 f[i_coord_offset+DIM*0+ZZ] += fiz0;
753 f[i_coord_offset+DIM*1+XX] += fix1;
754 f[i_coord_offset+DIM*1+YY] += fiy1;
755 f[i_coord_offset+DIM*1+ZZ] += fiz1;
759 f[i_coord_offset+DIM*2+XX] += fix2;
760 f[i_coord_offset+DIM*2+YY] += fiy2;
761 f[i_coord_offset+DIM*2+ZZ] += fiz2;
765 f[i_coord_offset+DIM*3+XX] += fix3;
766 f[i_coord_offset+DIM*3+YY] += fiy3;
767 f[i_coord_offset+DIM*3+ZZ] += fiz3;
771 fshift[i_shift_offset+XX] += tx;
772 fshift[i_shift_offset+YY] += ty;
773 fshift[i_shift_offset+ZZ] += tz;
775 /* Increment number of inner iterations */
776 inneriter += j_index_end - j_index_start;
778 /* Outer loop uses 39 flops */
781 /* Increment number of outer iterations */
784 /* Update outer/inner flops */
786 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*128);