Merge 'release-4-6' into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_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_ElecCSTab_VdwCSTab_GeomW3W3_VF_c
35  * Electrostatics interaction: CubicSplineTable
36  * VdW interaction:            CubicSplineTable
37  * Geometry:                   Water3-Water3
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_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              vdwjidx0;
63     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64     int              vdwjidx1;
65     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
66     int              vdwjidx2;
67     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
68     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
69     real             dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
70     real             dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
71     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
72     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
73     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
74     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
75     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
76     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
77     real             velec,felec,velecsum,facel,crf,krf,krf2;
78     real             *charge;
79     int              nvdwtype;
80     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
81     int              *vdwtype;
82     real             *vdwparam;
83     int              vfitab;
84     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
85     real             *vftab;
86
87     x                = xx[0];
88     f                = ff[0];
89
90     nri              = nlist->nri;
91     iinr             = nlist->iinr;
92     jindex           = nlist->jindex;
93     jjnr             = nlist->jjnr;
94     shiftidx         = nlist->shift;
95     gid              = nlist->gid;
96     shiftvec         = fr->shift_vec[0];
97     fshift           = fr->fshift[0];
98     facel            = fr->epsfac;
99     charge           = mdatoms->chargeA;
100     nvdwtype         = fr->ntype;
101     vdwparam         = fr->nbfp;
102     vdwtype          = mdatoms->typeA;
103
104     vftab            = kernel_data->table_elec_vdw->data;
105     vftabscale       = kernel_data->table_elec_vdw->scale;
106
107     /* Setup water-specific parameters */
108     inr              = nlist->iinr[0];
109     iq0              = facel*charge[inr+0];
110     iq1              = facel*charge[inr+1];
111     iq2              = facel*charge[inr+2];
112     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
113
114     jq0              = charge[inr+0];
115     jq1              = charge[inr+1];
116     jq2              = charge[inr+2];
117     vdwjidx0         = 2*vdwtype[inr+0];
118     qq00             = iq0*jq0;
119     c6_00            = vdwparam[vdwioffset0+vdwjidx0];
120     c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
121     qq01             = iq0*jq1;
122     qq02             = iq0*jq2;
123     qq10             = iq1*jq0;
124     qq11             = iq1*jq1;
125     qq12             = iq1*jq2;
126     qq20             = iq2*jq0;
127     qq21             = iq2*jq1;
128     qq22             = iq2*jq2;
129
130     outeriter        = 0;
131     inneriter        = 0;
132
133     /* Start outer loop over neighborlists */
134     for(iidx=0; iidx<nri; iidx++)
135     {
136         /* Load shift vector for this list */
137         i_shift_offset   = DIM*shiftidx[iidx];
138         shX              = shiftvec[i_shift_offset+XX];
139         shY              = shiftvec[i_shift_offset+YY];
140         shZ              = shiftvec[i_shift_offset+ZZ];
141
142         /* Load limits for loop over neighbors */
143         j_index_start    = jindex[iidx];
144         j_index_end      = jindex[iidx+1];
145
146         /* Get outer coordinate index */
147         inr              = iinr[iidx];
148         i_coord_offset   = DIM*inr;
149
150         /* Load i particle coords and add shift vector */
151         ix0              = shX + x[i_coord_offset+DIM*0+XX];
152         iy0              = shY + x[i_coord_offset+DIM*0+YY];
153         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
154         ix1              = shX + x[i_coord_offset+DIM*1+XX];
155         iy1              = shY + x[i_coord_offset+DIM*1+YY];
156         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
157         ix2              = shX + x[i_coord_offset+DIM*2+XX];
158         iy2              = shY + x[i_coord_offset+DIM*2+YY];
159         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
160
161         fix0             = 0.0;
162         fiy0             = 0.0;
163         fiz0             = 0.0;
164         fix1             = 0.0;
165         fiy1             = 0.0;
166         fiz1             = 0.0;
167         fix2             = 0.0;
168         fiy2             = 0.0;
169         fiz2             = 0.0;
170
171         /* Reset potential sums */
172         velecsum         = 0.0;
173         vvdwsum          = 0.0;
174
175         /* Start inner kernel loop */
176         for(jidx=j_index_start; jidx<j_index_end; jidx++)
177         {
178             /* Get j neighbor index, and coordinate index */
179             jnr              = jjnr[jidx];
180             j_coord_offset   = DIM*jnr;
181
182             /* load j atom coordinates */
183             jx0              = x[j_coord_offset+DIM*0+XX];
184             jy0              = x[j_coord_offset+DIM*0+YY];
185             jz0              = x[j_coord_offset+DIM*0+ZZ];
186             jx1              = x[j_coord_offset+DIM*1+XX];
187             jy1              = x[j_coord_offset+DIM*1+YY];
188             jz1              = x[j_coord_offset+DIM*1+ZZ];
189             jx2              = x[j_coord_offset+DIM*2+XX];
190             jy2              = x[j_coord_offset+DIM*2+YY];
191             jz2              = x[j_coord_offset+DIM*2+ZZ];
192
193             /* Calculate displacement vector */
194             dx00             = ix0 - jx0;
195             dy00             = iy0 - jy0;
196             dz00             = iz0 - jz0;
197             dx01             = ix0 - jx1;
198             dy01             = iy0 - jy1;
199             dz01             = iz0 - jz1;
200             dx02             = ix0 - jx2;
201             dy02             = iy0 - jy2;
202             dz02             = iz0 - jz2;
203             dx10             = ix1 - jx0;
204             dy10             = iy1 - jy0;
205             dz10             = iz1 - jz0;
206             dx11             = ix1 - jx1;
207             dy11             = iy1 - jy1;
208             dz11             = iz1 - jz1;
209             dx12             = ix1 - jx2;
210             dy12             = iy1 - jy2;
211             dz12             = iz1 - jz2;
212             dx20             = ix2 - jx0;
213             dy20             = iy2 - jy0;
214             dz20             = iz2 - jz0;
215             dx21             = ix2 - jx1;
216             dy21             = iy2 - jy1;
217             dz21             = iz2 - jz1;
218             dx22             = ix2 - jx2;
219             dy22             = iy2 - jy2;
220             dz22             = iz2 - jz2;
221
222             /* Calculate squared distance and things based on it */
223             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
224             rsq01            = dx01*dx01+dy01*dy01+dz01*dz01;
225             rsq02            = dx02*dx02+dy02*dy02+dz02*dz02;
226             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
227             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
228             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
229             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
230             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
231             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
232
233             rinv00           = gmx_invsqrt(rsq00);
234             rinv01           = gmx_invsqrt(rsq01);
235             rinv02           = gmx_invsqrt(rsq02);
236             rinv10           = gmx_invsqrt(rsq10);
237             rinv11           = gmx_invsqrt(rsq11);
238             rinv12           = gmx_invsqrt(rsq12);
239             rinv20           = gmx_invsqrt(rsq20);
240             rinv21           = gmx_invsqrt(rsq21);
241             rinv22           = gmx_invsqrt(rsq22);
242
243             /**************************
244              * CALCULATE INTERACTIONS *
245              **************************/
246
247             r00              = rsq00*rinv00;
248
249             /* Calculate table index by multiplying r with table scale and truncate to integer */
250             rt               = r00*vftabscale;
251             vfitab           = rt;
252             vfeps            = rt-vfitab;
253             vfitab           = 3*4*vfitab;
254
255             /* CUBIC SPLINE TABLE ELECTROSTATICS */
256             Y                = vftab[vfitab];
257             F                = vftab[vfitab+1];
258             Geps             = vfeps*vftab[vfitab+2];
259             Heps2            = vfeps*vfeps*vftab[vfitab+3];
260             Fp               = F+Geps+Heps2;
261             VV               = Y+vfeps*Fp;
262             velec            = qq00*VV;
263             FF               = Fp+Geps+2.0*Heps2;
264             felec            = -qq00*FF*vftabscale*rinv00;
265
266             /* CUBIC SPLINE TABLE DISPERSION */
267             vfitab          += 4;
268             Y                = vftab[vfitab];
269             F                = vftab[vfitab+1];
270             Geps             = vfeps*vftab[vfitab+2];
271             Heps2            = vfeps*vfeps*vftab[vfitab+3];
272             Fp               = F+Geps+Heps2;
273             VV               = Y+vfeps*Fp;
274             vvdw6            = c6_00*VV;
275             FF               = Fp+Geps+2.0*Heps2;
276             fvdw6            = c6_00*FF;
277
278             /* CUBIC SPLINE TABLE REPULSION */
279             Y                = vftab[vfitab+4];
280             F                = vftab[vfitab+5];
281             Geps             = vfeps*vftab[vfitab+6];
282             Heps2            = vfeps*vfeps*vftab[vfitab+7];
283             Fp               = F+Geps+Heps2;
284             VV               = Y+vfeps*Fp;
285             vvdw12           = c12_00*VV;
286             FF               = Fp+Geps+2.0*Heps2;
287             fvdw12           = c12_00*FF;
288             vvdw             = vvdw12+vvdw6;
289             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
290
291             /* Update potential sums from outer loop */
292             velecsum        += velec;
293             vvdwsum         += vvdw;
294
295             fscal            = felec+fvdw;
296
297             /* Calculate temporary vectorial force */
298             tx               = fscal*dx00;
299             ty               = fscal*dy00;
300             tz               = fscal*dz00;
301
302             /* Update vectorial force */
303             fix0            += tx;
304             fiy0            += ty;
305             fiz0            += tz;
306             f[j_coord_offset+DIM*0+XX] -= tx;
307             f[j_coord_offset+DIM*0+YY] -= ty;
308             f[j_coord_offset+DIM*0+ZZ] -= tz;
309
310             /**************************
311              * CALCULATE INTERACTIONS *
312              **************************/
313
314             r01              = rsq01*rinv01;
315
316             /* Calculate table index by multiplying r with table scale and truncate to integer */
317             rt               = r01*vftabscale;
318             vfitab           = rt;
319             vfeps            = rt-vfitab;
320             vfitab           = 3*4*vfitab;
321
322             /* CUBIC SPLINE TABLE ELECTROSTATICS */
323             Y                = vftab[vfitab];
324             F                = vftab[vfitab+1];
325             Geps             = vfeps*vftab[vfitab+2];
326             Heps2            = vfeps*vfeps*vftab[vfitab+3];
327             Fp               = F+Geps+Heps2;
328             VV               = Y+vfeps*Fp;
329             velec            = qq01*VV;
330             FF               = Fp+Geps+2.0*Heps2;
331             felec            = -qq01*FF*vftabscale*rinv01;
332
333             /* Update potential sums from outer loop */
334             velecsum        += velec;
335
336             fscal            = felec;
337
338             /* Calculate temporary vectorial force */
339             tx               = fscal*dx01;
340             ty               = fscal*dy01;
341             tz               = fscal*dz01;
342
343             /* Update vectorial force */
344             fix0            += tx;
345             fiy0            += ty;
346             fiz0            += tz;
347             f[j_coord_offset+DIM*1+XX] -= tx;
348             f[j_coord_offset+DIM*1+YY] -= ty;
349             f[j_coord_offset+DIM*1+ZZ] -= tz;
350
351             /**************************
352              * CALCULATE INTERACTIONS *
353              **************************/
354
355             r02              = rsq02*rinv02;
356
357             /* Calculate table index by multiplying r with table scale and truncate to integer */
358             rt               = r02*vftabscale;
359             vfitab           = rt;
360             vfeps            = rt-vfitab;
361             vfitab           = 3*4*vfitab;
362
363             /* CUBIC SPLINE TABLE ELECTROSTATICS */
364             Y                = vftab[vfitab];
365             F                = vftab[vfitab+1];
366             Geps             = vfeps*vftab[vfitab+2];
367             Heps2            = vfeps*vfeps*vftab[vfitab+3];
368             Fp               = F+Geps+Heps2;
369             VV               = Y+vfeps*Fp;
370             velec            = qq02*VV;
371             FF               = Fp+Geps+2.0*Heps2;
372             felec            = -qq02*FF*vftabscale*rinv02;
373
374             /* Update potential sums from outer loop */
375             velecsum        += velec;
376
377             fscal            = felec;
378
379             /* Calculate temporary vectorial force */
380             tx               = fscal*dx02;
381             ty               = fscal*dy02;
382             tz               = fscal*dz02;
383
384             /* Update vectorial force */
385             fix0            += tx;
386             fiy0            += ty;
387             fiz0            += tz;
388             f[j_coord_offset+DIM*2+XX] -= tx;
389             f[j_coord_offset+DIM*2+YY] -= ty;
390             f[j_coord_offset+DIM*2+ZZ] -= tz;
391
392             /**************************
393              * CALCULATE INTERACTIONS *
394              **************************/
395
396             r10              = rsq10*rinv10;
397
398             /* Calculate table index by multiplying r with table scale and truncate to integer */
399             rt               = r10*vftabscale;
400             vfitab           = rt;
401             vfeps            = rt-vfitab;
402             vfitab           = 3*4*vfitab;
403
404             /* CUBIC SPLINE TABLE ELECTROSTATICS */
405             Y                = vftab[vfitab];
406             F                = vftab[vfitab+1];
407             Geps             = vfeps*vftab[vfitab+2];
408             Heps2            = vfeps*vfeps*vftab[vfitab+3];
409             Fp               = F+Geps+Heps2;
410             VV               = Y+vfeps*Fp;
411             velec            = qq10*VV;
412             FF               = Fp+Geps+2.0*Heps2;
413             felec            = -qq10*FF*vftabscale*rinv10;
414
415             /* Update potential sums from outer loop */
416             velecsum        += velec;
417
418             fscal            = felec;
419
420             /* Calculate temporary vectorial force */
421             tx               = fscal*dx10;
422             ty               = fscal*dy10;
423             tz               = fscal*dz10;
424
425             /* Update vectorial force */
426             fix1            += tx;
427             fiy1            += ty;
428             fiz1            += tz;
429             f[j_coord_offset+DIM*0+XX] -= tx;
430             f[j_coord_offset+DIM*0+YY] -= ty;
431             f[j_coord_offset+DIM*0+ZZ] -= tz;
432
433             /**************************
434              * CALCULATE INTERACTIONS *
435              **************************/
436
437             r11              = rsq11*rinv11;
438
439             /* Calculate table index by multiplying r with table scale and truncate to integer */
440             rt               = r11*vftabscale;
441             vfitab           = rt;
442             vfeps            = rt-vfitab;
443             vfitab           = 3*4*vfitab;
444
445             /* CUBIC SPLINE TABLE ELECTROSTATICS */
446             Y                = vftab[vfitab];
447             F                = vftab[vfitab+1];
448             Geps             = vfeps*vftab[vfitab+2];
449             Heps2            = vfeps*vfeps*vftab[vfitab+3];
450             Fp               = F+Geps+Heps2;
451             VV               = Y+vfeps*Fp;
452             velec            = qq11*VV;
453             FF               = Fp+Geps+2.0*Heps2;
454             felec            = -qq11*FF*vftabscale*rinv11;
455
456             /* Update potential sums from outer loop */
457             velecsum        += velec;
458
459             fscal            = felec;
460
461             /* Calculate temporary vectorial force */
462             tx               = fscal*dx11;
463             ty               = fscal*dy11;
464             tz               = fscal*dz11;
465
466             /* Update vectorial force */
467             fix1            += tx;
468             fiy1            += ty;
469             fiz1            += tz;
470             f[j_coord_offset+DIM*1+XX] -= tx;
471             f[j_coord_offset+DIM*1+YY] -= ty;
472             f[j_coord_offset+DIM*1+ZZ] -= tz;
473
474             /**************************
475              * CALCULATE INTERACTIONS *
476              **************************/
477
478             r12              = rsq12*rinv12;
479
480             /* Calculate table index by multiplying r with table scale and truncate to integer */
481             rt               = r12*vftabscale;
482             vfitab           = rt;
483             vfeps            = rt-vfitab;
484             vfitab           = 3*4*vfitab;
485
486             /* CUBIC SPLINE TABLE ELECTROSTATICS */
487             Y                = vftab[vfitab];
488             F                = vftab[vfitab+1];
489             Geps             = vfeps*vftab[vfitab+2];
490             Heps2            = vfeps*vfeps*vftab[vfitab+3];
491             Fp               = F+Geps+Heps2;
492             VV               = Y+vfeps*Fp;
493             velec            = qq12*VV;
494             FF               = Fp+Geps+2.0*Heps2;
495             felec            = -qq12*FF*vftabscale*rinv12;
496
497             /* Update potential sums from outer loop */
498             velecsum        += velec;
499
500             fscal            = felec;
501
502             /* Calculate temporary vectorial force */
503             tx               = fscal*dx12;
504             ty               = fscal*dy12;
505             tz               = fscal*dz12;
506
507             /* Update vectorial force */
508             fix1            += tx;
509             fiy1            += ty;
510             fiz1            += tz;
511             f[j_coord_offset+DIM*2+XX] -= tx;
512             f[j_coord_offset+DIM*2+YY] -= ty;
513             f[j_coord_offset+DIM*2+ZZ] -= tz;
514
515             /**************************
516              * CALCULATE INTERACTIONS *
517              **************************/
518
519             r20              = rsq20*rinv20;
520
521             /* Calculate table index by multiplying r with table scale and truncate to integer */
522             rt               = r20*vftabscale;
523             vfitab           = rt;
524             vfeps            = rt-vfitab;
525             vfitab           = 3*4*vfitab;
526
527             /* CUBIC SPLINE TABLE ELECTROSTATICS */
528             Y                = vftab[vfitab];
529             F                = vftab[vfitab+1];
530             Geps             = vfeps*vftab[vfitab+2];
531             Heps2            = vfeps*vfeps*vftab[vfitab+3];
532             Fp               = F+Geps+Heps2;
533             VV               = Y+vfeps*Fp;
534             velec            = qq20*VV;
535             FF               = Fp+Geps+2.0*Heps2;
536             felec            = -qq20*FF*vftabscale*rinv20;
537
538             /* Update potential sums from outer loop */
539             velecsum        += velec;
540
541             fscal            = felec;
542
543             /* Calculate temporary vectorial force */
544             tx               = fscal*dx20;
545             ty               = fscal*dy20;
546             tz               = fscal*dz20;
547
548             /* Update vectorial force */
549             fix2            += tx;
550             fiy2            += ty;
551             fiz2            += tz;
552             f[j_coord_offset+DIM*0+XX] -= tx;
553             f[j_coord_offset+DIM*0+YY] -= ty;
554             f[j_coord_offset+DIM*0+ZZ] -= tz;
555
556             /**************************
557              * CALCULATE INTERACTIONS *
558              **************************/
559
560             r21              = rsq21*rinv21;
561
562             /* Calculate table index by multiplying r with table scale and truncate to integer */
563             rt               = r21*vftabscale;
564             vfitab           = rt;
565             vfeps            = rt-vfitab;
566             vfitab           = 3*4*vfitab;
567
568             /* CUBIC SPLINE TABLE ELECTROSTATICS */
569             Y                = vftab[vfitab];
570             F                = vftab[vfitab+1];
571             Geps             = vfeps*vftab[vfitab+2];
572             Heps2            = vfeps*vfeps*vftab[vfitab+3];
573             Fp               = F+Geps+Heps2;
574             VV               = Y+vfeps*Fp;
575             velec            = qq21*VV;
576             FF               = Fp+Geps+2.0*Heps2;
577             felec            = -qq21*FF*vftabscale*rinv21;
578
579             /* Update potential sums from outer loop */
580             velecsum        += velec;
581
582             fscal            = felec;
583
584             /* Calculate temporary vectorial force */
585             tx               = fscal*dx21;
586             ty               = fscal*dy21;
587             tz               = fscal*dz21;
588
589             /* Update vectorial force */
590             fix2            += tx;
591             fiy2            += ty;
592             fiz2            += tz;
593             f[j_coord_offset+DIM*1+XX] -= tx;
594             f[j_coord_offset+DIM*1+YY] -= ty;
595             f[j_coord_offset+DIM*1+ZZ] -= tz;
596
597             /**************************
598              * CALCULATE INTERACTIONS *
599              **************************/
600
601             r22              = rsq22*rinv22;
602
603             /* Calculate table index by multiplying r with table scale and truncate to integer */
604             rt               = r22*vftabscale;
605             vfitab           = rt;
606             vfeps            = rt-vfitab;
607             vfitab           = 3*4*vfitab;
608
609             /* CUBIC SPLINE TABLE ELECTROSTATICS */
610             Y                = vftab[vfitab];
611             F                = vftab[vfitab+1];
612             Geps             = vfeps*vftab[vfitab+2];
613             Heps2            = vfeps*vfeps*vftab[vfitab+3];
614             Fp               = F+Geps+Heps2;
615             VV               = Y+vfeps*Fp;
616             velec            = qq22*VV;
617             FF               = Fp+Geps+2.0*Heps2;
618             felec            = -qq22*FF*vftabscale*rinv22;
619
620             /* Update potential sums from outer loop */
621             velecsum        += velec;
622
623             fscal            = felec;
624
625             /* Calculate temporary vectorial force */
626             tx               = fscal*dx22;
627             ty               = fscal*dy22;
628             tz               = fscal*dz22;
629
630             /* Update vectorial force */
631             fix2            += tx;
632             fiy2            += ty;
633             fiz2            += tz;
634             f[j_coord_offset+DIM*2+XX] -= tx;
635             f[j_coord_offset+DIM*2+YY] -= ty;
636             f[j_coord_offset+DIM*2+ZZ] -= tz;
637
638             /* Inner loop uses 400 flops */
639         }
640         /* End of innermost loop */
641
642         tx = ty = tz = 0;
643         f[i_coord_offset+DIM*0+XX] += fix0;
644         f[i_coord_offset+DIM*0+YY] += fiy0;
645         f[i_coord_offset+DIM*0+ZZ] += fiz0;
646         tx                         += fix0;
647         ty                         += fiy0;
648         tz                         += fiz0;
649         f[i_coord_offset+DIM*1+XX] += fix1;
650         f[i_coord_offset+DIM*1+YY] += fiy1;
651         f[i_coord_offset+DIM*1+ZZ] += fiz1;
652         tx                         += fix1;
653         ty                         += fiy1;
654         tz                         += fiz1;
655         f[i_coord_offset+DIM*2+XX] += fix2;
656         f[i_coord_offset+DIM*2+YY] += fiy2;
657         f[i_coord_offset+DIM*2+ZZ] += fiz2;
658         tx                         += fix2;
659         ty                         += fiy2;
660         tz                         += fiz2;
661         fshift[i_shift_offset+XX]  += tx;
662         fshift[i_shift_offset+YY]  += ty;
663         fshift[i_shift_offset+ZZ]  += tz;
664
665         ggid                        = gid[iidx];
666         /* Update potential energies */
667         kernel_data->energygrp_elec[ggid] += velecsum;
668         kernel_data->energygrp_vdw[ggid] += vvdwsum;
669
670         /* Increment number of inner iterations */
671         inneriter                  += j_index_end - j_index_start;
672
673         /* Outer loop uses 32 flops */
674     }
675
676     /* Increment number of outer iterations */
677     outeriter        += nri;
678
679     /* Update outer/inner flops */
680
681     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*400);
682 }
683 /*
684  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_F_c
685  * Electrostatics interaction: CubicSplineTable
686  * VdW interaction:            CubicSplineTable
687  * Geometry:                   Water3-Water3
688  * Calculate force/pot:        Force
689  */
690 void
691 nb_kernel_ElecCSTab_VdwCSTab_GeomW3W3_F_c
692                     (t_nblist * gmx_restrict                nlist,
693                      rvec * gmx_restrict                    xx,
694                      rvec * gmx_restrict                    ff,
695                      t_forcerec * gmx_restrict              fr,
696                      t_mdatoms * gmx_restrict               mdatoms,
697                      nb_kernel_data_t * gmx_restrict        kernel_data,
698                      t_nrnb * gmx_restrict                  nrnb)
699 {
700     int              i_shift_offset,i_coord_offset,j_coord_offset;
701     int              j_index_start,j_index_end;
702     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
703     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
704     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
705     real             *shiftvec,*fshift,*x,*f;
706     int              vdwioffset0;
707     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
708     int              vdwioffset1;
709     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
710     int              vdwioffset2;
711     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
712     int              vdwjidx0;
713     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
714     int              vdwjidx1;
715     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
716     int              vdwjidx2;
717     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
718     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
719     real             dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
720     real             dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
721     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
722     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
723     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
724     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
725     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
726     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
727     real             velec,felec,velecsum,facel,crf,krf,krf2;
728     real             *charge;
729     int              nvdwtype;
730     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
731     int              *vdwtype;
732     real             *vdwparam;
733     int              vfitab;
734     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
735     real             *vftab;
736
737     x                = xx[0];
738     f                = ff[0];
739
740     nri              = nlist->nri;
741     iinr             = nlist->iinr;
742     jindex           = nlist->jindex;
743     jjnr             = nlist->jjnr;
744     shiftidx         = nlist->shift;
745     gid              = nlist->gid;
746     shiftvec         = fr->shift_vec[0];
747     fshift           = fr->fshift[0];
748     facel            = fr->epsfac;
749     charge           = mdatoms->chargeA;
750     nvdwtype         = fr->ntype;
751     vdwparam         = fr->nbfp;
752     vdwtype          = mdatoms->typeA;
753
754     vftab            = kernel_data->table_elec_vdw->data;
755     vftabscale       = kernel_data->table_elec_vdw->scale;
756
757     /* Setup water-specific parameters */
758     inr              = nlist->iinr[0];
759     iq0              = facel*charge[inr+0];
760     iq1              = facel*charge[inr+1];
761     iq2              = facel*charge[inr+2];
762     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
763
764     jq0              = charge[inr+0];
765     jq1              = charge[inr+1];
766     jq2              = charge[inr+2];
767     vdwjidx0         = 2*vdwtype[inr+0];
768     qq00             = iq0*jq0;
769     c6_00            = vdwparam[vdwioffset0+vdwjidx0];
770     c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
771     qq01             = iq0*jq1;
772     qq02             = iq0*jq2;
773     qq10             = iq1*jq0;
774     qq11             = iq1*jq1;
775     qq12             = iq1*jq2;
776     qq20             = iq2*jq0;
777     qq21             = iq2*jq1;
778     qq22             = iq2*jq2;
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
811         fix0             = 0.0;
812         fiy0             = 0.0;
813         fiz0             = 0.0;
814         fix1             = 0.0;
815         fiy1             = 0.0;
816         fiz1             = 0.0;
817         fix2             = 0.0;
818         fiy2             = 0.0;
819         fiz2             = 0.0;
820
821         /* Start inner kernel loop */
822         for(jidx=j_index_start; jidx<j_index_end; jidx++)
823         {
824             /* Get j neighbor index, and coordinate index */
825             jnr              = jjnr[jidx];
826             j_coord_offset   = DIM*jnr;
827
828             /* load j atom coordinates */
829             jx0              = x[j_coord_offset+DIM*0+XX];
830             jy0              = x[j_coord_offset+DIM*0+YY];
831             jz0              = x[j_coord_offset+DIM*0+ZZ];
832             jx1              = x[j_coord_offset+DIM*1+XX];
833             jy1              = x[j_coord_offset+DIM*1+YY];
834             jz1              = x[j_coord_offset+DIM*1+ZZ];
835             jx2              = x[j_coord_offset+DIM*2+XX];
836             jy2              = x[j_coord_offset+DIM*2+YY];
837             jz2              = x[j_coord_offset+DIM*2+ZZ];
838
839             /* Calculate displacement vector */
840             dx00             = ix0 - jx0;
841             dy00             = iy0 - jy0;
842             dz00             = iz0 - jz0;
843             dx01             = ix0 - jx1;
844             dy01             = iy0 - jy1;
845             dz01             = iz0 - jz1;
846             dx02             = ix0 - jx2;
847             dy02             = iy0 - jy2;
848             dz02             = iz0 - jz2;
849             dx10             = ix1 - jx0;
850             dy10             = iy1 - jy0;
851             dz10             = iz1 - 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             dx20             = ix2 - jx0;
859             dy20             = iy2 - jy0;
860             dz20             = iz2 - jz0;
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
868             /* Calculate squared distance and things based on it */
869             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
870             rsq01            = dx01*dx01+dy01*dy01+dz01*dz01;
871             rsq02            = dx02*dx02+dy02*dy02+dz02*dz02;
872             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
873             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
874             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
875             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
876             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
877             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
878
879             rinv00           = gmx_invsqrt(rsq00);
880             rinv01           = gmx_invsqrt(rsq01);
881             rinv02           = gmx_invsqrt(rsq02);
882             rinv10           = gmx_invsqrt(rsq10);
883             rinv11           = gmx_invsqrt(rsq11);
884             rinv12           = gmx_invsqrt(rsq12);
885             rinv20           = gmx_invsqrt(rsq20);
886             rinv21           = gmx_invsqrt(rsq21);
887             rinv22           = gmx_invsqrt(rsq22);
888
889             /**************************
890              * CALCULATE INTERACTIONS *
891              **************************/
892
893             r00              = rsq00*rinv00;
894
895             /* Calculate table index by multiplying r with table scale and truncate to integer */
896             rt               = r00*vftabscale;
897             vfitab           = rt;
898             vfeps            = rt-vfitab;
899             vfitab           = 3*4*vfitab;
900
901             /* CUBIC SPLINE TABLE ELECTROSTATICS */
902             F                = vftab[vfitab+1];
903             Geps             = vfeps*vftab[vfitab+2];
904             Heps2            = vfeps*vfeps*vftab[vfitab+3];
905             Fp               = F+Geps+Heps2;
906             FF               = Fp+Geps+2.0*Heps2;
907             felec            = -qq00*FF*vftabscale*rinv00;
908
909             /* CUBIC SPLINE TABLE DISPERSION */
910             vfitab          += 4;
911             F                = vftab[vfitab+1];
912             Geps             = vfeps*vftab[vfitab+2];
913             Heps2            = vfeps*vfeps*vftab[vfitab+3];
914             Fp               = F+Geps+Heps2;
915             FF               = Fp+Geps+2.0*Heps2;
916             fvdw6            = c6_00*FF;
917
918             /* CUBIC SPLINE TABLE REPULSION */
919             F                = vftab[vfitab+5];
920             Geps             = vfeps*vftab[vfitab+6];
921             Heps2            = vfeps*vfeps*vftab[vfitab+7];
922             Fp               = F+Geps+Heps2;
923             FF               = Fp+Geps+2.0*Heps2;
924             fvdw12           = c12_00*FF;
925             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
926
927             fscal            = felec+fvdw;
928
929             /* Calculate temporary vectorial force */
930             tx               = fscal*dx00;
931             ty               = fscal*dy00;
932             tz               = fscal*dz00;
933
934             /* Update vectorial force */
935             fix0            += tx;
936             fiy0            += ty;
937             fiz0            += tz;
938             f[j_coord_offset+DIM*0+XX] -= tx;
939             f[j_coord_offset+DIM*0+YY] -= ty;
940             f[j_coord_offset+DIM*0+ZZ] -= tz;
941
942             /**************************
943              * CALCULATE INTERACTIONS *
944              **************************/
945
946             r01              = rsq01*rinv01;
947
948             /* Calculate table index by multiplying r with table scale and truncate to integer */
949             rt               = r01*vftabscale;
950             vfitab           = rt;
951             vfeps            = rt-vfitab;
952             vfitab           = 3*4*vfitab;
953
954             /* CUBIC SPLINE TABLE ELECTROSTATICS */
955             F                = vftab[vfitab+1];
956             Geps             = vfeps*vftab[vfitab+2];
957             Heps2            = vfeps*vfeps*vftab[vfitab+3];
958             Fp               = F+Geps+Heps2;
959             FF               = Fp+Geps+2.0*Heps2;
960             felec            = -qq01*FF*vftabscale*rinv01;
961
962             fscal            = felec;
963
964             /* Calculate temporary vectorial force */
965             tx               = fscal*dx01;
966             ty               = fscal*dy01;
967             tz               = fscal*dz01;
968
969             /* Update vectorial force */
970             fix0            += tx;
971             fiy0            += ty;
972             fiz0            += tz;
973             f[j_coord_offset+DIM*1+XX] -= tx;
974             f[j_coord_offset+DIM*1+YY] -= ty;
975             f[j_coord_offset+DIM*1+ZZ] -= tz;
976
977             /**************************
978              * CALCULATE INTERACTIONS *
979              **************************/
980
981             r02              = rsq02*rinv02;
982
983             /* Calculate table index by multiplying r with table scale and truncate to integer */
984             rt               = r02*vftabscale;
985             vfitab           = rt;
986             vfeps            = rt-vfitab;
987             vfitab           = 3*4*vfitab;
988
989             /* CUBIC SPLINE TABLE ELECTROSTATICS */
990             F                = vftab[vfitab+1];
991             Geps             = vfeps*vftab[vfitab+2];
992             Heps2            = vfeps*vfeps*vftab[vfitab+3];
993             Fp               = F+Geps+Heps2;
994             FF               = Fp+Geps+2.0*Heps2;
995             felec            = -qq02*FF*vftabscale*rinv02;
996
997             fscal            = felec;
998
999             /* Calculate temporary vectorial force */
1000             tx               = fscal*dx02;
1001             ty               = fscal*dy02;
1002             tz               = fscal*dz02;
1003
1004             /* Update vectorial force */
1005             fix0            += tx;
1006             fiy0            += ty;
1007             fiz0            += tz;
1008             f[j_coord_offset+DIM*2+XX] -= tx;
1009             f[j_coord_offset+DIM*2+YY] -= ty;
1010             f[j_coord_offset+DIM*2+ZZ] -= tz;
1011
1012             /**************************
1013              * CALCULATE INTERACTIONS *
1014              **************************/
1015
1016             r10              = rsq10*rinv10;
1017
1018             /* Calculate table index by multiplying r with table scale and truncate to integer */
1019             rt               = r10*vftabscale;
1020             vfitab           = rt;
1021             vfeps            = rt-vfitab;
1022             vfitab           = 3*4*vfitab;
1023
1024             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1025             F                = vftab[vfitab+1];
1026             Geps             = vfeps*vftab[vfitab+2];
1027             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1028             Fp               = F+Geps+Heps2;
1029             FF               = Fp+Geps+2.0*Heps2;
1030             felec            = -qq10*FF*vftabscale*rinv10;
1031
1032             fscal            = felec;
1033
1034             /* Calculate temporary vectorial force */
1035             tx               = fscal*dx10;
1036             ty               = fscal*dy10;
1037             tz               = fscal*dz10;
1038
1039             /* Update vectorial force */
1040             fix1            += tx;
1041             fiy1            += ty;
1042             fiz1            += tz;
1043             f[j_coord_offset+DIM*0+XX] -= tx;
1044             f[j_coord_offset+DIM*0+YY] -= ty;
1045             f[j_coord_offset+DIM*0+ZZ] -= tz;
1046
1047             /**************************
1048              * CALCULATE INTERACTIONS *
1049              **************************/
1050
1051             r11              = rsq11*rinv11;
1052
1053             /* Calculate table index by multiplying r with table scale and truncate to integer */
1054             rt               = r11*vftabscale;
1055             vfitab           = rt;
1056             vfeps            = rt-vfitab;
1057             vfitab           = 3*4*vfitab;
1058
1059             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1060             F                = vftab[vfitab+1];
1061             Geps             = vfeps*vftab[vfitab+2];
1062             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1063             Fp               = F+Geps+Heps2;
1064             FF               = Fp+Geps+2.0*Heps2;
1065             felec            = -qq11*FF*vftabscale*rinv11;
1066
1067             fscal            = felec;
1068
1069             /* Calculate temporary vectorial force */
1070             tx               = fscal*dx11;
1071             ty               = fscal*dy11;
1072             tz               = fscal*dz11;
1073
1074             /* Update vectorial force */
1075             fix1            += tx;
1076             fiy1            += ty;
1077             fiz1            += tz;
1078             f[j_coord_offset+DIM*1+XX] -= tx;
1079             f[j_coord_offset+DIM*1+YY] -= ty;
1080             f[j_coord_offset+DIM*1+ZZ] -= tz;
1081
1082             /**************************
1083              * CALCULATE INTERACTIONS *
1084              **************************/
1085
1086             r12              = rsq12*rinv12;
1087
1088             /* Calculate table index by multiplying r with table scale and truncate to integer */
1089             rt               = r12*vftabscale;
1090             vfitab           = rt;
1091             vfeps            = rt-vfitab;
1092             vfitab           = 3*4*vfitab;
1093
1094             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1095             F                = vftab[vfitab+1];
1096             Geps             = vfeps*vftab[vfitab+2];
1097             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1098             Fp               = F+Geps+Heps2;
1099             FF               = Fp+Geps+2.0*Heps2;
1100             felec            = -qq12*FF*vftabscale*rinv12;
1101
1102             fscal            = felec;
1103
1104             /* Calculate temporary vectorial force */
1105             tx               = fscal*dx12;
1106             ty               = fscal*dy12;
1107             tz               = fscal*dz12;
1108
1109             /* Update vectorial force */
1110             fix1            += tx;
1111             fiy1            += ty;
1112             fiz1            += tz;
1113             f[j_coord_offset+DIM*2+XX] -= tx;
1114             f[j_coord_offset+DIM*2+YY] -= ty;
1115             f[j_coord_offset+DIM*2+ZZ] -= tz;
1116
1117             /**************************
1118              * CALCULATE INTERACTIONS *
1119              **************************/
1120
1121             r20              = rsq20*rinv20;
1122
1123             /* Calculate table index by multiplying r with table scale and truncate to integer */
1124             rt               = r20*vftabscale;
1125             vfitab           = rt;
1126             vfeps            = rt-vfitab;
1127             vfitab           = 3*4*vfitab;
1128
1129             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1130             F                = vftab[vfitab+1];
1131             Geps             = vfeps*vftab[vfitab+2];
1132             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1133             Fp               = F+Geps+Heps2;
1134             FF               = Fp+Geps+2.0*Heps2;
1135             felec            = -qq20*FF*vftabscale*rinv20;
1136
1137             fscal            = felec;
1138
1139             /* Calculate temporary vectorial force */
1140             tx               = fscal*dx20;
1141             ty               = fscal*dy20;
1142             tz               = fscal*dz20;
1143
1144             /* Update vectorial force */
1145             fix2            += tx;
1146             fiy2            += ty;
1147             fiz2            += tz;
1148             f[j_coord_offset+DIM*0+XX] -= tx;
1149             f[j_coord_offset+DIM*0+YY] -= ty;
1150             f[j_coord_offset+DIM*0+ZZ] -= tz;
1151
1152             /**************************
1153              * CALCULATE INTERACTIONS *
1154              **************************/
1155
1156             r21              = rsq21*rinv21;
1157
1158             /* Calculate table index by multiplying r with table scale and truncate to integer */
1159             rt               = r21*vftabscale;
1160             vfitab           = rt;
1161             vfeps            = rt-vfitab;
1162             vfitab           = 3*4*vfitab;
1163
1164             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1165             F                = vftab[vfitab+1];
1166             Geps             = vfeps*vftab[vfitab+2];
1167             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1168             Fp               = F+Geps+Heps2;
1169             FF               = Fp+Geps+2.0*Heps2;
1170             felec            = -qq21*FF*vftabscale*rinv21;
1171
1172             fscal            = felec;
1173
1174             /* Calculate temporary vectorial force */
1175             tx               = fscal*dx21;
1176             ty               = fscal*dy21;
1177             tz               = fscal*dz21;
1178
1179             /* Update vectorial force */
1180             fix2            += tx;
1181             fiy2            += ty;
1182             fiz2            += tz;
1183             f[j_coord_offset+DIM*1+XX] -= tx;
1184             f[j_coord_offset+DIM*1+YY] -= ty;
1185             f[j_coord_offset+DIM*1+ZZ] -= tz;
1186
1187             /**************************
1188              * CALCULATE INTERACTIONS *
1189              **************************/
1190
1191             r22              = rsq22*rinv22;
1192
1193             /* Calculate table index by multiplying r with table scale and truncate to integer */
1194             rt               = r22*vftabscale;
1195             vfitab           = rt;
1196             vfeps            = rt-vfitab;
1197             vfitab           = 3*4*vfitab;
1198
1199             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1200             F                = vftab[vfitab+1];
1201             Geps             = vfeps*vftab[vfitab+2];
1202             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1203             Fp               = F+Geps+Heps2;
1204             FF               = Fp+Geps+2.0*Heps2;
1205             felec            = -qq22*FF*vftabscale*rinv22;
1206
1207             fscal            = felec;
1208
1209             /* Calculate temporary vectorial force */
1210             tx               = fscal*dx22;
1211             ty               = fscal*dy22;
1212             tz               = fscal*dz22;
1213
1214             /* Update vectorial force */
1215             fix2            += tx;
1216             fiy2            += ty;
1217             fiz2            += tz;
1218             f[j_coord_offset+DIM*2+XX] -= tx;
1219             f[j_coord_offset+DIM*2+YY] -= ty;
1220             f[j_coord_offset+DIM*2+ZZ] -= tz;
1221
1222             /* Inner loop uses 356 flops */
1223         }
1224         /* End of innermost loop */
1225
1226         tx = ty = tz = 0;
1227         f[i_coord_offset+DIM*0+XX] += fix0;
1228         f[i_coord_offset+DIM*0+YY] += fiy0;
1229         f[i_coord_offset+DIM*0+ZZ] += fiz0;
1230         tx                         += fix0;
1231         ty                         += fiy0;
1232         tz                         += fiz0;
1233         f[i_coord_offset+DIM*1+XX] += fix1;
1234         f[i_coord_offset+DIM*1+YY] += fiy1;
1235         f[i_coord_offset+DIM*1+ZZ] += fiz1;
1236         tx                         += fix1;
1237         ty                         += fiy1;
1238         tz                         += fiz1;
1239         f[i_coord_offset+DIM*2+XX] += fix2;
1240         f[i_coord_offset+DIM*2+YY] += fiy2;
1241         f[i_coord_offset+DIM*2+ZZ] += fiz2;
1242         tx                         += fix2;
1243         ty                         += fiy2;
1244         tz                         += fiz2;
1245         fshift[i_shift_offset+XX]  += tx;
1246         fshift[i_shift_offset+YY]  += ty;
1247         fshift[i_shift_offset+ZZ]  += tz;
1248
1249         /* Increment number of inner iterations */
1250         inneriter                  += j_index_end - j_index_start;
1251
1252         /* Outer loop uses 30 flops */
1253     }
1254
1255     /* Increment number of outer iterations */
1256     outeriter        += nri;
1257
1258     /* Update outer/inner flops */
1259
1260     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*356);
1261 }