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_ElecRFCut_VdwBhamSw_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwBhamSw_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;
92 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
99 jindex = nlist->jindex;
101 shiftidx = nlist->shift;
103 shiftvec = fr->shift_vec[0];
104 fshift = fr->fshift[0];
106 charge = mdatoms->chargeA;
110 nvdwtype = fr->ntype;
112 vdwtype = mdatoms->typeA;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 iq3 = facel*charge[inr+3];
119 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
121 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
122 rcutoff = fr->rcoulomb;
123 rcutoff2 = rcutoff*rcutoff;
125 rswitch = fr->rvdw_switch;
126 /* Setup switch parameters */
128 swV3 = -10.0/(d*d*d);
129 swV4 = 15.0/(d*d*d*d);
130 swV5 = -6.0/(d*d*d*d*d);
131 swF2 = -30.0/(d*d*d);
132 swF3 = 60.0/(d*d*d*d);
133 swF4 = -30.0/(d*d*d*d*d);
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
143 shX = shiftvec[i_shift_offset+XX];
144 shY = shiftvec[i_shift_offset+YY];
145 shZ = shiftvec[i_shift_offset+ZZ];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 ix0 = shX + x[i_coord_offset+DIM*0+XX];
157 iy0 = shY + x[i_coord_offset+DIM*0+YY];
158 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
159 ix1 = shX + x[i_coord_offset+DIM*1+XX];
160 iy1 = shY + x[i_coord_offset+DIM*1+YY];
161 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
162 ix2 = shX + x[i_coord_offset+DIM*2+XX];
163 iy2 = shY + x[i_coord_offset+DIM*2+YY];
164 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
165 ix3 = shX + x[i_coord_offset+DIM*3+XX];
166 iy3 = shY + x[i_coord_offset+DIM*3+YY];
167 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
182 /* Reset potential sums */
186 /* Start inner kernel loop */
187 for(jidx=j_index_start; jidx<j_index_end; jidx++)
189 /* Get j neighbor index, and coordinate index */
191 j_coord_offset = DIM*jnr;
193 /* load j atom coordinates */
194 jx0 = x[j_coord_offset+DIM*0+XX];
195 jy0 = x[j_coord_offset+DIM*0+YY];
196 jz0 = x[j_coord_offset+DIM*0+ZZ];
198 /* Calculate displacement vector */
212 /* Calculate squared distance and things based on it */
213 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
214 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
215 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
216 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
218 rinv00 = gmx_invsqrt(rsq00);
219 rinv10 = gmx_invsqrt(rsq10);
220 rinv20 = gmx_invsqrt(rsq20);
221 rinv30 = gmx_invsqrt(rsq30);
223 rinvsq00 = rinv00*rinv00;
224 rinvsq10 = rinv10*rinv10;
225 rinvsq20 = rinv20*rinv20;
226 rinvsq30 = rinv30*rinv30;
228 /* Load parameters for j particles */
230 vdwjidx0 = 3*vdwtype[jnr+0];
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
241 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
242 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
243 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
245 /* BUCKINGHAM DISPERSION/REPULSION */
246 rinvsix = rinvsq00*rinvsq00*rinvsq00;
247 vvdw6 = c6_00*rinvsix;
249 vvdwexp = cexp1_00*exp(-br);
250 vvdw = vvdwexp - vvdw6*(1.0/6.0);
251 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
254 d = (d>0.0) ? d : 0.0;
256 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
258 dsw = d2*(swF2+d*(swF3+d*swF4));
260 /* Evaluate switch function */
261 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
262 fvdw = fvdw*sw - rinv00*vvdw*dsw;
265 /* Update potential sums from outer loop */
270 /* Calculate temporary vectorial force */
275 /* Update vectorial force */
279 f[j_coord_offset+DIM*0+XX] -= tx;
280 f[j_coord_offset+DIM*0+YY] -= ty;
281 f[j_coord_offset+DIM*0+ZZ] -= tz;
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
294 /* REACTION-FIELD ELECTROSTATICS */
295 velec = qq10*(rinv10+krf*rsq10-crf);
296 felec = qq10*(rinv10*rinvsq10-krf2);
298 /* Update potential sums from outer loop */
303 /* Calculate temporary vectorial force */
308 /* Update vectorial force */
312 f[j_coord_offset+DIM*0+XX] -= tx;
313 f[j_coord_offset+DIM*0+YY] -= ty;
314 f[j_coord_offset+DIM*0+ZZ] -= tz;
318 /**************************
319 * CALCULATE INTERACTIONS *
320 **************************/
327 /* REACTION-FIELD ELECTROSTATICS */
328 velec = qq20*(rinv20+krf*rsq20-crf);
329 felec = qq20*(rinv20*rinvsq20-krf2);
331 /* Update potential sums from outer loop */
336 /* Calculate temporary vectorial force */
341 /* Update vectorial force */
345 f[j_coord_offset+DIM*0+XX] -= tx;
346 f[j_coord_offset+DIM*0+YY] -= ty;
347 f[j_coord_offset+DIM*0+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = qq30*(rinv30+krf*rsq30-crf);
362 felec = qq30*(rinv30*rinvsq30-krf2);
364 /* Update potential sums from outer loop */
369 /* Calculate temporary vectorial force */
374 /* Update vectorial force */
378 f[j_coord_offset+DIM*0+XX] -= tx;
379 f[j_coord_offset+DIM*0+YY] -= ty;
380 f[j_coord_offset+DIM*0+ZZ] -= tz;
384 /* Inner loop uses 175 flops */
386 /* End of innermost loop */
389 f[i_coord_offset+DIM*0+XX] += fix0;
390 f[i_coord_offset+DIM*0+YY] += fiy0;
391 f[i_coord_offset+DIM*0+ZZ] += fiz0;
395 f[i_coord_offset+DIM*1+XX] += fix1;
396 f[i_coord_offset+DIM*1+YY] += fiy1;
397 f[i_coord_offset+DIM*1+ZZ] += fiz1;
401 f[i_coord_offset+DIM*2+XX] += fix2;
402 f[i_coord_offset+DIM*2+YY] += fiy2;
403 f[i_coord_offset+DIM*2+ZZ] += fiz2;
407 f[i_coord_offset+DIM*3+XX] += fix3;
408 f[i_coord_offset+DIM*3+YY] += fiy3;
409 f[i_coord_offset+DIM*3+ZZ] += fiz3;
413 fshift[i_shift_offset+XX] += tx;
414 fshift[i_shift_offset+YY] += ty;
415 fshift[i_shift_offset+ZZ] += tz;
418 /* Update potential energies */
419 kernel_data->energygrp_elec[ggid] += velecsum;
420 kernel_data->energygrp_vdw[ggid] += vvdwsum;
422 /* Increment number of inner iterations */
423 inneriter += j_index_end - j_index_start;
425 /* Outer loop uses 41 flops */
428 /* Increment number of outer iterations */
431 /* Update outer/inner flops */
433 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*175);
436 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW4P1_F_c
437 * Electrostatics interaction: ReactionField
438 * VdW interaction: Buckingham
439 * Geometry: Water4-Particle
440 * Calculate force/pot: Force
443 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4P1_F_c
444 (t_nblist * gmx_restrict nlist,
445 rvec * gmx_restrict xx,
446 rvec * gmx_restrict ff,
447 t_forcerec * gmx_restrict fr,
448 t_mdatoms * gmx_restrict mdatoms,
449 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
450 t_nrnb * gmx_restrict nrnb)
452 int i_shift_offset,i_coord_offset,j_coord_offset;
453 int j_index_start,j_index_end;
454 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
455 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
456 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
457 real *shiftvec,*fshift,*x,*f;
459 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
461 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
463 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
465 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
467 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
468 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
469 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
470 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
471 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
472 real velec,felec,velecsum,facel,crf,krf,krf2;
475 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
478 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
485 jindex = nlist->jindex;
487 shiftidx = nlist->shift;
489 shiftvec = fr->shift_vec[0];
490 fshift = fr->fshift[0];
492 charge = mdatoms->chargeA;
496 nvdwtype = fr->ntype;
498 vdwtype = mdatoms->typeA;
500 /* Setup water-specific parameters */
501 inr = nlist->iinr[0];
502 iq1 = facel*charge[inr+1];
503 iq2 = facel*charge[inr+2];
504 iq3 = facel*charge[inr+3];
505 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
507 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
508 rcutoff = fr->rcoulomb;
509 rcutoff2 = rcutoff*rcutoff;
511 rswitch = fr->rvdw_switch;
512 /* Setup switch parameters */
514 swV3 = -10.0/(d*d*d);
515 swV4 = 15.0/(d*d*d*d);
516 swV5 = -6.0/(d*d*d*d*d);
517 swF2 = -30.0/(d*d*d);
518 swF3 = 60.0/(d*d*d*d);
519 swF4 = -30.0/(d*d*d*d*d);
524 /* Start outer loop over neighborlists */
525 for(iidx=0; iidx<nri; iidx++)
527 /* Load shift vector for this list */
528 i_shift_offset = DIM*shiftidx[iidx];
529 shX = shiftvec[i_shift_offset+XX];
530 shY = shiftvec[i_shift_offset+YY];
531 shZ = shiftvec[i_shift_offset+ZZ];
533 /* Load limits for loop over neighbors */
534 j_index_start = jindex[iidx];
535 j_index_end = jindex[iidx+1];
537 /* Get outer coordinate index */
539 i_coord_offset = DIM*inr;
541 /* Load i particle coords and add shift vector */
542 ix0 = shX + x[i_coord_offset+DIM*0+XX];
543 iy0 = shY + x[i_coord_offset+DIM*0+YY];
544 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
545 ix1 = shX + x[i_coord_offset+DIM*1+XX];
546 iy1 = shY + x[i_coord_offset+DIM*1+YY];
547 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
548 ix2 = shX + x[i_coord_offset+DIM*2+XX];
549 iy2 = shY + x[i_coord_offset+DIM*2+YY];
550 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
551 ix3 = shX + x[i_coord_offset+DIM*3+XX];
552 iy3 = shY + x[i_coord_offset+DIM*3+YY];
553 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
568 /* Start inner kernel loop */
569 for(jidx=j_index_start; jidx<j_index_end; jidx++)
571 /* Get j neighbor index, and coordinate index */
573 j_coord_offset = DIM*jnr;
575 /* load j atom coordinates */
576 jx0 = x[j_coord_offset+DIM*0+XX];
577 jy0 = x[j_coord_offset+DIM*0+YY];
578 jz0 = x[j_coord_offset+DIM*0+ZZ];
580 /* Calculate displacement vector */
594 /* Calculate squared distance and things based on it */
595 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
596 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
597 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
598 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
600 rinv00 = gmx_invsqrt(rsq00);
601 rinv10 = gmx_invsqrt(rsq10);
602 rinv20 = gmx_invsqrt(rsq20);
603 rinv30 = gmx_invsqrt(rsq30);
605 rinvsq00 = rinv00*rinv00;
606 rinvsq10 = rinv10*rinv10;
607 rinvsq20 = rinv20*rinv20;
608 rinvsq30 = rinv30*rinv30;
610 /* Load parameters for j particles */
612 vdwjidx0 = 3*vdwtype[jnr+0];
614 /**************************
615 * CALCULATE INTERACTIONS *
616 **************************/
623 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
624 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
625 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
627 /* BUCKINGHAM DISPERSION/REPULSION */
628 rinvsix = rinvsq00*rinvsq00*rinvsq00;
629 vvdw6 = c6_00*rinvsix;
631 vvdwexp = cexp1_00*exp(-br);
632 vvdw = vvdwexp - vvdw6*(1.0/6.0);
633 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
636 d = (d>0.0) ? d : 0.0;
638 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
640 dsw = d2*(swF2+d*(swF3+d*swF4));
642 /* Evaluate switch function */
643 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
644 fvdw = fvdw*sw - rinv00*vvdw*dsw;
648 /* Calculate temporary vectorial force */
653 /* Update vectorial force */
657 f[j_coord_offset+DIM*0+XX] -= tx;
658 f[j_coord_offset+DIM*0+YY] -= ty;
659 f[j_coord_offset+DIM*0+ZZ] -= tz;
663 /**************************
664 * CALCULATE INTERACTIONS *
665 **************************/
672 /* REACTION-FIELD ELECTROSTATICS */
673 felec = qq10*(rinv10*rinvsq10-krf2);
677 /* Calculate temporary vectorial force */
682 /* Update vectorial force */
686 f[j_coord_offset+DIM*0+XX] -= tx;
687 f[j_coord_offset+DIM*0+YY] -= ty;
688 f[j_coord_offset+DIM*0+ZZ] -= tz;
692 /**************************
693 * CALCULATE INTERACTIONS *
694 **************************/
701 /* REACTION-FIELD ELECTROSTATICS */
702 felec = qq20*(rinv20*rinvsq20-krf2);
706 /* Calculate temporary vectorial force */
711 /* Update vectorial force */
715 f[j_coord_offset+DIM*0+XX] -= tx;
716 f[j_coord_offset+DIM*0+YY] -= ty;
717 f[j_coord_offset+DIM*0+ZZ] -= tz;
721 /**************************
722 * CALCULATE INTERACTIONS *
723 **************************/
730 /* REACTION-FIELD ELECTROSTATICS */
731 felec = qq30*(rinv30*rinvsq30-krf2);
735 /* Calculate temporary vectorial force */
740 /* Update vectorial force */
744 f[j_coord_offset+DIM*0+XX] -= tx;
745 f[j_coord_offset+DIM*0+YY] -= ty;
746 f[j_coord_offset+DIM*0+ZZ] -= tz;
750 /* Inner loop uses 158 flops */
752 /* End of innermost loop */
755 f[i_coord_offset+DIM*0+XX] += fix0;
756 f[i_coord_offset+DIM*0+YY] += fiy0;
757 f[i_coord_offset+DIM*0+ZZ] += fiz0;
761 f[i_coord_offset+DIM*1+XX] += fix1;
762 f[i_coord_offset+DIM*1+YY] += fiy1;
763 f[i_coord_offset+DIM*1+ZZ] += fiz1;
767 f[i_coord_offset+DIM*2+XX] += fix2;
768 f[i_coord_offset+DIM*2+YY] += fiy2;
769 f[i_coord_offset+DIM*2+ZZ] += fiz2;
773 f[i_coord_offset+DIM*3+XX] += fix3;
774 f[i_coord_offset+DIM*3+YY] += fiy3;
775 f[i_coord_offset+DIM*3+ZZ] += fiz3;
779 fshift[i_shift_offset+XX] += tx;
780 fshift[i_shift_offset+YY] += ty;
781 fshift[i_shift_offset+ZZ] += tz;
783 /* Increment number of inner iterations */
784 inneriter += j_index_end - j_index_start;
786 /* Outer loop uses 39 flops */
789 /* Increment number of outer iterations */
792 /* Update outer/inner flops */
794 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*158);