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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3P1_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
84 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
88 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
96 jindex = nlist->jindex;
98 shiftidx = nlist->shift;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
103 charge = mdatoms->chargeA;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 vftab = kernel_data->table_elec->data;
109 vftabscale = kernel_data->table_elec->scale;
111 /* Setup water-specific parameters */
112 inr = nlist->iinr[0];
113 iq0 = facel*charge[inr+0];
114 iq1 = facel*charge[inr+1];
115 iq2 = facel*charge[inr+2];
116 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
121 /* Start outer loop over neighborlists */
122 for(iidx=0; iidx<nri; iidx++)
124 /* Load shift vector for this list */
125 i_shift_offset = DIM*shiftidx[iidx];
126 shX = shiftvec[i_shift_offset+XX];
127 shY = shiftvec[i_shift_offset+YY];
128 shZ = shiftvec[i_shift_offset+ZZ];
130 /* Load limits for loop over neighbors */
131 j_index_start = jindex[iidx];
132 j_index_end = jindex[iidx+1];
134 /* Get outer coordinate index */
136 i_coord_offset = DIM*inr;
138 /* Load i particle coords and add shift vector */
139 ix0 = shX + x[i_coord_offset+DIM*0+XX];
140 iy0 = shY + x[i_coord_offset+DIM*0+YY];
141 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
142 ix1 = shX + x[i_coord_offset+DIM*1+XX];
143 iy1 = shY + x[i_coord_offset+DIM*1+YY];
144 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
145 ix2 = shX + x[i_coord_offset+DIM*2+XX];
146 iy2 = shY + x[i_coord_offset+DIM*2+YY];
147 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
159 /* Reset potential sums */
163 /* Start inner kernel loop */
164 for(jidx=j_index_start; jidx<j_index_end; jidx++)
166 /* Get j neighbor index, and coordinate index */
168 j_coord_offset = DIM*jnr;
170 /* load j atom coordinates */
171 jx0 = x[j_coord_offset+DIM*0+XX];
172 jy0 = x[j_coord_offset+DIM*0+YY];
173 jz0 = x[j_coord_offset+DIM*0+ZZ];
175 /* Calculate displacement vector */
186 /* Calculate squared distance and things based on it */
187 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
188 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
189 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
191 rinv00 = gmx_invsqrt(rsq00);
192 rinv10 = gmx_invsqrt(rsq10);
193 rinv20 = gmx_invsqrt(rsq20);
195 rinvsq00 = rinv00*rinv00;
197 /* Load parameters for j particles */
199 vdwjidx0 = 3*vdwtype[jnr+0];
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
208 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
209 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
210 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
212 /* Calculate table index by multiplying r with table scale and truncate to integer */
218 /* CUBIC SPLINE TABLE ELECTROSTATICS */
221 Geps = vfeps*vftab[vfitab+2];
222 Heps2 = vfeps*vfeps*vftab[vfitab+3];
226 FF = Fp+Geps+2.0*Heps2;
227 felec = -qq00*FF*vftabscale*rinv00;
229 /* BUCKINGHAM DISPERSION/REPULSION */
230 rinvsix = rinvsq00*rinvsq00*rinvsq00;
231 vvdw6 = c6_00*rinvsix;
233 vvdwexp = cexp1_00*exp(-br);
234 vvdw = vvdwexp - vvdw6*(1.0/6.0);
235 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
237 /* Update potential sums from outer loop */
243 /* Calculate temporary vectorial force */
248 /* Update vectorial force */
252 f[j_coord_offset+DIM*0+XX] -= tx;
253 f[j_coord_offset+DIM*0+YY] -= ty;
254 f[j_coord_offset+DIM*0+ZZ] -= tz;
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
264 /* Calculate table index by multiplying r with table scale and truncate to integer */
270 /* CUBIC SPLINE TABLE ELECTROSTATICS */
273 Geps = vfeps*vftab[vfitab+2];
274 Heps2 = vfeps*vfeps*vftab[vfitab+3];
278 FF = Fp+Geps+2.0*Heps2;
279 felec = -qq10*FF*vftabscale*rinv10;
281 /* Update potential sums from outer loop */
286 /* Calculate temporary vectorial force */
291 /* Update vectorial force */
295 f[j_coord_offset+DIM*0+XX] -= tx;
296 f[j_coord_offset+DIM*0+YY] -= ty;
297 f[j_coord_offset+DIM*0+ZZ] -= tz;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
307 /* Calculate table index by multiplying r with table scale and truncate to integer */
313 /* CUBIC SPLINE TABLE ELECTROSTATICS */
316 Geps = vfeps*vftab[vfitab+2];
317 Heps2 = vfeps*vfeps*vftab[vfitab+3];
321 FF = Fp+Geps+2.0*Heps2;
322 felec = -qq20*FF*vftabscale*rinv20;
324 /* Update potential sums from outer loop */
329 /* Calculate temporary vectorial force */
334 /* Update vectorial force */
338 f[j_coord_offset+DIM*0+XX] -= tx;
339 f[j_coord_offset+DIM*0+YY] -= ty;
340 f[j_coord_offset+DIM*0+ZZ] -= tz;
342 /* Inner loop uses 165 flops */
344 /* End of innermost loop */
347 f[i_coord_offset+DIM*0+XX] += fix0;
348 f[i_coord_offset+DIM*0+YY] += fiy0;
349 f[i_coord_offset+DIM*0+ZZ] += fiz0;
353 f[i_coord_offset+DIM*1+XX] += fix1;
354 f[i_coord_offset+DIM*1+YY] += fiy1;
355 f[i_coord_offset+DIM*1+ZZ] += fiz1;
359 f[i_coord_offset+DIM*2+XX] += fix2;
360 f[i_coord_offset+DIM*2+YY] += fiy2;
361 f[i_coord_offset+DIM*2+ZZ] += fiz2;
365 fshift[i_shift_offset+XX] += tx;
366 fshift[i_shift_offset+YY] += ty;
367 fshift[i_shift_offset+ZZ] += tz;
370 /* Update potential energies */
371 kernel_data->energygrp_elec[ggid] += velecsum;
372 kernel_data->energygrp_vdw[ggid] += vvdwsum;
374 /* Increment number of inner iterations */
375 inneriter += j_index_end - j_index_start;
377 /* Outer loop uses 32 flops */
380 /* Increment number of outer iterations */
383 /* Update outer/inner flops */
385 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*165);
388 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
389 * Electrostatics interaction: CubicSplineTable
390 * VdW interaction: Buckingham
391 * Geometry: Water3-Particle
392 * Calculate force/pot: Force
395 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
396 (t_nblist * gmx_restrict nlist,
397 rvec * gmx_restrict xx,
398 rvec * gmx_restrict ff,
399 t_forcerec * gmx_restrict fr,
400 t_mdatoms * gmx_restrict mdatoms,
401 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
402 t_nrnb * gmx_restrict nrnb)
404 int i_shift_offset,i_coord_offset,j_coord_offset;
405 int j_index_start,j_index_end;
406 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
407 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
408 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
409 real *shiftvec,*fshift,*x,*f;
411 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
413 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
415 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
417 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
419 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
420 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
421 real velec,felec,velecsum,facel,crf,krf,krf2;
424 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
428 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
436 jindex = nlist->jindex;
438 shiftidx = nlist->shift;
440 shiftvec = fr->shift_vec[0];
441 fshift = fr->fshift[0];
443 charge = mdatoms->chargeA;
444 nvdwtype = fr->ntype;
446 vdwtype = mdatoms->typeA;
448 vftab = kernel_data->table_elec->data;
449 vftabscale = kernel_data->table_elec->scale;
451 /* Setup water-specific parameters */
452 inr = nlist->iinr[0];
453 iq0 = facel*charge[inr+0];
454 iq1 = facel*charge[inr+1];
455 iq2 = facel*charge[inr+2];
456 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
461 /* Start outer loop over neighborlists */
462 for(iidx=0; iidx<nri; iidx++)
464 /* Load shift vector for this list */
465 i_shift_offset = DIM*shiftidx[iidx];
466 shX = shiftvec[i_shift_offset+XX];
467 shY = shiftvec[i_shift_offset+YY];
468 shZ = shiftvec[i_shift_offset+ZZ];
470 /* Load limits for loop over neighbors */
471 j_index_start = jindex[iidx];
472 j_index_end = jindex[iidx+1];
474 /* Get outer coordinate index */
476 i_coord_offset = DIM*inr;
478 /* Load i particle coords and add shift vector */
479 ix0 = shX + x[i_coord_offset+DIM*0+XX];
480 iy0 = shY + x[i_coord_offset+DIM*0+YY];
481 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
482 ix1 = shX + x[i_coord_offset+DIM*1+XX];
483 iy1 = shY + x[i_coord_offset+DIM*1+YY];
484 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
485 ix2 = shX + x[i_coord_offset+DIM*2+XX];
486 iy2 = shY + x[i_coord_offset+DIM*2+YY];
487 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
499 /* Start inner kernel loop */
500 for(jidx=j_index_start; jidx<j_index_end; jidx++)
502 /* Get j neighbor index, and coordinate index */
504 j_coord_offset = DIM*jnr;
506 /* load j atom coordinates */
507 jx0 = x[j_coord_offset+DIM*0+XX];
508 jy0 = x[j_coord_offset+DIM*0+YY];
509 jz0 = x[j_coord_offset+DIM*0+ZZ];
511 /* Calculate displacement vector */
522 /* Calculate squared distance and things based on it */
523 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
524 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
525 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
527 rinv00 = gmx_invsqrt(rsq00);
528 rinv10 = gmx_invsqrt(rsq10);
529 rinv20 = gmx_invsqrt(rsq20);
531 rinvsq00 = rinv00*rinv00;
533 /* Load parameters for j particles */
535 vdwjidx0 = 3*vdwtype[jnr+0];
537 /**************************
538 * CALCULATE INTERACTIONS *
539 **************************/
544 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
545 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
546 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
548 /* Calculate table index by multiplying r with table scale and truncate to integer */
554 /* CUBIC SPLINE TABLE ELECTROSTATICS */
556 Geps = vfeps*vftab[vfitab+2];
557 Heps2 = vfeps*vfeps*vftab[vfitab+3];
559 FF = Fp+Geps+2.0*Heps2;
560 felec = -qq00*FF*vftabscale*rinv00;
562 /* BUCKINGHAM DISPERSION/REPULSION */
563 rinvsix = rinvsq00*rinvsq00*rinvsq00;
564 vvdw6 = c6_00*rinvsix;
566 vvdwexp = cexp1_00*exp(-br);
567 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
571 /* Calculate temporary vectorial force */
576 /* Update vectorial force */
580 f[j_coord_offset+DIM*0+XX] -= tx;
581 f[j_coord_offset+DIM*0+YY] -= ty;
582 f[j_coord_offset+DIM*0+ZZ] -= tz;
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
592 /* Calculate table index by multiplying r with table scale and truncate to integer */
598 /* CUBIC SPLINE TABLE ELECTROSTATICS */
600 Geps = vfeps*vftab[vfitab+2];
601 Heps2 = vfeps*vfeps*vftab[vfitab+3];
603 FF = Fp+Geps+2.0*Heps2;
604 felec = -qq10*FF*vftabscale*rinv10;
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*0+XX] -= tx;
618 f[j_coord_offset+DIM*0+YY] -= ty;
619 f[j_coord_offset+DIM*0+ZZ] -= tz;
621 /**************************
622 * CALCULATE INTERACTIONS *
623 **************************/
629 /* Calculate table index by multiplying r with table scale and truncate to integer */
635 /* CUBIC SPLINE TABLE ELECTROSTATICS */
637 Geps = vfeps*vftab[vfitab+2];
638 Heps2 = vfeps*vfeps*vftab[vfitab+3];
640 FF = Fp+Geps+2.0*Heps2;
641 felec = -qq20*FF*vftabscale*rinv20;
645 /* Calculate temporary vectorial force */
650 /* Update vectorial force */
654 f[j_coord_offset+DIM*0+XX] -= tx;
655 f[j_coord_offset+DIM*0+YY] -= ty;
656 f[j_coord_offset+DIM*0+ZZ] -= tz;
658 /* Inner loop uses 150 flops */
660 /* End of innermost loop */
663 f[i_coord_offset+DIM*0+XX] += fix0;
664 f[i_coord_offset+DIM*0+YY] += fiy0;
665 f[i_coord_offset+DIM*0+ZZ] += fiz0;
669 f[i_coord_offset+DIM*1+XX] += fix1;
670 f[i_coord_offset+DIM*1+YY] += fiy1;
671 f[i_coord_offset+DIM*1+ZZ] += fiz1;
675 f[i_coord_offset+DIM*2+XX] += fix2;
676 f[i_coord_offset+DIM*2+YY] += fiy2;
677 f[i_coord_offset+DIM*2+ZZ] += fiz2;
681 fshift[i_shift_offset+XX] += tx;
682 fshift[i_shift_offset+YY] += ty;
683 fshift[i_shift_offset+ZZ] += tz;
685 /* Increment number of inner iterations */
686 inneriter += j_index_end - j_index_start;
688 /* Outer loop uses 30 flops */
691 /* Increment number of outer iterations */
694 /* Update outer/inner flops */
696 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*150);