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_ElecCSTab_VdwCSTab_GeomW4P1_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_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_elec_vdw->data;
114 vftabscale = kernel_data->table_elec_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 /* Load parameters for j particles */
213 vdwjidx0 = 2*vdwtype[jnr+0];
215 /**************************
216 * CALCULATE INTERACTIONS *
217 **************************/
221 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
222 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
224 /* Calculate table index by multiplying r with table scale and truncate to integer */
230 /* CUBIC SPLINE TABLE DISPERSION */
234 Geps = vfeps*vftab[vfitab+2];
235 Heps2 = vfeps*vfeps*vftab[vfitab+3];
239 FF = Fp+Geps+2.0*Heps2;
242 /* CUBIC SPLINE TABLE REPULSION */
245 Geps = vfeps*vftab[vfitab+6];
246 Heps2 = vfeps*vfeps*vftab[vfitab+7];
250 FF = Fp+Geps+2.0*Heps2;
253 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
255 /* Update potential sums from outer loop */
260 /* Calculate temporary vectorial force */
265 /* Update vectorial force */
269 f[j_coord_offset+DIM*0+XX] -= tx;
270 f[j_coord_offset+DIM*0+YY] -= ty;
271 f[j_coord_offset+DIM*0+ZZ] -= tz;
273 /**************************
274 * CALCULATE INTERACTIONS *
275 **************************/
281 /* Calculate table index by multiplying r with table scale and truncate to integer */
287 /* CUBIC SPLINE TABLE ELECTROSTATICS */
290 Geps = vfeps*vftab[vfitab+2];
291 Heps2 = vfeps*vfeps*vftab[vfitab+3];
295 FF = Fp+Geps+2.0*Heps2;
296 felec = -qq10*FF*vftabscale*rinv10;
298 /* Update potential sums from outer loop */
303 /* Calculate temporary vectorial force */
308 /* Update vectorial force */
312 f[j_coord_offset+DIM*0+XX] -= tx;
313 f[j_coord_offset+DIM*0+YY] -= ty;
314 f[j_coord_offset+DIM*0+ZZ] -= tz;
316 /**************************
317 * CALCULATE INTERACTIONS *
318 **************************/
324 /* Calculate table index by multiplying r with table scale and truncate to integer */
330 /* CUBIC SPLINE TABLE ELECTROSTATICS */
333 Geps = vfeps*vftab[vfitab+2];
334 Heps2 = vfeps*vfeps*vftab[vfitab+3];
338 FF = Fp+Geps+2.0*Heps2;
339 felec = -qq20*FF*vftabscale*rinv20;
341 /* Update potential sums from outer loop */
346 /* Calculate temporary vectorial force */
351 /* Update vectorial force */
355 f[j_coord_offset+DIM*0+XX] -= tx;
356 f[j_coord_offset+DIM*0+YY] -= ty;
357 f[j_coord_offset+DIM*0+ZZ] -= tz;
359 /**************************
360 * CALCULATE INTERACTIONS *
361 **************************/
367 /* Calculate table index by multiplying r with table scale and truncate to integer */
373 /* CUBIC SPLINE TABLE ELECTROSTATICS */
376 Geps = vfeps*vftab[vfitab+2];
377 Heps2 = vfeps*vfeps*vftab[vfitab+3];
381 FF = Fp+Geps+2.0*Heps2;
382 felec = -qq30*FF*vftabscale*rinv30;
384 /* Update potential sums from outer loop */
389 /* Calculate temporary vectorial force */
394 /* Update vectorial force */
398 f[j_coord_offset+DIM*0+XX] -= tx;
399 f[j_coord_offset+DIM*0+YY] -= ty;
400 f[j_coord_offset+DIM*0+ZZ] -= tz;
402 /* Inner loop uses 181 flops */
404 /* End of innermost loop */
407 f[i_coord_offset+DIM*0+XX] += fix0;
408 f[i_coord_offset+DIM*0+YY] += fiy0;
409 f[i_coord_offset+DIM*0+ZZ] += fiz0;
413 f[i_coord_offset+DIM*1+XX] += fix1;
414 f[i_coord_offset+DIM*1+YY] += fiy1;
415 f[i_coord_offset+DIM*1+ZZ] += fiz1;
419 f[i_coord_offset+DIM*2+XX] += fix2;
420 f[i_coord_offset+DIM*2+YY] += fiy2;
421 f[i_coord_offset+DIM*2+ZZ] += fiz2;
425 f[i_coord_offset+DIM*3+XX] += fix3;
426 f[i_coord_offset+DIM*3+YY] += fiy3;
427 f[i_coord_offset+DIM*3+ZZ] += fiz3;
431 fshift[i_shift_offset+XX] += tx;
432 fshift[i_shift_offset+YY] += ty;
433 fshift[i_shift_offset+ZZ] += tz;
436 /* Update potential energies */
437 kernel_data->energygrp_elec[ggid] += velecsum;
438 kernel_data->energygrp_vdw[ggid] += vvdwsum;
440 /* Increment number of inner iterations */
441 inneriter += j_index_end - j_index_start;
443 /* Outer loop uses 41 flops */
446 /* Increment number of outer iterations */
449 /* Update outer/inner flops */
451 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*181);
454 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_F_c
455 * Electrostatics interaction: CubicSplineTable
456 * VdW interaction: CubicSplineTable
457 * Geometry: Water4-Particle
458 * Calculate force/pot: Force
461 nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_F_c
462 (t_nblist * gmx_restrict nlist,
463 rvec * gmx_restrict xx,
464 rvec * gmx_restrict ff,
465 t_forcerec * gmx_restrict fr,
466 t_mdatoms * gmx_restrict mdatoms,
467 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
468 t_nrnb * gmx_restrict nrnb)
470 int i_shift_offset,i_coord_offset,j_coord_offset;
471 int j_index_start,j_index_end;
472 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
473 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
474 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
475 real *shiftvec,*fshift,*x,*f;
477 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
479 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
481 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
483 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
485 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
486 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
487 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
488 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
489 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
490 real velec,felec,velecsum,facel,crf,krf,krf2;
493 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
497 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
505 jindex = nlist->jindex;
507 shiftidx = nlist->shift;
509 shiftvec = fr->shift_vec[0];
510 fshift = fr->fshift[0];
512 charge = mdatoms->chargeA;
513 nvdwtype = fr->ntype;
515 vdwtype = mdatoms->typeA;
517 vftab = kernel_data->table_elec_vdw->data;
518 vftabscale = kernel_data->table_elec_vdw->scale;
520 /* Setup water-specific parameters */
521 inr = nlist->iinr[0];
522 iq1 = facel*charge[inr+1];
523 iq2 = facel*charge[inr+2];
524 iq3 = facel*charge[inr+3];
525 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
530 /* Start outer loop over neighborlists */
531 for(iidx=0; iidx<nri; iidx++)
533 /* Load shift vector for this list */
534 i_shift_offset = DIM*shiftidx[iidx];
535 shX = shiftvec[i_shift_offset+XX];
536 shY = shiftvec[i_shift_offset+YY];
537 shZ = shiftvec[i_shift_offset+ZZ];
539 /* Load limits for loop over neighbors */
540 j_index_start = jindex[iidx];
541 j_index_end = jindex[iidx+1];
543 /* Get outer coordinate index */
545 i_coord_offset = DIM*inr;
547 /* Load i particle coords and add shift vector */
548 ix0 = shX + x[i_coord_offset+DIM*0+XX];
549 iy0 = shY + x[i_coord_offset+DIM*0+YY];
550 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
551 ix1 = shX + x[i_coord_offset+DIM*1+XX];
552 iy1 = shY + x[i_coord_offset+DIM*1+YY];
553 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
554 ix2 = shX + x[i_coord_offset+DIM*2+XX];
555 iy2 = shY + x[i_coord_offset+DIM*2+YY];
556 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
557 ix3 = shX + x[i_coord_offset+DIM*3+XX];
558 iy3 = shY + x[i_coord_offset+DIM*3+YY];
559 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
574 /* Start inner kernel loop */
575 for(jidx=j_index_start; jidx<j_index_end; jidx++)
577 /* Get j neighbor index, and coordinate index */
579 j_coord_offset = DIM*jnr;
581 /* load j atom coordinates */
582 jx0 = x[j_coord_offset+DIM*0+XX];
583 jy0 = x[j_coord_offset+DIM*0+YY];
584 jz0 = x[j_coord_offset+DIM*0+ZZ];
586 /* Calculate displacement vector */
600 /* Calculate squared distance and things based on it */
601 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
602 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
603 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
604 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
606 rinv00 = gmx_invsqrt(rsq00);
607 rinv10 = gmx_invsqrt(rsq10);
608 rinv20 = gmx_invsqrt(rsq20);
609 rinv30 = gmx_invsqrt(rsq30);
611 /* Load parameters for j particles */
613 vdwjidx0 = 2*vdwtype[jnr+0];
615 /**************************
616 * CALCULATE INTERACTIONS *
617 **************************/
621 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
622 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
624 /* Calculate table index by multiplying r with table scale and truncate to integer */
630 /* CUBIC SPLINE TABLE DISPERSION */
633 Geps = vfeps*vftab[vfitab+2];
634 Heps2 = vfeps*vfeps*vftab[vfitab+3];
636 FF = Fp+Geps+2.0*Heps2;
639 /* CUBIC SPLINE TABLE REPULSION */
641 Geps = vfeps*vftab[vfitab+6];
642 Heps2 = vfeps*vfeps*vftab[vfitab+7];
644 FF = Fp+Geps+2.0*Heps2;
646 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
650 /* Calculate temporary vectorial force */
655 /* Update vectorial force */
659 f[j_coord_offset+DIM*0+XX] -= tx;
660 f[j_coord_offset+DIM*0+YY] -= ty;
661 f[j_coord_offset+DIM*0+ZZ] -= tz;
663 /**************************
664 * CALCULATE INTERACTIONS *
665 **************************/
671 /* Calculate table index by multiplying r with table scale and truncate to integer */
677 /* CUBIC SPLINE TABLE ELECTROSTATICS */
679 Geps = vfeps*vftab[vfitab+2];
680 Heps2 = vfeps*vfeps*vftab[vfitab+3];
682 FF = Fp+Geps+2.0*Heps2;
683 felec = -qq10*FF*vftabscale*rinv10;
687 /* Calculate temporary vectorial force */
692 /* Update vectorial force */
696 f[j_coord_offset+DIM*0+XX] -= tx;
697 f[j_coord_offset+DIM*0+YY] -= ty;
698 f[j_coord_offset+DIM*0+ZZ] -= tz;
700 /**************************
701 * CALCULATE INTERACTIONS *
702 **************************/
708 /* Calculate table index by multiplying r with table scale and truncate to integer */
714 /* CUBIC SPLINE TABLE ELECTROSTATICS */
716 Geps = vfeps*vftab[vfitab+2];
717 Heps2 = vfeps*vfeps*vftab[vfitab+3];
719 FF = Fp+Geps+2.0*Heps2;
720 felec = -qq20*FF*vftabscale*rinv20;
724 /* Calculate temporary vectorial force */
729 /* Update vectorial force */
733 f[j_coord_offset+DIM*0+XX] -= tx;
734 f[j_coord_offset+DIM*0+YY] -= ty;
735 f[j_coord_offset+DIM*0+ZZ] -= tz;
737 /**************************
738 * CALCULATE INTERACTIONS *
739 **************************/
745 /* Calculate table index by multiplying r with table scale and truncate to integer */
751 /* CUBIC SPLINE TABLE ELECTROSTATICS */
753 Geps = vfeps*vftab[vfitab+2];
754 Heps2 = vfeps*vfeps*vftab[vfitab+3];
756 FF = Fp+Geps+2.0*Heps2;
757 felec = -qq30*FF*vftabscale*rinv30;
761 /* Calculate temporary vectorial force */
766 /* Update vectorial force */
770 f[j_coord_offset+DIM*0+XX] -= tx;
771 f[j_coord_offset+DIM*0+YY] -= ty;
772 f[j_coord_offset+DIM*0+ZZ] -= tz;
774 /* Inner loop uses 161 flops */
776 /* End of innermost loop */
779 f[i_coord_offset+DIM*0+XX] += fix0;
780 f[i_coord_offset+DIM*0+YY] += fiy0;
781 f[i_coord_offset+DIM*0+ZZ] += fiz0;
785 f[i_coord_offset+DIM*1+XX] += fix1;
786 f[i_coord_offset+DIM*1+YY] += fiy1;
787 f[i_coord_offset+DIM*1+ZZ] += fiz1;
791 f[i_coord_offset+DIM*2+XX] += fix2;
792 f[i_coord_offset+DIM*2+YY] += fiy2;
793 f[i_coord_offset+DIM*2+ZZ] += fiz2;
797 f[i_coord_offset+DIM*3+XX] += fix3;
798 f[i_coord_offset+DIM*3+YY] += fiy3;
799 f[i_coord_offset+DIM*3+ZZ] += fiz3;
803 fshift[i_shift_offset+XX] += tx;
804 fshift[i_shift_offset+YY] += ty;
805 fshift[i_shift_offset+ZZ] += tz;
807 /* Increment number of inner iterations */
808 inneriter += j_index_end - j_index_start;
810 /* Outer loop uses 39 flops */
813 /* Increment number of outer iterations */
816 /* Update outer/inner flops */
818 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*161);