Merge origin/release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_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_GeomW3P1_VF_c
35  * Electrostatics interaction: CubicSplineTable
36  * VdW interaction:            CubicSplineTable
37  * Geometry:                   Water3-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_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     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67     real             velec,felec,velecsum,facel,crf,krf,krf2;
68     real             *charge;
69     int              nvdwtype;
70     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
71     int              *vdwtype;
72     real             *vdwparam;
73     int              vfitab;
74     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
75     real             *vftab;
76
77     x                = xx[0];
78     f                = ff[0];
79
80     nri              = nlist->nri;
81     iinr             = nlist->iinr;
82     jindex           = nlist->jindex;
83     jjnr             = nlist->jjnr;
84     shiftidx         = nlist->shift;
85     gid              = nlist->gid;
86     shiftvec         = fr->shift_vec[0];
87     fshift           = fr->fshift[0];
88     facel            = fr->epsfac;
89     charge           = mdatoms->chargeA;
90     nvdwtype         = fr->ntype;
91     vdwparam         = fr->nbfp;
92     vdwtype          = mdatoms->typeA;
93
94     vftab            = kernel_data->table_elec_vdw->data;
95     vftabscale       = kernel_data->table_elec_vdw->scale;
96
97     /* Setup water-specific parameters */
98     inr              = nlist->iinr[0];
99     iq0              = facel*charge[inr+0];
100     iq1              = facel*charge[inr+1];
101     iq2              = facel*charge[inr+2];
102     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
103
104     outeriter        = 0;
105     inneriter        = 0;
106
107     /* Start outer loop over neighborlists */
108     for(iidx=0; iidx<nri; iidx++)
109     {
110         /* Load shift vector for this list */
111         i_shift_offset   = DIM*shiftidx[iidx];
112         shX              = shiftvec[i_shift_offset+XX];
113         shY              = shiftvec[i_shift_offset+YY];
114         shZ              = shiftvec[i_shift_offset+ZZ];
115
116         /* Load limits for loop over neighbors */
117         j_index_start    = jindex[iidx];
118         j_index_end      = jindex[iidx+1];
119
120         /* Get outer coordinate index */
121         inr              = iinr[iidx];
122         i_coord_offset   = DIM*inr;
123
124         /* Load i particle coords and add shift vector */
125         ix0              = shX + x[i_coord_offset+DIM*0+XX];
126         iy0              = shY + x[i_coord_offset+DIM*0+YY];
127         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
128         ix1              = shX + x[i_coord_offset+DIM*1+XX];
129         iy1              = shY + x[i_coord_offset+DIM*1+YY];
130         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
131         ix2              = shX + x[i_coord_offset+DIM*2+XX];
132         iy2              = shY + x[i_coord_offset+DIM*2+YY];
133         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
134
135         fix0             = 0.0;
136         fiy0             = 0.0;
137         fiz0             = 0.0;
138         fix1             = 0.0;
139         fiy1             = 0.0;
140         fiz1             = 0.0;
141         fix2             = 0.0;
142         fiy2             = 0.0;
143         fiz2             = 0.0;
144
145         /* Reset potential sums */
146         velecsum         = 0.0;
147         vvdwsum          = 0.0;
148
149         /* Start inner kernel loop */
150         for(jidx=j_index_start; jidx<j_index_end; jidx++)
151         {
152             /* Get j neighbor index, and coordinate index */
153             jnr              = jjnr[jidx];
154             j_coord_offset   = DIM*jnr;
155
156             /* load j atom coordinates */
157             jx0              = x[j_coord_offset+DIM*0+XX];
158             jy0              = x[j_coord_offset+DIM*0+YY];
159             jz0              = x[j_coord_offset+DIM*0+ZZ];
160
161             /* Calculate displacement vector */
162             dx00             = ix0 - jx0;
163             dy00             = iy0 - jy0;
164             dz00             = iz0 - jz0;
165             dx10             = ix1 - jx0;
166             dy10             = iy1 - jy0;
167             dz10             = iz1 - jz0;
168             dx20             = ix2 - jx0;
169             dy20             = iy2 - jy0;
170             dz20             = iz2 - jz0;
171
172             /* Calculate squared distance and things based on it */
173             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
174             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
175             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
176
177             rinv00           = gmx_invsqrt(rsq00);
178             rinv10           = gmx_invsqrt(rsq10);
179             rinv20           = gmx_invsqrt(rsq20);
180
181             /* Load parameters for j particles */
182             jq0              = charge[jnr+0];
183             vdwjidx0         = 2*vdwtype[jnr+0];
184
185             /**************************
186              * CALCULATE INTERACTIONS *
187              **************************/
188
189             r00              = rsq00*rinv00;
190
191             qq00             = iq0*jq0;
192             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
193             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
194
195             /* Calculate table index by multiplying r with table scale and truncate to integer */
196             rt               = r00*vftabscale;
197             vfitab           = rt;
198             vfeps            = rt-vfitab;
199             vfitab           = 3*4*vfitab;
200
201             /* CUBIC SPLINE TABLE ELECTROSTATICS */
202             Y                = vftab[vfitab];
203             F                = vftab[vfitab+1];
204             Geps             = vfeps*vftab[vfitab+2];
205             Heps2            = vfeps*vfeps*vftab[vfitab+3];
206             Fp               = F+Geps+Heps2;
207             VV               = Y+vfeps*Fp;
208             velec            = qq00*VV;
209             FF               = Fp+Geps+2.0*Heps2;
210             felec            = -qq00*FF*vftabscale*rinv00;
211
212             /* CUBIC SPLINE TABLE DISPERSION */
213             vfitab          += 4;
214             Y                = vftab[vfitab];
215             F                = vftab[vfitab+1];
216             Geps             = vfeps*vftab[vfitab+2];
217             Heps2            = vfeps*vfeps*vftab[vfitab+3];
218             Fp               = F+Geps+Heps2;
219             VV               = Y+vfeps*Fp;
220             vvdw6            = c6_00*VV;
221             FF               = Fp+Geps+2.0*Heps2;
222             fvdw6            = c6_00*FF;
223
224             /* CUBIC SPLINE TABLE REPULSION */
225             Y                = vftab[vfitab+4];
226             F                = vftab[vfitab+5];
227             Geps             = vfeps*vftab[vfitab+6];
228             Heps2            = vfeps*vfeps*vftab[vfitab+7];
229             Fp               = F+Geps+Heps2;
230             VV               = Y+vfeps*Fp;
231             vvdw12           = c12_00*VV;
232             FF               = Fp+Geps+2.0*Heps2;
233             fvdw12           = c12_00*FF;
234             vvdw             = vvdw12+vvdw6;
235             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
236
237             /* Update potential sums from outer loop */
238             velecsum        += velec;
239             vvdwsum         += vvdw;
240
241             fscal            = felec+fvdw;
242
243             /* Calculate temporary vectorial force */
244             tx               = fscal*dx00;
245             ty               = fscal*dy00;
246             tz               = fscal*dz00;
247
248             /* Update vectorial force */
249             fix0            += tx;
250             fiy0            += ty;
251             fiz0            += tz;
252             f[j_coord_offset+DIM*0+XX] -= tx;
253             f[j_coord_offset+DIM*0+YY] -= ty;
254             f[j_coord_offset+DIM*0+ZZ] -= tz;
255
256             /**************************
257              * CALCULATE INTERACTIONS *
258              **************************/
259
260             r10              = rsq10*rinv10;
261
262             qq10             = iq1*jq0;
263
264             /* Calculate table index by multiplying r with table scale and truncate to integer */
265             rt               = r10*vftabscale;
266             vfitab           = rt;
267             vfeps            = rt-vfitab;
268             vfitab           = 3*4*vfitab;
269
270             /* CUBIC SPLINE TABLE ELECTROSTATICS */
271             Y                = vftab[vfitab];
272             F                = vftab[vfitab+1];
273             Geps             = vfeps*vftab[vfitab+2];
274             Heps2            = vfeps*vfeps*vftab[vfitab+3];
275             Fp               = F+Geps+Heps2;
276             VV               = Y+vfeps*Fp;
277             velec            = qq10*VV;
278             FF               = Fp+Geps+2.0*Heps2;
279             felec            = -qq10*FF*vftabscale*rinv10;
280
281             /* Update potential sums from outer loop */
282             velecsum        += velec;
283
284             fscal            = felec;
285
286             /* Calculate temporary vectorial force */
287             tx               = fscal*dx10;
288             ty               = fscal*dy10;
289             tz               = fscal*dz10;
290
291             /* Update vectorial force */
292             fix1            += tx;
293             fiy1            += ty;
294             fiz1            += tz;
295             f[j_coord_offset+DIM*0+XX] -= tx;
296             f[j_coord_offset+DIM*0+YY] -= ty;
297             f[j_coord_offset+DIM*0+ZZ] -= tz;
298
299             /**************************
300              * CALCULATE INTERACTIONS *
301              **************************/
302
303             r20              = rsq20*rinv20;
304
305             qq20             = iq2*jq0;
306
307             /* Calculate table index by multiplying r with table scale and truncate to integer */
308             rt               = r20*vftabscale;
309             vfitab           = rt;
310             vfeps            = rt-vfitab;
311             vfitab           = 3*4*vfitab;
312
313             /* CUBIC SPLINE TABLE ELECTROSTATICS */
314             Y                = vftab[vfitab];
315             F                = vftab[vfitab+1];
316             Geps             = vfeps*vftab[vfitab+2];
317             Heps2            = vfeps*vfeps*vftab[vfitab+3];
318             Fp               = F+Geps+Heps2;
319             VV               = Y+vfeps*Fp;
320             velec            = qq20*VV;
321             FF               = Fp+Geps+2.0*Heps2;
322             felec            = -qq20*FF*vftabscale*rinv20;
323
324             /* Update potential sums from outer loop */
325             velecsum        += velec;
326
327             fscal            = felec;
328
329             /* Calculate temporary vectorial force */
330             tx               = fscal*dx20;
331             ty               = fscal*dy20;
332             tz               = fscal*dz20;
333
334             /* Update vectorial force */
335             fix2            += tx;
336             fiy2            += ty;
337             fiz2            += tz;
338             f[j_coord_offset+DIM*0+XX] -= tx;
339             f[j_coord_offset+DIM*0+YY] -= ty;
340             f[j_coord_offset+DIM*0+ZZ] -= tz;
341
342             /* Inner loop uses 157 flops */
343         }
344         /* End of innermost loop */
345
346         tx = ty = tz = 0;
347         f[i_coord_offset+DIM*0+XX] += fix0;
348         f[i_coord_offset+DIM*0+YY] += fiy0;
349         f[i_coord_offset+DIM*0+ZZ] += fiz0;
350         tx                         += fix0;
351         ty                         += fiy0;
352         tz                         += fiz0;
353         f[i_coord_offset+DIM*1+XX] += fix1;
354         f[i_coord_offset+DIM*1+YY] += fiy1;
355         f[i_coord_offset+DIM*1+ZZ] += fiz1;
356         tx                         += fix1;
357         ty                         += fiy1;
358         tz                         += fiz1;
359         f[i_coord_offset+DIM*2+XX] += fix2;
360         f[i_coord_offset+DIM*2+YY] += fiy2;
361         f[i_coord_offset+DIM*2+ZZ] += fiz2;
362         tx                         += fix2;
363         ty                         += fiy2;
364         tz                         += fiz2;
365         fshift[i_shift_offset+XX]  += tx;
366         fshift[i_shift_offset+YY]  += ty;
367         fshift[i_shift_offset+ZZ]  += tz;
368
369         ggid                        = gid[iidx];
370         /* Update potential energies */
371         kernel_data->energygrp_elec[ggid] += velecsum;
372         kernel_data->energygrp_vdw[ggid] += vvdwsum;
373
374         /* Increment number of inner iterations */
375         inneriter                  += j_index_end - j_index_start;
376
377         /* Outer loop uses 32 flops */
378     }
379
380     /* Increment number of outer iterations */
381     outeriter        += nri;
382
383     /* Update outer/inner flops */
384
385     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*157);
386 }
387 /*
388  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_F_c
389  * Electrostatics interaction: CubicSplineTable
390  * VdW interaction:            CubicSplineTable
391  * Geometry:                   Water3-Particle
392  * Calculate force/pot:        Force
393  */
394 void
395 nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_F_c
396                     (t_nblist * gmx_restrict                nlist,
397                      rvec * gmx_restrict                    xx,
398                      rvec * gmx_restrict                    ff,
399                      t_forcerec * gmx_restrict              fr,
400                      t_mdatoms * gmx_restrict               mdatoms,
401                      nb_kernel_data_t * gmx_restrict        kernel_data,
402                      t_nrnb * gmx_restrict                  nrnb)
403 {
404     int              i_shift_offset,i_coord_offset,j_coord_offset;
405     int              j_index_start,j_index_end;
406     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
407     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
408     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
409     real             *shiftvec,*fshift,*x,*f;
410     int              vdwioffset0;
411     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
412     int              vdwioffset1;
413     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
414     int              vdwioffset2;
415     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
416     int              vdwjidx0;
417     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
419     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
420     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
421     real             velec,felec,velecsum,facel,crf,krf,krf2;
422     real             *charge;
423     int              nvdwtype;
424     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
425     int              *vdwtype;
426     real             *vdwparam;
427     int              vfitab;
428     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
429     real             *vftab;
430
431     x                = xx[0];
432     f                = ff[0];
433
434     nri              = nlist->nri;
435     iinr             = nlist->iinr;
436     jindex           = nlist->jindex;
437     jjnr             = nlist->jjnr;
438     shiftidx         = nlist->shift;
439     gid              = nlist->gid;
440     shiftvec         = fr->shift_vec[0];
441     fshift           = fr->fshift[0];
442     facel            = fr->epsfac;
443     charge           = mdatoms->chargeA;
444     nvdwtype         = fr->ntype;
445     vdwparam         = fr->nbfp;
446     vdwtype          = mdatoms->typeA;
447
448     vftab            = kernel_data->table_elec_vdw->data;
449     vftabscale       = kernel_data->table_elec_vdw->scale;
450
451     /* Setup water-specific parameters */
452     inr              = nlist->iinr[0];
453     iq0              = facel*charge[inr+0];
454     iq1              = facel*charge[inr+1];
455     iq2              = facel*charge[inr+2];
456     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
457
458     outeriter        = 0;
459     inneriter        = 0;
460
461     /* Start outer loop over neighborlists */
462     for(iidx=0; iidx<nri; iidx++)
463     {
464         /* Load shift vector for this list */
465         i_shift_offset   = DIM*shiftidx[iidx];
466         shX              = shiftvec[i_shift_offset+XX];
467         shY              = shiftvec[i_shift_offset+YY];
468         shZ              = shiftvec[i_shift_offset+ZZ];
469
470         /* Load limits for loop over neighbors */
471         j_index_start    = jindex[iidx];
472         j_index_end      = jindex[iidx+1];
473
474         /* Get outer coordinate index */
475         inr              = iinr[iidx];
476         i_coord_offset   = DIM*inr;
477
478         /* Load i particle coords and add shift vector */
479         ix0              = shX + x[i_coord_offset+DIM*0+XX];
480         iy0              = shY + x[i_coord_offset+DIM*0+YY];
481         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
482         ix1              = shX + x[i_coord_offset+DIM*1+XX];
483         iy1              = shY + x[i_coord_offset+DIM*1+YY];
484         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
485         ix2              = shX + x[i_coord_offset+DIM*2+XX];
486         iy2              = shY + x[i_coord_offset+DIM*2+YY];
487         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
488
489         fix0             = 0.0;
490         fiy0             = 0.0;
491         fiz0             = 0.0;
492         fix1             = 0.0;
493         fiy1             = 0.0;
494         fiz1             = 0.0;
495         fix2             = 0.0;
496         fiy2             = 0.0;
497         fiz2             = 0.0;
498
499         /* Start inner kernel loop */
500         for(jidx=j_index_start; jidx<j_index_end; jidx++)
501         {
502             /* Get j neighbor index, and coordinate index */
503             jnr              = jjnr[jidx];
504             j_coord_offset   = DIM*jnr;
505
506             /* load j atom coordinates */
507             jx0              = x[j_coord_offset+DIM*0+XX];
508             jy0              = x[j_coord_offset+DIM*0+YY];
509             jz0              = x[j_coord_offset+DIM*0+ZZ];
510
511             /* Calculate displacement vector */
512             dx00             = ix0 - jx0;
513             dy00             = iy0 - jy0;
514             dz00             = iz0 - jz0;
515             dx10             = ix1 - jx0;
516             dy10             = iy1 - jy0;
517             dz10             = iz1 - jz0;
518             dx20             = ix2 - jx0;
519             dy20             = iy2 - jy0;
520             dz20             = iz2 - jz0;
521
522             /* Calculate squared distance and things based on it */
523             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
524             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
525             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
526
527             rinv00           = gmx_invsqrt(rsq00);
528             rinv10           = gmx_invsqrt(rsq10);
529             rinv20           = gmx_invsqrt(rsq20);
530
531             /* Load parameters for j particles */
532             jq0              = charge[jnr+0];
533             vdwjidx0         = 2*vdwtype[jnr+0];
534
535             /**************************
536              * CALCULATE INTERACTIONS *
537              **************************/
538
539             r00              = rsq00*rinv00;
540
541             qq00             = iq0*jq0;
542             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
543             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
544
545             /* Calculate table index by multiplying r with table scale and truncate to integer */
546             rt               = r00*vftabscale;
547             vfitab           = rt;
548             vfeps            = rt-vfitab;
549             vfitab           = 3*4*vfitab;
550
551             /* CUBIC SPLINE TABLE ELECTROSTATICS */
552             Y                = vftab[vfitab];
553             F                = vftab[vfitab+1];
554             Geps             = vfeps*vftab[vfitab+2];
555             Heps2            = vfeps*vfeps*vftab[vfitab+3];
556             Fp               = F+Geps+Heps2;
557             FF               = Fp+Geps+2.0*Heps2;
558             felec            = -qq00*FF*vftabscale*rinv00;
559
560             /* CUBIC SPLINE TABLE DISPERSION */
561             vfitab          += 4;
562             Y                = vftab[vfitab];
563             F                = vftab[vfitab+1];
564             Geps             = vfeps*vftab[vfitab+2];
565             Heps2            = vfeps*vfeps*vftab[vfitab+3];
566             Fp               = F+Geps+Heps2;
567             FF               = Fp+Geps+2.0*Heps2;
568             fvdw6            = c6_00*FF;
569
570             /* CUBIC SPLINE TABLE REPULSION */
571             Y                = vftab[vfitab+4];
572             F                = vftab[vfitab+5];
573             Geps             = vfeps*vftab[vfitab+6];
574             Heps2            = vfeps*vfeps*vftab[vfitab+7];
575             Fp               = F+Geps+Heps2;
576             FF               = Fp+Geps+2.0*Heps2;
577             fvdw12           = c12_00*FF;
578             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
579
580             fscal            = felec+fvdw;
581
582             /* Calculate temporary vectorial force */
583             tx               = fscal*dx00;
584             ty               = fscal*dy00;
585             tz               = fscal*dz00;
586
587             /* Update vectorial force */
588             fix0            += tx;
589             fiy0            += ty;
590             fiz0            += tz;
591             f[j_coord_offset+DIM*0+XX] -= tx;
592             f[j_coord_offset+DIM*0+YY] -= ty;
593             f[j_coord_offset+DIM*0+ZZ] -= tz;
594
595             /**************************
596              * CALCULATE INTERACTIONS *
597              **************************/
598
599             r10              = rsq10*rinv10;
600
601             qq10             = iq1*jq0;
602
603             /* Calculate table index by multiplying r with table scale and truncate to integer */
604             rt               = r10*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             FF               = Fp+Geps+2.0*Heps2;
616             felec            = -qq10*FF*vftabscale*rinv10;
617
618             fscal            = felec;
619
620             /* Calculate temporary vectorial force */
621             tx               = fscal*dx10;
622             ty               = fscal*dy10;
623             tz               = fscal*dz10;
624
625             /* Update vectorial force */
626             fix1            += tx;
627             fiy1            += ty;
628             fiz1            += tz;
629             f[j_coord_offset+DIM*0+XX] -= tx;
630             f[j_coord_offset+DIM*0+YY] -= ty;
631             f[j_coord_offset+DIM*0+ZZ] -= tz;
632
633             /**************************
634              * CALCULATE INTERACTIONS *
635              **************************/
636
637             r20              = rsq20*rinv20;
638
639             qq20             = iq2*jq0;
640
641             /* Calculate table index by multiplying r with table scale and truncate to integer */
642             rt               = r20*vftabscale;
643             vfitab           = rt;
644             vfeps            = rt-vfitab;
645             vfitab           = 3*4*vfitab;
646
647             /* CUBIC SPLINE TABLE ELECTROSTATICS */
648             Y                = vftab[vfitab];
649             F                = vftab[vfitab+1];
650             Geps             = vfeps*vftab[vfitab+2];
651             Heps2            = vfeps*vfeps*vftab[vfitab+3];
652             Fp               = F+Geps+Heps2;
653             FF               = Fp+Geps+2.0*Heps2;
654             felec            = -qq20*FF*vftabscale*rinv20;
655
656             fscal            = felec;
657
658             /* Calculate temporary vectorial force */
659             tx               = fscal*dx20;
660             ty               = fscal*dy20;
661             tz               = fscal*dz20;
662
663             /* Update vectorial force */
664             fix2            += tx;
665             fiy2            += ty;
666             fiz2            += tz;
667             f[j_coord_offset+DIM*0+XX] -= tx;
668             f[j_coord_offset+DIM*0+YY] -= ty;
669             f[j_coord_offset+DIM*0+ZZ] -= tz;
670
671             /* Inner loop uses 137 flops */
672         }
673         /* End of innermost loop */
674
675         tx = ty = tz = 0;
676         f[i_coord_offset+DIM*0+XX] += fix0;
677         f[i_coord_offset+DIM*0+YY] += fiy0;
678         f[i_coord_offset+DIM*0+ZZ] += fiz0;
679         tx                         += fix0;
680         ty                         += fiy0;
681         tz                         += fiz0;
682         f[i_coord_offset+DIM*1+XX] += fix1;
683         f[i_coord_offset+DIM*1+YY] += fiy1;
684         f[i_coord_offset+DIM*1+ZZ] += fiz1;
685         tx                         += fix1;
686         ty                         += fiy1;
687         tz                         += fiz1;
688         f[i_coord_offset+DIM*2+XX] += fix2;
689         f[i_coord_offset+DIM*2+YY] += fiy2;
690         f[i_coord_offset+DIM*2+ZZ] += fiz2;
691         tx                         += fix2;
692         ty                         += fiy2;
693         tz                         += fiz2;
694         fshift[i_shift_offset+XX]  += tx;
695         fshift[i_shift_offset+YY]  += ty;
696         fshift[i_shift_offset+ZZ]  += tz;
697
698         /* Increment number of inner iterations */
699         inneriter                  += j_index_end - j_index_start;
700
701         /* Outer loop uses 30 flops */
702     }
703
704     /* Increment number of outer iterations */
705     outeriter        += nri;
706
707     /* Update outer/inner flops */
708
709     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*137);
710 }