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