2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
84 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
88 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
96 jindex = nlist->jindex;
98 shiftidx = nlist->shift;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
103 charge = mdatoms->chargeA;
107 nvdwtype = fr->ntype;
109 vdwtype = mdatoms->typeA;
111 vftab = kernel_data->table_vdw->data;
112 vftabscale = kernel_data->table_vdw->scale;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq0 = facel*charge[inr+0];
117 iq1 = facel*charge[inr+1];
118 iq2 = facel*charge[inr+2];
119 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
121 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
122 rcutoff = fr->rcoulomb;
123 rcutoff2 = rcutoff*rcutoff;
128 /* Start outer loop over neighborlists */
129 for(iidx=0; iidx<nri; iidx++)
131 /* Load shift vector for this list */
132 i_shift_offset = DIM*shiftidx[iidx];
133 shX = shiftvec[i_shift_offset+XX];
134 shY = shiftvec[i_shift_offset+YY];
135 shZ = shiftvec[i_shift_offset+ZZ];
137 /* Load limits for loop over neighbors */
138 j_index_start = jindex[iidx];
139 j_index_end = jindex[iidx+1];
141 /* Get outer coordinate index */
143 i_coord_offset = DIM*inr;
145 /* Load i particle coords and add shift vector */
146 ix0 = shX + x[i_coord_offset+DIM*0+XX];
147 iy0 = shY + x[i_coord_offset+DIM*0+YY];
148 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
149 ix1 = shX + x[i_coord_offset+DIM*1+XX];
150 iy1 = shY + x[i_coord_offset+DIM*1+YY];
151 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
152 ix2 = shX + x[i_coord_offset+DIM*2+XX];
153 iy2 = shY + x[i_coord_offset+DIM*2+YY];
154 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
166 /* Reset potential sums */
170 /* Start inner kernel loop */
171 for(jidx=j_index_start; jidx<j_index_end; jidx++)
173 /* Get j neighbor index, and coordinate index */
175 j_coord_offset = DIM*jnr;
177 /* load j atom coordinates */
178 jx0 = x[j_coord_offset+DIM*0+XX];
179 jy0 = x[j_coord_offset+DIM*0+YY];
180 jz0 = x[j_coord_offset+DIM*0+ZZ];
182 /* Calculate displacement vector */
193 /* Calculate squared distance and things based on it */
194 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
195 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
196 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
198 rinv00 = gmx_invsqrt(rsq00);
199 rinv10 = gmx_invsqrt(rsq10);
200 rinv20 = gmx_invsqrt(rsq20);
202 rinvsq00 = rinv00*rinv00;
203 rinvsq10 = rinv10*rinv10;
204 rinvsq20 = rinv20*rinv20;
206 /* Load parameters for j particles */
208 vdwjidx0 = 2*vdwtype[jnr+0];
210 /**************************
211 * CALCULATE INTERACTIONS *
212 **************************/
220 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
221 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
223 /* Calculate table index by multiplying r with table scale and truncate to integer */
229 /* REACTION-FIELD ELECTROSTATICS */
230 velec = qq00*(rinv00+krf*rsq00-crf);
231 felec = qq00*(rinv00*rinvsq00-krf2);
233 /* CUBIC SPLINE TABLE DISPERSION */
237 Geps = vfeps*vftab[vfitab+2];
238 Heps2 = vfeps*vfeps*vftab[vfitab+3];
242 FF = Fp+Geps+2.0*Heps2;
245 /* CUBIC SPLINE TABLE REPULSION */
248 Geps = vfeps*vftab[vfitab+6];
249 Heps2 = vfeps*vfeps*vftab[vfitab+7];
253 FF = Fp+Geps+2.0*Heps2;
256 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
258 /* Update potential sums from outer loop */
264 /* Calculate temporary vectorial force */
269 /* Update vectorial force */
273 f[j_coord_offset+DIM*0+XX] -= tx;
274 f[j_coord_offset+DIM*0+YY] -= ty;
275 f[j_coord_offset+DIM*0+ZZ] -= tz;
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
288 /* REACTION-FIELD ELECTROSTATICS */
289 velec = qq10*(rinv10+krf*rsq10-crf);
290 felec = qq10*(rinv10*rinvsq10-krf2);
292 /* Update potential sums from outer loop */
297 /* Calculate temporary vectorial force */
302 /* Update vectorial force */
306 f[j_coord_offset+DIM*0+XX] -= tx;
307 f[j_coord_offset+DIM*0+YY] -= ty;
308 f[j_coord_offset+DIM*0+ZZ] -= tz;
312 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
321 /* REACTION-FIELD ELECTROSTATICS */
322 velec = qq20*(rinv20+krf*rsq20-crf);
323 felec = qq20*(rinv20*rinvsq20-krf2);
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;
345 /* Inner loop uses 130 flops */
347 /* End of innermost loop */
350 f[i_coord_offset+DIM*0+XX] += fix0;
351 f[i_coord_offset+DIM*0+YY] += fiy0;
352 f[i_coord_offset+DIM*0+ZZ] += fiz0;
356 f[i_coord_offset+DIM*1+XX] += fix1;
357 f[i_coord_offset+DIM*1+YY] += fiy1;
358 f[i_coord_offset+DIM*1+ZZ] += fiz1;
362 f[i_coord_offset+DIM*2+XX] += fix2;
363 f[i_coord_offset+DIM*2+YY] += fiy2;
364 f[i_coord_offset+DIM*2+ZZ] += fiz2;
368 fshift[i_shift_offset+XX] += tx;
369 fshift[i_shift_offset+YY] += ty;
370 fshift[i_shift_offset+ZZ] += tz;
373 /* Update potential energies */
374 kernel_data->energygrp_elec[ggid] += velecsum;
375 kernel_data->energygrp_vdw[ggid] += vvdwsum;
377 /* Increment number of inner iterations */
378 inneriter += j_index_end - j_index_start;
380 /* Outer loop uses 32 flops */
383 /* Increment number of outer iterations */
386 /* Update outer/inner flops */
388 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*130);
391 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_F_c
392 * Electrostatics interaction: ReactionField
393 * VdW interaction: CubicSplineTable
394 * Geometry: Water3-Particle
395 * Calculate force/pot: Force
398 nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_F_c
399 (t_nblist * gmx_restrict nlist,
400 rvec * gmx_restrict xx,
401 rvec * gmx_restrict ff,
402 t_forcerec * gmx_restrict fr,
403 t_mdatoms * gmx_restrict mdatoms,
404 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
405 t_nrnb * gmx_restrict nrnb)
407 int i_shift_offset,i_coord_offset,j_coord_offset;
408 int j_index_start,j_index_end;
409 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
410 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
411 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
412 real *shiftvec,*fshift,*x,*f;
414 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
416 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
418 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
420 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
421 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
422 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
423 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
424 real velec,felec,velecsum,facel,crf,krf,krf2;
427 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
431 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
439 jindex = nlist->jindex;
441 shiftidx = nlist->shift;
443 shiftvec = fr->shift_vec[0];
444 fshift = fr->fshift[0];
446 charge = mdatoms->chargeA;
450 nvdwtype = fr->ntype;
452 vdwtype = mdatoms->typeA;
454 vftab = kernel_data->table_vdw->data;
455 vftabscale = kernel_data->table_vdw->scale;
457 /* Setup water-specific parameters */
458 inr = nlist->iinr[0];
459 iq0 = facel*charge[inr+0];
460 iq1 = facel*charge[inr+1];
461 iq2 = facel*charge[inr+2];
462 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
464 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
465 rcutoff = fr->rcoulomb;
466 rcutoff2 = rcutoff*rcutoff;
471 /* Start outer loop over neighborlists */
472 for(iidx=0; iidx<nri; iidx++)
474 /* Load shift vector for this list */
475 i_shift_offset = DIM*shiftidx[iidx];
476 shX = shiftvec[i_shift_offset+XX];
477 shY = shiftvec[i_shift_offset+YY];
478 shZ = shiftvec[i_shift_offset+ZZ];
480 /* Load limits for loop over neighbors */
481 j_index_start = jindex[iidx];
482 j_index_end = jindex[iidx+1];
484 /* Get outer coordinate index */
486 i_coord_offset = DIM*inr;
488 /* Load i particle coords and add shift vector */
489 ix0 = shX + x[i_coord_offset+DIM*0+XX];
490 iy0 = shY + x[i_coord_offset+DIM*0+YY];
491 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
492 ix1 = shX + x[i_coord_offset+DIM*1+XX];
493 iy1 = shY + x[i_coord_offset+DIM*1+YY];
494 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
495 ix2 = shX + x[i_coord_offset+DIM*2+XX];
496 iy2 = shY + x[i_coord_offset+DIM*2+YY];
497 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
509 /* Start inner kernel loop */
510 for(jidx=j_index_start; jidx<j_index_end; jidx++)
512 /* Get j neighbor index, and coordinate index */
514 j_coord_offset = DIM*jnr;
516 /* load j atom coordinates */
517 jx0 = x[j_coord_offset+DIM*0+XX];
518 jy0 = x[j_coord_offset+DIM*0+YY];
519 jz0 = x[j_coord_offset+DIM*0+ZZ];
521 /* Calculate displacement vector */
532 /* Calculate squared distance and things based on it */
533 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
534 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
535 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
537 rinv00 = gmx_invsqrt(rsq00);
538 rinv10 = gmx_invsqrt(rsq10);
539 rinv20 = gmx_invsqrt(rsq20);
541 rinvsq00 = rinv00*rinv00;
542 rinvsq10 = rinv10*rinv10;
543 rinvsq20 = rinv20*rinv20;
545 /* Load parameters for j particles */
547 vdwjidx0 = 2*vdwtype[jnr+0];
549 /**************************
550 * CALCULATE INTERACTIONS *
551 **************************/
559 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
560 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
562 /* Calculate table index by multiplying r with table scale and truncate to integer */
568 /* REACTION-FIELD ELECTROSTATICS */
569 felec = qq00*(rinv00*rinvsq00-krf2);
571 /* CUBIC SPLINE TABLE DISPERSION */
574 Geps = vfeps*vftab[vfitab+2];
575 Heps2 = vfeps*vfeps*vftab[vfitab+3];
577 FF = Fp+Geps+2.0*Heps2;
580 /* CUBIC SPLINE TABLE REPULSION */
582 Geps = vfeps*vftab[vfitab+6];
583 Heps2 = vfeps*vfeps*vftab[vfitab+7];
585 FF = Fp+Geps+2.0*Heps2;
587 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
591 /* Calculate temporary vectorial force */
596 /* Update vectorial force */
600 f[j_coord_offset+DIM*0+XX] -= tx;
601 f[j_coord_offset+DIM*0+YY] -= ty;
602 f[j_coord_offset+DIM*0+ZZ] -= tz;
606 /**************************
607 * CALCULATE INTERACTIONS *
608 **************************/
615 /* REACTION-FIELD ELECTROSTATICS */
616 felec = qq10*(rinv10*rinvsq10-krf2);
620 /* Calculate temporary vectorial force */
625 /* Update vectorial force */
629 f[j_coord_offset+DIM*0+XX] -= tx;
630 f[j_coord_offset+DIM*0+YY] -= ty;
631 f[j_coord_offset+DIM*0+ZZ] -= tz;
635 /**************************
636 * CALCULATE INTERACTIONS *
637 **************************/
644 /* REACTION-FIELD ELECTROSTATICS */
645 felec = qq20*(rinv20*rinvsq20-krf2);
649 /* Calculate temporary vectorial force */
654 /* Update vectorial force */
658 f[j_coord_offset+DIM*0+XX] -= tx;
659 f[j_coord_offset+DIM*0+YY] -= ty;
660 f[j_coord_offset+DIM*0+ZZ] -= tz;
664 /* Inner loop uses 107 flops */
666 /* End of innermost loop */
669 f[i_coord_offset+DIM*0+XX] += fix0;
670 f[i_coord_offset+DIM*0+YY] += fiy0;
671 f[i_coord_offset+DIM*0+ZZ] += fiz0;
675 f[i_coord_offset+DIM*1+XX] += fix1;
676 f[i_coord_offset+DIM*1+YY] += fiy1;
677 f[i_coord_offset+DIM*1+ZZ] += fiz1;
681 f[i_coord_offset+DIM*2+XX] += fix2;
682 f[i_coord_offset+DIM*2+YY] += fiy2;
683 f[i_coord_offset+DIM*2+ZZ] += fiz2;
687 fshift[i_shift_offset+XX] += tx;
688 fshift[i_shift_offset+YY] += ty;
689 fshift[i_shift_offset+ZZ] += tz;
691 /* Increment number of inner iterations */
692 inneriter += j_index_end - j_index_start;
694 /* Outer loop uses 30 flops */
697 /* Increment number of outer iterations */
700 /* Update outer/inner flops */
702 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);