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_ElecCoul_VdwCSTab_GeomW4P1_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
93 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
108 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 iq1 = facel*charge[inr+1];
119 iq2 = facel*charge[inr+2];
120 iq3 = facel*charge[inr+3];
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];
153 ix3 = shX + x[i_coord_offset+DIM*3+XX];
154 iy3 = shY + x[i_coord_offset+DIM*3+YY];
155 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
170 /* Reset potential sums */
174 /* Start inner kernel loop */
175 for(jidx=j_index_start; jidx<j_index_end; jidx++)
177 /* Get j neighbor index, and coordinate index */
179 j_coord_offset = DIM*jnr;
181 /* load j atom coordinates */
182 jx0 = x[j_coord_offset+DIM*0+XX];
183 jy0 = x[j_coord_offset+DIM*0+YY];
184 jz0 = x[j_coord_offset+DIM*0+ZZ];
186 /* Calculate displacement vector */
200 /* Calculate squared distance and things based on it */
201 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
202 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
203 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
204 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
206 rinv00 = gmx_invsqrt(rsq00);
207 rinv10 = gmx_invsqrt(rsq10);
208 rinv20 = gmx_invsqrt(rsq20);
209 rinv30 = gmx_invsqrt(rsq30);
211 rinvsq10 = rinv10*rinv10;
212 rinvsq20 = rinv20*rinv20;
213 rinvsq30 = rinv30*rinv30;
215 /* Load parameters for j particles */
217 vdwjidx0 = 2*vdwtype[jnr+0];
219 /**************************
220 * CALCULATE INTERACTIONS *
221 **************************/
225 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
226 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
228 /* Calculate table index by multiplying r with table scale and truncate to integer */
234 /* CUBIC SPLINE TABLE DISPERSION */
238 Geps = vfeps*vftab[vfitab+2];
239 Heps2 = vfeps*vfeps*vftab[vfitab+3];
243 FF = Fp+Geps+2.0*Heps2;
246 /* CUBIC SPLINE TABLE REPULSION */
249 Geps = vfeps*vftab[vfitab+6];
250 Heps2 = vfeps*vfeps*vftab[vfitab+7];
254 FF = Fp+Geps+2.0*Heps2;
257 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
259 /* 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;
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
283 /* COULOMB ELECTROSTATICS */
285 felec = velec*rinvsq10;
287 /* Update potential sums from outer loop */
292 /* Calculate temporary vectorial force */
297 /* Update vectorial force */
301 f[j_coord_offset+DIM*0+XX] -= tx;
302 f[j_coord_offset+DIM*0+YY] -= ty;
303 f[j_coord_offset+DIM*0+ZZ] -= tz;
305 /**************************
306 * CALCULATE INTERACTIONS *
307 **************************/
311 /* COULOMB ELECTROSTATICS */
313 felec = velec*rinvsq20;
315 /* Update potential sums from outer loop */
320 /* Calculate temporary vectorial force */
325 /* Update vectorial force */
329 f[j_coord_offset+DIM*0+XX] -= tx;
330 f[j_coord_offset+DIM*0+YY] -= ty;
331 f[j_coord_offset+DIM*0+ZZ] -= tz;
333 /**************************
334 * CALCULATE INTERACTIONS *
335 **************************/
339 /* COULOMB ELECTROSTATICS */
341 felec = velec*rinvsq30;
343 /* Update potential sums from outer loop */
348 /* Calculate temporary vectorial force */
353 /* Update vectorial force */
357 f[j_coord_offset+DIM*0+XX] -= tx;
358 f[j_coord_offset+DIM*0+YY] -= ty;
359 f[j_coord_offset+DIM*0+ZZ] -= tz;
361 /* Inner loop uses 139 flops */
363 /* End of innermost loop */
366 f[i_coord_offset+DIM*0+XX] += fix0;
367 f[i_coord_offset+DIM*0+YY] += fiy0;
368 f[i_coord_offset+DIM*0+ZZ] += fiz0;
372 f[i_coord_offset+DIM*1+XX] += fix1;
373 f[i_coord_offset+DIM*1+YY] += fiy1;
374 f[i_coord_offset+DIM*1+ZZ] += fiz1;
378 f[i_coord_offset+DIM*2+XX] += fix2;
379 f[i_coord_offset+DIM*2+YY] += fiy2;
380 f[i_coord_offset+DIM*2+ZZ] += fiz2;
384 f[i_coord_offset+DIM*3+XX] += fix3;
385 f[i_coord_offset+DIM*3+YY] += fiy3;
386 f[i_coord_offset+DIM*3+ZZ] += fiz3;
390 fshift[i_shift_offset+XX] += tx;
391 fshift[i_shift_offset+YY] += ty;
392 fshift[i_shift_offset+ZZ] += tz;
395 /* Update potential energies */
396 kernel_data->energygrp_elec[ggid] += velecsum;
397 kernel_data->energygrp_vdw[ggid] += vvdwsum;
399 /* Increment number of inner iterations */
400 inneriter += j_index_end - j_index_start;
402 /* Outer loop uses 41 flops */
405 /* Increment number of outer iterations */
408 /* Update outer/inner flops */
410 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*139);
413 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_c
414 * Electrostatics interaction: Coulomb
415 * VdW interaction: CubicSplineTable
416 * Geometry: Water4-Particle
417 * Calculate force/pot: Force
420 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_c
421 (t_nblist * gmx_restrict nlist,
422 rvec * gmx_restrict xx,
423 rvec * gmx_restrict ff,
424 t_forcerec * gmx_restrict fr,
425 t_mdatoms * gmx_restrict mdatoms,
426 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
427 t_nrnb * gmx_restrict nrnb)
429 int i_shift_offset,i_coord_offset,j_coord_offset;
430 int j_index_start,j_index_end;
431 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
432 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
433 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
434 real *shiftvec,*fshift,*x,*f;
436 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
438 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
440 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
442 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
444 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
445 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
446 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
447 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
448 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
449 real velec,felec,velecsum,facel,crf,krf,krf2;
452 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
456 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
464 jindex = nlist->jindex;
466 shiftidx = nlist->shift;
468 shiftvec = fr->shift_vec[0];
469 fshift = fr->fshift[0];
471 charge = mdatoms->chargeA;
472 nvdwtype = fr->ntype;
474 vdwtype = mdatoms->typeA;
476 vftab = kernel_data->table_vdw->data;
477 vftabscale = kernel_data->table_vdw->scale;
479 /* Setup water-specific parameters */
480 inr = nlist->iinr[0];
481 iq1 = facel*charge[inr+1];
482 iq2 = facel*charge[inr+2];
483 iq3 = facel*charge[inr+3];
484 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
489 /* Start outer loop over neighborlists */
490 for(iidx=0; iidx<nri; iidx++)
492 /* Load shift vector for this list */
493 i_shift_offset = DIM*shiftidx[iidx];
494 shX = shiftvec[i_shift_offset+XX];
495 shY = shiftvec[i_shift_offset+YY];
496 shZ = shiftvec[i_shift_offset+ZZ];
498 /* Load limits for loop over neighbors */
499 j_index_start = jindex[iidx];
500 j_index_end = jindex[iidx+1];
502 /* Get outer coordinate index */
504 i_coord_offset = DIM*inr;
506 /* Load i particle coords and add shift vector */
507 ix0 = shX + x[i_coord_offset+DIM*0+XX];
508 iy0 = shY + x[i_coord_offset+DIM*0+YY];
509 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
510 ix1 = shX + x[i_coord_offset+DIM*1+XX];
511 iy1 = shY + x[i_coord_offset+DIM*1+YY];
512 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
513 ix2 = shX + x[i_coord_offset+DIM*2+XX];
514 iy2 = shY + x[i_coord_offset+DIM*2+YY];
515 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
516 ix3 = shX + x[i_coord_offset+DIM*3+XX];
517 iy3 = shY + x[i_coord_offset+DIM*3+YY];
518 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
533 /* Start inner kernel loop */
534 for(jidx=j_index_start; jidx<j_index_end; jidx++)
536 /* Get j neighbor index, and coordinate index */
538 j_coord_offset = DIM*jnr;
540 /* load j atom coordinates */
541 jx0 = x[j_coord_offset+DIM*0+XX];
542 jy0 = x[j_coord_offset+DIM*0+YY];
543 jz0 = x[j_coord_offset+DIM*0+ZZ];
545 /* Calculate displacement vector */
559 /* Calculate squared distance and things based on it */
560 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
561 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
562 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
563 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
565 rinv00 = gmx_invsqrt(rsq00);
566 rinv10 = gmx_invsqrt(rsq10);
567 rinv20 = gmx_invsqrt(rsq20);
568 rinv30 = gmx_invsqrt(rsq30);
570 rinvsq10 = rinv10*rinv10;
571 rinvsq20 = rinv20*rinv20;
572 rinvsq30 = rinv30*rinv30;
574 /* Load parameters for j particles */
576 vdwjidx0 = 2*vdwtype[jnr+0];
578 /**************************
579 * CALCULATE INTERACTIONS *
580 **************************/
584 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
585 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
587 /* Calculate table index by multiplying r with table scale and truncate to integer */
593 /* CUBIC SPLINE TABLE DISPERSION */
596 Geps = vfeps*vftab[vfitab+2];
597 Heps2 = vfeps*vfeps*vftab[vfitab+3];
599 FF = Fp+Geps+2.0*Heps2;
602 /* CUBIC SPLINE TABLE REPULSION */
604 Geps = vfeps*vftab[vfitab+6];
605 Heps2 = vfeps*vfeps*vftab[vfitab+7];
607 FF = Fp+Geps+2.0*Heps2;
609 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
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 /**************************
627 * CALCULATE INTERACTIONS *
628 **************************/
632 /* COULOMB ELECTROSTATICS */
634 felec = velec*rinvsq10;
638 /* Calculate temporary vectorial force */
643 /* Update vectorial force */
647 f[j_coord_offset+DIM*0+XX] -= tx;
648 f[j_coord_offset+DIM*0+YY] -= ty;
649 f[j_coord_offset+DIM*0+ZZ] -= tz;
651 /**************************
652 * CALCULATE INTERACTIONS *
653 **************************/
657 /* COULOMB ELECTROSTATICS */
659 felec = velec*rinvsq20;
663 /* Calculate temporary vectorial force */
668 /* Update vectorial force */
672 f[j_coord_offset+DIM*0+XX] -= tx;
673 f[j_coord_offset+DIM*0+YY] -= ty;
674 f[j_coord_offset+DIM*0+ZZ] -= tz;
676 /**************************
677 * CALCULATE INTERACTIONS *
678 **************************/
682 /* COULOMB ELECTROSTATICS */
684 felec = velec*rinvsq30;
688 /* Calculate temporary vectorial force */
693 /* Update vectorial force */
697 f[j_coord_offset+DIM*0+XX] -= tx;
698 f[j_coord_offset+DIM*0+YY] -= ty;
699 f[j_coord_offset+DIM*0+ZZ] -= tz;
701 /* Inner loop uses 128 flops */
703 /* End of innermost loop */
706 f[i_coord_offset+DIM*0+XX] += fix0;
707 f[i_coord_offset+DIM*0+YY] += fiy0;
708 f[i_coord_offset+DIM*0+ZZ] += fiz0;
712 f[i_coord_offset+DIM*1+XX] += fix1;
713 f[i_coord_offset+DIM*1+YY] += fiy1;
714 f[i_coord_offset+DIM*1+ZZ] += fiz1;
718 f[i_coord_offset+DIM*2+XX] += fix2;
719 f[i_coord_offset+DIM*2+YY] += fiy2;
720 f[i_coord_offset+DIM*2+ZZ] += fiz2;
724 f[i_coord_offset+DIM*3+XX] += fix3;
725 f[i_coord_offset+DIM*3+YY] += fiy3;
726 f[i_coord_offset+DIM*3+ZZ] += fiz3;
730 fshift[i_shift_offset+XX] += tx;
731 fshift[i_shift_offset+YY] += ty;
732 fshift[i_shift_offset+ZZ] += tz;
734 /* Increment number of inner iterations */
735 inneriter += j_index_end - j_index_start;
737 /* Outer loop uses 39 flops */
740 /* Increment number of outer iterations */
743 /* Update outer/inner flops */
745 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*128);