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_VdwBham_GeomW4P1_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwBham_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 = 3*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 rinvsq00 = rinv00*rinv00;
213 /* Load parameters for j particles */
215 vdwjidx0 = 3*vdwtype[jnr+0];
217 /**************************
218 * CALCULATE INTERACTIONS *
219 **************************/
223 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
224 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
225 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
227 /* BUCKINGHAM DISPERSION/REPULSION */
228 rinvsix = rinvsq00*rinvsq00*rinvsq00;
229 vvdw6 = c6_00*rinvsix;
231 vvdwexp = cexp1_00*exp(-br);
232 vvdw = vvdwexp - vvdw6*(1.0/6.0);
233 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
235 /* Update potential sums from outer loop */
240 /* Calculate temporary vectorial force */
245 /* Update vectorial force */
249 f[j_coord_offset+DIM*0+XX] -= tx;
250 f[j_coord_offset+DIM*0+YY] -= ty;
251 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
261 /* Calculate table index by multiplying r with table scale and truncate to integer */
267 /* CUBIC SPLINE TABLE ELECTROSTATICS */
270 Geps = vfeps*vftab[vfitab+2];
271 Heps2 = vfeps*vfeps*vftab[vfitab+3];
275 FF = Fp+Geps+2.0*Heps2;
276 felec = -qq10*FF*vftabscale*rinv10;
278 /* Update potential sums from outer loop */
283 /* Calculate temporary vectorial force */
288 /* Update vectorial force */
292 f[j_coord_offset+DIM*0+XX] -= tx;
293 f[j_coord_offset+DIM*0+YY] -= ty;
294 f[j_coord_offset+DIM*0+ZZ] -= tz;
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
304 /* Calculate table index by multiplying r with table scale and truncate to integer */
310 /* CUBIC SPLINE TABLE ELECTROSTATICS */
313 Geps = vfeps*vftab[vfitab+2];
314 Heps2 = vfeps*vfeps*vftab[vfitab+3];
318 FF = Fp+Geps+2.0*Heps2;
319 felec = -qq20*FF*vftabscale*rinv20;
321 /* Update potential sums from outer loop */
326 /* Calculate temporary vectorial force */
331 /* Update vectorial force */
335 f[j_coord_offset+DIM*0+XX] -= tx;
336 f[j_coord_offset+DIM*0+YY] -= ty;
337 f[j_coord_offset+DIM*0+ZZ] -= tz;
339 /**************************
340 * CALCULATE INTERACTIONS *
341 **************************/
347 /* Calculate table index by multiplying r with table scale and truncate to integer */
353 /* CUBIC SPLINE TABLE ELECTROSTATICS */
356 Geps = vfeps*vftab[vfitab+2];
357 Heps2 = vfeps*vfeps*vftab[vfitab+3];
361 FF = Fp+Geps+2.0*Heps2;
362 felec = -qq30*FF*vftabscale*rinv30;
364 /* Update potential sums from outer loop */
369 /* Calculate temporary vectorial force */
374 /* Update vectorial force */
378 f[j_coord_offset+DIM*0+XX] -= tx;
379 f[j_coord_offset+DIM*0+YY] -= ty;
380 f[j_coord_offset+DIM*0+ZZ] -= tz;
382 /* Inner loop uses 187 flops */
384 /* End of innermost loop */
387 f[i_coord_offset+DIM*0+XX] += fix0;
388 f[i_coord_offset+DIM*0+YY] += fiy0;
389 f[i_coord_offset+DIM*0+ZZ] += fiz0;
393 f[i_coord_offset+DIM*1+XX] += fix1;
394 f[i_coord_offset+DIM*1+YY] += fiy1;
395 f[i_coord_offset+DIM*1+ZZ] += fiz1;
399 f[i_coord_offset+DIM*2+XX] += fix2;
400 f[i_coord_offset+DIM*2+YY] += fiy2;
401 f[i_coord_offset+DIM*2+ZZ] += fiz2;
405 f[i_coord_offset+DIM*3+XX] += fix3;
406 f[i_coord_offset+DIM*3+YY] += fiy3;
407 f[i_coord_offset+DIM*3+ZZ] += fiz3;
411 fshift[i_shift_offset+XX] += tx;
412 fshift[i_shift_offset+YY] += ty;
413 fshift[i_shift_offset+ZZ] += tz;
416 /* Update potential energies */
417 kernel_data->energygrp_elec[ggid] += velecsum;
418 kernel_data->energygrp_vdw[ggid] += vvdwsum;
420 /* Increment number of inner iterations */
421 inneriter += j_index_end - j_index_start;
423 /* Outer loop uses 41 flops */
426 /* Increment number of outer iterations */
429 /* Update outer/inner flops */
431 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*187);
434 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW4P1_F_c
435 * Electrostatics interaction: CubicSplineTable
436 * VdW interaction: Buckingham
437 * Geometry: Water4-Particle
438 * Calculate force/pot: Force
441 nb_kernel_ElecCSTab_VdwBham_GeomW4P1_F_c
442 (t_nblist * gmx_restrict nlist,
443 rvec * gmx_restrict xx,
444 rvec * gmx_restrict ff,
445 t_forcerec * gmx_restrict fr,
446 t_mdatoms * gmx_restrict mdatoms,
447 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
448 t_nrnb * gmx_restrict nrnb)
450 int i_shift_offset,i_coord_offset,j_coord_offset;
451 int j_index_start,j_index_end;
452 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
453 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
454 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
455 real *shiftvec,*fshift,*x,*f;
457 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
459 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
461 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
463 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
465 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
466 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
467 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
468 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
469 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
470 real velec,felec,velecsum,facel,crf,krf,krf2;
473 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
477 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
485 jindex = nlist->jindex;
487 shiftidx = nlist->shift;
489 shiftvec = fr->shift_vec[0];
490 fshift = fr->fshift[0];
492 charge = mdatoms->chargeA;
493 nvdwtype = fr->ntype;
495 vdwtype = mdatoms->typeA;
497 vftab = kernel_data->table_elec->data;
498 vftabscale = kernel_data->table_elec->scale;
500 /* Setup water-specific parameters */
501 inr = nlist->iinr[0];
502 iq1 = facel*charge[inr+1];
503 iq2 = facel*charge[inr+2];
504 iq3 = facel*charge[inr+3];
505 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
510 /* Start outer loop over neighborlists */
511 for(iidx=0; iidx<nri; iidx++)
513 /* Load shift vector for this list */
514 i_shift_offset = DIM*shiftidx[iidx];
515 shX = shiftvec[i_shift_offset+XX];
516 shY = shiftvec[i_shift_offset+YY];
517 shZ = shiftvec[i_shift_offset+ZZ];
519 /* Load limits for loop over neighbors */
520 j_index_start = jindex[iidx];
521 j_index_end = jindex[iidx+1];
523 /* Get outer coordinate index */
525 i_coord_offset = DIM*inr;
527 /* Load i particle coords and add shift vector */
528 ix0 = shX + x[i_coord_offset+DIM*0+XX];
529 iy0 = shY + x[i_coord_offset+DIM*0+YY];
530 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
531 ix1 = shX + x[i_coord_offset+DIM*1+XX];
532 iy1 = shY + x[i_coord_offset+DIM*1+YY];
533 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
534 ix2 = shX + x[i_coord_offset+DIM*2+XX];
535 iy2 = shY + x[i_coord_offset+DIM*2+YY];
536 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
537 ix3 = shX + x[i_coord_offset+DIM*3+XX];
538 iy3 = shY + x[i_coord_offset+DIM*3+YY];
539 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
554 /* Start inner kernel loop */
555 for(jidx=j_index_start; jidx<j_index_end; jidx++)
557 /* Get j neighbor index, and coordinate index */
559 j_coord_offset = DIM*jnr;
561 /* load j atom coordinates */
562 jx0 = x[j_coord_offset+DIM*0+XX];
563 jy0 = x[j_coord_offset+DIM*0+YY];
564 jz0 = x[j_coord_offset+DIM*0+ZZ];
566 /* Calculate displacement vector */
580 /* Calculate squared distance and things based on it */
581 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
582 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
583 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
584 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
586 rinv00 = gmx_invsqrt(rsq00);
587 rinv10 = gmx_invsqrt(rsq10);
588 rinv20 = gmx_invsqrt(rsq20);
589 rinv30 = gmx_invsqrt(rsq30);
591 rinvsq00 = rinv00*rinv00;
593 /* Load parameters for j particles */
595 vdwjidx0 = 3*vdwtype[jnr+0];
597 /**************************
598 * CALCULATE INTERACTIONS *
599 **************************/
603 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
604 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
605 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
607 /* BUCKINGHAM DISPERSION/REPULSION */
608 rinvsix = rinvsq00*rinvsq00*rinvsq00;
609 vvdw6 = c6_00*rinvsix;
611 vvdwexp = cexp1_00*exp(-br);
612 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
616 /* Calculate temporary vectorial force */
621 /* Update vectorial force */
625 f[j_coord_offset+DIM*0+XX] -= tx;
626 f[j_coord_offset+DIM*0+YY] -= ty;
627 f[j_coord_offset+DIM*0+ZZ] -= tz;
629 /**************************
630 * CALCULATE INTERACTIONS *
631 **************************/
637 /* Calculate table index by multiplying r with table scale and truncate to integer */
643 /* CUBIC SPLINE TABLE ELECTROSTATICS */
645 Geps = vfeps*vftab[vfitab+2];
646 Heps2 = vfeps*vfeps*vftab[vfitab+3];
648 FF = Fp+Geps+2.0*Heps2;
649 felec = -qq10*FF*vftabscale*rinv10;
653 /* Calculate temporary vectorial force */
658 /* Update vectorial force */
662 f[j_coord_offset+DIM*0+XX] -= tx;
663 f[j_coord_offset+DIM*0+YY] -= ty;
664 f[j_coord_offset+DIM*0+ZZ] -= tz;
666 /**************************
667 * CALCULATE INTERACTIONS *
668 **************************/
674 /* Calculate table index by multiplying r with table scale and truncate to integer */
680 /* CUBIC SPLINE TABLE ELECTROSTATICS */
682 Geps = vfeps*vftab[vfitab+2];
683 Heps2 = vfeps*vfeps*vftab[vfitab+3];
685 FF = Fp+Geps+2.0*Heps2;
686 felec = -qq20*FF*vftabscale*rinv20;
690 /* Calculate temporary vectorial force */
695 /* Update vectorial force */
699 f[j_coord_offset+DIM*0+XX] -= tx;
700 f[j_coord_offset+DIM*0+YY] -= ty;
701 f[j_coord_offset+DIM*0+ZZ] -= tz;
703 /**************************
704 * CALCULATE INTERACTIONS *
705 **************************/
711 /* Calculate table index by multiplying r with table scale and truncate to integer */
717 /* CUBIC SPLINE TABLE ELECTROSTATICS */
719 Geps = vfeps*vftab[vfitab+2];
720 Heps2 = vfeps*vfeps*vftab[vfitab+3];
722 FF = Fp+Geps+2.0*Heps2;
723 felec = -qq30*FF*vftabscale*rinv30;
727 /* Calculate temporary vectorial force */
732 /* Update vectorial force */
736 f[j_coord_offset+DIM*0+XX] -= tx;
737 f[j_coord_offset+DIM*0+YY] -= ty;
738 f[j_coord_offset+DIM*0+ZZ] -= tz;
740 /* Inner loop uses 172 flops */
742 /* End of innermost loop */
745 f[i_coord_offset+DIM*0+XX] += fix0;
746 f[i_coord_offset+DIM*0+YY] += fiy0;
747 f[i_coord_offset+DIM*0+ZZ] += fiz0;
751 f[i_coord_offset+DIM*1+XX] += fix1;
752 f[i_coord_offset+DIM*1+YY] += fiy1;
753 f[i_coord_offset+DIM*1+ZZ] += fiz1;
757 f[i_coord_offset+DIM*2+XX] += fix2;
758 f[i_coord_offset+DIM*2+YY] += fiy2;
759 f[i_coord_offset+DIM*2+ZZ] += fiz2;
763 f[i_coord_offset+DIM*3+XX] += fix3;
764 f[i_coord_offset+DIM*3+YY] += fiy3;
765 f[i_coord_offset+DIM*3+ZZ] += fiz3;
769 fshift[i_shift_offset+XX] += tx;
770 fshift[i_shift_offset+YY] += ty;
771 fshift[i_shift_offset+ZZ] += tz;
773 /* Increment number of inner iterations */
774 inneriter += j_index_end - j_index_start;
776 /* Outer loop uses 39 flops */
779 /* Increment number of outer iterations */
782 /* Update outer/inner flops */
784 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*172);