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_GeomW3P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_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];
123 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
124 rcutoff = fr->rcoulomb;
125 rcutoff2 = rcutoff*rcutoff;
130 /* Start outer loop over neighborlists */
131 for(iidx=0; iidx<nri; iidx++)
133 /* Load shift vector for this list */
134 i_shift_offset = DIM*shiftidx[iidx];
135 shX = shiftvec[i_shift_offset+XX];
136 shY = shiftvec[i_shift_offset+YY];
137 shZ = shiftvec[i_shift_offset+ZZ];
139 /* Load limits for loop over neighbors */
140 j_index_start = jindex[iidx];
141 j_index_end = jindex[iidx+1];
143 /* Get outer coordinate index */
145 i_coord_offset = DIM*inr;
147 /* Load i particle coords and add shift vector */
148 ix0 = shX + x[i_coord_offset+DIM*0+XX];
149 iy0 = shY + x[i_coord_offset+DIM*0+YY];
150 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
151 ix1 = shX + x[i_coord_offset+DIM*1+XX];
152 iy1 = shY + x[i_coord_offset+DIM*1+YY];
153 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
154 ix2 = shX + x[i_coord_offset+DIM*2+XX];
155 iy2 = shY + x[i_coord_offset+DIM*2+YY];
156 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
168 /* Reset potential sums */
172 /* Start inner kernel loop */
173 for(jidx=j_index_start; jidx<j_index_end; jidx++)
175 /* Get j neighbor index, and coordinate index */
177 j_coord_offset = DIM*jnr;
179 /* load j atom coordinates */
180 jx0 = x[j_coord_offset+DIM*0+XX];
181 jy0 = x[j_coord_offset+DIM*0+YY];
182 jz0 = x[j_coord_offset+DIM*0+ZZ];
184 /* Calculate displacement vector */
195 /* Calculate squared distance and things based on it */
196 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
197 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
198 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
200 rinv00 = gmx_invsqrt(rsq00);
201 rinv10 = gmx_invsqrt(rsq10);
202 rinv20 = gmx_invsqrt(rsq20);
204 rinvsq00 = rinv00*rinv00;
205 rinvsq10 = rinv10*rinv10;
206 rinvsq20 = rinv20*rinv20;
208 /* Load parameters for j particles */
210 vdwjidx0 = 2*vdwtype[jnr+0];
212 /**************************
213 * CALCULATE INTERACTIONS *
214 **************************/
222 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
223 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
225 /* Calculate table index by multiplying r with table scale and truncate to integer */
231 /* REACTION-FIELD ELECTROSTATICS */
232 velec = qq00*(rinv00+krf*rsq00-crf);
233 felec = qq00*(rinv00*rinvsq00-krf2);
235 /* CUBIC SPLINE TABLE DISPERSION */
239 Geps = vfeps*vftab[vfitab+2];
240 Heps2 = vfeps*vfeps*vftab[vfitab+3];
244 FF = Fp+Geps+2.0*Heps2;
247 /* CUBIC SPLINE TABLE REPULSION */
250 Geps = vfeps*vftab[vfitab+6];
251 Heps2 = vfeps*vfeps*vftab[vfitab+7];
255 FF = Fp+Geps+2.0*Heps2;
258 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
260 /* Update potential sums from outer loop */
266 /* Calculate temporary vectorial force */
271 /* Update vectorial force */
275 f[j_coord_offset+DIM*0+XX] -= tx;
276 f[j_coord_offset+DIM*0+YY] -= ty;
277 f[j_coord_offset+DIM*0+ZZ] -= tz;
281 /**************************
282 * CALCULATE INTERACTIONS *
283 **************************/
290 /* REACTION-FIELD ELECTROSTATICS */
291 velec = qq10*(rinv10+krf*rsq10-crf);
292 felec = qq10*(rinv10*rinvsq10-krf2);
294 /* Update potential sums from outer loop */
299 /* Calculate temporary vectorial force */
304 /* Update vectorial force */
308 f[j_coord_offset+DIM*0+XX] -= tx;
309 f[j_coord_offset+DIM*0+YY] -= ty;
310 f[j_coord_offset+DIM*0+ZZ] -= tz;
314 /**************************
315 * CALCULATE INTERACTIONS *
316 **************************/
323 /* REACTION-FIELD ELECTROSTATICS */
324 velec = qq20*(rinv20+krf*rsq20-crf);
325 felec = qq20*(rinv20*rinvsq20-krf2);
327 /* Update potential sums from outer loop */
332 /* Calculate temporary vectorial force */
337 /* Update vectorial force */
341 f[j_coord_offset+DIM*0+XX] -= tx;
342 f[j_coord_offset+DIM*0+YY] -= ty;
343 f[j_coord_offset+DIM*0+ZZ] -= tz;
347 /* Inner loop uses 130 flops */
349 /* End of innermost loop */
352 f[i_coord_offset+DIM*0+XX] += fix0;
353 f[i_coord_offset+DIM*0+YY] += fiy0;
354 f[i_coord_offset+DIM*0+ZZ] += fiz0;
358 f[i_coord_offset+DIM*1+XX] += fix1;
359 f[i_coord_offset+DIM*1+YY] += fiy1;
360 f[i_coord_offset+DIM*1+ZZ] += fiz1;
364 f[i_coord_offset+DIM*2+XX] += fix2;
365 f[i_coord_offset+DIM*2+YY] += fiy2;
366 f[i_coord_offset+DIM*2+ZZ] += fiz2;
370 fshift[i_shift_offset+XX] += tx;
371 fshift[i_shift_offset+YY] += ty;
372 fshift[i_shift_offset+ZZ] += tz;
375 /* Update potential energies */
376 kernel_data->energygrp_elec[ggid] += velecsum;
377 kernel_data->energygrp_vdw[ggid] += vvdwsum;
379 /* Increment number of inner iterations */
380 inneriter += j_index_end - j_index_start;
382 /* Outer loop uses 32 flops */
385 /* Increment number of outer iterations */
388 /* Update outer/inner flops */
390 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*130);
393 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_F_c
394 * Electrostatics interaction: ReactionField
395 * VdW interaction: CubicSplineTable
396 * Geometry: Water3-Particle
397 * Calculate force/pot: Force
400 nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_F_c
401 (t_nblist * gmx_restrict nlist,
402 rvec * gmx_restrict xx,
403 rvec * gmx_restrict ff,
404 t_forcerec * gmx_restrict fr,
405 t_mdatoms * gmx_restrict mdatoms,
406 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
407 t_nrnb * gmx_restrict nrnb)
409 int i_shift_offset,i_coord_offset,j_coord_offset;
410 int j_index_start,j_index_end;
411 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
412 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
413 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
414 real *shiftvec,*fshift,*x,*f;
416 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
418 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
420 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
422 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
423 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
424 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
425 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
426 real velec,felec,velecsum,facel,crf,krf,krf2;
429 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
433 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
441 jindex = nlist->jindex;
443 shiftidx = nlist->shift;
445 shiftvec = fr->shift_vec[0];
446 fshift = fr->fshift[0];
448 charge = mdatoms->chargeA;
452 nvdwtype = fr->ntype;
454 vdwtype = mdatoms->typeA;
456 vftab = kernel_data->table_vdw->data;
457 vftabscale = kernel_data->table_vdw->scale;
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];
466 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
467 rcutoff = fr->rcoulomb;
468 rcutoff2 = rcutoff*rcutoff;
473 /* Start outer loop over neighborlists */
474 for(iidx=0; iidx<nri; iidx++)
476 /* Load shift vector for this list */
477 i_shift_offset = DIM*shiftidx[iidx];
478 shX = shiftvec[i_shift_offset+XX];
479 shY = shiftvec[i_shift_offset+YY];
480 shZ = shiftvec[i_shift_offset+ZZ];
482 /* Load limits for loop over neighbors */
483 j_index_start = jindex[iidx];
484 j_index_end = jindex[iidx+1];
486 /* Get outer coordinate index */
488 i_coord_offset = DIM*inr;
490 /* Load i particle coords and add shift vector */
491 ix0 = shX + x[i_coord_offset+DIM*0+XX];
492 iy0 = shY + x[i_coord_offset+DIM*0+YY];
493 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
494 ix1 = shX + x[i_coord_offset+DIM*1+XX];
495 iy1 = shY + x[i_coord_offset+DIM*1+YY];
496 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
497 ix2 = shX + x[i_coord_offset+DIM*2+XX];
498 iy2 = shY + x[i_coord_offset+DIM*2+YY];
499 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
511 /* Start inner kernel loop */
512 for(jidx=j_index_start; jidx<j_index_end; jidx++)
514 /* Get j neighbor index, and coordinate index */
516 j_coord_offset = DIM*jnr;
518 /* load j atom coordinates */
519 jx0 = x[j_coord_offset+DIM*0+XX];
520 jy0 = x[j_coord_offset+DIM*0+YY];
521 jz0 = x[j_coord_offset+DIM*0+ZZ];
523 /* Calculate displacement vector */
534 /* Calculate squared distance and things based on it */
535 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
536 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
537 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
539 rinv00 = gmx_invsqrt(rsq00);
540 rinv10 = gmx_invsqrt(rsq10);
541 rinv20 = gmx_invsqrt(rsq20);
543 rinvsq00 = rinv00*rinv00;
544 rinvsq10 = rinv10*rinv10;
545 rinvsq20 = rinv20*rinv20;
547 /* Load parameters for j particles */
549 vdwjidx0 = 2*vdwtype[jnr+0];
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
561 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
562 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
564 /* Calculate table index by multiplying r with table scale and truncate to integer */
570 /* REACTION-FIELD ELECTROSTATICS */
571 felec = qq00*(rinv00*rinvsq00-krf2);
573 /* 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 */
584 Geps = vfeps*vftab[vfitab+6];
585 Heps2 = vfeps*vfeps*vftab[vfitab+7];
587 FF = Fp+Geps+2.0*Heps2;
589 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
593 /* Calculate temporary vectorial force */
598 /* Update vectorial force */
602 f[j_coord_offset+DIM*0+XX] -= tx;
603 f[j_coord_offset+DIM*0+YY] -= ty;
604 f[j_coord_offset+DIM*0+ZZ] -= tz;
608 /**************************
609 * CALCULATE INTERACTIONS *
610 **************************/
617 /* REACTION-FIELD ELECTROSTATICS */
618 felec = qq10*(rinv10*rinvsq10-krf2);
622 /* Calculate temporary vectorial force */
627 /* Update vectorial force */
631 f[j_coord_offset+DIM*0+XX] -= tx;
632 f[j_coord_offset+DIM*0+YY] -= ty;
633 f[j_coord_offset+DIM*0+ZZ] -= tz;
637 /**************************
638 * CALCULATE INTERACTIONS *
639 **************************/
646 /* REACTION-FIELD ELECTROSTATICS */
647 felec = qq20*(rinv20*rinvsq20-krf2);
651 /* Calculate temporary vectorial force */
656 /* Update vectorial force */
660 f[j_coord_offset+DIM*0+XX] -= tx;
661 f[j_coord_offset+DIM*0+YY] -= ty;
662 f[j_coord_offset+DIM*0+ZZ] -= tz;
666 /* Inner loop uses 107 flops */
668 /* End of innermost loop */
671 f[i_coord_offset+DIM*0+XX] += fix0;
672 f[i_coord_offset+DIM*0+YY] += fiy0;
673 f[i_coord_offset+DIM*0+ZZ] += fiz0;
677 f[i_coord_offset+DIM*1+XX] += fix1;
678 f[i_coord_offset+DIM*1+YY] += fiy1;
679 f[i_coord_offset+DIM*1+ZZ] += fiz1;
683 f[i_coord_offset+DIM*2+XX] += fix2;
684 f[i_coord_offset+DIM*2+YY] += fiy2;
685 f[i_coord_offset+DIM*2+ZZ] += fiz2;
689 fshift[i_shift_offset+XX] += tx;
690 fshift[i_shift_offset+YY] += ty;
691 fshift[i_shift_offset+ZZ] += tz;
693 /* Increment number of inner iterations */
694 inneriter += j_index_end - j_index_start;
696 /* Outer loop uses 30 flops */
699 /* Increment number of outer iterations */
702 /* Update outer/inner flops */
704 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);