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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwCSTab_GeomW3P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real velec,felec,velecsum,facel,crf,krf,krf2;
86 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
90 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
105 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 vftab = kernel_data->table_vdw->data;
114 vftabscale = kernel_data->table_vdw->scale;
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq0 = facel*charge[inr+0];
119 iq1 = facel*charge[inr+1];
120 iq2 = facel*charge[inr+2];
121 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
126 /* Start outer loop over neighborlists */
127 for(iidx=0; iidx<nri; iidx++)
129 /* Load shift vector for this list */
130 i_shift_offset = DIM*shiftidx[iidx];
131 shX = shiftvec[i_shift_offset+XX];
132 shY = shiftvec[i_shift_offset+YY];
133 shZ = shiftvec[i_shift_offset+ZZ];
135 /* Load limits for loop over neighbors */
136 j_index_start = jindex[iidx];
137 j_index_end = jindex[iidx+1];
139 /* Get outer coordinate index */
141 i_coord_offset = DIM*inr;
143 /* Load i particle coords and add shift vector */
144 ix0 = shX + x[i_coord_offset+DIM*0+XX];
145 iy0 = shY + x[i_coord_offset+DIM*0+YY];
146 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
147 ix1 = shX + x[i_coord_offset+DIM*1+XX];
148 iy1 = shY + x[i_coord_offset+DIM*1+YY];
149 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
150 ix2 = shX + x[i_coord_offset+DIM*2+XX];
151 iy2 = shY + x[i_coord_offset+DIM*2+YY];
152 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
164 /* Reset potential sums */
168 /* Start inner kernel loop */
169 for(jidx=j_index_start; jidx<j_index_end; jidx++)
171 /* Get j neighbor index, and coordinate index */
173 j_coord_offset = DIM*jnr;
175 /* load j atom coordinates */
176 jx0 = x[j_coord_offset+DIM*0+XX];
177 jy0 = x[j_coord_offset+DIM*0+YY];
178 jz0 = x[j_coord_offset+DIM*0+ZZ];
180 /* Calculate displacement vector */
191 /* Calculate squared distance and things based on it */
192 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
193 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
194 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
196 rinv00 = gmx_invsqrt(rsq00);
197 rinv10 = gmx_invsqrt(rsq10);
198 rinv20 = gmx_invsqrt(rsq20);
200 rinvsq00 = rinv00*rinv00;
201 rinvsq10 = rinv10*rinv10;
202 rinvsq20 = rinv20*rinv20;
204 /* Load parameters for j particles */
206 vdwjidx0 = 2*vdwtype[jnr+0];
208 /**************************
209 * CALCULATE INTERACTIONS *
210 **************************/
215 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
216 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
218 /* Calculate table index by multiplying r with table scale and truncate to integer */
224 /* REACTION-FIELD ELECTROSTATICS */
225 velec = qq00*(rinv00+krf*rsq00-crf);
226 felec = qq00*(rinv00*rinvsq00-krf2);
228 /* CUBIC SPLINE TABLE DISPERSION */
232 Geps = vfeps*vftab[vfitab+2];
233 Heps2 = vfeps*vfeps*vftab[vfitab+3];
237 FF = Fp+Geps+2.0*Heps2;
240 /* CUBIC SPLINE TABLE REPULSION */
243 Geps = vfeps*vftab[vfitab+6];
244 Heps2 = vfeps*vfeps*vftab[vfitab+7];
248 FF = Fp+Geps+2.0*Heps2;
251 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
253 /* Update potential sums from outer loop */
259 /* Calculate temporary vectorial force */
264 /* Update vectorial force */
268 f[j_coord_offset+DIM*0+XX] -= tx;
269 f[j_coord_offset+DIM*0+YY] -= ty;
270 f[j_coord_offset+DIM*0+ZZ] -= tz;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
278 /* REACTION-FIELD ELECTROSTATICS */
279 velec = qq10*(rinv10+krf*rsq10-crf);
280 felec = qq10*(rinv10*rinvsq10-krf2);
282 /* Update potential sums from outer loop */
287 /* Calculate temporary vectorial force */
292 /* Update vectorial force */
296 f[j_coord_offset+DIM*0+XX] -= tx;
297 f[j_coord_offset+DIM*0+YY] -= ty;
298 f[j_coord_offset+DIM*0+ZZ] -= tz;
300 /**************************
301 * CALCULATE INTERACTIONS *
302 **************************/
306 /* REACTION-FIELD ELECTROSTATICS */
307 velec = qq20*(rinv20+krf*rsq20-crf);
308 felec = qq20*(rinv20*rinvsq20-krf2);
310 /* Update potential sums from outer loop */
315 /* Calculate temporary vectorial force */
320 /* Update vectorial force */
324 f[j_coord_offset+DIM*0+XX] -= tx;
325 f[j_coord_offset+DIM*0+YY] -= ty;
326 f[j_coord_offset+DIM*0+ZZ] -= tz;
328 /* Inner loop uses 130 flops */
330 /* End of innermost loop */
333 f[i_coord_offset+DIM*0+XX] += fix0;
334 f[i_coord_offset+DIM*0+YY] += fiy0;
335 f[i_coord_offset+DIM*0+ZZ] += fiz0;
339 f[i_coord_offset+DIM*1+XX] += fix1;
340 f[i_coord_offset+DIM*1+YY] += fiy1;
341 f[i_coord_offset+DIM*1+ZZ] += fiz1;
345 f[i_coord_offset+DIM*2+XX] += fix2;
346 f[i_coord_offset+DIM*2+YY] += fiy2;
347 f[i_coord_offset+DIM*2+ZZ] += fiz2;
351 fshift[i_shift_offset+XX] += tx;
352 fshift[i_shift_offset+YY] += ty;
353 fshift[i_shift_offset+ZZ] += tz;
356 /* Update potential energies */
357 kernel_data->energygrp_elec[ggid] += velecsum;
358 kernel_data->energygrp_vdw[ggid] += vvdwsum;
360 /* Increment number of inner iterations */
361 inneriter += j_index_end - j_index_start;
363 /* Outer loop uses 32 flops */
366 /* Increment number of outer iterations */
369 /* Update outer/inner flops */
371 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*130);
374 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_c
375 * Electrostatics interaction: ReactionField
376 * VdW interaction: CubicSplineTable
377 * Geometry: Water3-Particle
378 * Calculate force/pot: Force
381 nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_c
382 (t_nblist * gmx_restrict nlist,
383 rvec * gmx_restrict xx,
384 rvec * gmx_restrict ff,
385 t_forcerec * gmx_restrict fr,
386 t_mdatoms * gmx_restrict mdatoms,
387 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
388 t_nrnb * gmx_restrict nrnb)
390 int i_shift_offset,i_coord_offset,j_coord_offset;
391 int j_index_start,j_index_end;
392 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
393 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
394 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
395 real *shiftvec,*fshift,*x,*f;
397 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
399 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
401 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
403 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
404 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
405 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
406 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
407 real velec,felec,velecsum,facel,crf,krf,krf2;
410 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
414 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
422 jindex = nlist->jindex;
424 shiftidx = nlist->shift;
426 shiftvec = fr->shift_vec[0];
427 fshift = fr->fshift[0];
429 charge = mdatoms->chargeA;
433 nvdwtype = fr->ntype;
435 vdwtype = mdatoms->typeA;
437 vftab = kernel_data->table_vdw->data;
438 vftabscale = kernel_data->table_vdw->scale;
440 /* Setup water-specific parameters */
441 inr = nlist->iinr[0];
442 iq0 = facel*charge[inr+0];
443 iq1 = facel*charge[inr+1];
444 iq2 = facel*charge[inr+2];
445 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
450 /* Start outer loop over neighborlists */
451 for(iidx=0; iidx<nri; iidx++)
453 /* Load shift vector for this list */
454 i_shift_offset = DIM*shiftidx[iidx];
455 shX = shiftvec[i_shift_offset+XX];
456 shY = shiftvec[i_shift_offset+YY];
457 shZ = shiftvec[i_shift_offset+ZZ];
459 /* Load limits for loop over neighbors */
460 j_index_start = jindex[iidx];
461 j_index_end = jindex[iidx+1];
463 /* Get outer coordinate index */
465 i_coord_offset = DIM*inr;
467 /* Load i particle coords and add shift vector */
468 ix0 = shX + x[i_coord_offset+DIM*0+XX];
469 iy0 = shY + x[i_coord_offset+DIM*0+YY];
470 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
471 ix1 = shX + x[i_coord_offset+DIM*1+XX];
472 iy1 = shY + x[i_coord_offset+DIM*1+YY];
473 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
474 ix2 = shX + x[i_coord_offset+DIM*2+XX];
475 iy2 = shY + x[i_coord_offset+DIM*2+YY];
476 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
488 /* Start inner kernel loop */
489 for(jidx=j_index_start; jidx<j_index_end; jidx++)
491 /* Get j neighbor index, and coordinate index */
493 j_coord_offset = DIM*jnr;
495 /* load j atom coordinates */
496 jx0 = x[j_coord_offset+DIM*0+XX];
497 jy0 = x[j_coord_offset+DIM*0+YY];
498 jz0 = x[j_coord_offset+DIM*0+ZZ];
500 /* Calculate displacement vector */
511 /* Calculate squared distance and things based on it */
512 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
513 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
514 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
516 rinv00 = gmx_invsqrt(rsq00);
517 rinv10 = gmx_invsqrt(rsq10);
518 rinv20 = gmx_invsqrt(rsq20);
520 rinvsq00 = rinv00*rinv00;
521 rinvsq10 = rinv10*rinv10;
522 rinvsq20 = rinv20*rinv20;
524 /* Load parameters for j particles */
526 vdwjidx0 = 2*vdwtype[jnr+0];
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
535 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
536 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
538 /* Calculate table index by multiplying r with table scale and truncate to integer */
544 /* REACTION-FIELD ELECTROSTATICS */
545 felec = qq00*(rinv00*rinvsq00-krf2);
547 /* CUBIC SPLINE TABLE DISPERSION */
550 Geps = vfeps*vftab[vfitab+2];
551 Heps2 = vfeps*vfeps*vftab[vfitab+3];
553 FF = Fp+Geps+2.0*Heps2;
556 /* CUBIC SPLINE TABLE REPULSION */
558 Geps = vfeps*vftab[vfitab+6];
559 Heps2 = vfeps*vfeps*vftab[vfitab+7];
561 FF = Fp+Geps+2.0*Heps2;
563 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
567 /* Calculate temporary vectorial force */
572 /* Update vectorial force */
576 f[j_coord_offset+DIM*0+XX] -= tx;
577 f[j_coord_offset+DIM*0+YY] -= ty;
578 f[j_coord_offset+DIM*0+ZZ] -= tz;
580 /**************************
581 * CALCULATE INTERACTIONS *
582 **************************/
586 /* REACTION-FIELD ELECTROSTATICS */
587 felec = qq10*(rinv10*rinvsq10-krf2);
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;
604 /**************************
605 * CALCULATE INTERACTIONS *
606 **************************/
610 /* REACTION-FIELD ELECTROSTATICS */
611 felec = qq20*(rinv20*rinvsq20-krf2);
615 /* Calculate temporary vectorial force */
620 /* Update vectorial force */
624 f[j_coord_offset+DIM*0+XX] -= tx;
625 f[j_coord_offset+DIM*0+YY] -= ty;
626 f[j_coord_offset+DIM*0+ZZ] -= tz;
628 /* Inner loop uses 107 flops */
630 /* End of innermost loop */
633 f[i_coord_offset+DIM*0+XX] += fix0;
634 f[i_coord_offset+DIM*0+YY] += fiy0;
635 f[i_coord_offset+DIM*0+ZZ] += fiz0;
639 f[i_coord_offset+DIM*1+XX] += fix1;
640 f[i_coord_offset+DIM*1+YY] += fiy1;
641 f[i_coord_offset+DIM*1+ZZ] += fiz1;
645 f[i_coord_offset+DIM*2+XX] += fix2;
646 f[i_coord_offset+DIM*2+YY] += fiy2;
647 f[i_coord_offset+DIM*2+ZZ] += fiz2;
651 fshift[i_shift_offset+XX] += tx;
652 fshift[i_shift_offset+YY] += ty;
653 fshift[i_shift_offset+ZZ] += tz;
655 /* Increment number of inner iterations */
656 inneriter += j_index_end - j_index_start;
658 /* Outer loop uses 30 flops */
661 /* Increment number of outer iterations */
664 /* Update outer/inner flops */
666 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);