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 "types/simple.h"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwCSTab_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_vdw->data;
111 vftabscale = kernel_data->table_vdw->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 = 2*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;
198 rinvsq10 = rinv10*rinv10;
199 rinvsq20 = rinv20*rinv20;
201 /* Load parameters for j particles */
203 vdwjidx0 = 2*vdwtype[jnr+0];
205 /**************************
206 * CALCULATE INTERACTIONS *
207 **************************/
212 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
213 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
215 /* Calculate table index by multiplying r with table scale and truncate to integer */
221 /* COULOMB ELECTROSTATICS */
223 felec = velec*rinvsq00;
225 /* CUBIC SPLINE TABLE DISPERSION */
229 Geps = vfeps*vftab[vfitab+2];
230 Heps2 = vfeps*vfeps*vftab[vfitab+3];
234 FF = Fp+Geps+2.0*Heps2;
237 /* CUBIC SPLINE TABLE REPULSION */
240 Geps = vfeps*vftab[vfitab+6];
241 Heps2 = vfeps*vfeps*vftab[vfitab+7];
245 FF = Fp+Geps+2.0*Heps2;
248 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
250 /* Update potential sums from outer loop */
256 /* Calculate temporary vectorial force */
261 /* Update vectorial force */
265 f[j_coord_offset+DIM*0+XX] -= tx;
266 f[j_coord_offset+DIM*0+YY] -= ty;
267 f[j_coord_offset+DIM*0+ZZ] -= tz;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
275 /* COULOMB ELECTROSTATICS */
277 felec = velec*rinvsq10;
279 /* Update potential sums from outer loop */
284 /* Calculate temporary vectorial force */
289 /* Update vectorial force */
293 f[j_coord_offset+DIM*0+XX] -= tx;
294 f[j_coord_offset+DIM*0+YY] -= ty;
295 f[j_coord_offset+DIM*0+ZZ] -= tz;
297 /**************************
298 * CALCULATE INTERACTIONS *
299 **************************/
303 /* COULOMB ELECTROSTATICS */
305 felec = velec*rinvsq20;
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*0+XX] -= tx;
322 f[j_coord_offset+DIM*0+YY] -= ty;
323 f[j_coord_offset+DIM*0+ZZ] -= tz;
325 /* Inner loop uses 118 flops */
327 /* End of innermost loop */
330 f[i_coord_offset+DIM*0+XX] += fix0;
331 f[i_coord_offset+DIM*0+YY] += fiy0;
332 f[i_coord_offset+DIM*0+ZZ] += fiz0;
336 f[i_coord_offset+DIM*1+XX] += fix1;
337 f[i_coord_offset+DIM*1+YY] += fiy1;
338 f[i_coord_offset+DIM*1+ZZ] += fiz1;
342 f[i_coord_offset+DIM*2+XX] += fix2;
343 f[i_coord_offset+DIM*2+YY] += fiy2;
344 f[i_coord_offset+DIM*2+ZZ] += fiz2;
348 fshift[i_shift_offset+XX] += tx;
349 fshift[i_shift_offset+YY] += ty;
350 fshift[i_shift_offset+ZZ] += tz;
353 /* Update potential energies */
354 kernel_data->energygrp_elec[ggid] += velecsum;
355 kernel_data->energygrp_vdw[ggid] += vvdwsum;
357 /* Increment number of inner iterations */
358 inneriter += j_index_end - j_index_start;
360 /* Outer loop uses 32 flops */
363 /* Increment number of outer iterations */
366 /* Update outer/inner flops */
368 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*118);
371 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
372 * Electrostatics interaction: Coulomb
373 * VdW interaction: CubicSplineTable
374 * Geometry: Water3-Particle
375 * Calculate force/pot: Force
378 nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
379 (t_nblist * gmx_restrict nlist,
380 rvec * gmx_restrict xx,
381 rvec * gmx_restrict ff,
382 t_forcerec * gmx_restrict fr,
383 t_mdatoms * gmx_restrict mdatoms,
384 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
385 t_nrnb * gmx_restrict nrnb)
387 int i_shift_offset,i_coord_offset,j_coord_offset;
388 int j_index_start,j_index_end;
389 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
390 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
391 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
392 real *shiftvec,*fshift,*x,*f;
394 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
396 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
398 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
400 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
401 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
402 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
403 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
404 real velec,felec,velecsum,facel,crf,krf,krf2;
407 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
411 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
419 jindex = nlist->jindex;
421 shiftidx = nlist->shift;
423 shiftvec = fr->shift_vec[0];
424 fshift = fr->fshift[0];
426 charge = mdatoms->chargeA;
427 nvdwtype = fr->ntype;
429 vdwtype = mdatoms->typeA;
431 vftab = kernel_data->table_vdw->data;
432 vftabscale = kernel_data->table_vdw->scale;
434 /* Setup water-specific parameters */
435 inr = nlist->iinr[0];
436 iq0 = facel*charge[inr+0];
437 iq1 = facel*charge[inr+1];
438 iq2 = facel*charge[inr+2];
439 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
444 /* Start outer loop over neighborlists */
445 for(iidx=0; iidx<nri; iidx++)
447 /* Load shift vector for this list */
448 i_shift_offset = DIM*shiftidx[iidx];
449 shX = shiftvec[i_shift_offset+XX];
450 shY = shiftvec[i_shift_offset+YY];
451 shZ = shiftvec[i_shift_offset+ZZ];
453 /* Load limits for loop over neighbors */
454 j_index_start = jindex[iidx];
455 j_index_end = jindex[iidx+1];
457 /* Get outer coordinate index */
459 i_coord_offset = DIM*inr;
461 /* Load i particle coords and add shift vector */
462 ix0 = shX + x[i_coord_offset+DIM*0+XX];
463 iy0 = shY + x[i_coord_offset+DIM*0+YY];
464 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
465 ix1 = shX + x[i_coord_offset+DIM*1+XX];
466 iy1 = shY + x[i_coord_offset+DIM*1+YY];
467 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
468 ix2 = shX + x[i_coord_offset+DIM*2+XX];
469 iy2 = shY + x[i_coord_offset+DIM*2+YY];
470 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
482 /* Start inner kernel loop */
483 for(jidx=j_index_start; jidx<j_index_end; jidx++)
485 /* Get j neighbor index, and coordinate index */
487 j_coord_offset = DIM*jnr;
489 /* load j atom coordinates */
490 jx0 = x[j_coord_offset+DIM*0+XX];
491 jy0 = x[j_coord_offset+DIM*0+YY];
492 jz0 = x[j_coord_offset+DIM*0+ZZ];
494 /* Calculate displacement vector */
505 /* Calculate squared distance and things based on it */
506 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
507 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
508 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
510 rinv00 = gmx_invsqrt(rsq00);
511 rinv10 = gmx_invsqrt(rsq10);
512 rinv20 = gmx_invsqrt(rsq20);
514 rinvsq00 = rinv00*rinv00;
515 rinvsq10 = rinv10*rinv10;
516 rinvsq20 = rinv20*rinv20;
518 /* Load parameters for j particles */
520 vdwjidx0 = 2*vdwtype[jnr+0];
522 /**************************
523 * CALCULATE INTERACTIONS *
524 **************************/
529 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
530 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
532 /* Calculate table index by multiplying r with table scale and truncate to integer */
538 /* COULOMB ELECTROSTATICS */
540 felec = velec*rinvsq00;
542 /* CUBIC SPLINE TABLE DISPERSION */
545 Geps = vfeps*vftab[vfitab+2];
546 Heps2 = vfeps*vfeps*vftab[vfitab+3];
548 FF = Fp+Geps+2.0*Heps2;
551 /* CUBIC SPLINE TABLE REPULSION */
553 Geps = vfeps*vftab[vfitab+6];
554 Heps2 = vfeps*vfeps*vftab[vfitab+7];
556 FF = Fp+Geps+2.0*Heps2;
558 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
562 /* Calculate temporary vectorial force */
567 /* Update vectorial force */
571 f[j_coord_offset+DIM*0+XX] -= tx;
572 f[j_coord_offset+DIM*0+YY] -= ty;
573 f[j_coord_offset+DIM*0+ZZ] -= tz;
575 /**************************
576 * CALCULATE INTERACTIONS *
577 **************************/
581 /* COULOMB ELECTROSTATICS */
583 felec = velec*rinvsq10;
587 /* Calculate temporary vectorial force */
592 /* Update vectorial force */
596 f[j_coord_offset+DIM*0+XX] -= tx;
597 f[j_coord_offset+DIM*0+YY] -= ty;
598 f[j_coord_offset+DIM*0+ZZ] -= tz;
600 /**************************
601 * CALCULATE INTERACTIONS *
602 **************************/
606 /* COULOMB ELECTROSTATICS */
608 felec = velec*rinvsq20;
612 /* Calculate temporary vectorial force */
617 /* Update vectorial force */
621 f[j_coord_offset+DIM*0+XX] -= tx;
622 f[j_coord_offset+DIM*0+YY] -= ty;
623 f[j_coord_offset+DIM*0+ZZ] -= tz;
625 /* Inner loop uses 107 flops */
627 /* End of innermost loop */
630 f[i_coord_offset+DIM*0+XX] += fix0;
631 f[i_coord_offset+DIM*0+YY] += fiy0;
632 f[i_coord_offset+DIM*0+ZZ] += fiz0;
636 f[i_coord_offset+DIM*1+XX] += fix1;
637 f[i_coord_offset+DIM*1+YY] += fiy1;
638 f[i_coord_offset+DIM*1+ZZ] += fiz1;
642 f[i_coord_offset+DIM*2+XX] += fix2;
643 f[i_coord_offset+DIM*2+YY] += fiy2;
644 f[i_coord_offset+DIM*2+ZZ] += fiz2;
648 fshift[i_shift_offset+XX] += tx;
649 fshift[i_shift_offset+YY] += ty;
650 fshift[i_shift_offset+ZZ] += tz;
652 /* Increment number of inner iterations */
653 inneriter += j_index_end - j_index_start;
655 /* Outer loop uses 30 flops */
658 /* Increment number of outer iterations */
661 /* Update outer/inner flops */
663 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);