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_VdwLJSw_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSw_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 = 2*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 = 2*vdwtype[jnr+0];
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
241 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
242 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
244 /* LENNARD-JONES DISPERSION/REPULSION */
246 rinvsix = rinvsq00*rinvsq00*rinvsq00;
247 vvdw6 = c6_00*rinvsix;
248 vvdw12 = c12_00*rinvsix*rinvsix;
249 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
250 fvdw = (vvdw12-vvdw6)*rinvsq00;
253 d = (d>0.0) ? d : 0.0;
255 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
257 dsw = d2*(swF2+d*(swF3+d*swF4));
259 /* Evaluate switch function */
260 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
261 fvdw = fvdw*sw - rinv00*vvdw*dsw;
264 /* Update potential sums from outer loop */
269 /* Calculate temporary vectorial force */
274 /* Update vectorial force */
278 f[j_coord_offset+DIM*0+XX] -= tx;
279 f[j_coord_offset+DIM*0+YY] -= ty;
280 f[j_coord_offset+DIM*0+ZZ] -= tz;
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
293 /* REACTION-FIELD ELECTROSTATICS */
294 velec = qq10*(rinv10+krf*rsq10-crf);
295 felec = qq10*(rinv10*rinvsq10-krf2);
297 /* Update potential sums from outer loop */
302 /* Calculate temporary vectorial force */
307 /* Update vectorial force */
311 f[j_coord_offset+DIM*0+XX] -= tx;
312 f[j_coord_offset+DIM*0+YY] -= ty;
313 f[j_coord_offset+DIM*0+ZZ] -= tz;
317 /**************************
318 * CALCULATE INTERACTIONS *
319 **************************/
326 /* REACTION-FIELD ELECTROSTATICS */
327 velec = qq20*(rinv20+krf*rsq20-crf);
328 felec = qq20*(rinv20*rinvsq20-krf2);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*0+XX] -= tx;
345 f[j_coord_offset+DIM*0+YY] -= ty;
346 f[j_coord_offset+DIM*0+ZZ] -= tz;
350 /**************************
351 * CALCULATE INTERACTIONS *
352 **************************/
359 /* REACTION-FIELD ELECTROSTATICS */
360 velec = qq30*(rinv30+krf*rsq30-crf);
361 felec = qq30*(rinv30*rinvsq30-krf2);
363 /* Update potential sums from outer loop */
368 /* Calculate temporary vectorial force */
373 /* Update vectorial force */
377 f[j_coord_offset+DIM*0+XX] -= tx;
378 f[j_coord_offset+DIM*0+YY] -= ty;
379 f[j_coord_offset+DIM*0+ZZ] -= tz;
383 /* Inner loop uses 149 flops */
385 /* End of innermost loop */
388 f[i_coord_offset+DIM*0+XX] += fix0;
389 f[i_coord_offset+DIM*0+YY] += fiy0;
390 f[i_coord_offset+DIM*0+ZZ] += fiz0;
394 f[i_coord_offset+DIM*1+XX] += fix1;
395 f[i_coord_offset+DIM*1+YY] += fiy1;
396 f[i_coord_offset+DIM*1+ZZ] += fiz1;
400 f[i_coord_offset+DIM*2+XX] += fix2;
401 f[i_coord_offset+DIM*2+YY] += fiy2;
402 f[i_coord_offset+DIM*2+ZZ] += fiz2;
406 f[i_coord_offset+DIM*3+XX] += fix3;
407 f[i_coord_offset+DIM*3+YY] += fiy3;
408 f[i_coord_offset+DIM*3+ZZ] += fiz3;
412 fshift[i_shift_offset+XX] += tx;
413 fshift[i_shift_offset+YY] += ty;
414 fshift[i_shift_offset+ZZ] += tz;
417 /* Update potential energies */
418 kernel_data->energygrp_elec[ggid] += velecsum;
419 kernel_data->energygrp_vdw[ggid] += vvdwsum;
421 /* Increment number of inner iterations */
422 inneriter += j_index_end - j_index_start;
424 /* Outer loop uses 41 flops */
427 /* Increment number of outer iterations */
430 /* Update outer/inner flops */
432 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*149);
435 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_c
436 * Electrostatics interaction: ReactionField
437 * VdW interaction: LennardJones
438 * Geometry: Water4-Particle
439 * Calculate force/pot: Force
442 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_c
443 (t_nblist * gmx_restrict nlist,
444 rvec * gmx_restrict xx,
445 rvec * gmx_restrict ff,
446 t_forcerec * gmx_restrict fr,
447 t_mdatoms * gmx_restrict mdatoms,
448 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
449 t_nrnb * gmx_restrict nrnb)
451 int i_shift_offset,i_coord_offset,j_coord_offset;
452 int j_index_start,j_index_end;
453 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
454 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
455 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
456 real *shiftvec,*fshift,*x,*f;
458 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
460 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
462 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
464 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
466 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
467 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
468 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
469 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
470 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
471 real velec,felec,velecsum,facel,crf,krf,krf2;
474 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
477 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
484 jindex = nlist->jindex;
486 shiftidx = nlist->shift;
488 shiftvec = fr->shift_vec[0];
489 fshift = fr->fshift[0];
491 charge = mdatoms->chargeA;
495 nvdwtype = fr->ntype;
497 vdwtype = mdatoms->typeA;
499 /* Setup water-specific parameters */
500 inr = nlist->iinr[0];
501 iq1 = facel*charge[inr+1];
502 iq2 = facel*charge[inr+2];
503 iq3 = facel*charge[inr+3];
504 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
506 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
507 rcutoff = fr->rcoulomb;
508 rcutoff2 = rcutoff*rcutoff;
510 rswitch = fr->rvdw_switch;
511 /* Setup switch parameters */
513 swV3 = -10.0/(d*d*d);
514 swV4 = 15.0/(d*d*d*d);
515 swV5 = -6.0/(d*d*d*d*d);
516 swF2 = -30.0/(d*d*d);
517 swF3 = 60.0/(d*d*d*d);
518 swF4 = -30.0/(d*d*d*d*d);
523 /* Start outer loop over neighborlists */
524 for(iidx=0; iidx<nri; iidx++)
526 /* Load shift vector for this list */
527 i_shift_offset = DIM*shiftidx[iidx];
528 shX = shiftvec[i_shift_offset+XX];
529 shY = shiftvec[i_shift_offset+YY];
530 shZ = shiftvec[i_shift_offset+ZZ];
532 /* Load limits for loop over neighbors */
533 j_index_start = jindex[iidx];
534 j_index_end = jindex[iidx+1];
536 /* Get outer coordinate index */
538 i_coord_offset = DIM*inr;
540 /* Load i particle coords and add shift vector */
541 ix0 = shX + x[i_coord_offset+DIM*0+XX];
542 iy0 = shY + x[i_coord_offset+DIM*0+YY];
543 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
544 ix1 = shX + x[i_coord_offset+DIM*1+XX];
545 iy1 = shY + x[i_coord_offset+DIM*1+YY];
546 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
547 ix2 = shX + x[i_coord_offset+DIM*2+XX];
548 iy2 = shY + x[i_coord_offset+DIM*2+YY];
549 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
550 ix3 = shX + x[i_coord_offset+DIM*3+XX];
551 iy3 = shY + x[i_coord_offset+DIM*3+YY];
552 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
567 /* Start inner kernel loop */
568 for(jidx=j_index_start; jidx<j_index_end; jidx++)
570 /* Get j neighbor index, and coordinate index */
572 j_coord_offset = DIM*jnr;
574 /* load j atom coordinates */
575 jx0 = x[j_coord_offset+DIM*0+XX];
576 jy0 = x[j_coord_offset+DIM*0+YY];
577 jz0 = x[j_coord_offset+DIM*0+ZZ];
579 /* Calculate displacement vector */
593 /* Calculate squared distance and things based on it */
594 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
595 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
596 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
597 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
599 rinv00 = gmx_invsqrt(rsq00);
600 rinv10 = gmx_invsqrt(rsq10);
601 rinv20 = gmx_invsqrt(rsq20);
602 rinv30 = gmx_invsqrt(rsq30);
604 rinvsq00 = rinv00*rinv00;
605 rinvsq10 = rinv10*rinv10;
606 rinvsq20 = rinv20*rinv20;
607 rinvsq30 = rinv30*rinv30;
609 /* Load parameters for j particles */
611 vdwjidx0 = 2*vdwtype[jnr+0];
613 /**************************
614 * CALCULATE INTERACTIONS *
615 **************************/
622 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
623 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
625 /* LENNARD-JONES DISPERSION/REPULSION */
627 rinvsix = rinvsq00*rinvsq00*rinvsq00;
628 vvdw6 = c6_00*rinvsix;
629 vvdw12 = c12_00*rinvsix*rinvsix;
630 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
631 fvdw = (vvdw12-vvdw6)*rinvsq00;
634 d = (d>0.0) ? d : 0.0;
636 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
638 dsw = d2*(swF2+d*(swF3+d*swF4));
640 /* Evaluate switch function */
641 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
642 fvdw = fvdw*sw - rinv00*vvdw*dsw;
646 /* Calculate temporary vectorial force */
651 /* Update vectorial force */
655 f[j_coord_offset+DIM*0+XX] -= tx;
656 f[j_coord_offset+DIM*0+YY] -= ty;
657 f[j_coord_offset+DIM*0+ZZ] -= tz;
661 /**************************
662 * CALCULATE INTERACTIONS *
663 **************************/
670 /* REACTION-FIELD ELECTROSTATICS */
671 felec = qq10*(rinv10*rinvsq10-krf2);
675 /* Calculate temporary vectorial force */
680 /* Update vectorial force */
684 f[j_coord_offset+DIM*0+XX] -= tx;
685 f[j_coord_offset+DIM*0+YY] -= ty;
686 f[j_coord_offset+DIM*0+ZZ] -= tz;
690 /**************************
691 * CALCULATE INTERACTIONS *
692 **************************/
699 /* REACTION-FIELD ELECTROSTATICS */
700 felec = qq20*(rinv20*rinvsq20-krf2);
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;
719 /**************************
720 * CALCULATE INTERACTIONS *
721 **************************/
728 /* REACTION-FIELD ELECTROSTATICS */
729 felec = qq30*(rinv30*rinvsq30-krf2);
733 /* Calculate temporary vectorial force */
738 /* Update vectorial force */
742 f[j_coord_offset+DIM*0+XX] -= tx;
743 f[j_coord_offset+DIM*0+YY] -= ty;
744 f[j_coord_offset+DIM*0+ZZ] -= tz;
748 /* Inner loop uses 132 flops */
750 /* End of innermost loop */
753 f[i_coord_offset+DIM*0+XX] += fix0;
754 f[i_coord_offset+DIM*0+YY] += fiy0;
755 f[i_coord_offset+DIM*0+ZZ] += fiz0;
759 f[i_coord_offset+DIM*1+XX] += fix1;
760 f[i_coord_offset+DIM*1+YY] += fiy1;
761 f[i_coord_offset+DIM*1+ZZ] += fiz1;
765 f[i_coord_offset+DIM*2+XX] += fix2;
766 f[i_coord_offset+DIM*2+YY] += fiy2;
767 f[i_coord_offset+DIM*2+ZZ] += fiz2;
771 f[i_coord_offset+DIM*3+XX] += fix3;
772 f[i_coord_offset+DIM*3+YY] += fiy3;
773 f[i_coord_offset+DIM*3+ZZ] += fiz3;
777 fshift[i_shift_offset+XX] += tx;
778 fshift[i_shift_offset+YY] += ty;
779 fshift[i_shift_offset+ZZ] += tz;
781 /* Increment number of inner iterations */
782 inneriter += j_index_end - j_index_start;
784 /* Outer loop uses 39 flops */
787 /* Increment number of outer iterations */
790 /* Update outer/inner flops */
792 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*132);