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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRF_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];
124 /* Start outer loop over neighborlists */
125 for(iidx=0; iidx<nri; iidx++)
127 /* Load shift vector for this list */
128 i_shift_offset = DIM*shiftidx[iidx];
129 shX = shiftvec[i_shift_offset+XX];
130 shY = shiftvec[i_shift_offset+YY];
131 shZ = shiftvec[i_shift_offset+ZZ];
133 /* Load limits for loop over neighbors */
134 j_index_start = jindex[iidx];
135 j_index_end = jindex[iidx+1];
137 /* Get outer coordinate index */
139 i_coord_offset = DIM*inr;
141 /* Load i particle coords and add shift vector */
142 ix0 = shX + x[i_coord_offset+DIM*0+XX];
143 iy0 = shY + x[i_coord_offset+DIM*0+YY];
144 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
145 ix1 = shX + x[i_coord_offset+DIM*1+XX];
146 iy1 = shY + x[i_coord_offset+DIM*1+YY];
147 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
148 ix2 = shX + x[i_coord_offset+DIM*2+XX];
149 iy2 = shY + x[i_coord_offset+DIM*2+YY];
150 iz2 = shZ + x[i_coord_offset+DIM*2+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 */
189 /* Calculate squared distance and things based on it */
190 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
191 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
192 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
194 rinv00 = gmx_invsqrt(rsq00);
195 rinv10 = gmx_invsqrt(rsq10);
196 rinv20 = gmx_invsqrt(rsq20);
198 rinvsq00 = rinv00*rinv00;
199 rinvsq10 = rinv10*rinv10;
200 rinvsq20 = rinv20*rinv20;
202 /* Load parameters for j particles */
204 vdwjidx0 = 2*vdwtype[jnr+0];
206 /**************************
207 * CALCULATE INTERACTIONS *
208 **************************/
213 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
214 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
216 /* Calculate table index by multiplying r with table scale and truncate to integer */
222 /* REACTION-FIELD ELECTROSTATICS */
223 velec = qq00*(rinv00+krf*rsq00-crf);
224 felec = qq00*(rinv00*rinvsq00-krf2);
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 */
257 /* Calculate temporary vectorial force */
262 /* Update vectorial force */
266 f[j_coord_offset+DIM*0+XX] -= tx;
267 f[j_coord_offset+DIM*0+YY] -= ty;
268 f[j_coord_offset+DIM*0+ZZ] -= tz;
270 /**************************
271 * CALCULATE INTERACTIONS *
272 **************************/
276 /* REACTION-FIELD ELECTROSTATICS */
277 velec = qq10*(rinv10+krf*rsq10-crf);
278 felec = qq10*(rinv10*rinvsq10-krf2);
280 /* Update potential sums from outer loop */
285 /* Calculate temporary vectorial force */
290 /* Update vectorial force */
294 f[j_coord_offset+DIM*0+XX] -= tx;
295 f[j_coord_offset+DIM*0+YY] -= ty;
296 f[j_coord_offset+DIM*0+ZZ] -= tz;
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
304 /* REACTION-FIELD ELECTROSTATICS */
305 velec = qq20*(rinv20+krf*rsq20-crf);
306 felec = qq20*(rinv20*rinvsq20-krf2);
308 /* Update potential sums from outer loop */
313 /* Calculate temporary vectorial force */
318 /* Update vectorial force */
322 f[j_coord_offset+DIM*0+XX] -= tx;
323 f[j_coord_offset+DIM*0+YY] -= ty;
324 f[j_coord_offset+DIM*0+ZZ] -= tz;
326 /* Inner loop uses 130 flops */
328 /* End of innermost loop */
331 f[i_coord_offset+DIM*0+XX] += fix0;
332 f[i_coord_offset+DIM*0+YY] += fiy0;
333 f[i_coord_offset+DIM*0+ZZ] += fiz0;
337 f[i_coord_offset+DIM*1+XX] += fix1;
338 f[i_coord_offset+DIM*1+YY] += fiy1;
339 f[i_coord_offset+DIM*1+ZZ] += fiz1;
343 f[i_coord_offset+DIM*2+XX] += fix2;
344 f[i_coord_offset+DIM*2+YY] += fiy2;
345 f[i_coord_offset+DIM*2+ZZ] += fiz2;
349 fshift[i_shift_offset+XX] += tx;
350 fshift[i_shift_offset+YY] += ty;
351 fshift[i_shift_offset+ZZ] += tz;
354 /* Update potential energies */
355 kernel_data->energygrp_elec[ggid] += velecsum;
356 kernel_data->energygrp_vdw[ggid] += vvdwsum;
358 /* Increment number of inner iterations */
359 inneriter += j_index_end - j_index_start;
361 /* Outer loop uses 32 flops */
364 /* Increment number of outer iterations */
367 /* Update outer/inner flops */
369 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*130);
372 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_c
373 * Electrostatics interaction: ReactionField
374 * VdW interaction: CubicSplineTable
375 * Geometry: Water3-Particle
376 * Calculate force/pot: Force
379 nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_c
380 (t_nblist * gmx_restrict nlist,
381 rvec * gmx_restrict xx,
382 rvec * gmx_restrict ff,
383 t_forcerec * gmx_restrict fr,
384 t_mdatoms * gmx_restrict mdatoms,
385 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
386 t_nrnb * gmx_restrict nrnb)
388 int i_shift_offset,i_coord_offset,j_coord_offset;
389 int j_index_start,j_index_end;
390 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
391 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
392 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
393 real *shiftvec,*fshift,*x,*f;
395 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
397 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
399 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
401 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
402 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
403 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
404 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
405 real velec,felec,velecsum,facel,crf,krf,krf2;
408 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
412 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
420 jindex = nlist->jindex;
422 shiftidx = nlist->shift;
424 shiftvec = fr->shift_vec[0];
425 fshift = fr->fshift[0];
427 charge = mdatoms->chargeA;
431 nvdwtype = fr->ntype;
433 vdwtype = mdatoms->typeA;
435 vftab = kernel_data->table_vdw->data;
436 vftabscale = kernel_data->table_vdw->scale;
438 /* Setup water-specific parameters */
439 inr = nlist->iinr[0];
440 iq0 = facel*charge[inr+0];
441 iq1 = facel*charge[inr+1];
442 iq2 = facel*charge[inr+2];
443 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
448 /* Start outer loop over neighborlists */
449 for(iidx=0; iidx<nri; iidx++)
451 /* Load shift vector for this list */
452 i_shift_offset = DIM*shiftidx[iidx];
453 shX = shiftvec[i_shift_offset+XX];
454 shY = shiftvec[i_shift_offset+YY];
455 shZ = shiftvec[i_shift_offset+ZZ];
457 /* Load limits for loop over neighbors */
458 j_index_start = jindex[iidx];
459 j_index_end = jindex[iidx+1];
461 /* Get outer coordinate index */
463 i_coord_offset = DIM*inr;
465 /* Load i particle coords and add shift vector */
466 ix0 = shX + x[i_coord_offset+DIM*0+XX];
467 iy0 = shY + x[i_coord_offset+DIM*0+YY];
468 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
469 ix1 = shX + x[i_coord_offset+DIM*1+XX];
470 iy1 = shY + x[i_coord_offset+DIM*1+YY];
471 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
472 ix2 = shX + x[i_coord_offset+DIM*2+XX];
473 iy2 = shY + x[i_coord_offset+DIM*2+YY];
474 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
486 /* Start inner kernel loop */
487 for(jidx=j_index_start; jidx<j_index_end; jidx++)
489 /* Get j neighbor index, and coordinate index */
491 j_coord_offset = DIM*jnr;
493 /* load j atom coordinates */
494 jx0 = x[j_coord_offset+DIM*0+XX];
495 jy0 = x[j_coord_offset+DIM*0+YY];
496 jz0 = x[j_coord_offset+DIM*0+ZZ];
498 /* Calculate displacement vector */
509 /* Calculate squared distance and things based on it */
510 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
511 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
512 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
514 rinv00 = gmx_invsqrt(rsq00);
515 rinv10 = gmx_invsqrt(rsq10);
516 rinv20 = gmx_invsqrt(rsq20);
518 rinvsq00 = rinv00*rinv00;
519 rinvsq10 = rinv10*rinv10;
520 rinvsq20 = rinv20*rinv20;
522 /* Load parameters for j particles */
524 vdwjidx0 = 2*vdwtype[jnr+0];
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
533 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
534 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
536 /* Calculate table index by multiplying r with table scale and truncate to integer */
542 /* REACTION-FIELD ELECTROSTATICS */
543 felec = qq00*(rinv00*rinvsq00-krf2);
545 /* CUBIC SPLINE TABLE DISPERSION */
548 Geps = vfeps*vftab[vfitab+2];
549 Heps2 = vfeps*vfeps*vftab[vfitab+3];
551 FF = Fp+Geps+2.0*Heps2;
554 /* CUBIC SPLINE TABLE REPULSION */
556 Geps = vfeps*vftab[vfitab+6];
557 Heps2 = vfeps*vfeps*vftab[vfitab+7];
559 FF = Fp+Geps+2.0*Heps2;
561 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
565 /* Calculate temporary vectorial force */
570 /* Update vectorial force */
574 f[j_coord_offset+DIM*0+XX] -= tx;
575 f[j_coord_offset+DIM*0+YY] -= ty;
576 f[j_coord_offset+DIM*0+ZZ] -= tz;
578 /**************************
579 * CALCULATE INTERACTIONS *
580 **************************/
584 /* REACTION-FIELD ELECTROSTATICS */
585 felec = qq10*(rinv10*rinvsq10-krf2);
589 /* Calculate temporary vectorial force */
594 /* Update vectorial force */
598 f[j_coord_offset+DIM*0+XX] -= tx;
599 f[j_coord_offset+DIM*0+YY] -= ty;
600 f[j_coord_offset+DIM*0+ZZ] -= tz;
602 /**************************
603 * CALCULATE INTERACTIONS *
604 **************************/
608 /* REACTION-FIELD ELECTROSTATICS */
609 felec = qq20*(rinv20*rinvsq20-krf2);
613 /* Calculate temporary vectorial force */
618 /* Update vectorial force */
622 f[j_coord_offset+DIM*0+XX] -= tx;
623 f[j_coord_offset+DIM*0+YY] -= ty;
624 f[j_coord_offset+DIM*0+ZZ] -= tz;
626 /* Inner loop uses 107 flops */
628 /* End of innermost loop */
631 f[i_coord_offset+DIM*0+XX] += fix0;
632 f[i_coord_offset+DIM*0+YY] += fiy0;
633 f[i_coord_offset+DIM*0+ZZ] += fiz0;
637 f[i_coord_offset+DIM*1+XX] += fix1;
638 f[i_coord_offset+DIM*1+YY] += fiy1;
639 f[i_coord_offset+DIM*1+ZZ] += fiz1;
643 f[i_coord_offset+DIM*2+XX] += fix2;
644 f[i_coord_offset+DIM*2+YY] += fiy2;
645 f[i_coord_offset+DIM*2+ZZ] += fiz2;
649 fshift[i_shift_offset+XX] += tx;
650 fshift[i_shift_offset+YY] += ty;
651 fshift[i_shift_offset+ZZ] += tz;
653 /* Increment number of inner iterations */
654 inneriter += j_index_end - j_index_start;
656 /* Outer loop uses 30 flops */
659 /* Increment number of outer iterations */
662 /* Update outer/inner flops */
664 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);