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