2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW3P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
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 sh_ewald = fr->ic->sh_ewald;
111 ewtab = fr->ic->tabq_coul_FDV0;
112 ewtabscale = fr->ic->tabq_scale;
113 ewtabhalfspace = 0.5/ewtabscale;
115 /* Setup water-specific parameters */
116 inr = nlist->iinr[0];
117 iq0 = facel*charge[inr+0];
118 iq1 = facel*charge[inr+1];
119 iq2 = facel*charge[inr+2];
120 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
125 /* Start outer loop over neighborlists */
126 for(iidx=0; iidx<nri; iidx++)
128 /* Load shift vector for this list */
129 i_shift_offset = DIM*shiftidx[iidx];
130 shX = shiftvec[i_shift_offset+XX];
131 shY = shiftvec[i_shift_offset+YY];
132 shZ = shiftvec[i_shift_offset+ZZ];
134 /* Load limits for loop over neighbors */
135 j_index_start = jindex[iidx];
136 j_index_end = jindex[iidx+1];
138 /* Get outer coordinate index */
140 i_coord_offset = DIM*inr;
142 /* Load i particle coords and add shift vector */
143 ix0 = shX + x[i_coord_offset+DIM*0+XX];
144 iy0 = shY + x[i_coord_offset+DIM*0+YY];
145 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
146 ix1 = shX + x[i_coord_offset+DIM*1+XX];
147 iy1 = shY + x[i_coord_offset+DIM*1+YY];
148 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
149 ix2 = shX + x[i_coord_offset+DIM*2+XX];
150 iy2 = shY + x[i_coord_offset+DIM*2+YY];
151 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
163 /* Reset potential sums */
167 /* Start inner kernel loop */
168 for(jidx=j_index_start; jidx<j_index_end; jidx++)
170 /* Get j neighbor index, and coordinate index */
172 j_coord_offset = DIM*jnr;
174 /* load j atom coordinates */
175 jx0 = x[j_coord_offset+DIM*0+XX];
176 jy0 = x[j_coord_offset+DIM*0+YY];
177 jz0 = x[j_coord_offset+DIM*0+ZZ];
179 /* Calculate displacement vector */
190 /* Calculate squared distance and things based on it */
191 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
192 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
193 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
195 rinv00 = gmx_invsqrt(rsq00);
196 rinv10 = gmx_invsqrt(rsq10);
197 rinv20 = gmx_invsqrt(rsq20);
199 rinvsq00 = rinv00*rinv00;
200 rinvsq10 = rinv10*rinv10;
201 rinvsq20 = rinv20*rinv20;
203 /* Load parameters for j particles */
205 vdwjidx0 = 3*vdwtype[jnr+0];
207 /**************************
208 * CALCULATE INTERACTIONS *
209 **************************/
214 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
215 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
216 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
218 /* EWALD ELECTROSTATICS */
220 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
221 ewrt = r00*ewtabscale;
225 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
226 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
227 felec = qq00*rinv00*(rinvsq00-felec);
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 /* EWALD ELECTROSTATICS */
266 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
267 ewrt = r10*ewtabscale;
271 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
272 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
273 felec = qq10*rinv10*(rinvsq10-felec);
275 /* Update potential sums from outer loop */
280 /* Calculate temporary vectorial force */
285 /* Update vectorial force */
289 f[j_coord_offset+DIM*0+XX] -= tx;
290 f[j_coord_offset+DIM*0+YY] -= ty;
291 f[j_coord_offset+DIM*0+ZZ] -= tz;
293 /**************************
294 * CALCULATE INTERACTIONS *
295 **************************/
301 /* EWALD ELECTROSTATICS */
303 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
304 ewrt = r20*ewtabscale;
308 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
309 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
310 felec = qq20*rinv20*(rinvsq20-felec);
312 /* Update potential sums from outer loop */
317 /* Calculate temporary vectorial force */
322 /* Update vectorial force */
326 f[j_coord_offset+DIM*0+XX] -= tx;
327 f[j_coord_offset+DIM*0+YY] -= ty;
328 f[j_coord_offset+DIM*0+ZZ] -= tz;
330 /* Inner loop uses 161 flops */
332 /* End of innermost loop */
335 f[i_coord_offset+DIM*0+XX] += fix0;
336 f[i_coord_offset+DIM*0+YY] += fiy0;
337 f[i_coord_offset+DIM*0+ZZ] += fiz0;
341 f[i_coord_offset+DIM*1+XX] += fix1;
342 f[i_coord_offset+DIM*1+YY] += fiy1;
343 f[i_coord_offset+DIM*1+ZZ] += fiz1;
347 f[i_coord_offset+DIM*2+XX] += fix2;
348 f[i_coord_offset+DIM*2+YY] += fiy2;
349 f[i_coord_offset+DIM*2+ZZ] += fiz2;
353 fshift[i_shift_offset+XX] += tx;
354 fshift[i_shift_offset+YY] += ty;
355 fshift[i_shift_offset+ZZ] += tz;
358 /* Update potential energies */
359 kernel_data->energygrp_elec[ggid] += velecsum;
360 kernel_data->energygrp_vdw[ggid] += vvdwsum;
362 /* Increment number of inner iterations */
363 inneriter += j_index_end - j_index_start;
365 /* Outer loop uses 32 flops */
368 /* Increment number of outer iterations */
371 /* Update outer/inner flops */
373 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*161);
376 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW3P1_F_c
377 * Electrostatics interaction: Ewald
378 * VdW interaction: Buckingham
379 * Geometry: Water3-Particle
380 * Calculate force/pot: Force
383 nb_kernel_ElecEw_VdwBham_GeomW3P1_F_c
384 (t_nblist * gmx_restrict nlist,
385 rvec * gmx_restrict xx,
386 rvec * gmx_restrict ff,
387 t_forcerec * gmx_restrict fr,
388 t_mdatoms * gmx_restrict mdatoms,
389 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
390 t_nrnb * gmx_restrict nrnb)
392 int i_shift_offset,i_coord_offset,j_coord_offset;
393 int j_index_start,j_index_end;
394 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
395 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
396 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
397 real *shiftvec,*fshift,*x,*f;
399 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
401 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
403 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
405 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
406 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
407 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
408 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
409 real velec,felec,velecsum,facel,crf,krf,krf2;
412 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
416 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
424 jindex = nlist->jindex;
426 shiftidx = nlist->shift;
428 shiftvec = fr->shift_vec[0];
429 fshift = fr->fshift[0];
431 charge = mdatoms->chargeA;
432 nvdwtype = fr->ntype;
434 vdwtype = mdatoms->typeA;
436 sh_ewald = fr->ic->sh_ewald;
437 ewtab = fr->ic->tabq_coul_F;
438 ewtabscale = fr->ic->tabq_scale;
439 ewtabhalfspace = 0.5/ewtabscale;
441 /* Setup water-specific parameters */
442 inr = nlist->iinr[0];
443 iq0 = facel*charge[inr+0];
444 iq1 = facel*charge[inr+1];
445 iq2 = facel*charge[inr+2];
446 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
451 /* Start outer loop over neighborlists */
452 for(iidx=0; iidx<nri; iidx++)
454 /* Load shift vector for this list */
455 i_shift_offset = DIM*shiftidx[iidx];
456 shX = shiftvec[i_shift_offset+XX];
457 shY = shiftvec[i_shift_offset+YY];
458 shZ = shiftvec[i_shift_offset+ZZ];
460 /* Load limits for loop over neighbors */
461 j_index_start = jindex[iidx];
462 j_index_end = jindex[iidx+1];
464 /* Get outer coordinate index */
466 i_coord_offset = DIM*inr;
468 /* Load i particle coords and add shift vector */
469 ix0 = shX + x[i_coord_offset+DIM*0+XX];
470 iy0 = shY + x[i_coord_offset+DIM*0+YY];
471 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
472 ix1 = shX + x[i_coord_offset+DIM*1+XX];
473 iy1 = shY + x[i_coord_offset+DIM*1+YY];
474 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
475 ix2 = shX + x[i_coord_offset+DIM*2+XX];
476 iy2 = shY + x[i_coord_offset+DIM*2+YY];
477 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
489 /* Start inner kernel loop */
490 for(jidx=j_index_start; jidx<j_index_end; jidx++)
492 /* Get j neighbor index, and coordinate index */
494 j_coord_offset = DIM*jnr;
496 /* load j atom coordinates */
497 jx0 = x[j_coord_offset+DIM*0+XX];
498 jy0 = x[j_coord_offset+DIM*0+YY];
499 jz0 = x[j_coord_offset+DIM*0+ZZ];
501 /* Calculate displacement vector */
512 /* Calculate squared distance and things based on it */
513 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
514 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
515 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
517 rinv00 = gmx_invsqrt(rsq00);
518 rinv10 = gmx_invsqrt(rsq10);
519 rinv20 = gmx_invsqrt(rsq20);
521 rinvsq00 = rinv00*rinv00;
522 rinvsq10 = rinv10*rinv10;
523 rinvsq20 = rinv20*rinv20;
525 /* Load parameters for j particles */
527 vdwjidx0 = 3*vdwtype[jnr+0];
529 /**************************
530 * CALCULATE INTERACTIONS *
531 **************************/
536 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
537 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
538 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
540 /* EWALD ELECTROSTATICS */
542 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
543 ewrt = r00*ewtabscale;
546 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
547 felec = qq00*rinv00*(rinvsq00-felec);
549 /* BUCKINGHAM DISPERSION/REPULSION */
550 rinvsix = rinvsq00*rinvsq00*rinvsq00;
551 vvdw6 = c6_00*rinvsix;
553 vvdwexp = cexp1_00*exp(-br);
554 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
558 /* Calculate temporary vectorial force */
563 /* Update vectorial force */
567 f[j_coord_offset+DIM*0+XX] -= tx;
568 f[j_coord_offset+DIM*0+YY] -= ty;
569 f[j_coord_offset+DIM*0+ZZ] -= tz;
571 /**************************
572 * CALCULATE INTERACTIONS *
573 **************************/
579 /* EWALD ELECTROSTATICS */
581 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
582 ewrt = r10*ewtabscale;
585 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
586 felec = qq10*rinv10*(rinvsq10-felec);
590 /* Calculate temporary vectorial force */
595 /* Update vectorial force */
599 f[j_coord_offset+DIM*0+XX] -= tx;
600 f[j_coord_offset+DIM*0+YY] -= ty;
601 f[j_coord_offset+DIM*0+ZZ] -= tz;
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
611 /* EWALD ELECTROSTATICS */
613 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
614 ewrt = r20*ewtabscale;
617 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
618 felec = qq20*rinv20*(rinvsq20-felec);
622 /* Calculate temporary vectorial force */
627 /* Update vectorial force */
631 f[j_coord_offset+DIM*0+XX] -= tx;
632 f[j_coord_offset+DIM*0+YY] -= ty;
633 f[j_coord_offset+DIM*0+ZZ] -= tz;
635 /* Inner loop uses 137 flops */
637 /* End of innermost loop */
640 f[i_coord_offset+DIM*0+XX] += fix0;
641 f[i_coord_offset+DIM*0+YY] += fiy0;
642 f[i_coord_offset+DIM*0+ZZ] += fiz0;
646 f[i_coord_offset+DIM*1+XX] += fix1;
647 f[i_coord_offset+DIM*1+YY] += fiy1;
648 f[i_coord_offset+DIM*1+ZZ] += fiz1;
652 f[i_coord_offset+DIM*2+XX] += fix2;
653 f[i_coord_offset+DIM*2+YY] += fiy2;
654 f[i_coord_offset+DIM*2+ZZ] += fiz2;
658 fshift[i_shift_offset+XX] += tx;
659 fshift[i_shift_offset+YY] += ty;
660 fshift[i_shift_offset+ZZ] += tz;
662 /* Increment number of inner iterations */
663 inneriter += j_index_end - j_index_start;
665 /* Outer loop uses 30 flops */
668 /* Increment number of outer iterations */
671 /* Update outer/inner flops */
673 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*137);