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 "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
103 jindex = nlist->jindex;
105 shiftidx = nlist->shift;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
110 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 /* Setup water-specific parameters */
119 inr = nlist->iinr[0];
120 iq0 = facel*charge[inr+0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
123 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
128 vdwjidx0 = 2*vdwtype[inr+0];
130 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
131 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
141 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
142 rcutoff = fr->rcoulomb;
143 rcutoff2 = rcutoff*rcutoff;
145 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
151 /* Start outer loop over neighborlists */
152 for(iidx=0; iidx<nri; iidx++)
154 /* Load shift vector for this list */
155 i_shift_offset = DIM*shiftidx[iidx];
156 shX = shiftvec[i_shift_offset+XX];
157 shY = shiftvec[i_shift_offset+YY];
158 shZ = shiftvec[i_shift_offset+ZZ];
160 /* Load limits for loop over neighbors */
161 j_index_start = jindex[iidx];
162 j_index_end = jindex[iidx+1];
164 /* Get outer coordinate index */
166 i_coord_offset = DIM*inr;
168 /* Load i particle coords and add shift vector */
169 ix0 = shX + x[i_coord_offset+DIM*0+XX];
170 iy0 = shY + x[i_coord_offset+DIM*0+YY];
171 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
172 ix1 = shX + x[i_coord_offset+DIM*1+XX];
173 iy1 = shY + x[i_coord_offset+DIM*1+YY];
174 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
175 ix2 = shX + x[i_coord_offset+DIM*2+XX];
176 iy2 = shY + x[i_coord_offset+DIM*2+YY];
177 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
189 /* Reset potential sums */
193 /* Start inner kernel loop */
194 for(jidx=j_index_start; jidx<j_index_end; jidx++)
196 /* Get j neighbor index, and coordinate index */
198 j_coord_offset = DIM*jnr;
200 /* load j atom coordinates */
201 jx0 = x[j_coord_offset+DIM*0+XX];
202 jy0 = x[j_coord_offset+DIM*0+YY];
203 jz0 = x[j_coord_offset+DIM*0+ZZ];
204 jx1 = x[j_coord_offset+DIM*1+XX];
205 jy1 = x[j_coord_offset+DIM*1+YY];
206 jz1 = x[j_coord_offset+DIM*1+ZZ];
207 jx2 = x[j_coord_offset+DIM*2+XX];
208 jy2 = x[j_coord_offset+DIM*2+YY];
209 jz2 = x[j_coord_offset+DIM*2+ZZ];
211 /* Calculate displacement vector */
240 /* Calculate squared distance and things based on it */
241 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
242 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
243 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
244 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
245 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
246 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
247 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
248 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
249 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
251 rinv00 = gmx_invsqrt(rsq00);
252 rinv01 = gmx_invsqrt(rsq01);
253 rinv02 = gmx_invsqrt(rsq02);
254 rinv10 = gmx_invsqrt(rsq10);
255 rinv11 = gmx_invsqrt(rsq11);
256 rinv12 = gmx_invsqrt(rsq12);
257 rinv20 = gmx_invsqrt(rsq20);
258 rinv21 = gmx_invsqrt(rsq21);
259 rinv22 = gmx_invsqrt(rsq22);
261 rinvsq00 = rinv00*rinv00;
262 rinvsq01 = rinv01*rinv01;
263 rinvsq02 = rinv02*rinv02;
264 rinvsq10 = rinv10*rinv10;
265 rinvsq11 = rinv11*rinv11;
266 rinvsq12 = rinv12*rinv12;
267 rinvsq20 = rinv20*rinv20;
268 rinvsq21 = rinv21*rinv21;
269 rinvsq22 = rinv22*rinv22;
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
278 /* REACTION-FIELD ELECTROSTATICS */
279 velec = qq00*(rinv00+krf*rsq00-crf);
280 felec = qq00*(rinv00*rinvsq00-krf2);
282 /* LENNARD-JONES DISPERSION/REPULSION */
284 rinvsix = rinvsq00*rinvsq00*rinvsq00;
285 vvdw6 = c6_00*rinvsix;
286 vvdw12 = c12_00*rinvsix*rinvsix;
287 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
288 fvdw = (vvdw12-vvdw6)*rinvsq00;
290 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
318 /* REACTION-FIELD ELECTROSTATICS */
319 velec = qq01*(rinv01+krf*rsq01-crf);
320 felec = qq01*(rinv01*rinvsq01-krf2);
322 /* Update potential sums from outer loop */
327 /* Calculate temporary vectorial force */
332 /* Update vectorial force */
336 f[j_coord_offset+DIM*1+XX] -= tx;
337 f[j_coord_offset+DIM*1+YY] -= ty;
338 f[j_coord_offset+DIM*1+ZZ] -= tz;
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
349 /* REACTION-FIELD ELECTROSTATICS */
350 velec = qq02*(rinv02+krf*rsq02-crf);
351 felec = qq02*(rinv02*rinvsq02-krf2);
353 /* Update potential sums from outer loop */
358 /* Calculate temporary vectorial force */
363 /* Update vectorial force */
367 f[j_coord_offset+DIM*2+XX] -= tx;
368 f[j_coord_offset+DIM*2+YY] -= ty;
369 f[j_coord_offset+DIM*2+ZZ] -= tz;
373 /**************************
374 * CALCULATE INTERACTIONS *
375 **************************/
380 /* REACTION-FIELD ELECTROSTATICS */
381 velec = qq10*(rinv10+krf*rsq10-crf);
382 felec = qq10*(rinv10*rinvsq10-krf2);
384 /* Update potential sums from outer loop */
389 /* Calculate temporary vectorial force */
394 /* Update vectorial force */
398 f[j_coord_offset+DIM*0+XX] -= tx;
399 f[j_coord_offset+DIM*0+YY] -= ty;
400 f[j_coord_offset+DIM*0+ZZ] -= tz;
404 /**************************
405 * CALCULATE INTERACTIONS *
406 **************************/
411 /* REACTION-FIELD ELECTROSTATICS */
412 velec = qq11*(rinv11+krf*rsq11-crf);
413 felec = qq11*(rinv11*rinvsq11-krf2);
415 /* Update potential sums from outer loop */
420 /* Calculate temporary vectorial force */
425 /* Update vectorial force */
429 f[j_coord_offset+DIM*1+XX] -= tx;
430 f[j_coord_offset+DIM*1+YY] -= ty;
431 f[j_coord_offset+DIM*1+ZZ] -= tz;
435 /**************************
436 * CALCULATE INTERACTIONS *
437 **************************/
442 /* REACTION-FIELD ELECTROSTATICS */
443 velec = qq12*(rinv12+krf*rsq12-crf);
444 felec = qq12*(rinv12*rinvsq12-krf2);
446 /* Update potential sums from outer loop */
451 /* Calculate temporary vectorial force */
456 /* Update vectorial force */
460 f[j_coord_offset+DIM*2+XX] -= tx;
461 f[j_coord_offset+DIM*2+YY] -= ty;
462 f[j_coord_offset+DIM*2+ZZ] -= tz;
466 /**************************
467 * CALCULATE INTERACTIONS *
468 **************************/
473 /* REACTION-FIELD ELECTROSTATICS */
474 velec = qq20*(rinv20+krf*rsq20-crf);
475 felec = qq20*(rinv20*rinvsq20-krf2);
477 /* Update potential sums from outer loop */
482 /* Calculate temporary vectorial force */
487 /* Update vectorial force */
491 f[j_coord_offset+DIM*0+XX] -= tx;
492 f[j_coord_offset+DIM*0+YY] -= ty;
493 f[j_coord_offset+DIM*0+ZZ] -= tz;
497 /**************************
498 * CALCULATE INTERACTIONS *
499 **************************/
504 /* REACTION-FIELD ELECTROSTATICS */
505 velec = qq21*(rinv21+krf*rsq21-crf);
506 felec = qq21*(rinv21*rinvsq21-krf2);
508 /* Update potential sums from outer loop */
513 /* Calculate temporary vectorial force */
518 /* Update vectorial force */
522 f[j_coord_offset+DIM*1+XX] -= tx;
523 f[j_coord_offset+DIM*1+YY] -= ty;
524 f[j_coord_offset+DIM*1+ZZ] -= tz;
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
535 /* REACTION-FIELD ELECTROSTATICS */
536 velec = qq22*(rinv22+krf*rsq22-crf);
537 felec = qq22*(rinv22*rinvsq22-krf2);
539 /* Update potential sums from outer loop */
544 /* Calculate temporary vectorial force */
549 /* Update vectorial force */
553 f[j_coord_offset+DIM*2+XX] -= tx;
554 f[j_coord_offset+DIM*2+YY] -= ty;
555 f[j_coord_offset+DIM*2+ZZ] -= tz;
559 /* Inner loop uses 296 flops */
561 /* End of innermost loop */
564 f[i_coord_offset+DIM*0+XX] += fix0;
565 f[i_coord_offset+DIM*0+YY] += fiy0;
566 f[i_coord_offset+DIM*0+ZZ] += fiz0;
570 f[i_coord_offset+DIM*1+XX] += fix1;
571 f[i_coord_offset+DIM*1+YY] += fiy1;
572 f[i_coord_offset+DIM*1+ZZ] += fiz1;
576 f[i_coord_offset+DIM*2+XX] += fix2;
577 f[i_coord_offset+DIM*2+YY] += fiy2;
578 f[i_coord_offset+DIM*2+ZZ] += fiz2;
582 fshift[i_shift_offset+XX] += tx;
583 fshift[i_shift_offset+YY] += ty;
584 fshift[i_shift_offset+ZZ] += tz;
587 /* Update potential energies */
588 kernel_data->energygrp_elec[ggid] += velecsum;
589 kernel_data->energygrp_vdw[ggid] += vvdwsum;
591 /* Increment number of inner iterations */
592 inneriter += j_index_end - j_index_start;
594 /* Outer loop uses 32 flops */
597 /* Increment number of outer iterations */
600 /* Update outer/inner flops */
602 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*296);
605 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_F_c
606 * Electrostatics interaction: ReactionField
607 * VdW interaction: LennardJones
608 * Geometry: Water3-Water3
609 * Calculate force/pot: Force
612 nb_kernel_ElecRFCut_VdwLJSh_GeomW3W3_F_c
613 (t_nblist * gmx_restrict nlist,
614 rvec * gmx_restrict xx,
615 rvec * gmx_restrict ff,
616 t_forcerec * gmx_restrict fr,
617 t_mdatoms * gmx_restrict mdatoms,
618 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
619 t_nrnb * gmx_restrict nrnb)
621 int i_shift_offset,i_coord_offset,j_coord_offset;
622 int j_index_start,j_index_end;
623 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
624 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
625 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
626 real *shiftvec,*fshift,*x,*f;
628 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
630 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
632 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
634 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
636 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
638 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
639 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
640 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
641 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
642 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
643 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
644 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
645 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
646 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
647 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
648 real velec,felec,velecsum,facel,crf,krf,krf2;
651 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
660 jindex = nlist->jindex;
662 shiftidx = nlist->shift;
664 shiftvec = fr->shift_vec[0];
665 fshift = fr->fshift[0];
667 charge = mdatoms->chargeA;
671 nvdwtype = fr->ntype;
673 vdwtype = mdatoms->typeA;
675 /* Setup water-specific parameters */
676 inr = nlist->iinr[0];
677 iq0 = facel*charge[inr+0];
678 iq1 = facel*charge[inr+1];
679 iq2 = facel*charge[inr+2];
680 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
685 vdwjidx0 = 2*vdwtype[inr+0];
687 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
688 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
698 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
699 rcutoff = fr->rcoulomb;
700 rcutoff2 = rcutoff*rcutoff;
702 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
708 /* Start outer loop over neighborlists */
709 for(iidx=0; iidx<nri; iidx++)
711 /* Load shift vector for this list */
712 i_shift_offset = DIM*shiftidx[iidx];
713 shX = shiftvec[i_shift_offset+XX];
714 shY = shiftvec[i_shift_offset+YY];
715 shZ = shiftvec[i_shift_offset+ZZ];
717 /* Load limits for loop over neighbors */
718 j_index_start = jindex[iidx];
719 j_index_end = jindex[iidx+1];
721 /* Get outer coordinate index */
723 i_coord_offset = DIM*inr;
725 /* Load i particle coords and add shift vector */
726 ix0 = shX + x[i_coord_offset+DIM*0+XX];
727 iy0 = shY + x[i_coord_offset+DIM*0+YY];
728 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
729 ix1 = shX + x[i_coord_offset+DIM*1+XX];
730 iy1 = shY + x[i_coord_offset+DIM*1+YY];
731 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
732 ix2 = shX + x[i_coord_offset+DIM*2+XX];
733 iy2 = shY + x[i_coord_offset+DIM*2+YY];
734 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
746 /* Start inner kernel loop */
747 for(jidx=j_index_start; jidx<j_index_end; jidx++)
749 /* Get j neighbor index, and coordinate index */
751 j_coord_offset = DIM*jnr;
753 /* load j atom coordinates */
754 jx0 = x[j_coord_offset+DIM*0+XX];
755 jy0 = x[j_coord_offset+DIM*0+YY];
756 jz0 = x[j_coord_offset+DIM*0+ZZ];
757 jx1 = x[j_coord_offset+DIM*1+XX];
758 jy1 = x[j_coord_offset+DIM*1+YY];
759 jz1 = x[j_coord_offset+DIM*1+ZZ];
760 jx2 = x[j_coord_offset+DIM*2+XX];
761 jy2 = x[j_coord_offset+DIM*2+YY];
762 jz2 = x[j_coord_offset+DIM*2+ZZ];
764 /* Calculate displacement vector */
793 /* Calculate squared distance and things based on it */
794 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
795 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
796 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
797 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
798 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
799 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
800 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
801 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
802 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
804 rinv00 = gmx_invsqrt(rsq00);
805 rinv01 = gmx_invsqrt(rsq01);
806 rinv02 = gmx_invsqrt(rsq02);
807 rinv10 = gmx_invsqrt(rsq10);
808 rinv11 = gmx_invsqrt(rsq11);
809 rinv12 = gmx_invsqrt(rsq12);
810 rinv20 = gmx_invsqrt(rsq20);
811 rinv21 = gmx_invsqrt(rsq21);
812 rinv22 = gmx_invsqrt(rsq22);
814 rinvsq00 = rinv00*rinv00;
815 rinvsq01 = rinv01*rinv01;
816 rinvsq02 = rinv02*rinv02;
817 rinvsq10 = rinv10*rinv10;
818 rinvsq11 = rinv11*rinv11;
819 rinvsq12 = rinv12*rinv12;
820 rinvsq20 = rinv20*rinv20;
821 rinvsq21 = rinv21*rinv21;
822 rinvsq22 = rinv22*rinv22;
824 /**************************
825 * CALCULATE INTERACTIONS *
826 **************************/
831 /* REACTION-FIELD ELECTROSTATICS */
832 felec = qq00*(rinv00*rinvsq00-krf2);
834 /* LENNARD-JONES DISPERSION/REPULSION */
836 rinvsix = rinvsq00*rinvsq00*rinvsq00;
837 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
841 /* Calculate temporary vectorial force */
846 /* Update vectorial force */
850 f[j_coord_offset+DIM*0+XX] -= tx;
851 f[j_coord_offset+DIM*0+YY] -= ty;
852 f[j_coord_offset+DIM*0+ZZ] -= tz;
856 /**************************
857 * CALCULATE INTERACTIONS *
858 **************************/
863 /* REACTION-FIELD ELECTROSTATICS */
864 felec = qq01*(rinv01*rinvsq01-krf2);
868 /* Calculate temporary vectorial force */
873 /* Update vectorial force */
877 f[j_coord_offset+DIM*1+XX] -= tx;
878 f[j_coord_offset+DIM*1+YY] -= ty;
879 f[j_coord_offset+DIM*1+ZZ] -= tz;
883 /**************************
884 * CALCULATE INTERACTIONS *
885 **************************/
890 /* REACTION-FIELD ELECTROSTATICS */
891 felec = qq02*(rinv02*rinvsq02-krf2);
895 /* Calculate temporary vectorial force */
900 /* Update vectorial force */
904 f[j_coord_offset+DIM*2+XX] -= tx;
905 f[j_coord_offset+DIM*2+YY] -= ty;
906 f[j_coord_offset+DIM*2+ZZ] -= tz;
910 /**************************
911 * CALCULATE INTERACTIONS *
912 **************************/
917 /* REACTION-FIELD ELECTROSTATICS */
918 felec = qq10*(rinv10*rinvsq10-krf2);
922 /* Calculate temporary vectorial force */
927 /* Update vectorial force */
931 f[j_coord_offset+DIM*0+XX] -= tx;
932 f[j_coord_offset+DIM*0+YY] -= ty;
933 f[j_coord_offset+DIM*0+ZZ] -= tz;
937 /**************************
938 * CALCULATE INTERACTIONS *
939 **************************/
944 /* REACTION-FIELD ELECTROSTATICS */
945 felec = qq11*(rinv11*rinvsq11-krf2);
949 /* Calculate temporary vectorial force */
954 /* Update vectorial force */
958 f[j_coord_offset+DIM*1+XX] -= tx;
959 f[j_coord_offset+DIM*1+YY] -= ty;
960 f[j_coord_offset+DIM*1+ZZ] -= tz;
964 /**************************
965 * CALCULATE INTERACTIONS *
966 **************************/
971 /* REACTION-FIELD ELECTROSTATICS */
972 felec = qq12*(rinv12*rinvsq12-krf2);
976 /* Calculate temporary vectorial force */
981 /* Update vectorial force */
985 f[j_coord_offset+DIM*2+XX] -= tx;
986 f[j_coord_offset+DIM*2+YY] -= ty;
987 f[j_coord_offset+DIM*2+ZZ] -= tz;
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
998 /* REACTION-FIELD ELECTROSTATICS */
999 felec = qq20*(rinv20*rinvsq20-krf2);
1003 /* Calculate temporary vectorial force */
1008 /* Update vectorial force */
1012 f[j_coord_offset+DIM*0+XX] -= tx;
1013 f[j_coord_offset+DIM*0+YY] -= ty;
1014 f[j_coord_offset+DIM*0+ZZ] -= tz;
1018 /**************************
1019 * CALCULATE INTERACTIONS *
1020 **************************/
1025 /* REACTION-FIELD ELECTROSTATICS */
1026 felec = qq21*(rinv21*rinvsq21-krf2);
1030 /* Calculate temporary vectorial force */
1035 /* Update vectorial force */
1039 f[j_coord_offset+DIM*1+XX] -= tx;
1040 f[j_coord_offset+DIM*1+YY] -= ty;
1041 f[j_coord_offset+DIM*1+ZZ] -= tz;
1045 /**************************
1046 * CALCULATE INTERACTIONS *
1047 **************************/
1052 /* REACTION-FIELD ELECTROSTATICS */
1053 felec = qq22*(rinv22*rinvsq22-krf2);
1057 /* Calculate temporary vectorial force */
1062 /* Update vectorial force */
1066 f[j_coord_offset+DIM*2+XX] -= tx;
1067 f[j_coord_offset+DIM*2+YY] -= ty;
1068 f[j_coord_offset+DIM*2+ZZ] -= tz;
1072 /* Inner loop uses 241 flops */
1074 /* End of innermost loop */
1077 f[i_coord_offset+DIM*0+XX] += fix0;
1078 f[i_coord_offset+DIM*0+YY] += fiy0;
1079 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1083 f[i_coord_offset+DIM*1+XX] += fix1;
1084 f[i_coord_offset+DIM*1+YY] += fiy1;
1085 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1089 f[i_coord_offset+DIM*2+XX] += fix2;
1090 f[i_coord_offset+DIM*2+YY] += fiy2;
1091 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1095 fshift[i_shift_offset+XX] += tx;
1096 fshift[i_shift_offset+YY] += ty;
1097 fshift[i_shift_offset+ZZ] += tz;
1099 /* Increment number of inner iterations */
1100 inneriter += j_index_end - j_index_start;
1102 /* Outer loop uses 30 flops */
1105 /* Increment number of outer iterations */
1108 /* Update outer/inner flops */
1110 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*241);