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