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_ElecCSTab_VdwLJ_GeomW4P1_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwLJ_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_elec->data;
114 vftabscale = kernel_data->table_elec->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 rinv10 = gmx_invsqrt(rsq10);
207 rinv20 = gmx_invsqrt(rsq20);
208 rinv30 = gmx_invsqrt(rsq30);
210 rinvsq00 = 1.0/rsq00;
212 /* Load parameters for j particles */
214 vdwjidx0 = 2*vdwtype[jnr+0];
216 /**************************
217 * CALCULATE INTERACTIONS *
218 **************************/
220 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
221 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
223 /* LENNARD-JONES DISPERSION/REPULSION */
225 rinvsix = rinvsq00*rinvsq00*rinvsq00;
226 vvdw6 = c6_00*rinvsix;
227 vvdw12 = c12_00*rinvsix*rinvsix;
228 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
229 fvdw = (vvdw12-vvdw6)*rinvsq00;
231 /* Update potential sums from outer loop */
236 /* Calculate temporary vectorial force */
241 /* Update vectorial force */
245 f[j_coord_offset+DIM*0+XX] -= tx;
246 f[j_coord_offset+DIM*0+YY] -= ty;
247 f[j_coord_offset+DIM*0+ZZ] -= tz;
249 /**************************
250 * CALCULATE INTERACTIONS *
251 **************************/
257 /* Calculate table index by multiplying r with table scale and truncate to integer */
263 /* CUBIC SPLINE TABLE ELECTROSTATICS */
266 Geps = vfeps*vftab[vfitab+2];
267 Heps2 = vfeps*vfeps*vftab[vfitab+3];
271 FF = Fp+Geps+2.0*Heps2;
272 felec = -qq10*FF*vftabscale*rinv10;
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*0+XX] -= tx;
289 f[j_coord_offset+DIM*0+YY] -= ty;
290 f[j_coord_offset+DIM*0+ZZ] -= tz;
292 /**************************
293 * CALCULATE INTERACTIONS *
294 **************************/
300 /* Calculate table index by multiplying r with table scale and truncate to integer */
306 /* CUBIC SPLINE TABLE ELECTROSTATICS */
309 Geps = vfeps*vftab[vfitab+2];
310 Heps2 = vfeps*vfeps*vftab[vfitab+3];
314 FF = Fp+Geps+2.0*Heps2;
315 felec = -qq20*FF*vftabscale*rinv20;
317 /* Update potential sums from outer loop */
322 /* Calculate temporary vectorial force */
327 /* Update vectorial force */
331 f[j_coord_offset+DIM*0+XX] -= tx;
332 f[j_coord_offset+DIM*0+YY] -= ty;
333 f[j_coord_offset+DIM*0+ZZ] -= tz;
335 /**************************
336 * CALCULATE INTERACTIONS *
337 **************************/
343 /* Calculate table index by multiplying r with table scale and truncate to integer */
349 /* CUBIC SPLINE TABLE ELECTROSTATICS */
352 Geps = vfeps*vftab[vfitab+2];
353 Heps2 = vfeps*vfeps*vftab[vfitab+3];
357 FF = Fp+Geps+2.0*Heps2;
358 felec = -qq30*FF*vftabscale*rinv30;
360 /* Update potential sums from outer loop */
365 /* Calculate temporary vectorial force */
370 /* Update vectorial force */
374 f[j_coord_offset+DIM*0+XX] -= tx;
375 f[j_coord_offset+DIM*0+YY] -= ty;
376 f[j_coord_offset+DIM*0+ZZ] -= tz;
378 /* Inner loop uses 158 flops */
380 /* End of innermost loop */
383 f[i_coord_offset+DIM*0+XX] += fix0;
384 f[i_coord_offset+DIM*0+YY] += fiy0;
385 f[i_coord_offset+DIM*0+ZZ] += fiz0;
389 f[i_coord_offset+DIM*1+XX] += fix1;
390 f[i_coord_offset+DIM*1+YY] += fiy1;
391 f[i_coord_offset+DIM*1+ZZ] += fiz1;
395 f[i_coord_offset+DIM*2+XX] += fix2;
396 f[i_coord_offset+DIM*2+YY] += fiy2;
397 f[i_coord_offset+DIM*2+ZZ] += fiz2;
401 f[i_coord_offset+DIM*3+XX] += fix3;
402 f[i_coord_offset+DIM*3+YY] += fiy3;
403 f[i_coord_offset+DIM*3+ZZ] += fiz3;
407 fshift[i_shift_offset+XX] += tx;
408 fshift[i_shift_offset+YY] += ty;
409 fshift[i_shift_offset+ZZ] += tz;
412 /* Update potential energies */
413 kernel_data->energygrp_elec[ggid] += velecsum;
414 kernel_data->energygrp_vdw[ggid] += vvdwsum;
416 /* Increment number of inner iterations */
417 inneriter += j_index_end - j_index_start;
419 /* Outer loop uses 41 flops */
422 /* Increment number of outer iterations */
425 /* Update outer/inner flops */
427 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*158);
430 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4P1_F_c
431 * Electrostatics interaction: CubicSplineTable
432 * VdW interaction: LennardJones
433 * Geometry: Water4-Particle
434 * Calculate force/pot: Force
437 nb_kernel_ElecCSTab_VdwLJ_GeomW4P1_F_c
438 (t_nblist * gmx_restrict nlist,
439 rvec * gmx_restrict xx,
440 rvec * gmx_restrict ff,
441 t_forcerec * gmx_restrict fr,
442 t_mdatoms * gmx_restrict mdatoms,
443 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
444 t_nrnb * gmx_restrict nrnb)
446 int i_shift_offset,i_coord_offset,j_coord_offset;
447 int j_index_start,j_index_end;
448 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
449 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
450 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
451 real *shiftvec,*fshift,*x,*f;
453 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
455 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
457 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
459 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
461 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
462 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
463 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
464 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
465 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
466 real velec,felec,velecsum,facel,crf,krf,krf2;
469 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
473 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
481 jindex = nlist->jindex;
483 shiftidx = nlist->shift;
485 shiftvec = fr->shift_vec[0];
486 fshift = fr->fshift[0];
488 charge = mdatoms->chargeA;
489 nvdwtype = fr->ntype;
491 vdwtype = mdatoms->typeA;
493 vftab = kernel_data->table_elec->data;
494 vftabscale = kernel_data->table_elec->scale;
496 /* Setup water-specific parameters */
497 inr = nlist->iinr[0];
498 iq1 = facel*charge[inr+1];
499 iq2 = facel*charge[inr+2];
500 iq3 = facel*charge[inr+3];
501 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
506 /* Start outer loop over neighborlists */
507 for(iidx=0; iidx<nri; iidx++)
509 /* Load shift vector for this list */
510 i_shift_offset = DIM*shiftidx[iidx];
511 shX = shiftvec[i_shift_offset+XX];
512 shY = shiftvec[i_shift_offset+YY];
513 shZ = shiftvec[i_shift_offset+ZZ];
515 /* Load limits for loop over neighbors */
516 j_index_start = jindex[iidx];
517 j_index_end = jindex[iidx+1];
519 /* Get outer coordinate index */
521 i_coord_offset = DIM*inr;
523 /* Load i particle coords and add shift vector */
524 ix0 = shX + x[i_coord_offset+DIM*0+XX];
525 iy0 = shY + x[i_coord_offset+DIM*0+YY];
526 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
527 ix1 = shX + x[i_coord_offset+DIM*1+XX];
528 iy1 = shY + x[i_coord_offset+DIM*1+YY];
529 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
530 ix2 = shX + x[i_coord_offset+DIM*2+XX];
531 iy2 = shY + x[i_coord_offset+DIM*2+YY];
532 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
533 ix3 = shX + x[i_coord_offset+DIM*3+XX];
534 iy3 = shY + x[i_coord_offset+DIM*3+YY];
535 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
550 /* Start inner kernel loop */
551 for(jidx=j_index_start; jidx<j_index_end; jidx++)
553 /* Get j neighbor index, and coordinate index */
555 j_coord_offset = DIM*jnr;
557 /* load j atom coordinates */
558 jx0 = x[j_coord_offset+DIM*0+XX];
559 jy0 = x[j_coord_offset+DIM*0+YY];
560 jz0 = x[j_coord_offset+DIM*0+ZZ];
562 /* Calculate displacement vector */
576 /* Calculate squared distance and things based on it */
577 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
578 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
579 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
580 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
582 rinv10 = gmx_invsqrt(rsq10);
583 rinv20 = gmx_invsqrt(rsq20);
584 rinv30 = gmx_invsqrt(rsq30);
586 rinvsq00 = 1.0/rsq00;
588 /* Load parameters for j particles */
590 vdwjidx0 = 2*vdwtype[jnr+0];
592 /**************************
593 * CALCULATE INTERACTIONS *
594 **************************/
596 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
597 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
599 /* LENNARD-JONES DISPERSION/REPULSION */
601 rinvsix = rinvsq00*rinvsq00*rinvsq00;
602 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
606 /* Calculate temporary vectorial force */
611 /* Update vectorial force */
615 f[j_coord_offset+DIM*0+XX] -= tx;
616 f[j_coord_offset+DIM*0+YY] -= ty;
617 f[j_coord_offset+DIM*0+ZZ] -= tz;
619 /**************************
620 * CALCULATE INTERACTIONS *
621 **************************/
627 /* Calculate table index by multiplying r with table scale and truncate to integer */
633 /* CUBIC SPLINE TABLE ELECTROSTATICS */
635 Geps = vfeps*vftab[vfitab+2];
636 Heps2 = vfeps*vfeps*vftab[vfitab+3];
638 FF = Fp+Geps+2.0*Heps2;
639 felec = -qq10*FF*vftabscale*rinv10;
643 /* Calculate temporary vectorial force */
648 /* Update vectorial force */
652 f[j_coord_offset+DIM*0+XX] -= tx;
653 f[j_coord_offset+DIM*0+YY] -= ty;
654 f[j_coord_offset+DIM*0+ZZ] -= tz;
656 /**************************
657 * CALCULATE INTERACTIONS *
658 **************************/
664 /* Calculate table index by multiplying r with table scale and truncate to integer */
670 /* CUBIC SPLINE TABLE ELECTROSTATICS */
672 Geps = vfeps*vftab[vfitab+2];
673 Heps2 = vfeps*vfeps*vftab[vfitab+3];
675 FF = Fp+Geps+2.0*Heps2;
676 felec = -qq20*FF*vftabscale*rinv20;
680 /* Calculate temporary vectorial force */
685 /* Update vectorial force */
689 f[j_coord_offset+DIM*0+XX] -= tx;
690 f[j_coord_offset+DIM*0+YY] -= ty;
691 f[j_coord_offset+DIM*0+ZZ] -= tz;
693 /**************************
694 * CALCULATE INTERACTIONS *
695 **************************/
701 /* Calculate table index by multiplying r with table scale and truncate to integer */
707 /* CUBIC SPLINE TABLE ELECTROSTATICS */
709 Geps = vfeps*vftab[vfitab+2];
710 Heps2 = vfeps*vfeps*vftab[vfitab+3];
712 FF = Fp+Geps+2.0*Heps2;
713 felec = -qq30*FF*vftabscale*rinv30;
717 /* Calculate temporary vectorial force */
722 /* Update vectorial force */
726 f[j_coord_offset+DIM*0+XX] -= tx;
727 f[j_coord_offset+DIM*0+YY] -= ty;
728 f[j_coord_offset+DIM*0+ZZ] -= tz;
730 /* Inner loop uses 141 flops */
732 /* End of innermost loop */
735 f[i_coord_offset+DIM*0+XX] += fix0;
736 f[i_coord_offset+DIM*0+YY] += fiy0;
737 f[i_coord_offset+DIM*0+ZZ] += fiz0;
741 f[i_coord_offset+DIM*1+XX] += fix1;
742 f[i_coord_offset+DIM*1+YY] += fiy1;
743 f[i_coord_offset+DIM*1+ZZ] += fiz1;
747 f[i_coord_offset+DIM*2+XX] += fix2;
748 f[i_coord_offset+DIM*2+YY] += fiy2;
749 f[i_coord_offset+DIM*2+ZZ] += fiz2;
753 f[i_coord_offset+DIM*3+XX] += fix3;
754 f[i_coord_offset+DIM*3+YY] += fiy3;
755 f[i_coord_offset+DIM*3+ZZ] += fiz3;
759 fshift[i_shift_offset+XX] += tx;
760 fshift[i_shift_offset+YY] += ty;
761 fshift[i_shift_offset+ZZ] += tz;
763 /* Increment number of inner iterations */
764 inneriter += j_index_end - j_index_start;
766 /* Outer loop uses 39 flops */
769 /* Increment number of outer iterations */
772 /* Update outer/inner flops */
774 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*141);