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