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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW4P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: Buckingham
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwBhamSh_GeomW4P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
84 real velec,felec,velecsum,facel,crf,krf,krf2;
87 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
96 jindex = nlist->jindex;
98 shiftidx = nlist->shift;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
103 charge = mdatoms->chargeA;
107 nvdwtype = fr->ntype;
109 vdwtype = mdatoms->typeA;
111 /* Setup water-specific parameters */
112 inr = nlist->iinr[0];
113 iq1 = facel*charge[inr+1];
114 iq2 = facel*charge[inr+2];
115 iq3 = facel*charge[inr+3];
116 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
118 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
119 rcutoff = fr->rcoulomb;
120 rcutoff2 = rcutoff*rcutoff;
122 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
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 **************************/
231 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
232 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
233 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
235 /* BUCKINGHAM DISPERSION/REPULSION */
236 rinvsix = rinvsq00*rinvsq00*rinvsq00;
237 vvdw6 = c6_00*rinvsix;
239 vvdwexp = cexp1_00*exp(-br);
240 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
241 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
243 /* Update potential sums from outer loop */
248 /* Calculate temporary vectorial force */
253 /* Update vectorial force */
257 f[j_coord_offset+DIM*0+XX] -= tx;
258 f[j_coord_offset+DIM*0+YY] -= ty;
259 f[j_coord_offset+DIM*0+ZZ] -= tz;
263 /**************************
264 * CALCULATE INTERACTIONS *
265 **************************/
272 /* REACTION-FIELD ELECTROSTATICS */
273 velec = qq10*(rinv10+krf*rsq10-crf);
274 felec = qq10*(rinv10*rinvsq10-krf2);
276 /* Update potential sums from outer loop */
281 /* Calculate temporary vectorial force */
286 /* Update vectorial force */
290 f[j_coord_offset+DIM*0+XX] -= tx;
291 f[j_coord_offset+DIM*0+YY] -= ty;
292 f[j_coord_offset+DIM*0+ZZ] -= tz;
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
305 /* REACTION-FIELD ELECTROSTATICS */
306 velec = qq20*(rinv20+krf*rsq20-crf);
307 felec = qq20*(rinv20*rinvsq20-krf2);
309 /* Update potential sums from outer loop */
314 /* Calculate temporary vectorial force */
319 /* Update vectorial force */
323 f[j_coord_offset+DIM*0+XX] -= tx;
324 f[j_coord_offset+DIM*0+YY] -= ty;
325 f[j_coord_offset+DIM*0+ZZ] -= tz;
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
338 /* REACTION-FIELD ELECTROSTATICS */
339 velec = qq30*(rinv30+krf*rsq30-crf);
340 felec = qq30*(rinv30*rinvsq30-krf2);
342 /* Update potential sums from outer loop */
347 /* Calculate temporary vectorial force */
352 /* Update vectorial force */
356 f[j_coord_offset+DIM*0+XX] -= tx;
357 f[j_coord_offset+DIM*0+YY] -= ty;
358 f[j_coord_offset+DIM*0+ZZ] -= tz;
362 /* Inner loop uses 188 flops */
364 /* End of innermost loop */
367 f[i_coord_offset+DIM*0+XX] += fix0;
368 f[i_coord_offset+DIM*0+YY] += fiy0;
369 f[i_coord_offset+DIM*0+ZZ] += fiz0;
373 f[i_coord_offset+DIM*1+XX] += fix1;
374 f[i_coord_offset+DIM*1+YY] += fiy1;
375 f[i_coord_offset+DIM*1+ZZ] += fiz1;
379 f[i_coord_offset+DIM*2+XX] += fix2;
380 f[i_coord_offset+DIM*2+YY] += fiy2;
381 f[i_coord_offset+DIM*2+ZZ] += fiz2;
385 f[i_coord_offset+DIM*3+XX] += fix3;
386 f[i_coord_offset+DIM*3+YY] += fiy3;
387 f[i_coord_offset+DIM*3+ZZ] += fiz3;
391 fshift[i_shift_offset+XX] += tx;
392 fshift[i_shift_offset+YY] += ty;
393 fshift[i_shift_offset+ZZ] += tz;
396 /* Update potential energies */
397 kernel_data->energygrp_elec[ggid] += velecsum;
398 kernel_data->energygrp_vdw[ggid] += vvdwsum;
400 /* Increment number of inner iterations */
401 inneriter += j_index_end - j_index_start;
403 /* Outer loop uses 41 flops */
406 /* Increment number of outer iterations */
409 /* Update outer/inner flops */
411 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*188);
414 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW4P1_F_c
415 * Electrostatics interaction: ReactionField
416 * VdW interaction: Buckingham
417 * Geometry: Water4-Particle
418 * Calculate force/pot: Force
421 nb_kernel_ElecRFCut_VdwBhamSh_GeomW4P1_F_c
422 (t_nblist * gmx_restrict nlist,
423 rvec * gmx_restrict xx,
424 rvec * gmx_restrict ff,
425 t_forcerec * gmx_restrict fr,
426 t_mdatoms * gmx_restrict mdatoms,
427 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
428 t_nrnb * gmx_restrict nrnb)
430 int i_shift_offset,i_coord_offset,j_coord_offset;
431 int j_index_start,j_index_end;
432 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
433 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
434 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
435 real *shiftvec,*fshift,*x,*f;
437 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
439 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
441 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
443 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
445 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
446 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
447 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
448 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
449 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
450 real velec,felec,velecsum,facel,crf,krf,krf2;
453 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
462 jindex = nlist->jindex;
464 shiftidx = nlist->shift;
466 shiftvec = fr->shift_vec[0];
467 fshift = fr->fshift[0];
469 charge = mdatoms->chargeA;
473 nvdwtype = fr->ntype;
475 vdwtype = mdatoms->typeA;
477 /* Setup water-specific parameters */
478 inr = nlist->iinr[0];
479 iq1 = facel*charge[inr+1];
480 iq2 = facel*charge[inr+2];
481 iq3 = facel*charge[inr+3];
482 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
484 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
485 rcutoff = fr->rcoulomb;
486 rcutoff2 = rcutoff*rcutoff;
488 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
494 /* Start outer loop over neighborlists */
495 for(iidx=0; iidx<nri; iidx++)
497 /* Load shift vector for this list */
498 i_shift_offset = DIM*shiftidx[iidx];
499 shX = shiftvec[i_shift_offset+XX];
500 shY = shiftvec[i_shift_offset+YY];
501 shZ = shiftvec[i_shift_offset+ZZ];
503 /* Load limits for loop over neighbors */
504 j_index_start = jindex[iidx];
505 j_index_end = jindex[iidx+1];
507 /* Get outer coordinate index */
509 i_coord_offset = DIM*inr;
511 /* Load i particle coords and add shift vector */
512 ix0 = shX + x[i_coord_offset+DIM*0+XX];
513 iy0 = shY + x[i_coord_offset+DIM*0+YY];
514 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
515 ix1 = shX + x[i_coord_offset+DIM*1+XX];
516 iy1 = shY + x[i_coord_offset+DIM*1+YY];
517 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
518 ix2 = shX + x[i_coord_offset+DIM*2+XX];
519 iy2 = shY + x[i_coord_offset+DIM*2+YY];
520 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
521 ix3 = shX + x[i_coord_offset+DIM*3+XX];
522 iy3 = shY + x[i_coord_offset+DIM*3+YY];
523 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
538 /* Start inner kernel loop */
539 for(jidx=j_index_start; jidx<j_index_end; jidx++)
541 /* Get j neighbor index, and coordinate index */
543 j_coord_offset = DIM*jnr;
545 /* load j atom coordinates */
546 jx0 = x[j_coord_offset+DIM*0+XX];
547 jy0 = x[j_coord_offset+DIM*0+YY];
548 jz0 = x[j_coord_offset+DIM*0+ZZ];
550 /* Calculate displacement vector */
564 /* Calculate squared distance and things based on it */
565 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
566 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
567 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
568 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
570 rinv00 = gmx_invsqrt(rsq00);
571 rinv10 = gmx_invsqrt(rsq10);
572 rinv20 = gmx_invsqrt(rsq20);
573 rinv30 = gmx_invsqrt(rsq30);
575 rinvsq00 = rinv00*rinv00;
576 rinvsq10 = rinv10*rinv10;
577 rinvsq20 = rinv20*rinv20;
578 rinvsq30 = rinv30*rinv30;
580 /* Load parameters for j particles */
582 vdwjidx0 = 3*vdwtype[jnr+0];
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
593 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
594 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
595 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
597 /* BUCKINGHAM DISPERSION/REPULSION */
598 rinvsix = rinvsq00*rinvsq00*rinvsq00;
599 vvdw6 = c6_00*rinvsix;
601 vvdwexp = cexp1_00*exp(-br);
602 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
606 /* Calculate temporary vectorial force */
611 /* Update vectorial force */
615 f[j_coord_offset+DIM*0+XX] -= tx;
616 f[j_coord_offset+DIM*0+YY] -= ty;
617 f[j_coord_offset+DIM*0+ZZ] -= tz;
621 /**************************
622 * CALCULATE INTERACTIONS *
623 **************************/
630 /* REACTION-FIELD ELECTROSTATICS */
631 felec = qq10*(rinv10*rinvsq10-krf2);
635 /* Calculate temporary vectorial force */
640 /* Update vectorial force */
644 f[j_coord_offset+DIM*0+XX] -= tx;
645 f[j_coord_offset+DIM*0+YY] -= ty;
646 f[j_coord_offset+DIM*0+ZZ] -= tz;
650 /**************************
651 * CALCULATE INTERACTIONS *
652 **************************/
659 /* REACTION-FIELD ELECTROSTATICS */
660 felec = qq20*(rinv20*rinvsq20-krf2);
664 /* Calculate temporary vectorial force */
669 /* Update vectorial force */
673 f[j_coord_offset+DIM*0+XX] -= tx;
674 f[j_coord_offset+DIM*0+YY] -= ty;
675 f[j_coord_offset+DIM*0+ZZ] -= tz;
679 /**************************
680 * CALCULATE INTERACTIONS *
681 **************************/
688 /* REACTION-FIELD ELECTROSTATICS */
689 felec = qq30*(rinv30*rinvsq30-krf2);
693 /* Calculate temporary vectorial force */
698 /* Update vectorial force */
702 f[j_coord_offset+DIM*0+XX] -= tx;
703 f[j_coord_offset+DIM*0+YY] -= ty;
704 f[j_coord_offset+DIM*0+ZZ] -= tz;
708 /* Inner loop uses 139 flops */
710 /* End of innermost loop */
713 f[i_coord_offset+DIM*0+XX] += fix0;
714 f[i_coord_offset+DIM*0+YY] += fiy0;
715 f[i_coord_offset+DIM*0+ZZ] += fiz0;
719 f[i_coord_offset+DIM*1+XX] += fix1;
720 f[i_coord_offset+DIM*1+YY] += fiy1;
721 f[i_coord_offset+DIM*1+ZZ] += fiz1;
725 f[i_coord_offset+DIM*2+XX] += fix2;
726 f[i_coord_offset+DIM*2+YY] += fiy2;
727 f[i_coord_offset+DIM*2+ZZ] += fiz2;
731 f[i_coord_offset+DIM*3+XX] += fix3;
732 f[i_coord_offset+DIM*3+YY] += fiy3;
733 f[i_coord_offset+DIM*3+ZZ] += fiz3;
737 fshift[i_shift_offset+XX] += tx;
738 fshift[i_shift_offset+YY] += ty;
739 fshift[i_shift_offset+ZZ] += tz;
741 /* Increment number of inner iterations */
742 inneriter += j_index_end - j_index_start;
744 /* Outer loop uses 39 flops */
747 /* Increment number of outer iterations */
750 /* Update outer/inner flops */
752 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*139);