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_ElecRF_VdwCSTab_GeomW4P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRF_VdwCSTab_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
84 real velec,felec,velecsum,facel,crf,krf,krf2;
87 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
91 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
99 jindex = nlist->jindex;
101 shiftidx = nlist->shift;
103 shiftvec = fr->shift_vec[0];
104 fshift = fr->fshift[0];
106 charge = mdatoms->chargeA;
110 nvdwtype = fr->ntype;
112 vdwtype = mdatoms->typeA;
114 vftab = kernel_data->table_vdw->data;
115 vftabscale = kernel_data->table_vdw->scale;
117 /* Setup water-specific parameters */
118 inr = nlist->iinr[0];
119 iq1 = facel*charge[inr+1];
120 iq2 = facel*charge[inr+2];
121 iq3 = facel*charge[inr+3];
122 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
127 /* Start outer loop over neighborlists */
128 for(iidx=0; iidx<nri; iidx++)
130 /* Load shift vector for this list */
131 i_shift_offset = DIM*shiftidx[iidx];
132 shX = shiftvec[i_shift_offset+XX];
133 shY = shiftvec[i_shift_offset+YY];
134 shZ = shiftvec[i_shift_offset+ZZ];
136 /* Load limits for loop over neighbors */
137 j_index_start = jindex[iidx];
138 j_index_end = jindex[iidx+1];
140 /* Get outer coordinate index */
142 i_coord_offset = DIM*inr;
144 /* Load i particle coords and add shift vector */
145 ix0 = shX + x[i_coord_offset+DIM*0+XX];
146 iy0 = shY + x[i_coord_offset+DIM*0+YY];
147 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
148 ix1 = shX + x[i_coord_offset+DIM*1+XX];
149 iy1 = shY + x[i_coord_offset+DIM*1+YY];
150 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
151 ix2 = shX + x[i_coord_offset+DIM*2+XX];
152 iy2 = shY + x[i_coord_offset+DIM*2+YY];
153 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
154 ix3 = shX + x[i_coord_offset+DIM*3+XX];
155 iy3 = shY + x[i_coord_offset+DIM*3+YY];
156 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
171 /* Reset potential sums */
175 /* Start inner kernel loop */
176 for(jidx=j_index_start; jidx<j_index_end; jidx++)
178 /* Get j neighbor index, and coordinate index */
180 j_coord_offset = DIM*jnr;
182 /* load j atom coordinates */
183 jx0 = x[j_coord_offset+DIM*0+XX];
184 jy0 = x[j_coord_offset+DIM*0+YY];
185 jz0 = x[j_coord_offset+DIM*0+ZZ];
187 /* Calculate displacement vector */
201 /* Calculate squared distance and things based on it */
202 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
203 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
204 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
205 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
207 rinv00 = gmx_invsqrt(rsq00);
208 rinv10 = gmx_invsqrt(rsq10);
209 rinv20 = gmx_invsqrt(rsq20);
210 rinv30 = gmx_invsqrt(rsq30);
212 rinvsq10 = rinv10*rinv10;
213 rinvsq20 = rinv20*rinv20;
214 rinvsq30 = rinv30*rinv30;
216 /* Load parameters for j particles */
218 vdwjidx0 = 2*vdwtype[jnr+0];
220 /**************************
221 * CALCULATE INTERACTIONS *
222 **************************/
226 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
227 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
229 /* Calculate table index by multiplying r with table scale and truncate to integer */
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 */
265 /* Calculate temporary vectorial force */
270 /* Update vectorial force */
274 f[j_coord_offset+DIM*0+XX] -= tx;
275 f[j_coord_offset+DIM*0+YY] -= ty;
276 f[j_coord_offset+DIM*0+ZZ] -= tz;
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
284 /* REACTION-FIELD ELECTROSTATICS */
285 velec = qq10*(rinv10+krf*rsq10-crf);
286 felec = qq10*(rinv10*rinvsq10-krf2);
288 /* Update potential sums from outer loop */
293 /* Calculate temporary vectorial force */
298 /* Update vectorial force */
302 f[j_coord_offset+DIM*0+XX] -= tx;
303 f[j_coord_offset+DIM*0+YY] -= ty;
304 f[j_coord_offset+DIM*0+ZZ] -= tz;
306 /**************************
307 * CALCULATE INTERACTIONS *
308 **************************/
312 /* REACTION-FIELD ELECTROSTATICS */
313 velec = qq20*(rinv20+krf*rsq20-crf);
314 felec = qq20*(rinv20*rinvsq20-krf2);
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
340 /* REACTION-FIELD ELECTROSTATICS */
341 velec = qq30*(rinv30+krf*rsq30-crf);
342 felec = qq30*(rinv30*rinvsq30-krf2);
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*0+XX] -= tx;
359 f[j_coord_offset+DIM*0+YY] -= ty;
360 f[j_coord_offset+DIM*0+ZZ] -= tz;
362 /* Inner loop uses 151 flops */
364 /* End of innermost loop */
367 f[i_coord_offset+DIM*0+XX] += fix0;
368 f[i_coord_offset+DIM*0+YY] += fiy0;
369 f[i_coord_offset+DIM*0+ZZ] += fiz0;
373 f[i_coord_offset+DIM*1+XX] += fix1;
374 f[i_coord_offset+DIM*1+YY] += fiy1;
375 f[i_coord_offset+DIM*1+ZZ] += fiz1;
379 f[i_coord_offset+DIM*2+XX] += fix2;
380 f[i_coord_offset+DIM*2+YY] += fiy2;
381 f[i_coord_offset+DIM*2+ZZ] += fiz2;
385 f[i_coord_offset+DIM*3+XX] += fix3;
386 f[i_coord_offset+DIM*3+YY] += fiy3;
387 f[i_coord_offset+DIM*3+ZZ] += fiz3;
391 fshift[i_shift_offset+XX] += tx;
392 fshift[i_shift_offset+YY] += ty;
393 fshift[i_shift_offset+ZZ] += tz;
396 /* Update potential energies */
397 kernel_data->energygrp_elec[ggid] += velecsum;
398 kernel_data->energygrp_vdw[ggid] += vvdwsum;
400 /* Increment number of inner iterations */
401 inneriter += j_index_end - j_index_start;
403 /* Outer loop uses 41 flops */
406 /* Increment number of outer iterations */
409 /* Update outer/inner flops */
411 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*151);
414 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW4P1_F_c
415 * Electrostatics interaction: ReactionField
416 * VdW interaction: CubicSplineTable
417 * Geometry: Water4-Particle
418 * Calculate force/pot: Force
421 nb_kernel_ElecRF_VdwCSTab_GeomW4P1_F_c
422 (t_nblist * gmx_restrict nlist,
423 rvec * gmx_restrict xx,
424 rvec * gmx_restrict ff,
425 t_forcerec * gmx_restrict fr,
426 t_mdatoms * gmx_restrict mdatoms,
427 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
428 t_nrnb * gmx_restrict nrnb)
430 int i_shift_offset,i_coord_offset,j_coord_offset;
431 int j_index_start,j_index_end;
432 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
433 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
434 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
435 real *shiftvec,*fshift,*x,*f;
437 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
439 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
441 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
443 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
445 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
446 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
447 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
448 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
449 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
450 real velec,felec,velecsum,facel,crf,krf,krf2;
453 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
457 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
465 jindex = nlist->jindex;
467 shiftidx = nlist->shift;
469 shiftvec = fr->shift_vec[0];
470 fshift = fr->fshift[0];
472 charge = mdatoms->chargeA;
476 nvdwtype = fr->ntype;
478 vdwtype = mdatoms->typeA;
480 vftab = kernel_data->table_vdw->data;
481 vftabscale = kernel_data->table_vdw->scale;
483 /* Setup water-specific parameters */
484 inr = nlist->iinr[0];
485 iq1 = facel*charge[inr+1];
486 iq2 = facel*charge[inr+2];
487 iq3 = facel*charge[inr+3];
488 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
493 /* Start outer loop over neighborlists */
494 for(iidx=0; iidx<nri; iidx++)
496 /* Load shift vector for this list */
497 i_shift_offset = DIM*shiftidx[iidx];
498 shX = shiftvec[i_shift_offset+XX];
499 shY = shiftvec[i_shift_offset+YY];
500 shZ = shiftvec[i_shift_offset+ZZ];
502 /* Load limits for loop over neighbors */
503 j_index_start = jindex[iidx];
504 j_index_end = jindex[iidx+1];
506 /* Get outer coordinate index */
508 i_coord_offset = DIM*inr;
510 /* Load i particle coords and add shift vector */
511 ix0 = shX + x[i_coord_offset+DIM*0+XX];
512 iy0 = shY + x[i_coord_offset+DIM*0+YY];
513 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
514 ix1 = shX + x[i_coord_offset+DIM*1+XX];
515 iy1 = shY + x[i_coord_offset+DIM*1+YY];
516 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
517 ix2 = shX + x[i_coord_offset+DIM*2+XX];
518 iy2 = shY + x[i_coord_offset+DIM*2+YY];
519 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
520 ix3 = shX + x[i_coord_offset+DIM*3+XX];
521 iy3 = shY + x[i_coord_offset+DIM*3+YY];
522 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
537 /* Start inner kernel loop */
538 for(jidx=j_index_start; jidx<j_index_end; jidx++)
540 /* Get j neighbor index, and coordinate index */
542 j_coord_offset = DIM*jnr;
544 /* load j atom coordinates */
545 jx0 = x[j_coord_offset+DIM*0+XX];
546 jy0 = x[j_coord_offset+DIM*0+YY];
547 jz0 = x[j_coord_offset+DIM*0+ZZ];
549 /* Calculate displacement vector */
563 /* Calculate squared distance and things based on it */
564 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
565 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
566 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
567 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
569 rinv00 = gmx_invsqrt(rsq00);
570 rinv10 = gmx_invsqrt(rsq10);
571 rinv20 = gmx_invsqrt(rsq20);
572 rinv30 = gmx_invsqrt(rsq30);
574 rinvsq10 = rinv10*rinv10;
575 rinvsq20 = rinv20*rinv20;
576 rinvsq30 = rinv30*rinv30;
578 /* Load parameters for j particles */
580 vdwjidx0 = 2*vdwtype[jnr+0];
582 /**************************
583 * CALCULATE INTERACTIONS *
584 **************************/
588 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
589 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
591 /* Calculate table index by multiplying r with table scale and truncate to integer */
597 /* CUBIC SPLINE TABLE DISPERSION */
600 Geps = vfeps*vftab[vfitab+2];
601 Heps2 = vfeps*vfeps*vftab[vfitab+3];
603 FF = Fp+Geps+2.0*Heps2;
606 /* CUBIC SPLINE TABLE REPULSION */
608 Geps = vfeps*vftab[vfitab+6];
609 Heps2 = vfeps*vfeps*vftab[vfitab+7];
611 FF = Fp+Geps+2.0*Heps2;
613 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
617 /* Calculate temporary vectorial force */
622 /* Update vectorial force */
626 f[j_coord_offset+DIM*0+XX] -= tx;
627 f[j_coord_offset+DIM*0+YY] -= ty;
628 f[j_coord_offset+DIM*0+ZZ] -= tz;
630 /**************************
631 * CALCULATE INTERACTIONS *
632 **************************/
636 /* REACTION-FIELD ELECTROSTATICS */
637 felec = qq10*(rinv10*rinvsq10-krf2);
641 /* Calculate temporary vectorial force */
646 /* Update vectorial force */
650 f[j_coord_offset+DIM*0+XX] -= tx;
651 f[j_coord_offset+DIM*0+YY] -= ty;
652 f[j_coord_offset+DIM*0+ZZ] -= tz;
654 /**************************
655 * CALCULATE INTERACTIONS *
656 **************************/
660 /* REACTION-FIELD ELECTROSTATICS */
661 felec = qq20*(rinv20*rinvsq20-krf2);
665 /* Calculate temporary vectorial force */
670 /* Update vectorial force */
674 f[j_coord_offset+DIM*0+XX] -= tx;
675 f[j_coord_offset+DIM*0+YY] -= ty;
676 f[j_coord_offset+DIM*0+ZZ] -= tz;
678 /**************************
679 * CALCULATE INTERACTIONS *
680 **************************/
684 /* REACTION-FIELD ELECTROSTATICS */
685 felec = qq30*(rinv30*rinvsq30-krf2);
689 /* Calculate temporary vectorial force */
694 /* Update vectorial force */
698 f[j_coord_offset+DIM*0+XX] -= tx;
699 f[j_coord_offset+DIM*0+YY] -= ty;
700 f[j_coord_offset+DIM*0+ZZ] -= tz;
702 /* Inner loop uses 128 flops */
704 /* End of innermost loop */
707 f[i_coord_offset+DIM*0+XX] += fix0;
708 f[i_coord_offset+DIM*0+YY] += fiy0;
709 f[i_coord_offset+DIM*0+ZZ] += fiz0;
713 f[i_coord_offset+DIM*1+XX] += fix1;
714 f[i_coord_offset+DIM*1+YY] += fiy1;
715 f[i_coord_offset+DIM*1+ZZ] += fiz1;
719 f[i_coord_offset+DIM*2+XX] += fix2;
720 f[i_coord_offset+DIM*2+YY] += fiy2;
721 f[i_coord_offset+DIM*2+ZZ] += fiz2;
725 f[i_coord_offset+DIM*3+XX] += fix3;
726 f[i_coord_offset+DIM*3+YY] += fiy3;
727 f[i_coord_offset+DIM*3+ZZ] += fiz3;
731 fshift[i_shift_offset+XX] += tx;
732 fshift[i_shift_offset+YY] += ty;
733 fshift[i_shift_offset+ZZ] += tz;
735 /* Increment number of inner iterations */
736 inneriter += j_index_end - j_index_start;
738 /* Outer loop uses 39 flops */
741 /* Increment number of outer iterations */
744 /* Update outer/inner flops */
746 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*128);