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_GeomW4P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwBham_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
93 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
108 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 sh_ewald = fr->ic->sh_ewald;
114 ewtab = fr->ic->tabq_coul_FDV0;
115 ewtabscale = fr->ic->tabq_scale;
116 ewtabhalfspace = 0.5/ewtabscale;
118 /* Setup water-specific parameters */
119 inr = nlist->iinr[0];
120 iq1 = facel*charge[inr+1];
121 iq2 = facel*charge[inr+2];
122 iq3 = facel*charge[inr+3];
123 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
128 /* Start outer loop over neighborlists */
129 for(iidx=0; iidx<nri; iidx++)
131 /* Load shift vector for this list */
132 i_shift_offset = DIM*shiftidx[iidx];
133 shX = shiftvec[i_shift_offset+XX];
134 shY = shiftvec[i_shift_offset+YY];
135 shZ = shiftvec[i_shift_offset+ZZ];
137 /* Load limits for loop over neighbors */
138 j_index_start = jindex[iidx];
139 j_index_end = jindex[iidx+1];
141 /* Get outer coordinate index */
143 i_coord_offset = DIM*inr;
145 /* Load i particle coords and add shift vector */
146 ix0 = shX + x[i_coord_offset+DIM*0+XX];
147 iy0 = shY + x[i_coord_offset+DIM*0+YY];
148 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
149 ix1 = shX + x[i_coord_offset+DIM*1+XX];
150 iy1 = shY + x[i_coord_offset+DIM*1+YY];
151 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
152 ix2 = shX + x[i_coord_offset+DIM*2+XX];
153 iy2 = shY + x[i_coord_offset+DIM*2+YY];
154 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
155 ix3 = shX + x[i_coord_offset+DIM*3+XX];
156 iy3 = shY + x[i_coord_offset+DIM*3+YY];
157 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
172 /* Reset potential sums */
176 /* Start inner kernel loop */
177 for(jidx=j_index_start; jidx<j_index_end; jidx++)
179 /* Get j neighbor index, and coordinate index */
181 j_coord_offset = DIM*jnr;
183 /* load j atom coordinates */
184 jx0 = x[j_coord_offset+DIM*0+XX];
185 jy0 = x[j_coord_offset+DIM*0+YY];
186 jz0 = x[j_coord_offset+DIM*0+ZZ];
188 /* Calculate displacement vector */
202 /* Calculate squared distance and things based on it */
203 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
204 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
205 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
206 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
208 rinv00 = gmx_invsqrt(rsq00);
209 rinv10 = gmx_invsqrt(rsq10);
210 rinv20 = gmx_invsqrt(rsq20);
211 rinv30 = gmx_invsqrt(rsq30);
213 rinvsq00 = rinv00*rinv00;
214 rinvsq10 = rinv10*rinv10;
215 rinvsq20 = rinv20*rinv20;
216 rinvsq30 = rinv30*rinv30;
218 /* Load parameters for j particles */
220 vdwjidx0 = 3*vdwtype[jnr+0];
222 /**************************
223 * CALCULATE INTERACTIONS *
224 **************************/
228 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
229 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
230 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
232 /* BUCKINGHAM DISPERSION/REPULSION */
233 rinvsix = rinvsq00*rinvsq00*rinvsq00;
234 vvdw6 = c6_00*rinvsix;
236 vvdwexp = cexp1_00*exp(-br);
237 vvdw = vvdwexp - vvdw6*(1.0/6.0);
238 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
240 /* 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 /* EWALD ELECTROSTATICS */
268 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
269 ewrt = r10*ewtabscale;
273 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
274 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
275 felec = qq10*rinv10*(rinvsq10-felec);
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 **************************/
303 /* EWALD ELECTROSTATICS */
305 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
306 ewrt = r20*ewtabscale;
310 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
311 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
312 felec = qq20*rinv20*(rinvsq20-felec);
314 /* Update potential sums from outer loop */
319 /* Calculate temporary vectorial force */
324 /* Update vectorial force */
328 f[j_coord_offset+DIM*0+XX] -= tx;
329 f[j_coord_offset+DIM*0+YY] -= ty;
330 f[j_coord_offset+DIM*0+ZZ] -= tz;
332 /**************************
333 * CALCULATE INTERACTIONS *
334 **************************/
340 /* EWALD ELECTROSTATICS */
342 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
343 ewrt = r30*ewtabscale;
347 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
348 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
349 felec = qq30*rinv30*(rinvsq30-felec);
351 /* Update potential sums from outer loop */
356 /* Calculate temporary vectorial force */
361 /* Update vectorial force */
365 f[j_coord_offset+DIM*0+XX] -= tx;
366 f[j_coord_offset+DIM*0+YY] -= ty;
367 f[j_coord_offset+DIM*0+ZZ] -= tz;
369 /* Inner loop uses 184 flops */
371 /* End of innermost loop */
374 f[i_coord_offset+DIM*0+XX] += fix0;
375 f[i_coord_offset+DIM*0+YY] += fiy0;
376 f[i_coord_offset+DIM*0+ZZ] += fiz0;
380 f[i_coord_offset+DIM*1+XX] += fix1;
381 f[i_coord_offset+DIM*1+YY] += fiy1;
382 f[i_coord_offset+DIM*1+ZZ] += fiz1;
386 f[i_coord_offset+DIM*2+XX] += fix2;
387 f[i_coord_offset+DIM*2+YY] += fiy2;
388 f[i_coord_offset+DIM*2+ZZ] += fiz2;
392 f[i_coord_offset+DIM*3+XX] += fix3;
393 f[i_coord_offset+DIM*3+YY] += fiy3;
394 f[i_coord_offset+DIM*3+ZZ] += fiz3;
398 fshift[i_shift_offset+XX] += tx;
399 fshift[i_shift_offset+YY] += ty;
400 fshift[i_shift_offset+ZZ] += tz;
403 /* Update potential energies */
404 kernel_data->energygrp_elec[ggid] += velecsum;
405 kernel_data->energygrp_vdw[ggid] += vvdwsum;
407 /* Increment number of inner iterations */
408 inneriter += j_index_end - j_index_start;
410 /* Outer loop uses 41 flops */
413 /* Increment number of outer iterations */
416 /* Update outer/inner flops */
418 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*184);
421 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW4P1_F_c
422 * Electrostatics interaction: Ewald
423 * VdW interaction: Buckingham
424 * Geometry: Water4-Particle
425 * Calculate force/pot: Force
428 nb_kernel_ElecEw_VdwBham_GeomW4P1_F_c
429 (t_nblist * gmx_restrict nlist,
430 rvec * gmx_restrict xx,
431 rvec * gmx_restrict ff,
432 t_forcerec * gmx_restrict fr,
433 t_mdatoms * gmx_restrict mdatoms,
434 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
435 t_nrnb * gmx_restrict nrnb)
437 int i_shift_offset,i_coord_offset,j_coord_offset;
438 int j_index_start,j_index_end;
439 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
440 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
441 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
442 real *shiftvec,*fshift,*x,*f;
444 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
446 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
448 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
450 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
452 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
453 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
454 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
455 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
456 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
457 real velec,felec,velecsum,facel,crf,krf,krf2;
460 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
464 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
472 jindex = nlist->jindex;
474 shiftidx = nlist->shift;
476 shiftvec = fr->shift_vec[0];
477 fshift = fr->fshift[0];
479 charge = mdatoms->chargeA;
480 nvdwtype = fr->ntype;
482 vdwtype = mdatoms->typeA;
484 sh_ewald = fr->ic->sh_ewald;
485 ewtab = fr->ic->tabq_coul_F;
486 ewtabscale = fr->ic->tabq_scale;
487 ewtabhalfspace = 0.5/ewtabscale;
489 /* Setup water-specific parameters */
490 inr = nlist->iinr[0];
491 iq1 = facel*charge[inr+1];
492 iq2 = facel*charge[inr+2];
493 iq3 = facel*charge[inr+3];
494 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
499 /* Start outer loop over neighborlists */
500 for(iidx=0; iidx<nri; iidx++)
502 /* Load shift vector for this list */
503 i_shift_offset = DIM*shiftidx[iidx];
504 shX = shiftvec[i_shift_offset+XX];
505 shY = shiftvec[i_shift_offset+YY];
506 shZ = shiftvec[i_shift_offset+ZZ];
508 /* Load limits for loop over neighbors */
509 j_index_start = jindex[iidx];
510 j_index_end = jindex[iidx+1];
512 /* Get outer coordinate index */
514 i_coord_offset = DIM*inr;
516 /* Load i particle coords and add shift vector */
517 ix0 = shX + x[i_coord_offset+DIM*0+XX];
518 iy0 = shY + x[i_coord_offset+DIM*0+YY];
519 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
520 ix1 = shX + x[i_coord_offset+DIM*1+XX];
521 iy1 = shY + x[i_coord_offset+DIM*1+YY];
522 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
523 ix2 = shX + x[i_coord_offset+DIM*2+XX];
524 iy2 = shY + x[i_coord_offset+DIM*2+YY];
525 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
526 ix3 = shX + x[i_coord_offset+DIM*3+XX];
527 iy3 = shY + x[i_coord_offset+DIM*3+YY];
528 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
543 /* Start inner kernel loop */
544 for(jidx=j_index_start; jidx<j_index_end; jidx++)
546 /* Get j neighbor index, and coordinate index */
548 j_coord_offset = DIM*jnr;
550 /* load j atom coordinates */
551 jx0 = x[j_coord_offset+DIM*0+XX];
552 jy0 = x[j_coord_offset+DIM*0+YY];
553 jz0 = x[j_coord_offset+DIM*0+ZZ];
555 /* Calculate displacement vector */
569 /* Calculate squared distance and things based on it */
570 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
571 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
572 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
573 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
575 rinv00 = gmx_invsqrt(rsq00);
576 rinv10 = gmx_invsqrt(rsq10);
577 rinv20 = gmx_invsqrt(rsq20);
578 rinv30 = gmx_invsqrt(rsq30);
580 rinvsq00 = rinv00*rinv00;
581 rinvsq10 = rinv10*rinv10;
582 rinvsq20 = rinv20*rinv20;
583 rinvsq30 = rinv30*rinv30;
585 /* Load parameters for j particles */
587 vdwjidx0 = 3*vdwtype[jnr+0];
589 /**************************
590 * CALCULATE INTERACTIONS *
591 **************************/
595 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
596 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
597 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
599 /* BUCKINGHAM DISPERSION/REPULSION */
600 rinvsix = rinvsq00*rinvsq00*rinvsq00;
601 vvdw6 = c6_00*rinvsix;
603 vvdwexp = cexp1_00*exp(-br);
604 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
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 /* EWALD ELECTROSTATICS */
631 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
632 ewrt = r10*ewtabscale;
635 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
636 felec = qq10*rinv10*(rinvsq10-felec);
640 /* Calculate temporary vectorial force */
645 /* Update vectorial force */
649 f[j_coord_offset+DIM*0+XX] -= tx;
650 f[j_coord_offset+DIM*0+YY] -= ty;
651 f[j_coord_offset+DIM*0+ZZ] -= tz;
653 /**************************
654 * CALCULATE INTERACTIONS *
655 **************************/
661 /* EWALD ELECTROSTATICS */
663 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
664 ewrt = r20*ewtabscale;
667 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
668 felec = qq20*rinv20*(rinvsq20-felec);
672 /* Calculate temporary vectorial force */
677 /* Update vectorial force */
681 f[j_coord_offset+DIM*0+XX] -= tx;
682 f[j_coord_offset+DIM*0+YY] -= ty;
683 f[j_coord_offset+DIM*0+ZZ] -= tz;
685 /**************************
686 * CALCULATE INTERACTIONS *
687 **************************/
693 /* EWALD ELECTROSTATICS */
695 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
696 ewrt = r30*ewtabscale;
699 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
700 felec = qq30*rinv30*(rinvsq30-felec);
704 /* Calculate temporary vectorial force */
709 /* Update vectorial force */
713 f[j_coord_offset+DIM*0+XX] -= tx;
714 f[j_coord_offset+DIM*0+YY] -= ty;
715 f[j_coord_offset+DIM*0+ZZ] -= tz;
717 /* Inner loop uses 160 flops */
719 /* End of innermost loop */
722 f[i_coord_offset+DIM*0+XX] += fix0;
723 f[i_coord_offset+DIM*0+YY] += fiy0;
724 f[i_coord_offset+DIM*0+ZZ] += fiz0;
728 f[i_coord_offset+DIM*1+XX] += fix1;
729 f[i_coord_offset+DIM*1+YY] += fiy1;
730 f[i_coord_offset+DIM*1+ZZ] += fiz1;
734 f[i_coord_offset+DIM*2+XX] += fix2;
735 f[i_coord_offset+DIM*2+YY] += fiy2;
736 f[i_coord_offset+DIM*2+ZZ] += fiz2;
740 f[i_coord_offset+DIM*3+XX] += fix3;
741 f[i_coord_offset+DIM*3+YY] += fiy3;
742 f[i_coord_offset+DIM*3+ZZ] += fiz3;
746 fshift[i_shift_offset+XX] += tx;
747 fshift[i_shift_offset+YY] += ty;
748 fshift[i_shift_offset+ZZ] += tz;
750 /* Increment number of inner iterations */
751 inneriter += j_index_end - j_index_start;
753 /* Outer loop uses 39 flops */
756 /* Increment number of outer iterations */
759 /* Update outer/inner flops */
761 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*160);