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_VdwBhamSh_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_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;
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
105 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 /* Setup water-specific parameters */
114 inr = nlist->iinr[0];
115 iq1 = facel*charge[inr+1];
116 iq2 = facel*charge[inr+2];
117 iq3 = facel*charge[inr+3];
118 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
120 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
121 rcutoff = fr->rcoulomb;
122 rcutoff2 = rcutoff*rcutoff;
124 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
130 /* Start outer loop over neighborlists */
131 for(iidx=0; iidx<nri; iidx++)
133 /* Load shift vector for this list */
134 i_shift_offset = DIM*shiftidx[iidx];
135 shX = shiftvec[i_shift_offset+XX];
136 shY = shiftvec[i_shift_offset+YY];
137 shZ = shiftvec[i_shift_offset+ZZ];
139 /* Load limits for loop over neighbors */
140 j_index_start = jindex[iidx];
141 j_index_end = jindex[iidx+1];
143 /* Get outer coordinate index */
145 i_coord_offset = DIM*inr;
147 /* Load i particle coords and add shift vector */
148 ix0 = shX + x[i_coord_offset+DIM*0+XX];
149 iy0 = shY + x[i_coord_offset+DIM*0+YY];
150 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
151 ix1 = shX + x[i_coord_offset+DIM*1+XX];
152 iy1 = shY + x[i_coord_offset+DIM*1+YY];
153 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
154 ix2 = shX + x[i_coord_offset+DIM*2+XX];
155 iy2 = shY + x[i_coord_offset+DIM*2+YY];
156 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
157 ix3 = shX + x[i_coord_offset+DIM*3+XX];
158 iy3 = shY + x[i_coord_offset+DIM*3+YY];
159 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
174 /* Reset potential sums */
178 /* Start inner kernel loop */
179 for(jidx=j_index_start; jidx<j_index_end; jidx++)
181 /* Get j neighbor index, and coordinate index */
183 j_coord_offset = DIM*jnr;
185 /* load j atom coordinates */
186 jx0 = x[j_coord_offset+DIM*0+XX];
187 jy0 = x[j_coord_offset+DIM*0+YY];
188 jz0 = x[j_coord_offset+DIM*0+ZZ];
190 /* Calculate displacement vector */
204 /* Calculate squared distance and things based on it */
205 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
206 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
207 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
208 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
210 rinv00 = gmx_invsqrt(rsq00);
211 rinv10 = gmx_invsqrt(rsq10);
212 rinv20 = gmx_invsqrt(rsq20);
213 rinv30 = gmx_invsqrt(rsq30);
215 rinvsq00 = rinv00*rinv00;
216 rinvsq10 = rinv10*rinv10;
217 rinvsq20 = rinv20*rinv20;
218 rinvsq30 = rinv30*rinv30;
220 /* Load parameters for j particles */
222 vdwjidx0 = 3*vdwtype[jnr+0];
224 /**************************
225 * CALCULATE INTERACTIONS *
226 **************************/
233 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
234 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
235 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
237 /* BUCKINGHAM DISPERSION/REPULSION */
238 rinvsix = rinvsq00*rinvsq00*rinvsq00;
239 vvdw6 = c6_00*rinvsix;
241 vvdwexp = cexp1_00*exp(-br);
242 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
243 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
245 /* Update potential sums from outer loop */
250 /* Calculate temporary vectorial force */
255 /* Update vectorial force */
259 f[j_coord_offset+DIM*0+XX] -= tx;
260 f[j_coord_offset+DIM*0+YY] -= ty;
261 f[j_coord_offset+DIM*0+ZZ] -= tz;
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
274 /* REACTION-FIELD ELECTROSTATICS */
275 velec = qq10*(rinv10+krf*rsq10-crf);
276 felec = qq10*(rinv10*rinvsq10-krf2);
278 /* Update potential sums from outer loop */
283 /* Calculate temporary vectorial force */
288 /* Update vectorial force */
292 f[j_coord_offset+DIM*0+XX] -= tx;
293 f[j_coord_offset+DIM*0+YY] -= ty;
294 f[j_coord_offset+DIM*0+ZZ] -= tz;
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
307 /* REACTION-FIELD ELECTROSTATICS */
308 velec = qq20*(rinv20+krf*rsq20-crf);
309 felec = qq20*(rinv20*rinvsq20-krf2);
311 /* Update potential sums from outer loop */
316 /* Calculate temporary vectorial force */
321 /* Update vectorial force */
325 f[j_coord_offset+DIM*0+XX] -= tx;
326 f[j_coord_offset+DIM*0+YY] -= ty;
327 f[j_coord_offset+DIM*0+ZZ] -= tz;
331 /**************************
332 * CALCULATE INTERACTIONS *
333 **************************/
340 /* REACTION-FIELD ELECTROSTATICS */
341 velec = qq30*(rinv30+krf*rsq30-crf);
342 felec = qq30*(rinv30*rinvsq30-krf2);
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*0+XX] -= tx;
359 f[j_coord_offset+DIM*0+YY] -= ty;
360 f[j_coord_offset+DIM*0+ZZ] -= tz;
364 /* Inner loop uses 188 flops */
366 /* End of innermost loop */
369 f[i_coord_offset+DIM*0+XX] += fix0;
370 f[i_coord_offset+DIM*0+YY] += fiy0;
371 f[i_coord_offset+DIM*0+ZZ] += fiz0;
375 f[i_coord_offset+DIM*1+XX] += fix1;
376 f[i_coord_offset+DIM*1+YY] += fiy1;
377 f[i_coord_offset+DIM*1+ZZ] += fiz1;
381 f[i_coord_offset+DIM*2+XX] += fix2;
382 f[i_coord_offset+DIM*2+YY] += fiy2;
383 f[i_coord_offset+DIM*2+ZZ] += fiz2;
387 f[i_coord_offset+DIM*3+XX] += fix3;
388 f[i_coord_offset+DIM*3+YY] += fiy3;
389 f[i_coord_offset+DIM*3+ZZ] += fiz3;
393 fshift[i_shift_offset+XX] += tx;
394 fshift[i_shift_offset+YY] += ty;
395 fshift[i_shift_offset+ZZ] += tz;
398 /* Update potential energies */
399 kernel_data->energygrp_elec[ggid] += velecsum;
400 kernel_data->energygrp_vdw[ggid] += vvdwsum;
402 /* Increment number of inner iterations */
403 inneriter += j_index_end - j_index_start;
405 /* Outer loop uses 41 flops */
408 /* Increment number of outer iterations */
411 /* Update outer/inner flops */
413 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*188);
416 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW4P1_F_c
417 * Electrostatics interaction: ReactionField
418 * VdW interaction: Buckingham
419 * Geometry: Water4-Particle
420 * Calculate force/pot: Force
423 nb_kernel_ElecRFCut_VdwBhamSh_GeomW4P1_F_c
424 (t_nblist * gmx_restrict nlist,
425 rvec * gmx_restrict xx,
426 rvec * gmx_restrict ff,
427 t_forcerec * gmx_restrict fr,
428 t_mdatoms * gmx_restrict mdatoms,
429 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
430 t_nrnb * gmx_restrict nrnb)
432 int i_shift_offset,i_coord_offset,j_coord_offset;
433 int j_index_start,j_index_end;
434 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
435 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
436 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
437 real *shiftvec,*fshift,*x,*f;
439 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
441 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
443 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
445 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
447 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
448 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
449 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
450 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
451 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
452 real velec,felec,velecsum,facel,crf,krf,krf2;
455 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
464 jindex = nlist->jindex;
466 shiftidx = nlist->shift;
468 shiftvec = fr->shift_vec[0];
469 fshift = fr->fshift[0];
471 charge = mdatoms->chargeA;
475 nvdwtype = fr->ntype;
477 vdwtype = mdatoms->typeA;
479 /* Setup water-specific parameters */
480 inr = nlist->iinr[0];
481 iq1 = facel*charge[inr+1];
482 iq2 = facel*charge[inr+2];
483 iq3 = facel*charge[inr+3];
484 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
486 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
487 rcutoff = fr->rcoulomb;
488 rcutoff2 = rcutoff*rcutoff;
490 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
496 /* Start outer loop over neighborlists */
497 for(iidx=0; iidx<nri; iidx++)
499 /* Load shift vector for this list */
500 i_shift_offset = DIM*shiftidx[iidx];
501 shX = shiftvec[i_shift_offset+XX];
502 shY = shiftvec[i_shift_offset+YY];
503 shZ = shiftvec[i_shift_offset+ZZ];
505 /* Load limits for loop over neighbors */
506 j_index_start = jindex[iidx];
507 j_index_end = jindex[iidx+1];
509 /* Get outer coordinate index */
511 i_coord_offset = DIM*inr;
513 /* Load i particle coords and add shift vector */
514 ix0 = shX + x[i_coord_offset+DIM*0+XX];
515 iy0 = shY + x[i_coord_offset+DIM*0+YY];
516 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
517 ix1 = shX + x[i_coord_offset+DIM*1+XX];
518 iy1 = shY + x[i_coord_offset+DIM*1+YY];
519 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
520 ix2 = shX + x[i_coord_offset+DIM*2+XX];
521 iy2 = shY + x[i_coord_offset+DIM*2+YY];
522 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
523 ix3 = shX + x[i_coord_offset+DIM*3+XX];
524 iy3 = shY + x[i_coord_offset+DIM*3+YY];
525 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
540 /* Start inner kernel loop */
541 for(jidx=j_index_start; jidx<j_index_end; jidx++)
543 /* Get j neighbor index, and coordinate index */
545 j_coord_offset = DIM*jnr;
547 /* load j atom coordinates */
548 jx0 = x[j_coord_offset+DIM*0+XX];
549 jy0 = x[j_coord_offset+DIM*0+YY];
550 jz0 = x[j_coord_offset+DIM*0+ZZ];
552 /* Calculate displacement vector */
566 /* Calculate squared distance and things based on it */
567 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
568 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
569 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
570 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
572 rinv00 = gmx_invsqrt(rsq00);
573 rinv10 = gmx_invsqrt(rsq10);
574 rinv20 = gmx_invsqrt(rsq20);
575 rinv30 = gmx_invsqrt(rsq30);
577 rinvsq00 = rinv00*rinv00;
578 rinvsq10 = rinv10*rinv10;
579 rinvsq20 = rinv20*rinv20;
580 rinvsq30 = rinv30*rinv30;
582 /* Load parameters for j particles */
584 vdwjidx0 = 3*vdwtype[jnr+0];
586 /**************************
587 * CALCULATE INTERACTIONS *
588 **************************/
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;
623 /**************************
624 * CALCULATE INTERACTIONS *
625 **************************/
632 /* REACTION-FIELD ELECTROSTATICS */
633 felec = qq10*(rinv10*rinvsq10-krf2);
637 /* Calculate temporary vectorial force */
642 /* Update vectorial force */
646 f[j_coord_offset+DIM*0+XX] -= tx;
647 f[j_coord_offset+DIM*0+YY] -= ty;
648 f[j_coord_offset+DIM*0+ZZ] -= tz;
652 /**************************
653 * CALCULATE INTERACTIONS *
654 **************************/
661 /* REACTION-FIELD ELECTROSTATICS */
662 felec = qq20*(rinv20*rinvsq20-krf2);
666 /* Calculate temporary vectorial force */
671 /* Update vectorial force */
675 f[j_coord_offset+DIM*0+XX] -= tx;
676 f[j_coord_offset+DIM*0+YY] -= ty;
677 f[j_coord_offset+DIM*0+ZZ] -= tz;
681 /**************************
682 * CALCULATE INTERACTIONS *
683 **************************/
690 /* REACTION-FIELD ELECTROSTATICS */
691 felec = qq30*(rinv30*rinvsq30-krf2);
695 /* Calculate temporary vectorial force */
700 /* Update vectorial force */
704 f[j_coord_offset+DIM*0+XX] -= tx;
705 f[j_coord_offset+DIM*0+YY] -= ty;
706 f[j_coord_offset+DIM*0+ZZ] -= tz;
710 /* Inner loop uses 139 flops */
712 /* End of innermost loop */
715 f[i_coord_offset+DIM*0+XX] += fix0;
716 f[i_coord_offset+DIM*0+YY] += fiy0;
717 f[i_coord_offset+DIM*0+ZZ] += fiz0;
721 f[i_coord_offset+DIM*1+XX] += fix1;
722 f[i_coord_offset+DIM*1+YY] += fiy1;
723 f[i_coord_offset+DIM*1+ZZ] += fiz1;
727 f[i_coord_offset+DIM*2+XX] += fix2;
728 f[i_coord_offset+DIM*2+YY] += fiy2;
729 f[i_coord_offset+DIM*2+ZZ] += fiz2;
733 f[i_coord_offset+DIM*3+XX] += fix3;
734 f[i_coord_offset+DIM*3+YY] += fiy3;
735 f[i_coord_offset+DIM*3+ZZ] += fiz3;
739 fshift[i_shift_offset+XX] += tx;
740 fshift[i_shift_offset+YY] += ty;
741 fshift[i_shift_offset+ZZ] += tz;
743 /* Increment number of inner iterations */
744 inneriter += j_index_end - j_index_start;
746 /* Outer loop uses 39 flops */
749 /* Increment number of outer iterations */
752 /* Update outer/inner flops */
754 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*139);