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_ElecRFCut_VdwBhamSh_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
112 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 /* Setup water-specific parameters */
121 inr = nlist->iinr[0];
122 iq0 = facel*charge[inr+0];
123 iq1 = facel*charge[inr+1];
124 iq2 = facel*charge[inr+2];
125 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
130 vdwjidx0 = 3*vdwtype[inr+0];
132 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
133 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
134 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
144 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
145 rcutoff = fr->rcoulomb;
146 rcutoff2 = rcutoff*rcutoff;
148 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
154 /* Start outer loop over neighborlists */
155 for(iidx=0; iidx<nri; iidx++)
157 /* Load shift vector for this list */
158 i_shift_offset = DIM*shiftidx[iidx];
159 shX = shiftvec[i_shift_offset+XX];
160 shY = shiftvec[i_shift_offset+YY];
161 shZ = shiftvec[i_shift_offset+ZZ];
163 /* Load limits for loop over neighbors */
164 j_index_start = jindex[iidx];
165 j_index_end = jindex[iidx+1];
167 /* Get outer coordinate index */
169 i_coord_offset = DIM*inr;
171 /* Load i particle coords and add shift vector */
172 ix0 = shX + x[i_coord_offset+DIM*0+XX];
173 iy0 = shY + x[i_coord_offset+DIM*0+YY];
174 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
175 ix1 = shX + x[i_coord_offset+DIM*1+XX];
176 iy1 = shY + x[i_coord_offset+DIM*1+YY];
177 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
178 ix2 = shX + x[i_coord_offset+DIM*2+XX];
179 iy2 = shY + x[i_coord_offset+DIM*2+YY];
180 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
192 /* Reset potential sums */
196 /* Start inner kernel loop */
197 for(jidx=j_index_start; jidx<j_index_end; jidx++)
199 /* Get j neighbor index, and coordinate index */
201 j_coord_offset = DIM*jnr;
203 /* load j atom coordinates */
204 jx0 = x[j_coord_offset+DIM*0+XX];
205 jy0 = x[j_coord_offset+DIM*0+YY];
206 jz0 = x[j_coord_offset+DIM*0+ZZ];
207 jx1 = x[j_coord_offset+DIM*1+XX];
208 jy1 = x[j_coord_offset+DIM*1+YY];
209 jz1 = x[j_coord_offset+DIM*1+ZZ];
210 jx2 = x[j_coord_offset+DIM*2+XX];
211 jy2 = x[j_coord_offset+DIM*2+YY];
212 jz2 = x[j_coord_offset+DIM*2+ZZ];
214 /* Calculate displacement vector */
243 /* Calculate squared distance and things based on it */
244 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
245 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
246 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
247 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
248 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
249 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
250 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
251 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
252 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
254 rinv00 = gmx_invsqrt(rsq00);
255 rinv01 = gmx_invsqrt(rsq01);
256 rinv02 = gmx_invsqrt(rsq02);
257 rinv10 = gmx_invsqrt(rsq10);
258 rinv11 = gmx_invsqrt(rsq11);
259 rinv12 = gmx_invsqrt(rsq12);
260 rinv20 = gmx_invsqrt(rsq20);
261 rinv21 = gmx_invsqrt(rsq21);
262 rinv22 = gmx_invsqrt(rsq22);
264 rinvsq00 = rinv00*rinv00;
265 rinvsq01 = rinv01*rinv01;
266 rinvsq02 = rinv02*rinv02;
267 rinvsq10 = rinv10*rinv10;
268 rinvsq11 = rinv11*rinv11;
269 rinvsq12 = rinv12*rinv12;
270 rinvsq20 = rinv20*rinv20;
271 rinvsq21 = rinv21*rinv21;
272 rinvsq22 = rinv22*rinv22;
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
283 /* REACTION-FIELD ELECTROSTATICS */
284 velec = qq00*(rinv00+krf*rsq00-crf);
285 felec = qq00*(rinv00*rinvsq00-krf2);
287 /* BUCKINGHAM DISPERSION/REPULSION */
288 rinvsix = rinvsq00*rinvsq00*rinvsq00;
289 vvdw6 = c6_00*rinvsix;
291 vvdwexp = cexp1_00*exp(-br);
292 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
293 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
295 /* Update potential sums from outer loop */
301 /* Calculate temporary vectorial force */
306 /* Update vectorial force */
310 f[j_coord_offset+DIM*0+XX] -= tx;
311 f[j_coord_offset+DIM*0+YY] -= ty;
312 f[j_coord_offset+DIM*0+ZZ] -= tz;
316 /**************************
317 * CALCULATE INTERACTIONS *
318 **************************/
323 /* REACTION-FIELD ELECTROSTATICS */
324 velec = qq01*(rinv01+krf*rsq01-crf);
325 felec = qq01*(rinv01*rinvsq01-krf2);
327 /* Update potential sums from outer loop */
332 /* Calculate temporary vectorial force */
337 /* Update vectorial force */
341 f[j_coord_offset+DIM*1+XX] -= tx;
342 f[j_coord_offset+DIM*1+YY] -= ty;
343 f[j_coord_offset+DIM*1+ZZ] -= tz;
347 /**************************
348 * CALCULATE INTERACTIONS *
349 **************************/
354 /* REACTION-FIELD ELECTROSTATICS */
355 velec = qq02*(rinv02+krf*rsq02-crf);
356 felec = qq02*(rinv02*rinvsq02-krf2);
358 /* Update potential sums from outer loop */
363 /* Calculate temporary vectorial force */
368 /* Update vectorial force */
372 f[j_coord_offset+DIM*2+XX] -= tx;
373 f[j_coord_offset+DIM*2+YY] -= ty;
374 f[j_coord_offset+DIM*2+ZZ] -= tz;
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
385 /* REACTION-FIELD ELECTROSTATICS */
386 velec = qq10*(rinv10+krf*rsq10-crf);
387 felec = qq10*(rinv10*rinvsq10-krf2);
389 /* Update potential sums from outer loop */
394 /* Calculate temporary vectorial force */
399 /* Update vectorial force */
403 f[j_coord_offset+DIM*0+XX] -= tx;
404 f[j_coord_offset+DIM*0+YY] -= ty;
405 f[j_coord_offset+DIM*0+ZZ] -= tz;
409 /**************************
410 * CALCULATE INTERACTIONS *
411 **************************/
416 /* REACTION-FIELD ELECTROSTATICS */
417 velec = qq11*(rinv11+krf*rsq11-crf);
418 felec = qq11*(rinv11*rinvsq11-krf2);
420 /* Update potential sums from outer loop */
425 /* Calculate temporary vectorial force */
430 /* Update vectorial force */
434 f[j_coord_offset+DIM*1+XX] -= tx;
435 f[j_coord_offset+DIM*1+YY] -= ty;
436 f[j_coord_offset+DIM*1+ZZ] -= tz;
440 /**************************
441 * CALCULATE INTERACTIONS *
442 **************************/
447 /* REACTION-FIELD ELECTROSTATICS */
448 velec = qq12*(rinv12+krf*rsq12-crf);
449 felec = qq12*(rinv12*rinvsq12-krf2);
451 /* Update potential sums from outer loop */
456 /* Calculate temporary vectorial force */
461 /* Update vectorial force */
465 f[j_coord_offset+DIM*2+XX] -= tx;
466 f[j_coord_offset+DIM*2+YY] -= ty;
467 f[j_coord_offset+DIM*2+ZZ] -= tz;
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
478 /* REACTION-FIELD ELECTROSTATICS */
479 velec = qq20*(rinv20+krf*rsq20-crf);
480 felec = qq20*(rinv20*rinvsq20-krf2);
482 /* Update potential sums from outer loop */
487 /* Calculate temporary vectorial force */
492 /* Update vectorial force */
496 f[j_coord_offset+DIM*0+XX] -= tx;
497 f[j_coord_offset+DIM*0+YY] -= ty;
498 f[j_coord_offset+DIM*0+ZZ] -= tz;
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
509 /* REACTION-FIELD ELECTROSTATICS */
510 velec = qq21*(rinv21+krf*rsq21-crf);
511 felec = qq21*(rinv21*rinvsq21-krf2);
513 /* Update potential sums from outer loop */
518 /* Calculate temporary vectorial force */
523 /* Update vectorial force */
527 f[j_coord_offset+DIM*1+XX] -= tx;
528 f[j_coord_offset+DIM*1+YY] -= ty;
529 f[j_coord_offset+DIM*1+ZZ] -= tz;
533 /**************************
534 * CALCULATE INTERACTIONS *
535 **************************/
540 /* REACTION-FIELD ELECTROSTATICS */
541 velec = qq22*(rinv22+krf*rsq22-crf);
542 felec = qq22*(rinv22*rinvsq22-krf2);
544 /* Update potential sums from outer loop */
549 /* Calculate temporary vectorial force */
554 /* Update vectorial force */
558 f[j_coord_offset+DIM*2+XX] -= tx;
559 f[j_coord_offset+DIM*2+YY] -= ty;
560 f[j_coord_offset+DIM*2+ZZ] -= tz;
564 /* Inner loop uses 349 flops */
566 /* End of innermost loop */
569 f[i_coord_offset+DIM*0+XX] += fix0;
570 f[i_coord_offset+DIM*0+YY] += fiy0;
571 f[i_coord_offset+DIM*0+ZZ] += fiz0;
575 f[i_coord_offset+DIM*1+XX] += fix1;
576 f[i_coord_offset+DIM*1+YY] += fiy1;
577 f[i_coord_offset+DIM*1+ZZ] += fiz1;
581 f[i_coord_offset+DIM*2+XX] += fix2;
582 f[i_coord_offset+DIM*2+YY] += fiy2;
583 f[i_coord_offset+DIM*2+ZZ] += fiz2;
587 fshift[i_shift_offset+XX] += tx;
588 fshift[i_shift_offset+YY] += ty;
589 fshift[i_shift_offset+ZZ] += tz;
592 /* Update potential energies */
593 kernel_data->energygrp_elec[ggid] += velecsum;
594 kernel_data->energygrp_vdw[ggid] += vvdwsum;
596 /* Increment number of inner iterations */
597 inneriter += j_index_end - j_index_start;
599 /* Outer loop uses 32 flops */
602 /* Increment number of outer iterations */
605 /* Update outer/inner flops */
607 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*349);
610 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_F_c
611 * Electrostatics interaction: ReactionField
612 * VdW interaction: Buckingham
613 * Geometry: Water3-Water3
614 * Calculate force/pot: Force
617 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_F_c
618 (t_nblist * gmx_restrict nlist,
619 rvec * gmx_restrict xx,
620 rvec * gmx_restrict ff,
621 t_forcerec * gmx_restrict fr,
622 t_mdatoms * gmx_restrict mdatoms,
623 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
624 t_nrnb * gmx_restrict nrnb)
626 int i_shift_offset,i_coord_offset,j_coord_offset;
627 int j_index_start,j_index_end;
628 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
629 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
630 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
631 real *shiftvec,*fshift,*x,*f;
633 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
635 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
637 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
639 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
641 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
643 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
644 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
645 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
646 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
647 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
648 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
649 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
650 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
651 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
652 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
653 real velec,felec,velecsum,facel,crf,krf,krf2;
656 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
665 jindex = nlist->jindex;
667 shiftidx = nlist->shift;
669 shiftvec = fr->shift_vec[0];
670 fshift = fr->fshift[0];
672 charge = mdatoms->chargeA;
676 nvdwtype = fr->ntype;
678 vdwtype = mdatoms->typeA;
680 /* Setup water-specific parameters */
681 inr = nlist->iinr[0];
682 iq0 = facel*charge[inr+0];
683 iq1 = facel*charge[inr+1];
684 iq2 = facel*charge[inr+2];
685 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
690 vdwjidx0 = 3*vdwtype[inr+0];
692 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
693 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
694 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
704 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
705 rcutoff = fr->rcoulomb;
706 rcutoff2 = rcutoff*rcutoff;
708 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
714 /* Start outer loop over neighborlists */
715 for(iidx=0; iidx<nri; iidx++)
717 /* Load shift vector for this list */
718 i_shift_offset = DIM*shiftidx[iidx];
719 shX = shiftvec[i_shift_offset+XX];
720 shY = shiftvec[i_shift_offset+YY];
721 shZ = shiftvec[i_shift_offset+ZZ];
723 /* Load limits for loop over neighbors */
724 j_index_start = jindex[iidx];
725 j_index_end = jindex[iidx+1];
727 /* Get outer coordinate index */
729 i_coord_offset = DIM*inr;
731 /* Load i particle coords and add shift vector */
732 ix0 = shX + x[i_coord_offset+DIM*0+XX];
733 iy0 = shY + x[i_coord_offset+DIM*0+YY];
734 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
735 ix1 = shX + x[i_coord_offset+DIM*1+XX];
736 iy1 = shY + x[i_coord_offset+DIM*1+YY];
737 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
738 ix2 = shX + x[i_coord_offset+DIM*2+XX];
739 iy2 = shY + x[i_coord_offset+DIM*2+YY];
740 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
752 /* Start inner kernel loop */
753 for(jidx=j_index_start; jidx<j_index_end; jidx++)
755 /* Get j neighbor index, and coordinate index */
757 j_coord_offset = DIM*jnr;
759 /* load j atom coordinates */
760 jx0 = x[j_coord_offset+DIM*0+XX];
761 jy0 = x[j_coord_offset+DIM*0+YY];
762 jz0 = x[j_coord_offset+DIM*0+ZZ];
763 jx1 = x[j_coord_offset+DIM*1+XX];
764 jy1 = x[j_coord_offset+DIM*1+YY];
765 jz1 = x[j_coord_offset+DIM*1+ZZ];
766 jx2 = x[j_coord_offset+DIM*2+XX];
767 jy2 = x[j_coord_offset+DIM*2+YY];
768 jz2 = x[j_coord_offset+DIM*2+ZZ];
770 /* Calculate displacement vector */
799 /* Calculate squared distance and things based on it */
800 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
801 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
802 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
803 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
804 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
805 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
806 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
807 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
808 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
810 rinv00 = gmx_invsqrt(rsq00);
811 rinv01 = gmx_invsqrt(rsq01);
812 rinv02 = gmx_invsqrt(rsq02);
813 rinv10 = gmx_invsqrt(rsq10);
814 rinv11 = gmx_invsqrt(rsq11);
815 rinv12 = gmx_invsqrt(rsq12);
816 rinv20 = gmx_invsqrt(rsq20);
817 rinv21 = gmx_invsqrt(rsq21);
818 rinv22 = gmx_invsqrt(rsq22);
820 rinvsq00 = rinv00*rinv00;
821 rinvsq01 = rinv01*rinv01;
822 rinvsq02 = rinv02*rinv02;
823 rinvsq10 = rinv10*rinv10;
824 rinvsq11 = rinv11*rinv11;
825 rinvsq12 = rinv12*rinv12;
826 rinvsq20 = rinv20*rinv20;
827 rinvsq21 = rinv21*rinv21;
828 rinvsq22 = rinv22*rinv22;
830 /**************************
831 * CALCULATE INTERACTIONS *
832 **************************/
839 /* REACTION-FIELD ELECTROSTATICS */
840 felec = qq00*(rinv00*rinvsq00-krf2);
842 /* BUCKINGHAM DISPERSION/REPULSION */
843 rinvsix = rinvsq00*rinvsq00*rinvsq00;
844 vvdw6 = c6_00*rinvsix;
846 vvdwexp = cexp1_00*exp(-br);
847 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
851 /* Calculate temporary vectorial force */
856 /* Update vectorial force */
860 f[j_coord_offset+DIM*0+XX] -= tx;
861 f[j_coord_offset+DIM*0+YY] -= ty;
862 f[j_coord_offset+DIM*0+ZZ] -= tz;
866 /**************************
867 * CALCULATE INTERACTIONS *
868 **************************/
873 /* REACTION-FIELD ELECTROSTATICS */
874 felec = qq01*(rinv01*rinvsq01-krf2);
878 /* Calculate temporary vectorial force */
883 /* Update vectorial force */
887 f[j_coord_offset+DIM*1+XX] -= tx;
888 f[j_coord_offset+DIM*1+YY] -= ty;
889 f[j_coord_offset+DIM*1+ZZ] -= tz;
893 /**************************
894 * CALCULATE INTERACTIONS *
895 **************************/
900 /* REACTION-FIELD ELECTROSTATICS */
901 felec = qq02*(rinv02*rinvsq02-krf2);
905 /* Calculate temporary vectorial force */
910 /* Update vectorial force */
914 f[j_coord_offset+DIM*2+XX] -= tx;
915 f[j_coord_offset+DIM*2+YY] -= ty;
916 f[j_coord_offset+DIM*2+ZZ] -= tz;
920 /**************************
921 * CALCULATE INTERACTIONS *
922 **************************/
927 /* REACTION-FIELD ELECTROSTATICS */
928 felec = qq10*(rinv10*rinvsq10-krf2);
932 /* Calculate temporary vectorial force */
937 /* Update vectorial force */
941 f[j_coord_offset+DIM*0+XX] -= tx;
942 f[j_coord_offset+DIM*0+YY] -= ty;
943 f[j_coord_offset+DIM*0+ZZ] -= tz;
947 /**************************
948 * CALCULATE INTERACTIONS *
949 **************************/
954 /* REACTION-FIELD ELECTROSTATICS */
955 felec = qq11*(rinv11*rinvsq11-krf2);
959 /* Calculate temporary vectorial force */
964 /* Update vectorial force */
968 f[j_coord_offset+DIM*1+XX] -= tx;
969 f[j_coord_offset+DIM*1+YY] -= ty;
970 f[j_coord_offset+DIM*1+ZZ] -= tz;
974 /**************************
975 * CALCULATE INTERACTIONS *
976 **************************/
981 /* REACTION-FIELD ELECTROSTATICS */
982 felec = qq12*(rinv12*rinvsq12-krf2);
986 /* Calculate temporary vectorial force */
991 /* Update vectorial force */
995 f[j_coord_offset+DIM*2+XX] -= tx;
996 f[j_coord_offset+DIM*2+YY] -= ty;
997 f[j_coord_offset+DIM*2+ZZ] -= tz;
1001 /**************************
1002 * CALCULATE INTERACTIONS *
1003 **************************/
1008 /* REACTION-FIELD ELECTROSTATICS */
1009 felec = qq20*(rinv20*rinvsq20-krf2);
1013 /* Calculate temporary vectorial force */
1018 /* Update vectorial force */
1022 f[j_coord_offset+DIM*0+XX] -= tx;
1023 f[j_coord_offset+DIM*0+YY] -= ty;
1024 f[j_coord_offset+DIM*0+ZZ] -= tz;
1028 /**************************
1029 * CALCULATE INTERACTIONS *
1030 **************************/
1035 /* REACTION-FIELD ELECTROSTATICS */
1036 felec = qq21*(rinv21*rinvsq21-krf2);
1040 /* Calculate temporary vectorial force */
1045 /* Update vectorial force */
1049 f[j_coord_offset+DIM*1+XX] -= tx;
1050 f[j_coord_offset+DIM*1+YY] -= ty;
1051 f[j_coord_offset+DIM*1+ZZ] -= tz;
1055 /**************************
1056 * CALCULATE INTERACTIONS *
1057 **************************/
1062 /* REACTION-FIELD ELECTROSTATICS */
1063 felec = qq22*(rinv22*rinvsq22-krf2);
1067 /* Calculate temporary vectorial force */
1072 /* Update vectorial force */
1076 f[j_coord_offset+DIM*2+XX] -= tx;
1077 f[j_coord_offset+DIM*2+YY] -= ty;
1078 f[j_coord_offset+DIM*2+ZZ] -= tz;
1082 /* Inner loop uses 270 flops */
1084 /* End of innermost loop */
1087 f[i_coord_offset+DIM*0+XX] += fix0;
1088 f[i_coord_offset+DIM*0+YY] += fiy0;
1089 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1093 f[i_coord_offset+DIM*1+XX] += fix1;
1094 f[i_coord_offset+DIM*1+YY] += fiy1;
1095 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1099 f[i_coord_offset+DIM*2+XX] += fix2;
1100 f[i_coord_offset+DIM*2+YY] += fiy2;
1101 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1105 fshift[i_shift_offset+XX] += tx;
1106 fshift[i_shift_offset+YY] += ty;
1107 fshift[i_shift_offset+ZZ] += tz;
1109 /* Increment number of inner iterations */
1110 inneriter += j_index_end - j_index_start;
1112 /* Outer loop uses 30 flops */
1115 /* Increment number of outer iterations */
1118 /* Update outer/inner flops */
1120 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*270);