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 "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSh_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 = 2*nvdwtype*vdwtype[inr+0];
130 vdwjidx0 = 2*vdwtype[inr+0];
132 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
133 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
143 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
144 rcutoff = fr->rcoulomb;
145 rcutoff2 = rcutoff*rcutoff;
147 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
153 /* Start outer loop over neighborlists */
154 for(iidx=0; iidx<nri; iidx++)
156 /* Load shift vector for this list */
157 i_shift_offset = DIM*shiftidx[iidx];
158 shX = shiftvec[i_shift_offset+XX];
159 shY = shiftvec[i_shift_offset+YY];
160 shZ = shiftvec[i_shift_offset+ZZ];
162 /* Load limits for loop over neighbors */
163 j_index_start = jindex[iidx];
164 j_index_end = jindex[iidx+1];
166 /* Get outer coordinate index */
168 i_coord_offset = DIM*inr;
170 /* Load i particle coords and add shift vector */
171 ix0 = shX + x[i_coord_offset+DIM*0+XX];
172 iy0 = shY + x[i_coord_offset+DIM*0+YY];
173 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
174 ix1 = shX + x[i_coord_offset+DIM*1+XX];
175 iy1 = shY + x[i_coord_offset+DIM*1+YY];
176 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
177 ix2 = shX + x[i_coord_offset+DIM*2+XX];
178 iy2 = shY + x[i_coord_offset+DIM*2+YY];
179 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
191 /* Reset potential sums */
195 /* Start inner kernel loop */
196 for(jidx=j_index_start; jidx<j_index_end; jidx++)
198 /* Get j neighbor index, and coordinate index */
200 j_coord_offset = DIM*jnr;
202 /* load j atom coordinates */
203 jx0 = x[j_coord_offset+DIM*0+XX];
204 jy0 = x[j_coord_offset+DIM*0+YY];
205 jz0 = x[j_coord_offset+DIM*0+ZZ];
206 jx1 = x[j_coord_offset+DIM*1+XX];
207 jy1 = x[j_coord_offset+DIM*1+YY];
208 jz1 = x[j_coord_offset+DIM*1+ZZ];
209 jx2 = x[j_coord_offset+DIM*2+XX];
210 jy2 = x[j_coord_offset+DIM*2+YY];
211 jz2 = x[j_coord_offset+DIM*2+ZZ];
213 /* Calculate displacement vector */
242 /* Calculate squared distance and things based on it */
243 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
244 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
245 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
246 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
247 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
248 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
249 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
250 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
251 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
253 rinv00 = gmx_invsqrt(rsq00);
254 rinv01 = gmx_invsqrt(rsq01);
255 rinv02 = gmx_invsqrt(rsq02);
256 rinv10 = gmx_invsqrt(rsq10);
257 rinv11 = gmx_invsqrt(rsq11);
258 rinv12 = gmx_invsqrt(rsq12);
259 rinv20 = gmx_invsqrt(rsq20);
260 rinv21 = gmx_invsqrt(rsq21);
261 rinv22 = gmx_invsqrt(rsq22);
263 rinvsq00 = rinv00*rinv00;
264 rinvsq01 = rinv01*rinv01;
265 rinvsq02 = rinv02*rinv02;
266 rinvsq10 = rinv10*rinv10;
267 rinvsq11 = rinv11*rinv11;
268 rinvsq12 = rinv12*rinv12;
269 rinvsq20 = rinv20*rinv20;
270 rinvsq21 = rinv21*rinv21;
271 rinvsq22 = rinv22*rinv22;
273 /**************************
274 * CALCULATE INTERACTIONS *
275 **************************/
280 /* REACTION-FIELD ELECTROSTATICS */
281 velec = qq00*(rinv00+krf*rsq00-crf);
282 felec = qq00*(rinv00*rinvsq00-krf2);
284 /* LENNARD-JONES DISPERSION/REPULSION */
286 rinvsix = rinvsq00*rinvsq00*rinvsq00;
287 vvdw6 = c6_00*rinvsix;
288 vvdw12 = c12_00*rinvsix*rinvsix;
289 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
290 fvdw = (vvdw12-vvdw6)*rinvsq00;
292 /* Update potential sums from outer loop */
298 /* Calculate temporary vectorial force */
303 /* Update vectorial force */
307 f[j_coord_offset+DIM*0+XX] -= tx;
308 f[j_coord_offset+DIM*0+YY] -= ty;
309 f[j_coord_offset+DIM*0+ZZ] -= tz;
313 /**************************
314 * CALCULATE INTERACTIONS *
315 **************************/
320 /* REACTION-FIELD ELECTROSTATICS */
321 velec = qq01*(rinv01+krf*rsq01-crf);
322 felec = qq01*(rinv01*rinvsq01-krf2);
324 /* Update potential sums from outer loop */
329 /* Calculate temporary vectorial force */
334 /* Update vectorial force */
338 f[j_coord_offset+DIM*1+XX] -= tx;
339 f[j_coord_offset+DIM*1+YY] -= ty;
340 f[j_coord_offset+DIM*1+ZZ] -= tz;
344 /**************************
345 * CALCULATE INTERACTIONS *
346 **************************/
351 /* REACTION-FIELD ELECTROSTATICS */
352 velec = qq02*(rinv02+krf*rsq02-crf);
353 felec = qq02*(rinv02*rinvsq02-krf2);
355 /* Update potential sums from outer loop */
360 /* Calculate temporary vectorial force */
365 /* Update vectorial force */
369 f[j_coord_offset+DIM*2+XX] -= tx;
370 f[j_coord_offset+DIM*2+YY] -= ty;
371 f[j_coord_offset+DIM*2+ZZ] -= tz;
375 /**************************
376 * CALCULATE INTERACTIONS *
377 **************************/
382 /* REACTION-FIELD ELECTROSTATICS */
383 velec = qq10*(rinv10+krf*rsq10-crf);
384 felec = qq10*(rinv10*rinvsq10-krf2);
386 /* Update potential sums from outer loop */
391 /* Calculate temporary vectorial force */
396 /* Update vectorial force */
400 f[j_coord_offset+DIM*0+XX] -= tx;
401 f[j_coord_offset+DIM*0+YY] -= ty;
402 f[j_coord_offset+DIM*0+ZZ] -= tz;
406 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
413 /* REACTION-FIELD ELECTROSTATICS */
414 velec = qq11*(rinv11+krf*rsq11-crf);
415 felec = qq11*(rinv11*rinvsq11-krf2);
417 /* Update potential sums from outer loop */
422 /* Calculate temporary vectorial force */
427 /* Update vectorial force */
431 f[j_coord_offset+DIM*1+XX] -= tx;
432 f[j_coord_offset+DIM*1+YY] -= ty;
433 f[j_coord_offset+DIM*1+ZZ] -= tz;
437 /**************************
438 * CALCULATE INTERACTIONS *
439 **************************/
444 /* REACTION-FIELD ELECTROSTATICS */
445 velec = qq12*(rinv12+krf*rsq12-crf);
446 felec = qq12*(rinv12*rinvsq12-krf2);
448 /* Update potential sums from outer loop */
453 /* Calculate temporary vectorial force */
458 /* Update vectorial force */
462 f[j_coord_offset+DIM*2+XX] -= tx;
463 f[j_coord_offset+DIM*2+YY] -= ty;
464 f[j_coord_offset+DIM*2+ZZ] -= tz;
468 /**************************
469 * CALCULATE INTERACTIONS *
470 **************************/
475 /* REACTION-FIELD ELECTROSTATICS */
476 velec = qq20*(rinv20+krf*rsq20-crf);
477 felec = qq20*(rinv20*rinvsq20-krf2);
479 /* Update potential sums from outer loop */
484 /* Calculate temporary vectorial force */
489 /* Update vectorial force */
493 f[j_coord_offset+DIM*0+XX] -= tx;
494 f[j_coord_offset+DIM*0+YY] -= ty;
495 f[j_coord_offset+DIM*0+ZZ] -= tz;
499 /**************************
500 * CALCULATE INTERACTIONS *
501 **************************/
506 /* REACTION-FIELD ELECTROSTATICS */
507 velec = qq21*(rinv21+krf*rsq21-crf);
508 felec = qq21*(rinv21*rinvsq21-krf2);
510 /* Update potential sums from outer loop */
515 /* Calculate temporary vectorial force */
520 /* Update vectorial force */
524 f[j_coord_offset+DIM*1+XX] -= tx;
525 f[j_coord_offset+DIM*1+YY] -= ty;
526 f[j_coord_offset+DIM*1+ZZ] -= tz;
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
537 /* REACTION-FIELD ELECTROSTATICS */
538 velec = qq22*(rinv22+krf*rsq22-crf);
539 felec = qq22*(rinv22*rinvsq22-krf2);
541 /* Update potential sums from outer loop */
546 /* Calculate temporary vectorial force */
551 /* Update vectorial force */
555 f[j_coord_offset+DIM*2+XX] -= tx;
556 f[j_coord_offset+DIM*2+YY] -= ty;
557 f[j_coord_offset+DIM*2+ZZ] -= tz;
561 /* Inner loop uses 296 flops */
563 /* End of innermost loop */
566 f[i_coord_offset+DIM*0+XX] += fix0;
567 f[i_coord_offset+DIM*0+YY] += fiy0;
568 f[i_coord_offset+DIM*0+ZZ] += fiz0;
572 f[i_coord_offset+DIM*1+XX] += fix1;
573 f[i_coord_offset+DIM*1+YY] += fiy1;
574 f[i_coord_offset+DIM*1+ZZ] += fiz1;
578 f[i_coord_offset+DIM*2+XX] += fix2;
579 f[i_coord_offset+DIM*2+YY] += fiy2;
580 f[i_coord_offset+DIM*2+ZZ] += fiz2;
584 fshift[i_shift_offset+XX] += tx;
585 fshift[i_shift_offset+YY] += ty;
586 fshift[i_shift_offset+ZZ] += tz;
589 /* Update potential energies */
590 kernel_data->energygrp_elec[ggid] += velecsum;
591 kernel_data->energygrp_vdw[ggid] += vvdwsum;
593 /* Increment number of inner iterations */
594 inneriter += j_index_end - j_index_start;
596 /* Outer loop uses 32 flops */
599 /* Increment number of outer iterations */
602 /* Update outer/inner flops */
604 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*296);
607 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_F_c
608 * Electrostatics interaction: ReactionField
609 * VdW interaction: LennardJones
610 * Geometry: Water3-Water3
611 * Calculate force/pot: Force
614 nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_F_c
615 (t_nblist * gmx_restrict nlist,
616 rvec * gmx_restrict xx,
617 rvec * gmx_restrict ff,
618 t_forcerec * gmx_restrict fr,
619 t_mdatoms * gmx_restrict mdatoms,
620 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
621 t_nrnb * gmx_restrict nrnb)
623 int i_shift_offset,i_coord_offset,j_coord_offset;
624 int j_index_start,j_index_end;
625 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
626 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
627 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
628 real *shiftvec,*fshift,*x,*f;
630 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
632 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
634 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
636 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
638 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
640 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
641 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
642 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
643 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
644 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
645 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
646 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
647 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
648 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
649 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
650 real velec,felec,velecsum,facel,crf,krf,krf2;
653 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
662 jindex = nlist->jindex;
664 shiftidx = nlist->shift;
666 shiftvec = fr->shift_vec[0];
667 fshift = fr->fshift[0];
669 charge = mdatoms->chargeA;
673 nvdwtype = fr->ntype;
675 vdwtype = mdatoms->typeA;
677 /* Setup water-specific parameters */
678 inr = nlist->iinr[0];
679 iq0 = facel*charge[inr+0];
680 iq1 = facel*charge[inr+1];
681 iq2 = facel*charge[inr+2];
682 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
687 vdwjidx0 = 2*vdwtype[inr+0];
689 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
690 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
700 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
701 rcutoff = fr->rcoulomb;
702 rcutoff2 = rcutoff*rcutoff;
704 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
710 /* Start outer loop over neighborlists */
711 for(iidx=0; iidx<nri; iidx++)
713 /* Load shift vector for this list */
714 i_shift_offset = DIM*shiftidx[iidx];
715 shX = shiftvec[i_shift_offset+XX];
716 shY = shiftvec[i_shift_offset+YY];
717 shZ = shiftvec[i_shift_offset+ZZ];
719 /* Load limits for loop over neighbors */
720 j_index_start = jindex[iidx];
721 j_index_end = jindex[iidx+1];
723 /* Get outer coordinate index */
725 i_coord_offset = DIM*inr;
727 /* Load i particle coords and add shift vector */
728 ix0 = shX + x[i_coord_offset+DIM*0+XX];
729 iy0 = shY + x[i_coord_offset+DIM*0+YY];
730 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
731 ix1 = shX + x[i_coord_offset+DIM*1+XX];
732 iy1 = shY + x[i_coord_offset+DIM*1+YY];
733 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
734 ix2 = shX + x[i_coord_offset+DIM*2+XX];
735 iy2 = shY + x[i_coord_offset+DIM*2+YY];
736 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
748 /* Start inner kernel loop */
749 for(jidx=j_index_start; jidx<j_index_end; jidx++)
751 /* Get j neighbor index, and coordinate index */
753 j_coord_offset = DIM*jnr;
755 /* load j atom coordinates */
756 jx0 = x[j_coord_offset+DIM*0+XX];
757 jy0 = x[j_coord_offset+DIM*0+YY];
758 jz0 = x[j_coord_offset+DIM*0+ZZ];
759 jx1 = x[j_coord_offset+DIM*1+XX];
760 jy1 = x[j_coord_offset+DIM*1+YY];
761 jz1 = x[j_coord_offset+DIM*1+ZZ];
762 jx2 = x[j_coord_offset+DIM*2+XX];
763 jy2 = x[j_coord_offset+DIM*2+YY];
764 jz2 = x[j_coord_offset+DIM*2+ZZ];
766 /* Calculate displacement vector */
795 /* Calculate squared distance and things based on it */
796 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
797 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
798 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
799 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
800 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
801 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
802 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
803 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
804 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
806 rinv00 = gmx_invsqrt(rsq00);
807 rinv01 = gmx_invsqrt(rsq01);
808 rinv02 = gmx_invsqrt(rsq02);
809 rinv10 = gmx_invsqrt(rsq10);
810 rinv11 = gmx_invsqrt(rsq11);
811 rinv12 = gmx_invsqrt(rsq12);
812 rinv20 = gmx_invsqrt(rsq20);
813 rinv21 = gmx_invsqrt(rsq21);
814 rinv22 = gmx_invsqrt(rsq22);
816 rinvsq00 = rinv00*rinv00;
817 rinvsq01 = rinv01*rinv01;
818 rinvsq02 = rinv02*rinv02;
819 rinvsq10 = rinv10*rinv10;
820 rinvsq11 = rinv11*rinv11;
821 rinvsq12 = rinv12*rinv12;
822 rinvsq20 = rinv20*rinv20;
823 rinvsq21 = rinv21*rinv21;
824 rinvsq22 = rinv22*rinv22;
826 /**************************
827 * CALCULATE INTERACTIONS *
828 **************************/
833 /* REACTION-FIELD ELECTROSTATICS */
834 felec = qq00*(rinv00*rinvsq00-krf2);
836 /* LENNARD-JONES DISPERSION/REPULSION */
838 rinvsix = rinvsq00*rinvsq00*rinvsq00;
839 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
843 /* Calculate temporary vectorial force */
848 /* Update vectorial force */
852 f[j_coord_offset+DIM*0+XX] -= tx;
853 f[j_coord_offset+DIM*0+YY] -= ty;
854 f[j_coord_offset+DIM*0+ZZ] -= tz;
858 /**************************
859 * CALCULATE INTERACTIONS *
860 **************************/
865 /* REACTION-FIELD ELECTROSTATICS */
866 felec = qq01*(rinv01*rinvsq01-krf2);
870 /* Calculate temporary vectorial force */
875 /* Update vectorial force */
879 f[j_coord_offset+DIM*1+XX] -= tx;
880 f[j_coord_offset+DIM*1+YY] -= ty;
881 f[j_coord_offset+DIM*1+ZZ] -= tz;
885 /**************************
886 * CALCULATE INTERACTIONS *
887 **************************/
892 /* REACTION-FIELD ELECTROSTATICS */
893 felec = qq02*(rinv02*rinvsq02-krf2);
897 /* Calculate temporary vectorial force */
902 /* Update vectorial force */
906 f[j_coord_offset+DIM*2+XX] -= tx;
907 f[j_coord_offset+DIM*2+YY] -= ty;
908 f[j_coord_offset+DIM*2+ZZ] -= tz;
912 /**************************
913 * CALCULATE INTERACTIONS *
914 **************************/
919 /* REACTION-FIELD ELECTROSTATICS */
920 felec = qq10*(rinv10*rinvsq10-krf2);
924 /* Calculate temporary vectorial force */
929 /* Update vectorial force */
933 f[j_coord_offset+DIM*0+XX] -= tx;
934 f[j_coord_offset+DIM*0+YY] -= ty;
935 f[j_coord_offset+DIM*0+ZZ] -= tz;
939 /**************************
940 * CALCULATE INTERACTIONS *
941 **************************/
946 /* REACTION-FIELD ELECTROSTATICS */
947 felec = qq11*(rinv11*rinvsq11-krf2);
951 /* Calculate temporary vectorial force */
956 /* Update vectorial force */
960 f[j_coord_offset+DIM*1+XX] -= tx;
961 f[j_coord_offset+DIM*1+YY] -= ty;
962 f[j_coord_offset+DIM*1+ZZ] -= tz;
966 /**************************
967 * CALCULATE INTERACTIONS *
968 **************************/
973 /* REACTION-FIELD ELECTROSTATICS */
974 felec = qq12*(rinv12*rinvsq12-krf2);
978 /* Calculate temporary vectorial force */
983 /* Update vectorial force */
987 f[j_coord_offset+DIM*2+XX] -= tx;
988 f[j_coord_offset+DIM*2+YY] -= ty;
989 f[j_coord_offset+DIM*2+ZZ] -= tz;
993 /**************************
994 * CALCULATE INTERACTIONS *
995 **************************/
1000 /* REACTION-FIELD ELECTROSTATICS */
1001 felec = qq20*(rinv20*rinvsq20-krf2);
1005 /* Calculate temporary vectorial force */
1010 /* Update vectorial force */
1014 f[j_coord_offset+DIM*0+XX] -= tx;
1015 f[j_coord_offset+DIM*0+YY] -= ty;
1016 f[j_coord_offset+DIM*0+ZZ] -= tz;
1020 /**************************
1021 * CALCULATE INTERACTIONS *
1022 **************************/
1027 /* REACTION-FIELD ELECTROSTATICS */
1028 felec = qq21*(rinv21*rinvsq21-krf2);
1032 /* Calculate temporary vectorial force */
1037 /* Update vectorial force */
1041 f[j_coord_offset+DIM*1+XX] -= tx;
1042 f[j_coord_offset+DIM*1+YY] -= ty;
1043 f[j_coord_offset+DIM*1+ZZ] -= tz;
1047 /**************************
1048 * CALCULATE INTERACTIONS *
1049 **************************/
1054 /* REACTION-FIELD ELECTROSTATICS */
1055 felec = qq22*(rinv22*rinvsq22-krf2);
1059 /* Calculate temporary vectorial force */
1064 /* Update vectorial force */
1068 f[j_coord_offset+DIM*2+XX] -= tx;
1069 f[j_coord_offset+DIM*2+YY] -= ty;
1070 f[j_coord_offset+DIM*2+ZZ] -= tz;
1074 /* Inner loop uses 241 flops */
1076 /* End of innermost loop */
1079 f[i_coord_offset+DIM*0+XX] += fix0;
1080 f[i_coord_offset+DIM*0+YY] += fiy0;
1081 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1085 f[i_coord_offset+DIM*1+XX] += fix1;
1086 f[i_coord_offset+DIM*1+YY] += fiy1;
1087 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1091 f[i_coord_offset+DIM*2+XX] += fix2;
1092 f[i_coord_offset+DIM*2+YY] += fiy2;
1093 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1097 fshift[i_shift_offset+XX] += tx;
1098 fshift[i_shift_offset+YY] += ty;
1099 fshift[i_shift_offset+ZZ] += tz;
1101 /* Increment number of inner iterations */
1102 inneriter += j_index_end - j_index_start;
1104 /* Outer loop uses 30 flops */
1107 /* Increment number of outer iterations */
1110 /* Update outer/inner flops */
1112 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*241);