f96242365720731cfa052a463221a74ec84716e2
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_c.c
1 /*
2  * Note: this file was generated by the Gromacs c kernel generator.
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  * Copyright (c) 2001-2012, The GROMACS Development Team
9  *
10  * Gromacs is a library for molecular simulation and trajectory analysis,
11  * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12  * a full list of developers and information, check out http://www.gromacs.org
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License as published by the Free
16  * Software Foundation; either version 2 of the License, or (at your option) any
17  * later version.
18  *
19  * To help fund GROMACS development, we humbly ask that you cite
20  * the papers people have written on it - you can find them on the website.
21  */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <math.h>
27
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
30 #include "vec.h"
31 #include "nrnb.h"
32
33 /*
34  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_VF_c
35  * Electrostatics interaction: ReactionField
36  * VdW interaction:            Buckingham
37  * Geometry:                   Water4-Water4
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_VF_c
42                     (t_nblist * gmx_restrict                nlist,
43                      rvec * gmx_restrict                    xx,
44                      rvec * gmx_restrict                    ff,
45                      t_forcerec * gmx_restrict              fr,
46                      t_mdatoms * gmx_restrict               mdatoms,
47                      nb_kernel_data_t * gmx_restrict        kernel_data,
48                      t_nrnb * gmx_restrict                  nrnb)
49 {
50     int              i_shift_offset,i_coord_offset,j_coord_offset;
51     int              j_index_start,j_index_end;
52     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
55     real             *shiftvec,*fshift,*x,*f;
56     int              vdwioffset0;
57     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
58     int              vdwioffset1;
59     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
60     int              vdwioffset2;
61     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
62     int              vdwioffset3;
63     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
64     int              vdwjidx0;
65     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
66     int              vdwjidx1;
67     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
68     int              vdwjidx2;
69     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
70     int              vdwjidx3;
71     real             jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
72     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
73     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
74     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
75     real             dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
76     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
77     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
78     real             dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
79     real             dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
80     real             dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
81     real             dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
82     real             velec,felec,velecsum,facel,crf,krf,krf2;
83     real             *charge;
84     int              nvdwtype;
85     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
86     int              *vdwtype;
87     real             *vdwparam;
88     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
89
90     x                = xx[0];
91     f                = ff[0];
92
93     nri              = nlist->nri;
94     iinr             = nlist->iinr;
95     jindex           = nlist->jindex;
96     jjnr             = nlist->jjnr;
97     shiftidx         = nlist->shift;
98     gid              = nlist->gid;
99     shiftvec         = fr->shift_vec[0];
100     fshift           = fr->fshift[0];
101     facel            = fr->epsfac;
102     charge           = mdatoms->chargeA;
103     krf              = fr->ic->k_rf;
104     krf2             = krf*2.0;
105     crf              = fr->ic->c_rf;
106     nvdwtype         = fr->ntype;
107     vdwparam         = fr->nbfp;
108     vdwtype          = mdatoms->typeA;
109
110     /* Setup water-specific parameters */
111     inr              = nlist->iinr[0];
112     iq1              = facel*charge[inr+1];
113     iq2              = facel*charge[inr+2];
114     iq3              = facel*charge[inr+3];
115     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
116
117     jq1              = charge[inr+1];
118     jq2              = charge[inr+2];
119     jq3              = charge[inr+3];
120     vdwjidx0         = 3*vdwtype[inr+0];
121     c6_00            = vdwparam[vdwioffset0+vdwjidx0];
122     cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
123     cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
124     qq11             = iq1*jq1;
125     qq12             = iq1*jq2;
126     qq13             = iq1*jq3;
127     qq21             = iq2*jq1;
128     qq22             = iq2*jq2;
129     qq23             = iq2*jq3;
130     qq31             = iq3*jq1;
131     qq32             = iq3*jq2;
132     qq33             = iq3*jq3;
133
134     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
135     rcutoff          = fr->rcoulomb;
136     rcutoff2         = rcutoff*rcutoff;
137
138     rswitch          = fr->rvdw_switch;
139     /* Setup switch parameters */
140     d                = rcutoff-rswitch;
141     swV3             = -10.0/(d*d*d);
142     swV4             =  15.0/(d*d*d*d);
143     swV5             =  -6.0/(d*d*d*d*d);
144     swF2             = -30.0/(d*d*d);
145     swF3             =  60.0/(d*d*d*d);
146     swF4             = -30.0/(d*d*d*d*d);
147
148     outeriter        = 0;
149     inneriter        = 0;
150
151     /* Start outer loop over neighborlists */
152     for(iidx=0; iidx<nri; iidx++)
153     {
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];
159
160         /* Load limits for loop over neighbors */
161         j_index_start    = jindex[iidx];
162         j_index_end      = jindex[iidx+1];
163
164         /* Get outer coordinate index */
165         inr              = iinr[iidx];
166         i_coord_offset   = DIM*inr;
167
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];
178         ix3              = shX + x[i_coord_offset+DIM*3+XX];
179         iy3              = shY + x[i_coord_offset+DIM*3+YY];
180         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
181
182         fix0             = 0.0;
183         fiy0             = 0.0;
184         fiz0             = 0.0;
185         fix1             = 0.0;
186         fiy1             = 0.0;
187         fiz1             = 0.0;
188         fix2             = 0.0;
189         fiy2             = 0.0;
190         fiz2             = 0.0;
191         fix3             = 0.0;
192         fiy3             = 0.0;
193         fiz3             = 0.0;
194
195         /* Reset potential sums */
196         velecsum         = 0.0;
197         vvdwsum          = 0.0;
198
199         /* Start inner kernel loop */
200         for(jidx=j_index_start; jidx<j_index_end; jidx++)
201         {
202             /* Get j neighbor index, and coordinate index */
203             jnr              = jjnr[jidx];
204             j_coord_offset   = DIM*jnr;
205
206             /* load j atom coordinates */
207             jx0              = x[j_coord_offset+DIM*0+XX];
208             jy0              = x[j_coord_offset+DIM*0+YY];
209             jz0              = x[j_coord_offset+DIM*0+ZZ];
210             jx1              = x[j_coord_offset+DIM*1+XX];
211             jy1              = x[j_coord_offset+DIM*1+YY];
212             jz1              = x[j_coord_offset+DIM*1+ZZ];
213             jx2              = x[j_coord_offset+DIM*2+XX];
214             jy2              = x[j_coord_offset+DIM*2+YY];
215             jz2              = x[j_coord_offset+DIM*2+ZZ];
216             jx3              = x[j_coord_offset+DIM*3+XX];
217             jy3              = x[j_coord_offset+DIM*3+YY];
218             jz3              = x[j_coord_offset+DIM*3+ZZ];
219
220             /* Calculate displacement vector */
221             dx00             = ix0 - jx0;
222             dy00             = iy0 - jy0;
223             dz00             = iz0 - jz0;
224             dx11             = ix1 - jx1;
225             dy11             = iy1 - jy1;
226             dz11             = iz1 - jz1;
227             dx12             = ix1 - jx2;
228             dy12             = iy1 - jy2;
229             dz12             = iz1 - jz2;
230             dx13             = ix1 - jx3;
231             dy13             = iy1 - jy3;
232             dz13             = iz1 - jz3;
233             dx21             = ix2 - jx1;
234             dy21             = iy2 - jy1;
235             dz21             = iz2 - jz1;
236             dx22             = ix2 - jx2;
237             dy22             = iy2 - jy2;
238             dz22             = iz2 - jz2;
239             dx23             = ix2 - jx3;
240             dy23             = iy2 - jy3;
241             dz23             = iz2 - jz3;
242             dx31             = ix3 - jx1;
243             dy31             = iy3 - jy1;
244             dz31             = iz3 - jz1;
245             dx32             = ix3 - jx2;
246             dy32             = iy3 - jy2;
247             dz32             = iz3 - jz2;
248             dx33             = ix3 - jx3;
249             dy33             = iy3 - jy3;
250             dz33             = iz3 - jz3;
251
252             /* Calculate squared distance and things based on it */
253             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
254             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
255             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
256             rsq13            = dx13*dx13+dy13*dy13+dz13*dz13;
257             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
258             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
259             rsq23            = dx23*dx23+dy23*dy23+dz23*dz23;
260             rsq31            = dx31*dx31+dy31*dy31+dz31*dz31;
261             rsq32            = dx32*dx32+dy32*dy32+dz32*dz32;
262             rsq33            = dx33*dx33+dy33*dy33+dz33*dz33;
263
264             rinv00           = gmx_invsqrt(rsq00);
265             rinv11           = gmx_invsqrt(rsq11);
266             rinv12           = gmx_invsqrt(rsq12);
267             rinv13           = gmx_invsqrt(rsq13);
268             rinv21           = gmx_invsqrt(rsq21);
269             rinv22           = gmx_invsqrt(rsq22);
270             rinv23           = gmx_invsqrt(rsq23);
271             rinv31           = gmx_invsqrt(rsq31);
272             rinv32           = gmx_invsqrt(rsq32);
273             rinv33           = gmx_invsqrt(rsq33);
274
275             rinvsq00         = rinv00*rinv00;
276             rinvsq11         = rinv11*rinv11;
277             rinvsq12         = rinv12*rinv12;
278             rinvsq13         = rinv13*rinv13;
279             rinvsq21         = rinv21*rinv21;
280             rinvsq22         = rinv22*rinv22;
281             rinvsq23         = rinv23*rinv23;
282             rinvsq31         = rinv31*rinv31;
283             rinvsq32         = rinv32*rinv32;
284             rinvsq33         = rinv33*rinv33;
285
286             /**************************
287              * CALCULATE INTERACTIONS *
288              **************************/
289
290             if (rsq00<rcutoff2)
291             {
292
293             r00              = rsq00*rinv00;
294
295             /* BUCKINGHAM DISPERSION/REPULSION */
296             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
297             vvdw6            = c6_00*rinvsix;
298             br               = cexp2_00*r00;
299             vvdwexp          = cexp1_00*exp(-br);
300             vvdw             = vvdwexp - vvdw6*(1.0/6.0);
301             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
302
303             d                = r00-rswitch;
304             d                = (d>0.0) ? d : 0.0;
305             d2               = d*d;
306             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
307
308             dsw              = d2*(swF2+d*(swF3+d*swF4));
309
310             /* Evaluate switch function */
311             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
312             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
313             vvdw            *= sw;
314
315             /* Update potential sums from outer loop */
316             vvdwsum         += vvdw;
317
318             fscal            = fvdw;
319
320             /* Calculate temporary vectorial force */
321             tx               = fscal*dx00;
322             ty               = fscal*dy00;
323             tz               = fscal*dz00;
324
325             /* Update vectorial force */
326             fix0            += tx;
327             fiy0            += ty;
328             fiz0            += tz;
329             f[j_coord_offset+DIM*0+XX] -= tx;
330             f[j_coord_offset+DIM*0+YY] -= ty;
331             f[j_coord_offset+DIM*0+ZZ] -= tz;
332
333             }
334
335             /**************************
336              * CALCULATE INTERACTIONS *
337              **************************/
338
339             if (rsq11<rcutoff2)
340             {
341
342             /* REACTION-FIELD ELECTROSTATICS */
343             velec            = qq11*(rinv11+krf*rsq11-crf);
344             felec            = qq11*(rinv11*rinvsq11-krf2);
345
346             /* Update potential sums from outer loop */
347             velecsum        += velec;
348
349             fscal            = felec;
350
351             /* Calculate temporary vectorial force */
352             tx               = fscal*dx11;
353             ty               = fscal*dy11;
354             tz               = fscal*dz11;
355
356             /* Update vectorial force */
357             fix1            += tx;
358             fiy1            += ty;
359             fiz1            += tz;
360             f[j_coord_offset+DIM*1+XX] -= tx;
361             f[j_coord_offset+DIM*1+YY] -= ty;
362             f[j_coord_offset+DIM*1+ZZ] -= tz;
363
364             }
365
366             /**************************
367              * CALCULATE INTERACTIONS *
368              **************************/
369
370             if (rsq12<rcutoff2)
371             {
372
373             /* REACTION-FIELD ELECTROSTATICS */
374             velec            = qq12*(rinv12+krf*rsq12-crf);
375             felec            = qq12*(rinv12*rinvsq12-krf2);
376
377             /* Update potential sums from outer loop */
378             velecsum        += velec;
379
380             fscal            = felec;
381
382             /* Calculate temporary vectorial force */
383             tx               = fscal*dx12;
384             ty               = fscal*dy12;
385             tz               = fscal*dz12;
386
387             /* Update vectorial force */
388             fix1            += tx;
389             fiy1            += ty;
390             fiz1            += tz;
391             f[j_coord_offset+DIM*2+XX] -= tx;
392             f[j_coord_offset+DIM*2+YY] -= ty;
393             f[j_coord_offset+DIM*2+ZZ] -= tz;
394
395             }
396
397             /**************************
398              * CALCULATE INTERACTIONS *
399              **************************/
400
401             if (rsq13<rcutoff2)
402             {
403
404             /* REACTION-FIELD ELECTROSTATICS */
405             velec            = qq13*(rinv13+krf*rsq13-crf);
406             felec            = qq13*(rinv13*rinvsq13-krf2);
407
408             /* Update potential sums from outer loop */
409             velecsum        += velec;
410
411             fscal            = felec;
412
413             /* Calculate temporary vectorial force */
414             tx               = fscal*dx13;
415             ty               = fscal*dy13;
416             tz               = fscal*dz13;
417
418             /* Update vectorial force */
419             fix1            += tx;
420             fiy1            += ty;
421             fiz1            += tz;
422             f[j_coord_offset+DIM*3+XX] -= tx;
423             f[j_coord_offset+DIM*3+YY] -= ty;
424             f[j_coord_offset+DIM*3+ZZ] -= tz;
425
426             }
427
428             /**************************
429              * CALCULATE INTERACTIONS *
430              **************************/
431
432             if (rsq21<rcutoff2)
433             {
434
435             /* REACTION-FIELD ELECTROSTATICS */
436             velec            = qq21*(rinv21+krf*rsq21-crf);
437             felec            = qq21*(rinv21*rinvsq21-krf2);
438
439             /* Update potential sums from outer loop */
440             velecsum        += velec;
441
442             fscal            = felec;
443
444             /* Calculate temporary vectorial force */
445             tx               = fscal*dx21;
446             ty               = fscal*dy21;
447             tz               = fscal*dz21;
448
449             /* Update vectorial force */
450             fix2            += tx;
451             fiy2            += ty;
452             fiz2            += tz;
453             f[j_coord_offset+DIM*1+XX] -= tx;
454             f[j_coord_offset+DIM*1+YY] -= ty;
455             f[j_coord_offset+DIM*1+ZZ] -= tz;
456
457             }
458
459             /**************************
460              * CALCULATE INTERACTIONS *
461              **************************/
462
463             if (rsq22<rcutoff2)
464             {
465
466             /* REACTION-FIELD ELECTROSTATICS */
467             velec            = qq22*(rinv22+krf*rsq22-crf);
468             felec            = qq22*(rinv22*rinvsq22-krf2);
469
470             /* Update potential sums from outer loop */
471             velecsum        += velec;
472
473             fscal            = felec;
474
475             /* Calculate temporary vectorial force */
476             tx               = fscal*dx22;
477             ty               = fscal*dy22;
478             tz               = fscal*dz22;
479
480             /* Update vectorial force */
481             fix2            += tx;
482             fiy2            += ty;
483             fiz2            += tz;
484             f[j_coord_offset+DIM*2+XX] -= tx;
485             f[j_coord_offset+DIM*2+YY] -= ty;
486             f[j_coord_offset+DIM*2+ZZ] -= tz;
487
488             }
489
490             /**************************
491              * CALCULATE INTERACTIONS *
492              **************************/
493
494             if (rsq23<rcutoff2)
495             {
496
497             /* REACTION-FIELD ELECTROSTATICS */
498             velec            = qq23*(rinv23+krf*rsq23-crf);
499             felec            = qq23*(rinv23*rinvsq23-krf2);
500
501             /* Update potential sums from outer loop */
502             velecsum        += velec;
503
504             fscal            = felec;
505
506             /* Calculate temporary vectorial force */
507             tx               = fscal*dx23;
508             ty               = fscal*dy23;
509             tz               = fscal*dz23;
510
511             /* Update vectorial force */
512             fix2            += tx;
513             fiy2            += ty;
514             fiz2            += tz;
515             f[j_coord_offset+DIM*3+XX] -= tx;
516             f[j_coord_offset+DIM*3+YY] -= ty;
517             f[j_coord_offset+DIM*3+ZZ] -= tz;
518
519             }
520
521             /**************************
522              * CALCULATE INTERACTIONS *
523              **************************/
524
525             if (rsq31<rcutoff2)
526             {
527
528             /* REACTION-FIELD ELECTROSTATICS */
529             velec            = qq31*(rinv31+krf*rsq31-crf);
530             felec            = qq31*(rinv31*rinvsq31-krf2);
531
532             /* Update potential sums from outer loop */
533             velecsum        += velec;
534
535             fscal            = felec;
536
537             /* Calculate temporary vectorial force */
538             tx               = fscal*dx31;
539             ty               = fscal*dy31;
540             tz               = fscal*dz31;
541
542             /* Update vectorial force */
543             fix3            += tx;
544             fiy3            += ty;
545             fiz3            += tz;
546             f[j_coord_offset+DIM*1+XX] -= tx;
547             f[j_coord_offset+DIM*1+YY] -= ty;
548             f[j_coord_offset+DIM*1+ZZ] -= tz;
549
550             }
551
552             /**************************
553              * CALCULATE INTERACTIONS *
554              **************************/
555
556             if (rsq32<rcutoff2)
557             {
558
559             /* REACTION-FIELD ELECTROSTATICS */
560             velec            = qq32*(rinv32+krf*rsq32-crf);
561             felec            = qq32*(rinv32*rinvsq32-krf2);
562
563             /* Update potential sums from outer loop */
564             velecsum        += velec;
565
566             fscal            = felec;
567
568             /* Calculate temporary vectorial force */
569             tx               = fscal*dx32;
570             ty               = fscal*dy32;
571             tz               = fscal*dz32;
572
573             /* Update vectorial force */
574             fix3            += tx;
575             fiy3            += ty;
576             fiz3            += tz;
577             f[j_coord_offset+DIM*2+XX] -= tx;
578             f[j_coord_offset+DIM*2+YY] -= ty;
579             f[j_coord_offset+DIM*2+ZZ] -= tz;
580
581             }
582
583             /**************************
584              * CALCULATE INTERACTIONS *
585              **************************/
586
587             if (rsq33<rcutoff2)
588             {
589
590             /* REACTION-FIELD ELECTROSTATICS */
591             velec            = qq33*(rinv33+krf*rsq33-crf);
592             felec            = qq33*(rinv33*rinvsq33-krf2);
593
594             /* Update potential sums from outer loop */
595             velecsum        += velec;
596
597             fscal            = felec;
598
599             /* Calculate temporary vectorial force */
600             tx               = fscal*dx33;
601             ty               = fscal*dy33;
602             tz               = fscal*dz33;
603
604             /* Update vectorial force */
605             fix3            += tx;
606             fiy3            += ty;
607             fiz3            += tz;
608             f[j_coord_offset+DIM*3+XX] -= tx;
609             f[j_coord_offset+DIM*3+YY] -= ty;
610             f[j_coord_offset+DIM*3+ZZ] -= tz;
611
612             }
613
614             /* Inner loop uses 358 flops */
615         }
616         /* End of innermost loop */
617
618         tx = ty = tz = 0;
619         f[i_coord_offset+DIM*0+XX] += fix0;
620         f[i_coord_offset+DIM*0+YY] += fiy0;
621         f[i_coord_offset+DIM*0+ZZ] += fiz0;
622         tx                         += fix0;
623         ty                         += fiy0;
624         tz                         += fiz0;
625         f[i_coord_offset+DIM*1+XX] += fix1;
626         f[i_coord_offset+DIM*1+YY] += fiy1;
627         f[i_coord_offset+DIM*1+ZZ] += fiz1;
628         tx                         += fix1;
629         ty                         += fiy1;
630         tz                         += fiz1;
631         f[i_coord_offset+DIM*2+XX] += fix2;
632         f[i_coord_offset+DIM*2+YY] += fiy2;
633         f[i_coord_offset+DIM*2+ZZ] += fiz2;
634         tx                         += fix2;
635         ty                         += fiy2;
636         tz                         += fiz2;
637         f[i_coord_offset+DIM*3+XX] += fix3;
638         f[i_coord_offset+DIM*3+YY] += fiy3;
639         f[i_coord_offset+DIM*3+ZZ] += fiz3;
640         tx                         += fix3;
641         ty                         += fiy3;
642         tz                         += fiz3;
643         fshift[i_shift_offset+XX]  += tx;
644         fshift[i_shift_offset+YY]  += ty;
645         fshift[i_shift_offset+ZZ]  += tz;
646
647         ggid                        = gid[iidx];
648         /* Update potential energies */
649         kernel_data->energygrp_elec[ggid] += velecsum;
650         kernel_data->energygrp_vdw[ggid] += vvdwsum;
651
652         /* Increment number of inner iterations */
653         inneriter                  += j_index_end - j_index_start;
654
655         /* Outer loop uses 41 flops */
656     }
657
658     /* Increment number of outer iterations */
659     outeriter        += nri;
660
661     /* Update outer/inner flops */
662
663     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*358);
664 }
665 /*
666  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
667  * Electrostatics interaction: ReactionField
668  * VdW interaction:            Buckingham
669  * Geometry:                   Water4-Water4
670  * Calculate force/pot:        Force
671  */
672 void
673 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
674                     (t_nblist * gmx_restrict                nlist,
675                      rvec * gmx_restrict                    xx,
676                      rvec * gmx_restrict                    ff,
677                      t_forcerec * gmx_restrict              fr,
678                      t_mdatoms * gmx_restrict               mdatoms,
679                      nb_kernel_data_t * gmx_restrict        kernel_data,
680                      t_nrnb * gmx_restrict                  nrnb)
681 {
682     int              i_shift_offset,i_coord_offset,j_coord_offset;
683     int              j_index_start,j_index_end;
684     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
685     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
686     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
687     real             *shiftvec,*fshift,*x,*f;
688     int              vdwioffset0;
689     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
690     int              vdwioffset1;
691     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
692     int              vdwioffset2;
693     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
694     int              vdwioffset3;
695     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
696     int              vdwjidx0;
697     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
698     int              vdwjidx1;
699     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
700     int              vdwjidx2;
701     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
702     int              vdwjidx3;
703     real             jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
704     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
705     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
706     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
707     real             dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
708     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
709     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
710     real             dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
711     real             dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
712     real             dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
713     real             dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
714     real             velec,felec,velecsum,facel,crf,krf,krf2;
715     real             *charge;
716     int              nvdwtype;
717     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
718     int              *vdwtype;
719     real             *vdwparam;
720     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
721
722     x                = xx[0];
723     f                = ff[0];
724
725     nri              = nlist->nri;
726     iinr             = nlist->iinr;
727     jindex           = nlist->jindex;
728     jjnr             = nlist->jjnr;
729     shiftidx         = nlist->shift;
730     gid              = nlist->gid;
731     shiftvec         = fr->shift_vec[0];
732     fshift           = fr->fshift[0];
733     facel            = fr->epsfac;
734     charge           = mdatoms->chargeA;
735     krf              = fr->ic->k_rf;
736     krf2             = krf*2.0;
737     crf              = fr->ic->c_rf;
738     nvdwtype         = fr->ntype;
739     vdwparam         = fr->nbfp;
740     vdwtype          = mdatoms->typeA;
741
742     /* Setup water-specific parameters */
743     inr              = nlist->iinr[0];
744     iq1              = facel*charge[inr+1];
745     iq2              = facel*charge[inr+2];
746     iq3              = facel*charge[inr+3];
747     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
748
749     jq1              = charge[inr+1];
750     jq2              = charge[inr+2];
751     jq3              = charge[inr+3];
752     vdwjidx0         = 3*vdwtype[inr+0];
753     c6_00            = vdwparam[vdwioffset0+vdwjidx0];
754     cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
755     cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
756     qq11             = iq1*jq1;
757     qq12             = iq1*jq2;
758     qq13             = iq1*jq3;
759     qq21             = iq2*jq1;
760     qq22             = iq2*jq2;
761     qq23             = iq2*jq3;
762     qq31             = iq3*jq1;
763     qq32             = iq3*jq2;
764     qq33             = iq3*jq3;
765
766     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
767     rcutoff          = fr->rcoulomb;
768     rcutoff2         = rcutoff*rcutoff;
769
770     rswitch          = fr->rvdw_switch;
771     /* Setup switch parameters */
772     d                = rcutoff-rswitch;
773     swV3             = -10.0/(d*d*d);
774     swV4             =  15.0/(d*d*d*d);
775     swV5             =  -6.0/(d*d*d*d*d);
776     swF2             = -30.0/(d*d*d);
777     swF3             =  60.0/(d*d*d*d);
778     swF4             = -30.0/(d*d*d*d*d);
779
780     outeriter        = 0;
781     inneriter        = 0;
782
783     /* Start outer loop over neighborlists */
784     for(iidx=0; iidx<nri; iidx++)
785     {
786         /* Load shift vector for this list */
787         i_shift_offset   = DIM*shiftidx[iidx];
788         shX              = shiftvec[i_shift_offset+XX];
789         shY              = shiftvec[i_shift_offset+YY];
790         shZ              = shiftvec[i_shift_offset+ZZ];
791
792         /* Load limits for loop over neighbors */
793         j_index_start    = jindex[iidx];
794         j_index_end      = jindex[iidx+1];
795
796         /* Get outer coordinate index */
797         inr              = iinr[iidx];
798         i_coord_offset   = DIM*inr;
799
800         /* Load i particle coords and add shift vector */
801         ix0              = shX + x[i_coord_offset+DIM*0+XX];
802         iy0              = shY + x[i_coord_offset+DIM*0+YY];
803         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
804         ix1              = shX + x[i_coord_offset+DIM*1+XX];
805         iy1              = shY + x[i_coord_offset+DIM*1+YY];
806         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
807         ix2              = shX + x[i_coord_offset+DIM*2+XX];
808         iy2              = shY + x[i_coord_offset+DIM*2+YY];
809         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
810         ix3              = shX + x[i_coord_offset+DIM*3+XX];
811         iy3              = shY + x[i_coord_offset+DIM*3+YY];
812         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
813
814         fix0             = 0.0;
815         fiy0             = 0.0;
816         fiz0             = 0.0;
817         fix1             = 0.0;
818         fiy1             = 0.0;
819         fiz1             = 0.0;
820         fix2             = 0.0;
821         fiy2             = 0.0;
822         fiz2             = 0.0;
823         fix3             = 0.0;
824         fiy3             = 0.0;
825         fiz3             = 0.0;
826
827         /* Start inner kernel loop */
828         for(jidx=j_index_start; jidx<j_index_end; jidx++)
829         {
830             /* Get j neighbor index, and coordinate index */
831             jnr              = jjnr[jidx];
832             j_coord_offset   = DIM*jnr;
833
834             /* load j atom coordinates */
835             jx0              = x[j_coord_offset+DIM*0+XX];
836             jy0              = x[j_coord_offset+DIM*0+YY];
837             jz0              = x[j_coord_offset+DIM*0+ZZ];
838             jx1              = x[j_coord_offset+DIM*1+XX];
839             jy1              = x[j_coord_offset+DIM*1+YY];
840             jz1              = x[j_coord_offset+DIM*1+ZZ];
841             jx2              = x[j_coord_offset+DIM*2+XX];
842             jy2              = x[j_coord_offset+DIM*2+YY];
843             jz2              = x[j_coord_offset+DIM*2+ZZ];
844             jx3              = x[j_coord_offset+DIM*3+XX];
845             jy3              = x[j_coord_offset+DIM*3+YY];
846             jz3              = x[j_coord_offset+DIM*3+ZZ];
847
848             /* Calculate displacement vector */
849             dx00             = ix0 - jx0;
850             dy00             = iy0 - jy0;
851             dz00             = iz0 - jz0;
852             dx11             = ix1 - jx1;
853             dy11             = iy1 - jy1;
854             dz11             = iz1 - jz1;
855             dx12             = ix1 - jx2;
856             dy12             = iy1 - jy2;
857             dz12             = iz1 - jz2;
858             dx13             = ix1 - jx3;
859             dy13             = iy1 - jy3;
860             dz13             = iz1 - jz3;
861             dx21             = ix2 - jx1;
862             dy21             = iy2 - jy1;
863             dz21             = iz2 - jz1;
864             dx22             = ix2 - jx2;
865             dy22             = iy2 - jy2;
866             dz22             = iz2 - jz2;
867             dx23             = ix2 - jx3;
868             dy23             = iy2 - jy3;
869             dz23             = iz2 - jz3;
870             dx31             = ix3 - jx1;
871             dy31             = iy3 - jy1;
872             dz31             = iz3 - jz1;
873             dx32             = ix3 - jx2;
874             dy32             = iy3 - jy2;
875             dz32             = iz3 - jz2;
876             dx33             = ix3 - jx3;
877             dy33             = iy3 - jy3;
878             dz33             = iz3 - jz3;
879
880             /* Calculate squared distance and things based on it */
881             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
882             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
883             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
884             rsq13            = dx13*dx13+dy13*dy13+dz13*dz13;
885             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
886             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
887             rsq23            = dx23*dx23+dy23*dy23+dz23*dz23;
888             rsq31            = dx31*dx31+dy31*dy31+dz31*dz31;
889             rsq32            = dx32*dx32+dy32*dy32+dz32*dz32;
890             rsq33            = dx33*dx33+dy33*dy33+dz33*dz33;
891
892             rinv00           = gmx_invsqrt(rsq00);
893             rinv11           = gmx_invsqrt(rsq11);
894             rinv12           = gmx_invsqrt(rsq12);
895             rinv13           = gmx_invsqrt(rsq13);
896             rinv21           = gmx_invsqrt(rsq21);
897             rinv22           = gmx_invsqrt(rsq22);
898             rinv23           = gmx_invsqrt(rsq23);
899             rinv31           = gmx_invsqrt(rsq31);
900             rinv32           = gmx_invsqrt(rsq32);
901             rinv33           = gmx_invsqrt(rsq33);
902
903             rinvsq00         = rinv00*rinv00;
904             rinvsq11         = rinv11*rinv11;
905             rinvsq12         = rinv12*rinv12;
906             rinvsq13         = rinv13*rinv13;
907             rinvsq21         = rinv21*rinv21;
908             rinvsq22         = rinv22*rinv22;
909             rinvsq23         = rinv23*rinv23;
910             rinvsq31         = rinv31*rinv31;
911             rinvsq32         = rinv32*rinv32;
912             rinvsq33         = rinv33*rinv33;
913
914             /**************************
915              * CALCULATE INTERACTIONS *
916              **************************/
917
918             if (rsq00<rcutoff2)
919             {
920
921             r00              = rsq00*rinv00;
922
923             /* BUCKINGHAM DISPERSION/REPULSION */
924             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
925             vvdw6            = c6_00*rinvsix;
926             br               = cexp2_00*r00;
927             vvdwexp          = cexp1_00*exp(-br);
928             vvdw             = vvdwexp - vvdw6*(1.0/6.0);
929             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
930
931             d                = r00-rswitch;
932             d                = (d>0.0) ? d : 0.0;
933             d2               = d*d;
934             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
935
936             dsw              = d2*(swF2+d*(swF3+d*swF4));
937
938             /* Evaluate switch function */
939             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
940             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
941
942             fscal            = fvdw;
943
944             /* Calculate temporary vectorial force */
945             tx               = fscal*dx00;
946             ty               = fscal*dy00;
947             tz               = fscal*dz00;
948
949             /* Update vectorial force */
950             fix0            += tx;
951             fiy0            += ty;
952             fiz0            += tz;
953             f[j_coord_offset+DIM*0+XX] -= tx;
954             f[j_coord_offset+DIM*0+YY] -= ty;
955             f[j_coord_offset+DIM*0+ZZ] -= tz;
956
957             }
958
959             /**************************
960              * CALCULATE INTERACTIONS *
961              **************************/
962
963             if (rsq11<rcutoff2)
964             {
965
966             /* REACTION-FIELD ELECTROSTATICS */
967             felec            = qq11*(rinv11*rinvsq11-krf2);
968
969             fscal            = felec;
970
971             /* Calculate temporary vectorial force */
972             tx               = fscal*dx11;
973             ty               = fscal*dy11;
974             tz               = fscal*dz11;
975
976             /* Update vectorial force */
977             fix1            += tx;
978             fiy1            += ty;
979             fiz1            += tz;
980             f[j_coord_offset+DIM*1+XX] -= tx;
981             f[j_coord_offset+DIM*1+YY] -= ty;
982             f[j_coord_offset+DIM*1+ZZ] -= tz;
983
984             }
985
986             /**************************
987              * CALCULATE INTERACTIONS *
988              **************************/
989
990             if (rsq12<rcutoff2)
991             {
992
993             /* REACTION-FIELD ELECTROSTATICS */
994             felec            = qq12*(rinv12*rinvsq12-krf2);
995
996             fscal            = felec;
997
998             /* Calculate temporary vectorial force */
999             tx               = fscal*dx12;
1000             ty               = fscal*dy12;
1001             tz               = fscal*dz12;
1002
1003             /* Update vectorial force */
1004             fix1            += tx;
1005             fiy1            += ty;
1006             fiz1            += tz;
1007             f[j_coord_offset+DIM*2+XX] -= tx;
1008             f[j_coord_offset+DIM*2+YY] -= ty;
1009             f[j_coord_offset+DIM*2+ZZ] -= tz;
1010
1011             }
1012
1013             /**************************
1014              * CALCULATE INTERACTIONS *
1015              **************************/
1016
1017             if (rsq13<rcutoff2)
1018             {
1019
1020             /* REACTION-FIELD ELECTROSTATICS */
1021             felec            = qq13*(rinv13*rinvsq13-krf2);
1022
1023             fscal            = felec;
1024
1025             /* Calculate temporary vectorial force */
1026             tx               = fscal*dx13;
1027             ty               = fscal*dy13;
1028             tz               = fscal*dz13;
1029
1030             /* Update vectorial force */
1031             fix1            += tx;
1032             fiy1            += ty;
1033             fiz1            += tz;
1034             f[j_coord_offset+DIM*3+XX] -= tx;
1035             f[j_coord_offset+DIM*3+YY] -= ty;
1036             f[j_coord_offset+DIM*3+ZZ] -= tz;
1037
1038             }
1039
1040             /**************************
1041              * CALCULATE INTERACTIONS *
1042              **************************/
1043
1044             if (rsq21<rcutoff2)
1045             {
1046
1047             /* REACTION-FIELD ELECTROSTATICS */
1048             felec            = qq21*(rinv21*rinvsq21-krf2);
1049
1050             fscal            = felec;
1051
1052             /* Calculate temporary vectorial force */
1053             tx               = fscal*dx21;
1054             ty               = fscal*dy21;
1055             tz               = fscal*dz21;
1056
1057             /* Update vectorial force */
1058             fix2            += tx;
1059             fiy2            += ty;
1060             fiz2            += tz;
1061             f[j_coord_offset+DIM*1+XX] -= tx;
1062             f[j_coord_offset+DIM*1+YY] -= ty;
1063             f[j_coord_offset+DIM*1+ZZ] -= tz;
1064
1065             }
1066
1067             /**************************
1068              * CALCULATE INTERACTIONS *
1069              **************************/
1070
1071             if (rsq22<rcutoff2)
1072             {
1073
1074             /* REACTION-FIELD ELECTROSTATICS */
1075             felec            = qq22*(rinv22*rinvsq22-krf2);
1076
1077             fscal            = felec;
1078
1079             /* Calculate temporary vectorial force */
1080             tx               = fscal*dx22;
1081             ty               = fscal*dy22;
1082             tz               = fscal*dz22;
1083
1084             /* Update vectorial force */
1085             fix2            += tx;
1086             fiy2            += ty;
1087             fiz2            += tz;
1088             f[j_coord_offset+DIM*2+XX] -= tx;
1089             f[j_coord_offset+DIM*2+YY] -= ty;
1090             f[j_coord_offset+DIM*2+ZZ] -= tz;
1091
1092             }
1093
1094             /**************************
1095              * CALCULATE INTERACTIONS *
1096              **************************/
1097
1098             if (rsq23<rcutoff2)
1099             {
1100
1101             /* REACTION-FIELD ELECTROSTATICS */
1102             felec            = qq23*(rinv23*rinvsq23-krf2);
1103
1104             fscal            = felec;
1105
1106             /* Calculate temporary vectorial force */
1107             tx               = fscal*dx23;
1108             ty               = fscal*dy23;
1109             tz               = fscal*dz23;
1110
1111             /* Update vectorial force */
1112             fix2            += tx;
1113             fiy2            += ty;
1114             fiz2            += tz;
1115             f[j_coord_offset+DIM*3+XX] -= tx;
1116             f[j_coord_offset+DIM*3+YY] -= ty;
1117             f[j_coord_offset+DIM*3+ZZ] -= tz;
1118
1119             }
1120
1121             /**************************
1122              * CALCULATE INTERACTIONS *
1123              **************************/
1124
1125             if (rsq31<rcutoff2)
1126             {
1127
1128             /* REACTION-FIELD ELECTROSTATICS */
1129             felec            = qq31*(rinv31*rinvsq31-krf2);
1130
1131             fscal            = felec;
1132
1133             /* Calculate temporary vectorial force */
1134             tx               = fscal*dx31;
1135             ty               = fscal*dy31;
1136             tz               = fscal*dz31;
1137
1138             /* Update vectorial force */
1139             fix3            += tx;
1140             fiy3            += ty;
1141             fiz3            += tz;
1142             f[j_coord_offset+DIM*1+XX] -= tx;
1143             f[j_coord_offset+DIM*1+YY] -= ty;
1144             f[j_coord_offset+DIM*1+ZZ] -= tz;
1145
1146             }
1147
1148             /**************************
1149              * CALCULATE INTERACTIONS *
1150              **************************/
1151
1152             if (rsq32<rcutoff2)
1153             {
1154
1155             /* REACTION-FIELD ELECTROSTATICS */
1156             felec            = qq32*(rinv32*rinvsq32-krf2);
1157
1158             fscal            = felec;
1159
1160             /* Calculate temporary vectorial force */
1161             tx               = fscal*dx32;
1162             ty               = fscal*dy32;
1163             tz               = fscal*dz32;
1164
1165             /* Update vectorial force */
1166             fix3            += tx;
1167             fiy3            += ty;
1168             fiz3            += tz;
1169             f[j_coord_offset+DIM*2+XX] -= tx;
1170             f[j_coord_offset+DIM*2+YY] -= ty;
1171             f[j_coord_offset+DIM*2+ZZ] -= tz;
1172
1173             }
1174
1175             /**************************
1176              * CALCULATE INTERACTIONS *
1177              **************************/
1178
1179             if (rsq33<rcutoff2)
1180             {
1181
1182             /* REACTION-FIELD ELECTROSTATICS */
1183             felec            = qq33*(rinv33*rinvsq33-krf2);
1184
1185             fscal            = felec;
1186
1187             /* Calculate temporary vectorial force */
1188             tx               = fscal*dx33;
1189             ty               = fscal*dy33;
1190             tz               = fscal*dz33;
1191
1192             /* Update vectorial force */
1193             fix3            += tx;
1194             fiy3            += ty;
1195             fiz3            += tz;
1196             f[j_coord_offset+DIM*3+XX] -= tx;
1197             f[j_coord_offset+DIM*3+YY] -= ty;
1198             f[j_coord_offset+DIM*3+ZZ] -= tz;
1199
1200             }
1201
1202             /* Inner loop uses 311 flops */
1203         }
1204         /* End of innermost loop */
1205
1206         tx = ty = tz = 0;
1207         f[i_coord_offset+DIM*0+XX] += fix0;
1208         f[i_coord_offset+DIM*0+YY] += fiy0;
1209         f[i_coord_offset+DIM*0+ZZ] += fiz0;
1210         tx                         += fix0;
1211         ty                         += fiy0;
1212         tz                         += fiz0;
1213         f[i_coord_offset+DIM*1+XX] += fix1;
1214         f[i_coord_offset+DIM*1+YY] += fiy1;
1215         f[i_coord_offset+DIM*1+ZZ] += fiz1;
1216         tx                         += fix1;
1217         ty                         += fiy1;
1218         tz                         += fiz1;
1219         f[i_coord_offset+DIM*2+XX] += fix2;
1220         f[i_coord_offset+DIM*2+YY] += fiy2;
1221         f[i_coord_offset+DIM*2+ZZ] += fiz2;
1222         tx                         += fix2;
1223         ty                         += fiy2;
1224         tz                         += fiz2;
1225         f[i_coord_offset+DIM*3+XX] += fix3;
1226         f[i_coord_offset+DIM*3+YY] += fiy3;
1227         f[i_coord_offset+DIM*3+ZZ] += fiz3;
1228         tx                         += fix3;
1229         ty                         += fiy3;
1230         tz                         += fiz3;
1231         fshift[i_shift_offset+XX]  += tx;
1232         fshift[i_shift_offset+YY]  += ty;
1233         fshift[i_shift_offset+ZZ]  += tz;
1234
1235         /* Increment number of inner iterations */
1236         inneriter                  += j_index_end - j_index_start;
1237
1238         /* Outer loop uses 39 flops */
1239     }
1240
1241     /* Increment number of outer iterations */
1242     outeriter        += nri;
1243
1244     /* Update outer/inner flops */
1245
1246     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*311);
1247 }