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_ElecEwSh_VdwBhamSh_GeomW4P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwBhamSh_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];
125 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
126 rcutoff = fr->rcoulomb;
127 rcutoff2 = rcutoff*rcutoff;
129 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
140 shX = shiftvec[i_shift_offset+XX];
141 shY = shiftvec[i_shift_offset+YY];
142 shZ = shiftvec[i_shift_offset+ZZ];
144 /* Load limits for loop over neighbors */
145 j_index_start = jindex[iidx];
146 j_index_end = jindex[iidx+1];
148 /* Get outer coordinate index */
150 i_coord_offset = DIM*inr;
152 /* Load i particle coords and add shift vector */
153 ix0 = shX + x[i_coord_offset+DIM*0+XX];
154 iy0 = shY + x[i_coord_offset+DIM*0+YY];
155 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
156 ix1 = shX + x[i_coord_offset+DIM*1+XX];
157 iy1 = shY + x[i_coord_offset+DIM*1+YY];
158 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
159 ix2 = shX + x[i_coord_offset+DIM*2+XX];
160 iy2 = shY + x[i_coord_offset+DIM*2+YY];
161 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
162 ix3 = shX + x[i_coord_offset+DIM*3+XX];
163 iy3 = shY + x[i_coord_offset+DIM*3+YY];
164 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
179 /* Reset potential sums */
183 /* Start inner kernel loop */
184 for(jidx=j_index_start; jidx<j_index_end; jidx++)
186 /* Get j neighbor index, and coordinate index */
188 j_coord_offset = DIM*jnr;
190 /* load j atom coordinates */
191 jx0 = x[j_coord_offset+DIM*0+XX];
192 jy0 = x[j_coord_offset+DIM*0+YY];
193 jz0 = x[j_coord_offset+DIM*0+ZZ];
195 /* Calculate displacement vector */
209 /* Calculate squared distance and things based on it */
210 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
211 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
212 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
213 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
215 rinv00 = gmx_invsqrt(rsq00);
216 rinv10 = gmx_invsqrt(rsq10);
217 rinv20 = gmx_invsqrt(rsq20);
218 rinv30 = gmx_invsqrt(rsq30);
220 rinvsq00 = rinv00*rinv00;
221 rinvsq10 = rinv10*rinv10;
222 rinvsq20 = rinv20*rinv20;
223 rinvsq30 = rinv30*rinv30;
225 /* Load parameters for j particles */
227 vdwjidx0 = 3*vdwtype[jnr+0];
229 /**************************
230 * CALCULATE INTERACTIONS *
231 **************************/
238 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
239 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
240 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
242 /* BUCKINGHAM DISPERSION/REPULSION */
243 rinvsix = rinvsq00*rinvsq00*rinvsq00;
244 vvdw6 = c6_00*rinvsix;
246 vvdwexp = cexp1_00*exp(-br);
247 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
248 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
250 /* Update potential sums from outer loop */
255 /* Calculate temporary vectorial force */
260 /* Update vectorial force */
264 f[j_coord_offset+DIM*0+XX] -= tx;
265 f[j_coord_offset+DIM*0+YY] -= ty;
266 f[j_coord_offset+DIM*0+ZZ] -= tz;
270 /**************************
271 * CALCULATE INTERACTIONS *
272 **************************/
281 /* EWALD ELECTROSTATICS */
283 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
284 ewrt = r10*ewtabscale;
288 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
289 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
290 felec = qq10*rinv10*(rinvsq10-felec);
292 /* Update potential sums from outer loop */
297 /* Calculate temporary vectorial force */
302 /* Update vectorial force */
306 f[j_coord_offset+DIM*0+XX] -= tx;
307 f[j_coord_offset+DIM*0+YY] -= ty;
308 f[j_coord_offset+DIM*0+ZZ] -= tz;
312 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
323 /* EWALD ELECTROSTATICS */
325 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
326 ewrt = r20*ewtabscale;
330 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
331 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
332 felec = qq20*rinv20*(rinvsq20-felec);
334 /* Update potential sums from outer loop */
339 /* Calculate temporary vectorial force */
344 /* Update vectorial force */
348 f[j_coord_offset+DIM*0+XX] -= tx;
349 f[j_coord_offset+DIM*0+YY] -= ty;
350 f[j_coord_offset+DIM*0+ZZ] -= tz;
354 /**************************
355 * CALCULATE INTERACTIONS *
356 **************************/
365 /* EWALD ELECTROSTATICS */
367 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
368 ewrt = r30*ewtabscale;
372 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
373 velec = qq30*((rinv30-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
374 felec = qq30*rinv30*(rinvsq30-felec);
376 /* Update potential sums from outer loop */
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*0+XX] -= tx;
391 f[j_coord_offset+DIM*0+YY] -= ty;
392 f[j_coord_offset+DIM*0+ZZ] -= tz;
396 /* Inner loop uses 218 flops */
398 /* End of innermost loop */
401 f[i_coord_offset+DIM*0+XX] += fix0;
402 f[i_coord_offset+DIM*0+YY] += fiy0;
403 f[i_coord_offset+DIM*0+ZZ] += fiz0;
407 f[i_coord_offset+DIM*1+XX] += fix1;
408 f[i_coord_offset+DIM*1+YY] += fiy1;
409 f[i_coord_offset+DIM*1+ZZ] += fiz1;
413 f[i_coord_offset+DIM*2+XX] += fix2;
414 f[i_coord_offset+DIM*2+YY] += fiy2;
415 f[i_coord_offset+DIM*2+ZZ] += fiz2;
419 f[i_coord_offset+DIM*3+XX] += fix3;
420 f[i_coord_offset+DIM*3+YY] += fiy3;
421 f[i_coord_offset+DIM*3+ZZ] += fiz3;
425 fshift[i_shift_offset+XX] += tx;
426 fshift[i_shift_offset+YY] += ty;
427 fshift[i_shift_offset+ZZ] += tz;
430 /* Update potential energies */
431 kernel_data->energygrp_elec[ggid] += velecsum;
432 kernel_data->energygrp_vdw[ggid] += vvdwsum;
434 /* Increment number of inner iterations */
435 inneriter += j_index_end - j_index_start;
437 /* Outer loop uses 41 flops */
440 /* Increment number of outer iterations */
443 /* Update outer/inner flops */
445 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*218);
448 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4P1_F_c
449 * Electrostatics interaction: Ewald
450 * VdW interaction: Buckingham
451 * Geometry: Water4-Particle
452 * Calculate force/pot: Force
455 nb_kernel_ElecEwSh_VdwBhamSh_GeomW4P1_F_c
456 (t_nblist * gmx_restrict nlist,
457 rvec * gmx_restrict xx,
458 rvec * gmx_restrict ff,
459 t_forcerec * gmx_restrict fr,
460 t_mdatoms * gmx_restrict mdatoms,
461 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
462 t_nrnb * gmx_restrict nrnb)
464 int i_shift_offset,i_coord_offset,j_coord_offset;
465 int j_index_start,j_index_end;
466 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
467 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
468 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
469 real *shiftvec,*fshift,*x,*f;
471 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
473 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
475 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
477 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
479 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
480 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
481 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
482 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
483 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
484 real velec,felec,velecsum,facel,crf,krf,krf2;
487 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
491 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
499 jindex = nlist->jindex;
501 shiftidx = nlist->shift;
503 shiftvec = fr->shift_vec[0];
504 fshift = fr->fshift[0];
506 charge = mdatoms->chargeA;
507 nvdwtype = fr->ntype;
509 vdwtype = mdatoms->typeA;
511 sh_ewald = fr->ic->sh_ewald;
512 ewtab = fr->ic->tabq_coul_F;
513 ewtabscale = fr->ic->tabq_scale;
514 ewtabhalfspace = 0.5/ewtabscale;
516 /* Setup water-specific parameters */
517 inr = nlist->iinr[0];
518 iq1 = facel*charge[inr+1];
519 iq2 = facel*charge[inr+2];
520 iq3 = facel*charge[inr+3];
521 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
523 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
524 rcutoff = fr->rcoulomb;
525 rcutoff2 = rcutoff*rcutoff;
527 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
533 /* Start outer loop over neighborlists */
534 for(iidx=0; iidx<nri; iidx++)
536 /* Load shift vector for this list */
537 i_shift_offset = DIM*shiftidx[iidx];
538 shX = shiftvec[i_shift_offset+XX];
539 shY = shiftvec[i_shift_offset+YY];
540 shZ = shiftvec[i_shift_offset+ZZ];
542 /* Load limits for loop over neighbors */
543 j_index_start = jindex[iidx];
544 j_index_end = jindex[iidx+1];
546 /* Get outer coordinate index */
548 i_coord_offset = DIM*inr;
550 /* Load i particle coords and add shift vector */
551 ix0 = shX + x[i_coord_offset+DIM*0+XX];
552 iy0 = shY + x[i_coord_offset+DIM*0+YY];
553 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
554 ix1 = shX + x[i_coord_offset+DIM*1+XX];
555 iy1 = shY + x[i_coord_offset+DIM*1+YY];
556 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
557 ix2 = shX + x[i_coord_offset+DIM*2+XX];
558 iy2 = shY + x[i_coord_offset+DIM*2+YY];
559 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
560 ix3 = shX + x[i_coord_offset+DIM*3+XX];
561 iy3 = shY + x[i_coord_offset+DIM*3+YY];
562 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
577 /* Start inner kernel loop */
578 for(jidx=j_index_start; jidx<j_index_end; jidx++)
580 /* Get j neighbor index, and coordinate index */
582 j_coord_offset = DIM*jnr;
584 /* load j atom coordinates */
585 jx0 = x[j_coord_offset+DIM*0+XX];
586 jy0 = x[j_coord_offset+DIM*0+YY];
587 jz0 = x[j_coord_offset+DIM*0+ZZ];
589 /* Calculate displacement vector */
603 /* Calculate squared distance and things based on it */
604 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
605 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
606 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
607 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
609 rinv00 = gmx_invsqrt(rsq00);
610 rinv10 = gmx_invsqrt(rsq10);
611 rinv20 = gmx_invsqrt(rsq20);
612 rinv30 = gmx_invsqrt(rsq30);
614 rinvsq00 = rinv00*rinv00;
615 rinvsq10 = rinv10*rinv10;
616 rinvsq20 = rinv20*rinv20;
617 rinvsq30 = rinv30*rinv30;
619 /* Load parameters for j particles */
621 vdwjidx0 = 3*vdwtype[jnr+0];
623 /**************************
624 * CALCULATE INTERACTIONS *
625 **************************/
632 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
633 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
634 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
636 /* BUCKINGHAM DISPERSION/REPULSION */
637 rinvsix = rinvsq00*rinvsq00*rinvsq00;
638 vvdw6 = c6_00*rinvsix;
640 vvdwexp = cexp1_00*exp(-br);
641 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
645 /* Calculate temporary vectorial force */
650 /* Update vectorial force */
654 f[j_coord_offset+DIM*0+XX] -= tx;
655 f[j_coord_offset+DIM*0+YY] -= ty;
656 f[j_coord_offset+DIM*0+ZZ] -= tz;
660 /**************************
661 * CALCULATE INTERACTIONS *
662 **************************/
671 /* EWALD ELECTROSTATICS */
673 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
674 ewrt = r10*ewtabscale;
677 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
678 felec = qq10*rinv10*(rinvsq10-felec);
682 /* Calculate temporary vectorial force */
687 /* Update vectorial force */
691 f[j_coord_offset+DIM*0+XX] -= tx;
692 f[j_coord_offset+DIM*0+YY] -= ty;
693 f[j_coord_offset+DIM*0+ZZ] -= tz;
697 /**************************
698 * CALCULATE INTERACTIONS *
699 **************************/
708 /* EWALD ELECTROSTATICS */
710 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
711 ewrt = r20*ewtabscale;
714 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
715 felec = qq20*rinv20*(rinvsq20-felec);
719 /* Calculate temporary vectorial force */
724 /* Update vectorial force */
728 f[j_coord_offset+DIM*0+XX] -= tx;
729 f[j_coord_offset+DIM*0+YY] -= ty;
730 f[j_coord_offset+DIM*0+ZZ] -= tz;
734 /**************************
735 * CALCULATE INTERACTIONS *
736 **************************/
745 /* EWALD ELECTROSTATICS */
747 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
748 ewrt = r30*ewtabscale;
751 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
752 felec = qq30*rinv30*(rinvsq30-felec);
756 /* Calculate temporary vectorial force */
761 /* Update vectorial force */
765 f[j_coord_offset+DIM*0+XX] -= tx;
766 f[j_coord_offset+DIM*0+YY] -= ty;
767 f[j_coord_offset+DIM*0+ZZ] -= tz;
771 /* Inner loop uses 160 flops */
773 /* End of innermost loop */
776 f[i_coord_offset+DIM*0+XX] += fix0;
777 f[i_coord_offset+DIM*0+YY] += fiy0;
778 f[i_coord_offset+DIM*0+ZZ] += fiz0;
782 f[i_coord_offset+DIM*1+XX] += fix1;
783 f[i_coord_offset+DIM*1+YY] += fiy1;
784 f[i_coord_offset+DIM*1+ZZ] += fiz1;
788 f[i_coord_offset+DIM*2+XX] += fix2;
789 f[i_coord_offset+DIM*2+YY] += fiy2;
790 f[i_coord_offset+DIM*2+ZZ] += fiz2;
794 f[i_coord_offset+DIM*3+XX] += fix3;
795 f[i_coord_offset+DIM*3+YY] += fiy3;
796 f[i_coord_offset+DIM*3+ZZ] += fiz3;
800 fshift[i_shift_offset+XX] += tx;
801 fshift[i_shift_offset+YY] += ty;
802 fshift[i_shift_offset+ZZ] += tz;
804 /* Increment number of inner iterations */
805 inneriter += j_index_end - j_index_start;
807 /* Outer loop uses 39 flops */
810 /* Increment number of outer iterations */
813 /* Update outer/inner flops */
815 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*160);