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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwCSTab_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_vdw->data;
109 vftabscale = kernel_data->table_vdw->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 = 2*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;
196 rinvsq10 = rinv10*rinv10;
197 rinvsq20 = rinv20*rinv20;
199 /* Load parameters for j particles */
201 vdwjidx0 = 2*vdwtype[jnr+0];
203 /**************************
204 * CALCULATE INTERACTIONS *
205 **************************/
210 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
211 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
213 /* Calculate table index by multiplying r with table scale and truncate to integer */
219 /* COULOMB ELECTROSTATICS */
221 felec = velec*rinvsq00;
223 /* CUBIC SPLINE TABLE DISPERSION */
227 Geps = vfeps*vftab[vfitab+2];
228 Heps2 = vfeps*vfeps*vftab[vfitab+3];
232 FF = Fp+Geps+2.0*Heps2;
235 /* CUBIC SPLINE TABLE REPULSION */
238 Geps = vfeps*vftab[vfitab+6];
239 Heps2 = vfeps*vfeps*vftab[vfitab+7];
243 FF = Fp+Geps+2.0*Heps2;
246 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
248 /* Update potential sums from outer loop */
254 /* Calculate temporary vectorial force */
259 /* Update vectorial force */
263 f[j_coord_offset+DIM*0+XX] -= tx;
264 f[j_coord_offset+DIM*0+YY] -= ty;
265 f[j_coord_offset+DIM*0+ZZ] -= tz;
267 /**************************
268 * CALCULATE INTERACTIONS *
269 **************************/
273 /* COULOMB ELECTROSTATICS */
275 felec = velec*rinvsq10;
277 /* Update potential sums from outer loop */
282 /* Calculate temporary vectorial force */
287 /* Update vectorial force */
291 f[j_coord_offset+DIM*0+XX] -= tx;
292 f[j_coord_offset+DIM*0+YY] -= ty;
293 f[j_coord_offset+DIM*0+ZZ] -= tz;
295 /**************************
296 * CALCULATE INTERACTIONS *
297 **************************/
301 /* COULOMB ELECTROSTATICS */
303 felec = velec*rinvsq20;
305 /* Update potential sums from outer loop */
310 /* Calculate temporary vectorial force */
315 /* Update vectorial force */
319 f[j_coord_offset+DIM*0+XX] -= tx;
320 f[j_coord_offset+DIM*0+YY] -= ty;
321 f[j_coord_offset+DIM*0+ZZ] -= tz;
323 /* Inner loop uses 118 flops */
325 /* End of innermost loop */
328 f[i_coord_offset+DIM*0+XX] += fix0;
329 f[i_coord_offset+DIM*0+YY] += fiy0;
330 f[i_coord_offset+DIM*0+ZZ] += fiz0;
334 f[i_coord_offset+DIM*1+XX] += fix1;
335 f[i_coord_offset+DIM*1+YY] += fiy1;
336 f[i_coord_offset+DIM*1+ZZ] += fiz1;
340 f[i_coord_offset+DIM*2+XX] += fix2;
341 f[i_coord_offset+DIM*2+YY] += fiy2;
342 f[i_coord_offset+DIM*2+ZZ] += fiz2;
346 fshift[i_shift_offset+XX] += tx;
347 fshift[i_shift_offset+YY] += ty;
348 fshift[i_shift_offset+ZZ] += tz;
351 /* Update potential energies */
352 kernel_data->energygrp_elec[ggid] += velecsum;
353 kernel_data->energygrp_vdw[ggid] += vvdwsum;
355 /* Increment number of inner iterations */
356 inneriter += j_index_end - j_index_start;
358 /* Outer loop uses 32 flops */
361 /* Increment number of outer iterations */
364 /* Update outer/inner flops */
366 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*118);
369 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
370 * Electrostatics interaction: Coulomb
371 * VdW interaction: CubicSplineTable
372 * Geometry: Water3-Particle
373 * Calculate force/pot: Force
376 nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
377 (t_nblist * gmx_restrict nlist,
378 rvec * gmx_restrict xx,
379 rvec * gmx_restrict ff,
380 t_forcerec * gmx_restrict fr,
381 t_mdatoms * gmx_restrict mdatoms,
382 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
383 t_nrnb * gmx_restrict nrnb)
385 int i_shift_offset,i_coord_offset,j_coord_offset;
386 int j_index_start,j_index_end;
387 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
388 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
389 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
390 real *shiftvec,*fshift,*x,*f;
392 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
394 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
396 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
398 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
399 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
400 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
401 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
402 real velec,felec,velecsum,facel,crf,krf,krf2;
405 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
409 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
417 jindex = nlist->jindex;
419 shiftidx = nlist->shift;
421 shiftvec = fr->shift_vec[0];
422 fshift = fr->fshift[0];
424 charge = mdatoms->chargeA;
425 nvdwtype = fr->ntype;
427 vdwtype = mdatoms->typeA;
429 vftab = kernel_data->table_vdw->data;
430 vftabscale = kernel_data->table_vdw->scale;
432 /* Setup water-specific parameters */
433 inr = nlist->iinr[0];
434 iq0 = facel*charge[inr+0];
435 iq1 = facel*charge[inr+1];
436 iq2 = facel*charge[inr+2];
437 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
442 /* Start outer loop over neighborlists */
443 for(iidx=0; iidx<nri; iidx++)
445 /* Load shift vector for this list */
446 i_shift_offset = DIM*shiftidx[iidx];
447 shX = shiftvec[i_shift_offset+XX];
448 shY = shiftvec[i_shift_offset+YY];
449 shZ = shiftvec[i_shift_offset+ZZ];
451 /* Load limits for loop over neighbors */
452 j_index_start = jindex[iidx];
453 j_index_end = jindex[iidx+1];
455 /* Get outer coordinate index */
457 i_coord_offset = DIM*inr;
459 /* Load i particle coords and add shift vector */
460 ix0 = shX + x[i_coord_offset+DIM*0+XX];
461 iy0 = shY + x[i_coord_offset+DIM*0+YY];
462 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
463 ix1 = shX + x[i_coord_offset+DIM*1+XX];
464 iy1 = shY + x[i_coord_offset+DIM*1+YY];
465 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
466 ix2 = shX + x[i_coord_offset+DIM*2+XX];
467 iy2 = shY + x[i_coord_offset+DIM*2+YY];
468 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
480 /* Start inner kernel loop */
481 for(jidx=j_index_start; jidx<j_index_end; jidx++)
483 /* Get j neighbor index, and coordinate index */
485 j_coord_offset = DIM*jnr;
487 /* load j atom coordinates */
488 jx0 = x[j_coord_offset+DIM*0+XX];
489 jy0 = x[j_coord_offset+DIM*0+YY];
490 jz0 = x[j_coord_offset+DIM*0+ZZ];
492 /* Calculate displacement vector */
503 /* Calculate squared distance and things based on it */
504 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
505 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
506 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
508 rinv00 = gmx_invsqrt(rsq00);
509 rinv10 = gmx_invsqrt(rsq10);
510 rinv20 = gmx_invsqrt(rsq20);
512 rinvsq00 = rinv00*rinv00;
513 rinvsq10 = rinv10*rinv10;
514 rinvsq20 = rinv20*rinv20;
516 /* Load parameters for j particles */
518 vdwjidx0 = 2*vdwtype[jnr+0];
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
527 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
528 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
530 /* Calculate table index by multiplying r with table scale and truncate to integer */
536 /* COULOMB ELECTROSTATICS */
538 felec = velec*rinvsq00;
540 /* CUBIC SPLINE TABLE DISPERSION */
543 Geps = vfeps*vftab[vfitab+2];
544 Heps2 = vfeps*vfeps*vftab[vfitab+3];
546 FF = Fp+Geps+2.0*Heps2;
549 /* CUBIC SPLINE TABLE REPULSION */
551 Geps = vfeps*vftab[vfitab+6];
552 Heps2 = vfeps*vfeps*vftab[vfitab+7];
554 FF = Fp+Geps+2.0*Heps2;
556 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
560 /* Calculate temporary vectorial force */
565 /* Update vectorial force */
569 f[j_coord_offset+DIM*0+XX] -= tx;
570 f[j_coord_offset+DIM*0+YY] -= ty;
571 f[j_coord_offset+DIM*0+ZZ] -= tz;
573 /**************************
574 * CALCULATE INTERACTIONS *
575 **************************/
579 /* COULOMB ELECTROSTATICS */
581 felec = velec*rinvsq10;
585 /* Calculate temporary vectorial force */
590 /* Update vectorial force */
594 f[j_coord_offset+DIM*0+XX] -= tx;
595 f[j_coord_offset+DIM*0+YY] -= ty;
596 f[j_coord_offset+DIM*0+ZZ] -= tz;
598 /**************************
599 * CALCULATE INTERACTIONS *
600 **************************/
604 /* COULOMB ELECTROSTATICS */
606 felec = velec*rinvsq20;
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 /* Inner loop uses 107 flops */
625 /* End of innermost loop */
628 f[i_coord_offset+DIM*0+XX] += fix0;
629 f[i_coord_offset+DIM*0+YY] += fiy0;
630 f[i_coord_offset+DIM*0+ZZ] += fiz0;
634 f[i_coord_offset+DIM*1+XX] += fix1;
635 f[i_coord_offset+DIM*1+YY] += fiy1;
636 f[i_coord_offset+DIM*1+ZZ] += fiz1;
640 f[i_coord_offset+DIM*2+XX] += fix2;
641 f[i_coord_offset+DIM*2+YY] += fiy2;
642 f[i_coord_offset+DIM*2+ZZ] += fiz2;
646 fshift[i_shift_offset+XX] += tx;
647 fshift[i_shift_offset+YY] += ty;
648 fshift[i_shift_offset+ZZ] += tz;
650 /* Increment number of inner iterations */
651 inneriter += j_index_end - j_index_start;
653 /* Outer loop uses 30 flops */
656 /* Increment number of outer iterations */
659 /* Update outer/inner flops */
661 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);