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_ElecRF_VdwCSTab_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_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;
112 nvdwtype = fr->ntype;
114 vdwtype = mdatoms->typeA;
116 vftab = kernel_data->table_vdw->data;
117 vftabscale = kernel_data->table_vdw->scale;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
123 iq3 = facel*charge[inr+3];
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
129 /* Start outer loop over neighborlists */
130 for(iidx=0; iidx<nri; iidx++)
132 /* Load shift vector for this list */
133 i_shift_offset = DIM*shiftidx[iidx];
134 shX = shiftvec[i_shift_offset+XX];
135 shY = shiftvec[i_shift_offset+YY];
136 shZ = shiftvec[i_shift_offset+ZZ];
138 /* Load limits for loop over neighbors */
139 j_index_start = jindex[iidx];
140 j_index_end = jindex[iidx+1];
142 /* Get outer coordinate index */
144 i_coord_offset = DIM*inr;
146 /* Load i particle coords and add shift vector */
147 ix0 = shX + x[i_coord_offset+DIM*0+XX];
148 iy0 = shY + x[i_coord_offset+DIM*0+YY];
149 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
150 ix1 = shX + x[i_coord_offset+DIM*1+XX];
151 iy1 = shY + x[i_coord_offset+DIM*1+YY];
152 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
153 ix2 = shX + x[i_coord_offset+DIM*2+XX];
154 iy2 = shY + x[i_coord_offset+DIM*2+YY];
155 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
156 ix3 = shX + x[i_coord_offset+DIM*3+XX];
157 iy3 = shY + x[i_coord_offset+DIM*3+YY];
158 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
173 /* Reset potential sums */
177 /* Start inner kernel loop */
178 for(jidx=j_index_start; jidx<j_index_end; jidx++)
180 /* Get j neighbor index, and coordinate index */
182 j_coord_offset = DIM*jnr;
184 /* load j atom coordinates */
185 jx0 = x[j_coord_offset+DIM*0+XX];
186 jy0 = x[j_coord_offset+DIM*0+YY];
187 jz0 = x[j_coord_offset+DIM*0+ZZ];
189 /* Calculate displacement vector */
203 /* Calculate squared distance and things based on it */
204 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
205 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
206 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
207 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
209 rinv00 = gmx_invsqrt(rsq00);
210 rinv10 = gmx_invsqrt(rsq10);
211 rinv20 = gmx_invsqrt(rsq20);
212 rinv30 = gmx_invsqrt(rsq30);
214 rinvsq10 = rinv10*rinv10;
215 rinvsq20 = rinv20*rinv20;
216 rinvsq30 = rinv30*rinv30;
218 /* Load parameters for j particles */
220 vdwjidx0 = 2*vdwtype[jnr+0];
222 /**************************
223 * CALCULATE INTERACTIONS *
224 **************************/
228 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
229 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
231 /* Calculate table index by multiplying r with table scale and truncate to integer */
237 /* CUBIC SPLINE TABLE DISPERSION */
241 Geps = vfeps*vftab[vfitab+2];
242 Heps2 = vfeps*vfeps*vftab[vfitab+3];
246 FF = Fp+Geps+2.0*Heps2;
249 /* CUBIC SPLINE TABLE REPULSION */
252 Geps = vfeps*vftab[vfitab+6];
253 Heps2 = vfeps*vfeps*vftab[vfitab+7];
257 FF = Fp+Geps+2.0*Heps2;
260 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
262 /* Update potential sums from outer loop */
267 /* Calculate temporary vectorial force */
272 /* Update vectorial force */
276 f[j_coord_offset+DIM*0+XX] -= tx;
277 f[j_coord_offset+DIM*0+YY] -= ty;
278 f[j_coord_offset+DIM*0+ZZ] -= tz;
280 /**************************
281 * CALCULATE INTERACTIONS *
282 **************************/
286 /* REACTION-FIELD ELECTROSTATICS */
287 velec = qq10*(rinv10+krf*rsq10-crf);
288 felec = qq10*(rinv10*rinvsq10-krf2);
290 /* Update potential sums from outer loop */
295 /* Calculate temporary vectorial force */
300 /* Update vectorial force */
304 f[j_coord_offset+DIM*0+XX] -= tx;
305 f[j_coord_offset+DIM*0+YY] -= ty;
306 f[j_coord_offset+DIM*0+ZZ] -= tz;
308 /**************************
309 * CALCULATE INTERACTIONS *
310 **************************/
314 /* REACTION-FIELD ELECTROSTATICS */
315 velec = qq20*(rinv20+krf*rsq20-crf);
316 felec = qq20*(rinv20*rinvsq20-krf2);
318 /* Update potential sums from outer loop */
323 /* Calculate temporary vectorial force */
328 /* Update vectorial force */
332 f[j_coord_offset+DIM*0+XX] -= tx;
333 f[j_coord_offset+DIM*0+YY] -= ty;
334 f[j_coord_offset+DIM*0+ZZ] -= tz;
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
342 /* REACTION-FIELD ELECTROSTATICS */
343 velec = qq30*(rinv30+krf*rsq30-crf);
344 felec = qq30*(rinv30*rinvsq30-krf2);
346 /* Update potential sums from outer loop */
351 /* Calculate temporary vectorial force */
356 /* Update vectorial force */
360 f[j_coord_offset+DIM*0+XX] -= tx;
361 f[j_coord_offset+DIM*0+YY] -= ty;
362 f[j_coord_offset+DIM*0+ZZ] -= tz;
364 /* Inner loop uses 151 flops */
366 /* End of innermost loop */
369 f[i_coord_offset+DIM*0+XX] += fix0;
370 f[i_coord_offset+DIM*0+YY] += fiy0;
371 f[i_coord_offset+DIM*0+ZZ] += fiz0;
375 f[i_coord_offset+DIM*1+XX] += fix1;
376 f[i_coord_offset+DIM*1+YY] += fiy1;
377 f[i_coord_offset+DIM*1+ZZ] += fiz1;
381 f[i_coord_offset+DIM*2+XX] += fix2;
382 f[i_coord_offset+DIM*2+YY] += fiy2;
383 f[i_coord_offset+DIM*2+ZZ] += fiz2;
387 f[i_coord_offset+DIM*3+XX] += fix3;
388 f[i_coord_offset+DIM*3+YY] += fiy3;
389 f[i_coord_offset+DIM*3+ZZ] += fiz3;
393 fshift[i_shift_offset+XX] += tx;
394 fshift[i_shift_offset+YY] += ty;
395 fshift[i_shift_offset+ZZ] += tz;
398 /* Update potential energies */
399 kernel_data->energygrp_elec[ggid] += velecsum;
400 kernel_data->energygrp_vdw[ggid] += vvdwsum;
402 /* Increment number of inner iterations */
403 inneriter += j_index_end - j_index_start;
405 /* Outer loop uses 41 flops */
408 /* Increment number of outer iterations */
411 /* Update outer/inner flops */
413 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*151);
416 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW4P1_F_c
417 * Electrostatics interaction: ReactionField
418 * VdW interaction: CubicSplineTable
419 * Geometry: Water4-Particle
420 * Calculate force/pot: Force
423 nb_kernel_ElecRF_VdwCSTab_GeomW4P1_F_c
424 (t_nblist * gmx_restrict nlist,
425 rvec * gmx_restrict xx,
426 rvec * gmx_restrict ff,
427 t_forcerec * gmx_restrict fr,
428 t_mdatoms * gmx_restrict mdatoms,
429 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
430 t_nrnb * gmx_restrict nrnb)
432 int i_shift_offset,i_coord_offset,j_coord_offset;
433 int j_index_start,j_index_end;
434 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
435 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
436 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
437 real *shiftvec,*fshift,*x,*f;
439 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
441 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
443 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
445 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
447 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
448 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
449 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
450 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
451 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
452 real velec,felec,velecsum,facel,crf,krf,krf2;
455 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
459 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
467 jindex = nlist->jindex;
469 shiftidx = nlist->shift;
471 shiftvec = fr->shift_vec[0];
472 fshift = fr->fshift[0];
474 charge = mdatoms->chargeA;
478 nvdwtype = fr->ntype;
480 vdwtype = mdatoms->typeA;
482 vftab = kernel_data->table_vdw->data;
483 vftabscale = kernel_data->table_vdw->scale;
485 /* Setup water-specific parameters */
486 inr = nlist->iinr[0];
487 iq1 = facel*charge[inr+1];
488 iq2 = facel*charge[inr+2];
489 iq3 = facel*charge[inr+3];
490 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
495 /* Start outer loop over neighborlists */
496 for(iidx=0; iidx<nri; iidx++)
498 /* Load shift vector for this list */
499 i_shift_offset = DIM*shiftidx[iidx];
500 shX = shiftvec[i_shift_offset+XX];
501 shY = shiftvec[i_shift_offset+YY];
502 shZ = shiftvec[i_shift_offset+ZZ];
504 /* Load limits for loop over neighbors */
505 j_index_start = jindex[iidx];
506 j_index_end = jindex[iidx+1];
508 /* Get outer coordinate index */
510 i_coord_offset = DIM*inr;
512 /* Load i particle coords and add shift vector */
513 ix0 = shX + x[i_coord_offset+DIM*0+XX];
514 iy0 = shY + x[i_coord_offset+DIM*0+YY];
515 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
516 ix1 = shX + x[i_coord_offset+DIM*1+XX];
517 iy1 = shY + x[i_coord_offset+DIM*1+YY];
518 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
519 ix2 = shX + x[i_coord_offset+DIM*2+XX];
520 iy2 = shY + x[i_coord_offset+DIM*2+YY];
521 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
522 ix3 = shX + x[i_coord_offset+DIM*3+XX];
523 iy3 = shY + x[i_coord_offset+DIM*3+YY];
524 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
539 /* Start inner kernel loop */
540 for(jidx=j_index_start; jidx<j_index_end; jidx++)
542 /* Get j neighbor index, and coordinate index */
544 j_coord_offset = DIM*jnr;
546 /* load j atom coordinates */
547 jx0 = x[j_coord_offset+DIM*0+XX];
548 jy0 = x[j_coord_offset+DIM*0+YY];
549 jz0 = x[j_coord_offset+DIM*0+ZZ];
551 /* Calculate displacement vector */
565 /* Calculate squared distance and things based on it */
566 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
567 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
568 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
569 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
571 rinv00 = gmx_invsqrt(rsq00);
572 rinv10 = gmx_invsqrt(rsq10);
573 rinv20 = gmx_invsqrt(rsq20);
574 rinv30 = gmx_invsqrt(rsq30);
576 rinvsq10 = rinv10*rinv10;
577 rinvsq20 = rinv20*rinv20;
578 rinvsq30 = rinv30*rinv30;
580 /* Load parameters for j particles */
582 vdwjidx0 = 2*vdwtype[jnr+0];
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
590 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
591 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
593 /* Calculate table index by multiplying r with table scale and truncate to integer */
599 /* CUBIC SPLINE TABLE DISPERSION */
602 Geps = vfeps*vftab[vfitab+2];
603 Heps2 = vfeps*vfeps*vftab[vfitab+3];
605 FF = Fp+Geps+2.0*Heps2;
608 /* CUBIC SPLINE TABLE REPULSION */
610 Geps = vfeps*vftab[vfitab+6];
611 Heps2 = vfeps*vfeps*vftab[vfitab+7];
613 FF = Fp+Geps+2.0*Heps2;
615 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
619 /* Calculate temporary vectorial force */
624 /* Update vectorial force */
628 f[j_coord_offset+DIM*0+XX] -= tx;
629 f[j_coord_offset+DIM*0+YY] -= ty;
630 f[j_coord_offset+DIM*0+ZZ] -= tz;
632 /**************************
633 * CALCULATE INTERACTIONS *
634 **************************/
638 /* REACTION-FIELD ELECTROSTATICS */
639 felec = qq10*(rinv10*rinvsq10-krf2);
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 **************************/
662 /* REACTION-FIELD ELECTROSTATICS */
663 felec = qq20*(rinv20*rinvsq20-krf2);
667 /* Calculate temporary vectorial force */
672 /* Update vectorial force */
676 f[j_coord_offset+DIM*0+XX] -= tx;
677 f[j_coord_offset+DIM*0+YY] -= ty;
678 f[j_coord_offset+DIM*0+ZZ] -= tz;
680 /**************************
681 * CALCULATE INTERACTIONS *
682 **************************/
686 /* REACTION-FIELD ELECTROSTATICS */
687 felec = qq30*(rinv30*rinvsq30-krf2);
691 /* Calculate temporary vectorial force */
696 /* Update vectorial force */
700 f[j_coord_offset+DIM*0+XX] -= tx;
701 f[j_coord_offset+DIM*0+YY] -= ty;
702 f[j_coord_offset+DIM*0+ZZ] -= tz;
704 /* Inner loop uses 128 flops */
706 /* End of innermost loop */
709 f[i_coord_offset+DIM*0+XX] += fix0;
710 f[i_coord_offset+DIM*0+YY] += fiy0;
711 f[i_coord_offset+DIM*0+ZZ] += fiz0;
715 f[i_coord_offset+DIM*1+XX] += fix1;
716 f[i_coord_offset+DIM*1+YY] += fiy1;
717 f[i_coord_offset+DIM*1+ZZ] += fiz1;
721 f[i_coord_offset+DIM*2+XX] += fix2;
722 f[i_coord_offset+DIM*2+YY] += fiy2;
723 f[i_coord_offset+DIM*2+ZZ] += fiz2;
727 f[i_coord_offset+DIM*3+XX] += fix3;
728 f[i_coord_offset+DIM*3+YY] += fiy3;
729 f[i_coord_offset+DIM*3+ZZ] += fiz3;
733 fshift[i_shift_offset+XX] += tx;
734 fshift[i_shift_offset+YY] += ty;
735 fshift[i_shift_offset+ZZ] += tz;
737 /* Increment number of inner iterations */
738 inneriter += j_index_end - j_index_start;
740 /* Outer loop uses 39 flops */
743 /* Increment number of outer iterations */
746 /* Update outer/inner flops */
748 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*128);