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_GeomW3P1_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real velec,felec,velecsum,facel,crf,krf,krf2;
86 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
90 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
105 charge = mdatoms->chargeA;
106 nvdwtype = fr->ntype;
108 vdwtype = mdatoms->typeA;
110 vftab = kernel_data->table_elec->data;
111 vftabscale = kernel_data->table_elec->scale;
113 /* Setup water-specific parameters */
114 inr = nlist->iinr[0];
115 iq0 = facel*charge[inr+0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
123 /* Start outer loop over neighborlists */
124 for(iidx=0; iidx<nri; iidx++)
126 /* Load shift vector for this list */
127 i_shift_offset = DIM*shiftidx[iidx];
128 shX = shiftvec[i_shift_offset+XX];
129 shY = shiftvec[i_shift_offset+YY];
130 shZ = shiftvec[i_shift_offset+ZZ];
132 /* Load limits for loop over neighbors */
133 j_index_start = jindex[iidx];
134 j_index_end = jindex[iidx+1];
136 /* Get outer coordinate index */
138 i_coord_offset = DIM*inr;
140 /* Load i particle coords and add shift vector */
141 ix0 = shX + x[i_coord_offset+DIM*0+XX];
142 iy0 = shY + x[i_coord_offset+DIM*0+YY];
143 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
144 ix1 = shX + x[i_coord_offset+DIM*1+XX];
145 iy1 = shY + x[i_coord_offset+DIM*1+YY];
146 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
147 ix2 = shX + x[i_coord_offset+DIM*2+XX];
148 iy2 = shY + x[i_coord_offset+DIM*2+YY];
149 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
161 /* Reset potential sums */
165 /* Start inner kernel loop */
166 for(jidx=j_index_start; jidx<j_index_end; jidx++)
168 /* Get j neighbor index, and coordinate index */
170 j_coord_offset = DIM*jnr;
172 /* load j atom coordinates */
173 jx0 = x[j_coord_offset+DIM*0+XX];
174 jy0 = x[j_coord_offset+DIM*0+YY];
175 jz0 = x[j_coord_offset+DIM*0+ZZ];
177 /* Calculate displacement vector */
188 /* Calculate squared distance and things based on it */
189 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
190 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
191 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
193 rinv00 = gmx_invsqrt(rsq00);
194 rinv10 = gmx_invsqrt(rsq10);
195 rinv20 = gmx_invsqrt(rsq20);
197 rinvsq00 = rinv00*rinv00;
199 /* Load parameters for j particles */
201 vdwjidx0 = 3*vdwtype[jnr+0];
203 /**************************
204 * CALCULATE INTERACTIONS *
205 **************************/
210 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
211 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
212 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
214 /* Calculate table index by multiplying r with table scale and truncate to integer */
220 /* CUBIC SPLINE TABLE ELECTROSTATICS */
223 Geps = vfeps*vftab[vfitab+2];
224 Heps2 = vfeps*vfeps*vftab[vfitab+3];
228 FF = Fp+Geps+2.0*Heps2;
229 felec = -qq00*FF*vftabscale*rinv00;
231 /* BUCKINGHAM DISPERSION/REPULSION */
232 rinvsix = rinvsq00*rinvsq00*rinvsq00;
233 vvdw6 = c6_00*rinvsix;
235 vvdwexp = cexp1_00*exp(-br);
236 vvdw = vvdwexp - vvdw6*(1.0/6.0);
237 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
239 /* Update potential sums from outer loop */
245 /* Calculate temporary vectorial force */
250 /* Update vectorial force */
254 f[j_coord_offset+DIM*0+XX] -= tx;
255 f[j_coord_offset+DIM*0+YY] -= ty;
256 f[j_coord_offset+DIM*0+ZZ] -= tz;
258 /**************************
259 * CALCULATE INTERACTIONS *
260 **************************/
266 /* Calculate table index by multiplying r with table scale and truncate to integer */
272 /* CUBIC SPLINE TABLE ELECTROSTATICS */
275 Geps = vfeps*vftab[vfitab+2];
276 Heps2 = vfeps*vfeps*vftab[vfitab+3];
280 FF = Fp+Geps+2.0*Heps2;
281 felec = -qq10*FF*vftabscale*rinv10;
283 /* Update potential sums from outer loop */
288 /* Calculate temporary vectorial force */
293 /* Update vectorial force */
297 f[j_coord_offset+DIM*0+XX] -= tx;
298 f[j_coord_offset+DIM*0+YY] -= ty;
299 f[j_coord_offset+DIM*0+ZZ] -= tz;
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
309 /* Calculate table index by multiplying r with table scale and truncate to integer */
315 /* CUBIC SPLINE TABLE ELECTROSTATICS */
318 Geps = vfeps*vftab[vfitab+2];
319 Heps2 = vfeps*vfeps*vftab[vfitab+3];
323 FF = Fp+Geps+2.0*Heps2;
324 felec = -qq20*FF*vftabscale*rinv20;
326 /* Update potential sums from outer loop */
331 /* Calculate temporary vectorial force */
336 /* Update vectorial force */
340 f[j_coord_offset+DIM*0+XX] -= tx;
341 f[j_coord_offset+DIM*0+YY] -= ty;
342 f[j_coord_offset+DIM*0+ZZ] -= tz;
344 /* Inner loop uses 165 flops */
346 /* End of innermost loop */
349 f[i_coord_offset+DIM*0+XX] += fix0;
350 f[i_coord_offset+DIM*0+YY] += fiy0;
351 f[i_coord_offset+DIM*0+ZZ] += fiz0;
355 f[i_coord_offset+DIM*1+XX] += fix1;
356 f[i_coord_offset+DIM*1+YY] += fiy1;
357 f[i_coord_offset+DIM*1+ZZ] += fiz1;
361 f[i_coord_offset+DIM*2+XX] += fix2;
362 f[i_coord_offset+DIM*2+YY] += fiy2;
363 f[i_coord_offset+DIM*2+ZZ] += fiz2;
367 fshift[i_shift_offset+XX] += tx;
368 fshift[i_shift_offset+YY] += ty;
369 fshift[i_shift_offset+ZZ] += tz;
372 /* Update potential energies */
373 kernel_data->energygrp_elec[ggid] += velecsum;
374 kernel_data->energygrp_vdw[ggid] += vvdwsum;
376 /* Increment number of inner iterations */
377 inneriter += j_index_end - j_index_start;
379 /* Outer loop uses 32 flops */
382 /* Increment number of outer iterations */
385 /* Update outer/inner flops */
387 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*165);
390 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
391 * Electrostatics interaction: CubicSplineTable
392 * VdW interaction: Buckingham
393 * Geometry: Water3-Particle
394 * Calculate force/pot: Force
397 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
398 (t_nblist * gmx_restrict nlist,
399 rvec * gmx_restrict xx,
400 rvec * gmx_restrict ff,
401 t_forcerec * gmx_restrict fr,
402 t_mdatoms * gmx_restrict mdatoms,
403 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
404 t_nrnb * gmx_restrict nrnb)
406 int i_shift_offset,i_coord_offset,j_coord_offset;
407 int j_index_start,j_index_end;
408 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
409 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
410 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
411 real *shiftvec,*fshift,*x,*f;
413 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
415 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
417 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
419 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
420 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
421 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
422 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
423 real velec,felec,velecsum,facel,crf,krf,krf2;
426 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
430 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
438 jindex = nlist->jindex;
440 shiftidx = nlist->shift;
442 shiftvec = fr->shift_vec[0];
443 fshift = fr->fshift[0];
445 charge = mdatoms->chargeA;
446 nvdwtype = fr->ntype;
448 vdwtype = mdatoms->typeA;
450 vftab = kernel_data->table_elec->data;
451 vftabscale = kernel_data->table_elec->scale;
453 /* Setup water-specific parameters */
454 inr = nlist->iinr[0];
455 iq0 = facel*charge[inr+0];
456 iq1 = facel*charge[inr+1];
457 iq2 = facel*charge[inr+2];
458 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
463 /* Start outer loop over neighborlists */
464 for(iidx=0; iidx<nri; iidx++)
466 /* Load shift vector for this list */
467 i_shift_offset = DIM*shiftidx[iidx];
468 shX = shiftvec[i_shift_offset+XX];
469 shY = shiftvec[i_shift_offset+YY];
470 shZ = shiftvec[i_shift_offset+ZZ];
472 /* Load limits for loop over neighbors */
473 j_index_start = jindex[iidx];
474 j_index_end = jindex[iidx+1];
476 /* Get outer coordinate index */
478 i_coord_offset = DIM*inr;
480 /* Load i particle coords and add shift vector */
481 ix0 = shX + x[i_coord_offset+DIM*0+XX];
482 iy0 = shY + x[i_coord_offset+DIM*0+YY];
483 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
484 ix1 = shX + x[i_coord_offset+DIM*1+XX];
485 iy1 = shY + x[i_coord_offset+DIM*1+YY];
486 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
487 ix2 = shX + x[i_coord_offset+DIM*2+XX];
488 iy2 = shY + x[i_coord_offset+DIM*2+YY];
489 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
501 /* Start inner kernel loop */
502 for(jidx=j_index_start; jidx<j_index_end; jidx++)
504 /* Get j neighbor index, and coordinate index */
506 j_coord_offset = DIM*jnr;
508 /* load j atom coordinates */
509 jx0 = x[j_coord_offset+DIM*0+XX];
510 jy0 = x[j_coord_offset+DIM*0+YY];
511 jz0 = x[j_coord_offset+DIM*0+ZZ];
513 /* Calculate displacement vector */
524 /* Calculate squared distance and things based on it */
525 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
526 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
527 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
529 rinv00 = gmx_invsqrt(rsq00);
530 rinv10 = gmx_invsqrt(rsq10);
531 rinv20 = gmx_invsqrt(rsq20);
533 rinvsq00 = rinv00*rinv00;
535 /* Load parameters for j particles */
537 vdwjidx0 = 3*vdwtype[jnr+0];
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
546 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
547 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
548 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
550 /* Calculate table index by multiplying r with table scale and truncate to integer */
556 /* CUBIC SPLINE TABLE ELECTROSTATICS */
558 Geps = vfeps*vftab[vfitab+2];
559 Heps2 = vfeps*vfeps*vftab[vfitab+3];
561 FF = Fp+Geps+2.0*Heps2;
562 felec = -qq00*FF*vftabscale*rinv00;
564 /* BUCKINGHAM DISPERSION/REPULSION */
565 rinvsix = rinvsq00*rinvsq00*rinvsq00;
566 vvdw6 = c6_00*rinvsix;
568 vvdwexp = cexp1_00*exp(-br);
569 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
573 /* Calculate temporary vectorial force */
578 /* Update vectorial force */
582 f[j_coord_offset+DIM*0+XX] -= tx;
583 f[j_coord_offset+DIM*0+YY] -= ty;
584 f[j_coord_offset+DIM*0+ZZ] -= tz;
586 /**************************
587 * CALCULATE INTERACTIONS *
588 **************************/
594 /* Calculate table index by multiplying r with table scale and truncate to integer */
600 /* CUBIC SPLINE TABLE ELECTROSTATICS */
602 Geps = vfeps*vftab[vfitab+2];
603 Heps2 = vfeps*vfeps*vftab[vfitab+3];
605 FF = Fp+Geps+2.0*Heps2;
606 felec = -qq10*FF*vftabscale*rinv10;
610 /* Calculate temporary vectorial force */
615 /* Update vectorial force */
619 f[j_coord_offset+DIM*0+XX] -= tx;
620 f[j_coord_offset+DIM*0+YY] -= ty;
621 f[j_coord_offset+DIM*0+ZZ] -= tz;
623 /**************************
624 * CALCULATE INTERACTIONS *
625 **************************/
631 /* Calculate table index by multiplying r with table scale and truncate to integer */
637 /* CUBIC SPLINE TABLE ELECTROSTATICS */
639 Geps = vfeps*vftab[vfitab+2];
640 Heps2 = vfeps*vfeps*vftab[vfitab+3];
642 FF = Fp+Geps+2.0*Heps2;
643 felec = -qq20*FF*vftabscale*rinv20;
647 /* Calculate temporary vectorial force */
652 /* Update vectorial force */
656 f[j_coord_offset+DIM*0+XX] -= tx;
657 f[j_coord_offset+DIM*0+YY] -= ty;
658 f[j_coord_offset+DIM*0+ZZ] -= tz;
660 /* Inner loop uses 150 flops */
662 /* End of innermost loop */
665 f[i_coord_offset+DIM*0+XX] += fix0;
666 f[i_coord_offset+DIM*0+YY] += fiy0;
667 f[i_coord_offset+DIM*0+ZZ] += fiz0;
671 f[i_coord_offset+DIM*1+XX] += fix1;
672 f[i_coord_offset+DIM*1+YY] += fiy1;
673 f[i_coord_offset+DIM*1+ZZ] += fiz1;
677 f[i_coord_offset+DIM*2+XX] += fix2;
678 f[i_coord_offset+DIM*2+YY] += fiy2;
679 f[i_coord_offset+DIM*2+ZZ] += fiz2;
683 fshift[i_shift_offset+XX] += tx;
684 fshift[i_shift_offset+YY] += ty;
685 fshift[i_shift_offset+ZZ] += tz;
687 /* Increment number of inner iterations */
688 inneriter += j_index_end - j_index_start;
690 /* Outer loop uses 30 flops */
693 /* Increment number of outer iterations */
696 /* Update outer/inner flops */
698 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*150);