Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS c kernel generator.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_VF_c
51  * Electrostatics interaction: CubicSplineTable
52  * VdW interaction:            CubicSplineTable
53  * Geometry:                   Water3-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_VF_c
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     int              i_shift_offset,i_coord_offset,j_coord_offset;
67     int              j_index_start,j_index_end;
68     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
71     real             *shiftvec,*fshift,*x,*f;
72     int              vdwioffset0;
73     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
74     int              vdwioffset1;
75     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
76     int              vdwioffset2;
77     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
78     int              vdwjidx0;
79     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83     real             velec,felec,velecsum,facel,crf,krf,krf2;
84     real             *charge;
85     int              nvdwtype;
86     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
87     int              *vdwtype;
88     real             *vdwparam;
89     int              vfitab;
90     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
91     real             *vftab;
92
93     x                = xx[0];
94     f                = ff[0];
95
96     nri              = nlist->nri;
97     iinr             = nlist->iinr;
98     jindex           = nlist->jindex;
99     jjnr             = nlist->jjnr;
100     shiftidx         = nlist->shift;
101     gid              = nlist->gid;
102     shiftvec         = fr->shift_vec[0];
103     fshift           = fr->fshift[0];
104     facel            = fr->epsfac;
105     charge           = mdatoms->chargeA;
106     nvdwtype         = fr->ntype;
107     vdwparam         = fr->nbfp;
108     vdwtype          = mdatoms->typeA;
109
110     vftab            = kernel_data->table_elec_vdw->data;
111     vftabscale       = kernel_data->table_elec_vdw->scale;
112
113     /* Setup water-specific parameters */
114     inr              = nlist->iinr[0];
115     iq0              = facel*charge[inr+0];
116     iq1              = facel*charge[inr+1];
117     iq2              = facel*charge[inr+2];
118     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
119
120     outeriter        = 0;
121     inneriter        = 0;
122
123     /* Start outer loop over neighborlists */
124     for(iidx=0; iidx<nri; iidx++)
125     {
126         /* Load shift vector for this list */
127         i_shift_offset   = DIM*shiftidx[iidx];
128         shX              = shiftvec[i_shift_offset+XX];
129         shY              = shiftvec[i_shift_offset+YY];
130         shZ              = shiftvec[i_shift_offset+ZZ];
131
132         /* Load limits for loop over neighbors */
133         j_index_start    = jindex[iidx];
134         j_index_end      = jindex[iidx+1];
135
136         /* Get outer coordinate index */
137         inr              = iinr[iidx];
138         i_coord_offset   = DIM*inr;
139
140         /* Load i particle coords and add shift vector */
141         ix0              = shX + x[i_coord_offset+DIM*0+XX];
142         iy0              = shY + x[i_coord_offset+DIM*0+YY];
143         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
144         ix1              = shX + x[i_coord_offset+DIM*1+XX];
145         iy1              = shY + x[i_coord_offset+DIM*1+YY];
146         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
147         ix2              = shX + x[i_coord_offset+DIM*2+XX];
148         iy2              = shY + x[i_coord_offset+DIM*2+YY];
149         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
150
151         fix0             = 0.0;
152         fiy0             = 0.0;
153         fiz0             = 0.0;
154         fix1             = 0.0;
155         fiy1             = 0.0;
156         fiz1             = 0.0;
157         fix2             = 0.0;
158         fiy2             = 0.0;
159         fiz2             = 0.0;
160
161         /* Reset potential sums */
162         velecsum         = 0.0;
163         vvdwsum          = 0.0;
164
165         /* Start inner kernel loop */
166         for(jidx=j_index_start; jidx<j_index_end; jidx++)
167         {
168             /* Get j neighbor index, and coordinate index */
169             jnr              = jjnr[jidx];
170             j_coord_offset   = DIM*jnr;
171
172             /* load j atom coordinates */
173             jx0              = x[j_coord_offset+DIM*0+XX];
174             jy0              = x[j_coord_offset+DIM*0+YY];
175             jz0              = x[j_coord_offset+DIM*0+ZZ];
176
177             /* Calculate displacement vector */
178             dx00             = ix0 - jx0;
179             dy00             = iy0 - jy0;
180             dz00             = iz0 - jz0;
181             dx10             = ix1 - jx0;
182             dy10             = iy1 - jy0;
183             dz10             = iz1 - jz0;
184             dx20             = ix2 - jx0;
185             dy20             = iy2 - jy0;
186             dz20             = iz2 - jz0;
187
188             /* Calculate squared distance and things based on it */
189             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
190             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
191             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
192
193             rinv00           = gmx_invsqrt(rsq00);
194             rinv10           = gmx_invsqrt(rsq10);
195             rinv20           = gmx_invsqrt(rsq20);
196
197             /* Load parameters for j particles */
198             jq0              = charge[jnr+0];
199             vdwjidx0         = 2*vdwtype[jnr+0];
200
201             /**************************
202              * CALCULATE INTERACTIONS *
203              **************************/
204
205             r00              = rsq00*rinv00;
206
207             qq00             = iq0*jq0;
208             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
209             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
210
211             /* Calculate table index by multiplying r with table scale and truncate to integer */
212             rt               = r00*vftabscale;
213             vfitab           = rt;
214             vfeps            = rt-vfitab;
215             vfitab           = 3*4*vfitab;
216
217             /* CUBIC SPLINE TABLE ELECTROSTATICS */
218             Y                = vftab[vfitab];
219             F                = vftab[vfitab+1];
220             Geps             = vfeps*vftab[vfitab+2];
221             Heps2            = vfeps*vfeps*vftab[vfitab+3];
222             Fp               = F+Geps+Heps2;
223             VV               = Y+vfeps*Fp;
224             velec            = qq00*VV;
225             FF               = Fp+Geps+2.0*Heps2;
226             felec            = -qq00*FF*vftabscale*rinv00;
227
228             /* CUBIC SPLINE TABLE DISPERSION */
229             vfitab          += 4;
230             Y                = vftab[vfitab];
231             F                = vftab[vfitab+1];
232             Geps             = vfeps*vftab[vfitab+2];
233             Heps2            = vfeps*vfeps*vftab[vfitab+3];
234             Fp               = F+Geps+Heps2;
235             VV               = Y+vfeps*Fp;
236             vvdw6            = c6_00*VV;
237             FF               = Fp+Geps+2.0*Heps2;
238             fvdw6            = c6_00*FF;
239
240             /* CUBIC SPLINE TABLE REPULSION */
241             Y                = vftab[vfitab+4];
242             F                = vftab[vfitab+5];
243             Geps             = vfeps*vftab[vfitab+6];
244             Heps2            = vfeps*vfeps*vftab[vfitab+7];
245             Fp               = F+Geps+Heps2;
246             VV               = Y+vfeps*Fp;
247             vvdw12           = c12_00*VV;
248             FF               = Fp+Geps+2.0*Heps2;
249             fvdw12           = c12_00*FF;
250             vvdw             = vvdw12+vvdw6;
251             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
252
253             /* Update potential sums from outer loop */
254             velecsum        += velec;
255             vvdwsum         += vvdw;
256
257             fscal            = felec+fvdw;
258
259             /* Calculate temporary vectorial force */
260             tx               = fscal*dx00;
261             ty               = fscal*dy00;
262             tz               = fscal*dz00;
263
264             /* Update vectorial force */
265             fix0            += tx;
266             fiy0            += ty;
267             fiz0            += tz;
268             f[j_coord_offset+DIM*0+XX] -= tx;
269             f[j_coord_offset+DIM*0+YY] -= ty;
270             f[j_coord_offset+DIM*0+ZZ] -= tz;
271
272             /**************************
273              * CALCULATE INTERACTIONS *
274              **************************/
275
276             r10              = rsq10*rinv10;
277
278             qq10             = iq1*jq0;
279
280             /* Calculate table index by multiplying r with table scale and truncate to integer */
281             rt               = r10*vftabscale;
282             vfitab           = rt;
283             vfeps            = rt-vfitab;
284             vfitab           = 3*4*vfitab;
285
286             /* CUBIC SPLINE TABLE ELECTROSTATICS */
287             Y                = vftab[vfitab];
288             F                = vftab[vfitab+1];
289             Geps             = vfeps*vftab[vfitab+2];
290             Heps2            = vfeps*vfeps*vftab[vfitab+3];
291             Fp               = F+Geps+Heps2;
292             VV               = Y+vfeps*Fp;
293             velec            = qq10*VV;
294             FF               = Fp+Geps+2.0*Heps2;
295             felec            = -qq10*FF*vftabscale*rinv10;
296
297             /* Update potential sums from outer loop */
298             velecsum        += velec;
299
300             fscal            = felec;
301
302             /* Calculate temporary vectorial force */
303             tx               = fscal*dx10;
304             ty               = fscal*dy10;
305             tz               = fscal*dz10;
306
307             /* Update vectorial force */
308             fix1            += tx;
309             fiy1            += ty;
310             fiz1            += tz;
311             f[j_coord_offset+DIM*0+XX] -= tx;
312             f[j_coord_offset+DIM*0+YY] -= ty;
313             f[j_coord_offset+DIM*0+ZZ] -= tz;
314
315             /**************************
316              * CALCULATE INTERACTIONS *
317              **************************/
318
319             r20              = rsq20*rinv20;
320
321             qq20             = iq2*jq0;
322
323             /* Calculate table index by multiplying r with table scale and truncate to integer */
324             rt               = r20*vftabscale;
325             vfitab           = rt;
326             vfeps            = rt-vfitab;
327             vfitab           = 3*4*vfitab;
328
329             /* CUBIC SPLINE TABLE ELECTROSTATICS */
330             Y                = vftab[vfitab];
331             F                = vftab[vfitab+1];
332             Geps             = vfeps*vftab[vfitab+2];
333             Heps2            = vfeps*vfeps*vftab[vfitab+3];
334             Fp               = F+Geps+Heps2;
335             VV               = Y+vfeps*Fp;
336             velec            = qq20*VV;
337             FF               = Fp+Geps+2.0*Heps2;
338             felec            = -qq20*FF*vftabscale*rinv20;
339
340             /* Update potential sums from outer loop */
341             velecsum        += velec;
342
343             fscal            = felec;
344
345             /* Calculate temporary vectorial force */
346             tx               = fscal*dx20;
347             ty               = fscal*dy20;
348             tz               = fscal*dz20;
349
350             /* Update vectorial force */
351             fix2            += tx;
352             fiy2            += ty;
353             fiz2            += tz;
354             f[j_coord_offset+DIM*0+XX] -= tx;
355             f[j_coord_offset+DIM*0+YY] -= ty;
356             f[j_coord_offset+DIM*0+ZZ] -= tz;
357
358             /* Inner loop uses 157 flops */
359         }
360         /* End of innermost loop */
361
362         tx = ty = tz = 0;
363         f[i_coord_offset+DIM*0+XX] += fix0;
364         f[i_coord_offset+DIM*0+YY] += fiy0;
365         f[i_coord_offset+DIM*0+ZZ] += fiz0;
366         tx                         += fix0;
367         ty                         += fiy0;
368         tz                         += fiz0;
369         f[i_coord_offset+DIM*1+XX] += fix1;
370         f[i_coord_offset+DIM*1+YY] += fiy1;
371         f[i_coord_offset+DIM*1+ZZ] += fiz1;
372         tx                         += fix1;
373         ty                         += fiy1;
374         tz                         += fiz1;
375         f[i_coord_offset+DIM*2+XX] += fix2;
376         f[i_coord_offset+DIM*2+YY] += fiy2;
377         f[i_coord_offset+DIM*2+ZZ] += fiz2;
378         tx                         += fix2;
379         ty                         += fiy2;
380         tz                         += fiz2;
381         fshift[i_shift_offset+XX]  += tx;
382         fshift[i_shift_offset+YY]  += ty;
383         fshift[i_shift_offset+ZZ]  += tz;
384
385         ggid                        = gid[iidx];
386         /* Update potential energies */
387         kernel_data->energygrp_elec[ggid] += velecsum;
388         kernel_data->energygrp_vdw[ggid] += vvdwsum;
389
390         /* Increment number of inner iterations */
391         inneriter                  += j_index_end - j_index_start;
392
393         /* Outer loop uses 32 flops */
394     }
395
396     /* Increment number of outer iterations */
397     outeriter        += nri;
398
399     /* Update outer/inner flops */
400
401     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*157);
402 }
403 /*
404  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_F_c
405  * Electrostatics interaction: CubicSplineTable
406  * VdW interaction:            CubicSplineTable
407  * Geometry:                   Water3-Particle
408  * Calculate force/pot:        Force
409  */
410 void
411 nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_F_c
412                     (t_nblist                    * gmx_restrict       nlist,
413                      rvec                        * gmx_restrict          xx,
414                      rvec                        * gmx_restrict          ff,
415                      t_forcerec                  * gmx_restrict          fr,
416                      t_mdatoms                   * gmx_restrict     mdatoms,
417                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
418                      t_nrnb                      * gmx_restrict        nrnb)
419 {
420     int              i_shift_offset,i_coord_offset,j_coord_offset;
421     int              j_index_start,j_index_end;
422     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
423     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
424     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
425     real             *shiftvec,*fshift,*x,*f;
426     int              vdwioffset0;
427     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
428     int              vdwioffset1;
429     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
430     int              vdwioffset2;
431     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
432     int              vdwjidx0;
433     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
434     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
435     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
436     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
437     real             velec,felec,velecsum,facel,crf,krf,krf2;
438     real             *charge;
439     int              nvdwtype;
440     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
441     int              *vdwtype;
442     real             *vdwparam;
443     int              vfitab;
444     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
445     real             *vftab;
446
447     x                = xx[0];
448     f                = ff[0];
449
450     nri              = nlist->nri;
451     iinr             = nlist->iinr;
452     jindex           = nlist->jindex;
453     jjnr             = nlist->jjnr;
454     shiftidx         = nlist->shift;
455     gid              = nlist->gid;
456     shiftvec         = fr->shift_vec[0];
457     fshift           = fr->fshift[0];
458     facel            = fr->epsfac;
459     charge           = mdatoms->chargeA;
460     nvdwtype         = fr->ntype;
461     vdwparam         = fr->nbfp;
462     vdwtype          = mdatoms->typeA;
463
464     vftab            = kernel_data->table_elec_vdw->data;
465     vftabscale       = kernel_data->table_elec_vdw->scale;
466
467     /* Setup water-specific parameters */
468     inr              = nlist->iinr[0];
469     iq0              = facel*charge[inr+0];
470     iq1              = facel*charge[inr+1];
471     iq2              = facel*charge[inr+2];
472     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
473
474     outeriter        = 0;
475     inneriter        = 0;
476
477     /* Start outer loop over neighborlists */
478     for(iidx=0; iidx<nri; iidx++)
479     {
480         /* Load shift vector for this list */
481         i_shift_offset   = DIM*shiftidx[iidx];
482         shX              = shiftvec[i_shift_offset+XX];
483         shY              = shiftvec[i_shift_offset+YY];
484         shZ              = shiftvec[i_shift_offset+ZZ];
485
486         /* Load limits for loop over neighbors */
487         j_index_start    = jindex[iidx];
488         j_index_end      = jindex[iidx+1];
489
490         /* Get outer coordinate index */
491         inr              = iinr[iidx];
492         i_coord_offset   = DIM*inr;
493
494         /* Load i particle coords and add shift vector */
495         ix0              = shX + x[i_coord_offset+DIM*0+XX];
496         iy0              = shY + x[i_coord_offset+DIM*0+YY];
497         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
498         ix1              = shX + x[i_coord_offset+DIM*1+XX];
499         iy1              = shY + x[i_coord_offset+DIM*1+YY];
500         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
501         ix2              = shX + x[i_coord_offset+DIM*2+XX];
502         iy2              = shY + x[i_coord_offset+DIM*2+YY];
503         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
504
505         fix0             = 0.0;
506         fiy0             = 0.0;
507         fiz0             = 0.0;
508         fix1             = 0.0;
509         fiy1             = 0.0;
510         fiz1             = 0.0;
511         fix2             = 0.0;
512         fiy2             = 0.0;
513         fiz2             = 0.0;
514
515         /* Start inner kernel loop */
516         for(jidx=j_index_start; jidx<j_index_end; jidx++)
517         {
518             /* Get j neighbor index, and coordinate index */
519             jnr              = jjnr[jidx];
520             j_coord_offset   = DIM*jnr;
521
522             /* load j atom coordinates */
523             jx0              = x[j_coord_offset+DIM*0+XX];
524             jy0              = x[j_coord_offset+DIM*0+YY];
525             jz0              = x[j_coord_offset+DIM*0+ZZ];
526
527             /* Calculate displacement vector */
528             dx00             = ix0 - jx0;
529             dy00             = iy0 - jy0;
530             dz00             = iz0 - jz0;
531             dx10             = ix1 - jx0;
532             dy10             = iy1 - jy0;
533             dz10             = iz1 - jz0;
534             dx20             = ix2 - jx0;
535             dy20             = iy2 - jy0;
536             dz20             = iz2 - jz0;
537
538             /* Calculate squared distance and things based on it */
539             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
540             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
541             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
542
543             rinv00           = gmx_invsqrt(rsq00);
544             rinv10           = gmx_invsqrt(rsq10);
545             rinv20           = gmx_invsqrt(rsq20);
546
547             /* Load parameters for j particles */
548             jq0              = charge[jnr+0];
549             vdwjidx0         = 2*vdwtype[jnr+0];
550
551             /**************************
552              * CALCULATE INTERACTIONS *
553              **************************/
554
555             r00              = rsq00*rinv00;
556
557             qq00             = iq0*jq0;
558             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
559             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
560
561             /* Calculate table index by multiplying r with table scale and truncate to integer */
562             rt               = r00*vftabscale;
563             vfitab           = rt;
564             vfeps            = rt-vfitab;
565             vfitab           = 3*4*vfitab;
566
567             /* CUBIC SPLINE TABLE ELECTROSTATICS */
568             F                = vftab[vfitab+1];
569             Geps             = vfeps*vftab[vfitab+2];
570             Heps2            = vfeps*vfeps*vftab[vfitab+3];
571             Fp               = F+Geps+Heps2;
572             FF               = Fp+Geps+2.0*Heps2;
573             felec            = -qq00*FF*vftabscale*rinv00;
574
575             /* CUBIC SPLINE TABLE DISPERSION */
576             vfitab          += 4;
577             F                = vftab[vfitab+1];
578             Geps             = vfeps*vftab[vfitab+2];
579             Heps2            = vfeps*vfeps*vftab[vfitab+3];
580             Fp               = F+Geps+Heps2;
581             FF               = Fp+Geps+2.0*Heps2;
582             fvdw6            = c6_00*FF;
583
584             /* CUBIC SPLINE TABLE REPULSION */
585             F                = vftab[vfitab+5];
586             Geps             = vfeps*vftab[vfitab+6];
587             Heps2            = vfeps*vfeps*vftab[vfitab+7];
588             Fp               = F+Geps+Heps2;
589             FF               = Fp+Geps+2.0*Heps2;
590             fvdw12           = c12_00*FF;
591             fvdw             = -(fvdw6+fvdw12)*vftabscale*rinv00;
592
593             fscal            = felec+fvdw;
594
595             /* Calculate temporary vectorial force */
596             tx               = fscal*dx00;
597             ty               = fscal*dy00;
598             tz               = fscal*dz00;
599
600             /* Update vectorial force */
601             fix0            += tx;
602             fiy0            += ty;
603             fiz0            += tz;
604             f[j_coord_offset+DIM*0+XX] -= tx;
605             f[j_coord_offset+DIM*0+YY] -= ty;
606             f[j_coord_offset+DIM*0+ZZ] -= tz;
607
608             /**************************
609              * CALCULATE INTERACTIONS *
610              **************************/
611
612             r10              = rsq10*rinv10;
613
614             qq10             = iq1*jq0;
615
616             /* Calculate table index by multiplying r with table scale and truncate to integer */
617             rt               = r10*vftabscale;
618             vfitab           = rt;
619             vfeps            = rt-vfitab;
620             vfitab           = 3*4*vfitab;
621
622             /* CUBIC SPLINE TABLE ELECTROSTATICS */
623             F                = vftab[vfitab+1];
624             Geps             = vfeps*vftab[vfitab+2];
625             Heps2            = vfeps*vfeps*vftab[vfitab+3];
626             Fp               = F+Geps+Heps2;
627             FF               = Fp+Geps+2.0*Heps2;
628             felec            = -qq10*FF*vftabscale*rinv10;
629
630             fscal            = felec;
631
632             /* Calculate temporary vectorial force */
633             tx               = fscal*dx10;
634             ty               = fscal*dy10;
635             tz               = fscal*dz10;
636
637             /* Update vectorial force */
638             fix1            += tx;
639             fiy1            += ty;
640             fiz1            += tz;
641             f[j_coord_offset+DIM*0+XX] -= tx;
642             f[j_coord_offset+DIM*0+YY] -= ty;
643             f[j_coord_offset+DIM*0+ZZ] -= tz;
644
645             /**************************
646              * CALCULATE INTERACTIONS *
647              **************************/
648
649             r20              = rsq20*rinv20;
650
651             qq20             = iq2*jq0;
652
653             /* Calculate table index by multiplying r with table scale and truncate to integer */
654             rt               = r20*vftabscale;
655             vfitab           = rt;
656             vfeps            = rt-vfitab;
657             vfitab           = 3*4*vfitab;
658
659             /* CUBIC SPLINE TABLE ELECTROSTATICS */
660             F                = vftab[vfitab+1];
661             Geps             = vfeps*vftab[vfitab+2];
662             Heps2            = vfeps*vfeps*vftab[vfitab+3];
663             Fp               = F+Geps+Heps2;
664             FF               = Fp+Geps+2.0*Heps2;
665             felec            = -qq20*FF*vftabscale*rinv20;
666
667             fscal            = felec;
668
669             /* Calculate temporary vectorial force */
670             tx               = fscal*dx20;
671             ty               = fscal*dy20;
672             tz               = fscal*dz20;
673
674             /* Update vectorial force */
675             fix2            += tx;
676             fiy2            += ty;
677             fiz2            += tz;
678             f[j_coord_offset+DIM*0+XX] -= tx;
679             f[j_coord_offset+DIM*0+YY] -= ty;
680             f[j_coord_offset+DIM*0+ZZ] -= tz;
681
682             /* Inner loop uses 137 flops */
683         }
684         /* End of innermost loop */
685
686         tx = ty = tz = 0;
687         f[i_coord_offset+DIM*0+XX] += fix0;
688         f[i_coord_offset+DIM*0+YY] += fiy0;
689         f[i_coord_offset+DIM*0+ZZ] += fiz0;
690         tx                         += fix0;
691         ty                         += fiy0;
692         tz                         += fiz0;
693         f[i_coord_offset+DIM*1+XX] += fix1;
694         f[i_coord_offset+DIM*1+YY] += fiy1;
695         f[i_coord_offset+DIM*1+ZZ] += fiz1;
696         tx                         += fix1;
697         ty                         += fiy1;
698         tz                         += fiz1;
699         f[i_coord_offset+DIM*2+XX] += fix2;
700         f[i_coord_offset+DIM*2+YY] += fiy2;
701         f[i_coord_offset+DIM*2+ZZ] += fiz2;
702         tx                         += fix2;
703         ty                         += fiy2;
704         tz                         += fiz2;
705         fshift[i_shift_offset+XX]  += tx;
706         fshift[i_shift_offset+YY]  += ty;
707         fshift[i_shift_offset+ZZ]  += tz;
708
709         /* Increment number of inner iterations */
710         inneriter                  += j_index_end - j_index_start;
711
712         /* Outer loop uses 30 flops */
713     }
714
715     /* Increment number of outer iterations */
716     outeriter        += nri;
717
718     /* Update outer/inner flops */
719
720     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*137);
721 }