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