d6479bbacddc4656450c08646571332f3d1adaea
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwBham_GeomW3P1_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, 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 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 /*
48  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwBham_GeomW3P1_VF_c
49  * Electrostatics interaction: CubicSplineTable
50  * VdW interaction:            Buckingham
51  * Geometry:                   Water3-Particle
52  * Calculate force/pot:        PotentialAndForce
53  */
54 void
55 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_VF_c
56                     (t_nblist                    * gmx_restrict       nlist,
57                      rvec                        * gmx_restrict          xx,
58                      rvec                        * gmx_restrict          ff,
59                      t_forcerec                  * gmx_restrict          fr,
60                      t_mdatoms                   * gmx_restrict     mdatoms,
61                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62                      t_nrnb                      * gmx_restrict        nrnb)
63 {
64     int              i_shift_offset,i_coord_offset,j_coord_offset;
65     int              j_index_start,j_index_end;
66     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
69     real             *shiftvec,*fshift,*x,*f;
70     int              vdwioffset0;
71     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72     int              vdwioffset1;
73     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74     int              vdwioffset2;
75     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76     int              vdwjidx0;
77     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81     real             velec,felec,velecsum,facel,crf,krf,krf2;
82     real             *charge;
83     int              nvdwtype;
84     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
85     int              *vdwtype;
86     real             *vdwparam;
87     int              vfitab;
88     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
89     real             *vftab;
90
91     x                = xx[0];
92     f                = ff[0];
93
94     nri              = nlist->nri;
95     iinr             = nlist->iinr;
96     jindex           = nlist->jindex;
97     jjnr             = nlist->jjnr;
98     shiftidx         = nlist->shift;
99     gid              = nlist->gid;
100     shiftvec         = fr->shift_vec[0];
101     fshift           = fr->fshift[0];
102     facel            = fr->epsfac;
103     charge           = mdatoms->chargeA;
104     nvdwtype         = fr->ntype;
105     vdwparam         = fr->nbfp;
106     vdwtype          = mdatoms->typeA;
107
108     vftab            = kernel_data->table_elec->data;
109     vftabscale       = kernel_data->table_elec->scale;
110
111     /* Setup water-specific parameters */
112     inr              = nlist->iinr[0];
113     iq0              = facel*charge[inr+0];
114     iq1              = facel*charge[inr+1];
115     iq2              = facel*charge[inr+2];
116     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
117
118     outeriter        = 0;
119     inneriter        = 0;
120
121     /* Start outer loop over neighborlists */
122     for(iidx=0; iidx<nri; iidx++)
123     {
124         /* Load shift vector for this list */
125         i_shift_offset   = DIM*shiftidx[iidx];
126         shX              = shiftvec[i_shift_offset+XX];
127         shY              = shiftvec[i_shift_offset+YY];
128         shZ              = shiftvec[i_shift_offset+ZZ];
129
130         /* Load limits for loop over neighbors */
131         j_index_start    = jindex[iidx];
132         j_index_end      = jindex[iidx+1];
133
134         /* Get outer coordinate index */
135         inr              = iinr[iidx];
136         i_coord_offset   = DIM*inr;
137
138         /* Load i particle coords and add shift vector */
139         ix0              = shX + x[i_coord_offset+DIM*0+XX];
140         iy0              = shY + x[i_coord_offset+DIM*0+YY];
141         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
142         ix1              = shX + x[i_coord_offset+DIM*1+XX];
143         iy1              = shY + x[i_coord_offset+DIM*1+YY];
144         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
145         ix2              = shX + x[i_coord_offset+DIM*2+XX];
146         iy2              = shY + x[i_coord_offset+DIM*2+YY];
147         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
148
149         fix0             = 0.0;
150         fiy0             = 0.0;
151         fiz0             = 0.0;
152         fix1             = 0.0;
153         fiy1             = 0.0;
154         fiz1             = 0.0;
155         fix2             = 0.0;
156         fiy2             = 0.0;
157         fiz2             = 0.0;
158
159         /* Reset potential sums */
160         velecsum         = 0.0;
161         vvdwsum          = 0.0;
162
163         /* Start inner kernel loop */
164         for(jidx=j_index_start; jidx<j_index_end; jidx++)
165         {
166             /* Get j neighbor index, and coordinate index */
167             jnr              = jjnr[jidx];
168             j_coord_offset   = DIM*jnr;
169
170             /* load j atom coordinates */
171             jx0              = x[j_coord_offset+DIM*0+XX];
172             jy0              = x[j_coord_offset+DIM*0+YY];
173             jz0              = x[j_coord_offset+DIM*0+ZZ];
174
175             /* Calculate displacement vector */
176             dx00             = ix0 - jx0;
177             dy00             = iy0 - jy0;
178             dz00             = iz0 - jz0;
179             dx10             = ix1 - jx0;
180             dy10             = iy1 - jy0;
181             dz10             = iz1 - jz0;
182             dx20             = ix2 - jx0;
183             dy20             = iy2 - jy0;
184             dz20             = iz2 - jz0;
185
186             /* Calculate squared distance and things based on it */
187             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
188             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
189             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
190
191             rinv00           = gmx_invsqrt(rsq00);
192             rinv10           = gmx_invsqrt(rsq10);
193             rinv20           = gmx_invsqrt(rsq20);
194
195             rinvsq00         = rinv00*rinv00;
196
197             /* Load parameters for j particles */
198             jq0              = charge[jnr+0];
199             vdwjidx0         = 3*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             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
210             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
211
212             /* Calculate table index by multiplying r with table scale and truncate to integer */
213             rt               = r00*vftabscale;
214             vfitab           = rt;
215             vfeps            = rt-vfitab;
216             vfitab           = 1*4*vfitab;
217
218             /* CUBIC SPLINE TABLE ELECTROSTATICS */
219             Y                = vftab[vfitab];
220             F                = vftab[vfitab+1];
221             Geps             = vfeps*vftab[vfitab+2];
222             Heps2            = vfeps*vfeps*vftab[vfitab+3];
223             Fp               = F+Geps+Heps2;
224             VV               = Y+vfeps*Fp;
225             velec            = qq00*VV;
226             FF               = Fp+Geps+2.0*Heps2;
227             felec            = -qq00*FF*vftabscale*rinv00;
228
229             /* BUCKINGHAM DISPERSION/REPULSION */
230             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
231             vvdw6            = c6_00*rinvsix;
232             br               = cexp2_00*r00;
233             vvdwexp          = cexp1_00*exp(-br);
234             vvdw             = vvdwexp - vvdw6*(1.0/6.0);
235             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
236
237             /* Update potential sums from outer loop */
238             velecsum        += velec;
239             vvdwsum         += vvdw;
240
241             fscal            = felec+fvdw;
242
243             /* Calculate temporary vectorial force */
244             tx               = fscal*dx00;
245             ty               = fscal*dy00;
246             tz               = fscal*dz00;
247
248             /* Update vectorial force */
249             fix0            += tx;
250             fiy0            += ty;
251             fiz0            += tz;
252             f[j_coord_offset+DIM*0+XX] -= tx;
253             f[j_coord_offset+DIM*0+YY] -= ty;
254             f[j_coord_offset+DIM*0+ZZ] -= tz;
255
256             /**************************
257              * CALCULATE INTERACTIONS *
258              **************************/
259
260             r10              = rsq10*rinv10;
261
262             qq10             = iq1*jq0;
263
264             /* Calculate table index by multiplying r with table scale and truncate to integer */
265             rt               = r10*vftabscale;
266             vfitab           = rt;
267             vfeps            = rt-vfitab;
268             vfitab           = 1*4*vfitab;
269
270             /* CUBIC SPLINE TABLE ELECTROSTATICS */
271             Y                = vftab[vfitab];
272             F                = vftab[vfitab+1];
273             Geps             = vfeps*vftab[vfitab+2];
274             Heps2            = vfeps*vfeps*vftab[vfitab+3];
275             Fp               = F+Geps+Heps2;
276             VV               = Y+vfeps*Fp;
277             velec            = qq10*VV;
278             FF               = Fp+Geps+2.0*Heps2;
279             felec            = -qq10*FF*vftabscale*rinv10;
280
281             /* Update potential sums from outer loop */
282             velecsum        += velec;
283
284             fscal            = felec;
285
286             /* Calculate temporary vectorial force */
287             tx               = fscal*dx10;
288             ty               = fscal*dy10;
289             tz               = fscal*dz10;
290
291             /* Update vectorial force */
292             fix1            += tx;
293             fiy1            += ty;
294             fiz1            += tz;
295             f[j_coord_offset+DIM*0+XX] -= tx;
296             f[j_coord_offset+DIM*0+YY] -= ty;
297             f[j_coord_offset+DIM*0+ZZ] -= tz;
298
299             /**************************
300              * CALCULATE INTERACTIONS *
301              **************************/
302
303             r20              = rsq20*rinv20;
304
305             qq20             = iq2*jq0;
306
307             /* Calculate table index by multiplying r with table scale and truncate to integer */
308             rt               = r20*vftabscale;
309             vfitab           = rt;
310             vfeps            = rt-vfitab;
311             vfitab           = 1*4*vfitab;
312
313             /* CUBIC SPLINE TABLE ELECTROSTATICS */
314             Y                = vftab[vfitab];
315             F                = vftab[vfitab+1];
316             Geps             = vfeps*vftab[vfitab+2];
317             Heps2            = vfeps*vfeps*vftab[vfitab+3];
318             Fp               = F+Geps+Heps2;
319             VV               = Y+vfeps*Fp;
320             velec            = qq20*VV;
321             FF               = Fp+Geps+2.0*Heps2;
322             felec            = -qq20*FF*vftabscale*rinv20;
323
324             /* Update potential sums from outer loop */
325             velecsum        += velec;
326
327             fscal            = felec;
328
329             /* Calculate temporary vectorial force */
330             tx               = fscal*dx20;
331             ty               = fscal*dy20;
332             tz               = fscal*dz20;
333
334             /* Update vectorial force */
335             fix2            += tx;
336             fiy2            += ty;
337             fiz2            += tz;
338             f[j_coord_offset+DIM*0+XX] -= tx;
339             f[j_coord_offset+DIM*0+YY] -= ty;
340             f[j_coord_offset+DIM*0+ZZ] -= tz;
341
342             /* Inner loop uses 165 flops */
343         }
344         /* End of innermost loop */
345
346         tx = ty = tz = 0;
347         f[i_coord_offset+DIM*0+XX] += fix0;
348         f[i_coord_offset+DIM*0+YY] += fiy0;
349         f[i_coord_offset+DIM*0+ZZ] += fiz0;
350         tx                         += fix0;
351         ty                         += fiy0;
352         tz                         += fiz0;
353         f[i_coord_offset+DIM*1+XX] += fix1;
354         f[i_coord_offset+DIM*1+YY] += fiy1;
355         f[i_coord_offset+DIM*1+ZZ] += fiz1;
356         tx                         += fix1;
357         ty                         += fiy1;
358         tz                         += fiz1;
359         f[i_coord_offset+DIM*2+XX] += fix2;
360         f[i_coord_offset+DIM*2+YY] += fiy2;
361         f[i_coord_offset+DIM*2+ZZ] += fiz2;
362         tx                         += fix2;
363         ty                         += fiy2;
364         tz                         += fiz2;
365         fshift[i_shift_offset+XX]  += tx;
366         fshift[i_shift_offset+YY]  += ty;
367         fshift[i_shift_offset+ZZ]  += tz;
368
369         ggid                        = gid[iidx];
370         /* Update potential energies */
371         kernel_data->energygrp_elec[ggid] += velecsum;
372         kernel_data->energygrp_vdw[ggid] += vvdwsum;
373
374         /* Increment number of inner iterations */
375         inneriter                  += j_index_end - j_index_start;
376
377         /* Outer loop uses 32 flops */
378     }
379
380     /* Increment number of outer iterations */
381     outeriter        += nri;
382
383     /* Update outer/inner flops */
384
385     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*165);
386 }
387 /*
388  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
389  * Electrostatics interaction: CubicSplineTable
390  * VdW interaction:            Buckingham
391  * Geometry:                   Water3-Particle
392  * Calculate force/pot:        Force
393  */
394 void
395 nb_kernel_ElecCSTab_VdwBham_GeomW3P1_F_c
396                     (t_nblist                    * gmx_restrict       nlist,
397                      rvec                        * gmx_restrict          xx,
398                      rvec                        * gmx_restrict          ff,
399                      t_forcerec                  * gmx_restrict          fr,
400                      t_mdatoms                   * gmx_restrict     mdatoms,
401                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
402                      t_nrnb                      * gmx_restrict        nrnb)
403 {
404     int              i_shift_offset,i_coord_offset,j_coord_offset;
405     int              j_index_start,j_index_end;
406     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
407     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
408     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
409     real             *shiftvec,*fshift,*x,*f;
410     int              vdwioffset0;
411     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
412     int              vdwioffset1;
413     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
414     int              vdwioffset2;
415     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
416     int              vdwjidx0;
417     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
419     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
420     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
421     real             velec,felec,velecsum,facel,crf,krf,krf2;
422     real             *charge;
423     int              nvdwtype;
424     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
425     int              *vdwtype;
426     real             *vdwparam;
427     int              vfitab;
428     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
429     real             *vftab;
430
431     x                = xx[0];
432     f                = ff[0];
433
434     nri              = nlist->nri;
435     iinr             = nlist->iinr;
436     jindex           = nlist->jindex;
437     jjnr             = nlist->jjnr;
438     shiftidx         = nlist->shift;
439     gid              = nlist->gid;
440     shiftvec         = fr->shift_vec[0];
441     fshift           = fr->fshift[0];
442     facel            = fr->epsfac;
443     charge           = mdatoms->chargeA;
444     nvdwtype         = fr->ntype;
445     vdwparam         = fr->nbfp;
446     vdwtype          = mdatoms->typeA;
447
448     vftab            = kernel_data->table_elec->data;
449     vftabscale       = kernel_data->table_elec->scale;
450
451     /* Setup water-specific parameters */
452     inr              = nlist->iinr[0];
453     iq0              = facel*charge[inr+0];
454     iq1              = facel*charge[inr+1];
455     iq2              = facel*charge[inr+2];
456     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
457
458     outeriter        = 0;
459     inneriter        = 0;
460
461     /* Start outer loop over neighborlists */
462     for(iidx=0; iidx<nri; iidx++)
463     {
464         /* Load shift vector for this list */
465         i_shift_offset   = DIM*shiftidx[iidx];
466         shX              = shiftvec[i_shift_offset+XX];
467         shY              = shiftvec[i_shift_offset+YY];
468         shZ              = shiftvec[i_shift_offset+ZZ];
469
470         /* Load limits for loop over neighbors */
471         j_index_start    = jindex[iidx];
472         j_index_end      = jindex[iidx+1];
473
474         /* Get outer coordinate index */
475         inr              = iinr[iidx];
476         i_coord_offset   = DIM*inr;
477
478         /* Load i particle coords and add shift vector */
479         ix0              = shX + x[i_coord_offset+DIM*0+XX];
480         iy0              = shY + x[i_coord_offset+DIM*0+YY];
481         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
482         ix1              = shX + x[i_coord_offset+DIM*1+XX];
483         iy1              = shY + x[i_coord_offset+DIM*1+YY];
484         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
485         ix2              = shX + x[i_coord_offset+DIM*2+XX];
486         iy2              = shY + x[i_coord_offset+DIM*2+YY];
487         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
488
489         fix0             = 0.0;
490         fiy0             = 0.0;
491         fiz0             = 0.0;
492         fix1             = 0.0;
493         fiy1             = 0.0;
494         fiz1             = 0.0;
495         fix2             = 0.0;
496         fiy2             = 0.0;
497         fiz2             = 0.0;
498
499         /* Start inner kernel loop */
500         for(jidx=j_index_start; jidx<j_index_end; jidx++)
501         {
502             /* Get j neighbor index, and coordinate index */
503             jnr              = jjnr[jidx];
504             j_coord_offset   = DIM*jnr;
505
506             /* load j atom coordinates */
507             jx0              = x[j_coord_offset+DIM*0+XX];
508             jy0              = x[j_coord_offset+DIM*0+YY];
509             jz0              = x[j_coord_offset+DIM*0+ZZ];
510
511             /* Calculate displacement vector */
512             dx00             = ix0 - jx0;
513             dy00             = iy0 - jy0;
514             dz00             = iz0 - jz0;
515             dx10             = ix1 - jx0;
516             dy10             = iy1 - jy0;
517             dz10             = iz1 - jz0;
518             dx20             = ix2 - jx0;
519             dy20             = iy2 - jy0;
520             dz20             = iz2 - jz0;
521
522             /* Calculate squared distance and things based on it */
523             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
524             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
525             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
526
527             rinv00           = gmx_invsqrt(rsq00);
528             rinv10           = gmx_invsqrt(rsq10);
529             rinv20           = gmx_invsqrt(rsq20);
530
531             rinvsq00         = rinv00*rinv00;
532
533             /* Load parameters for j particles */
534             jq0              = charge[jnr+0];
535             vdwjidx0         = 3*vdwtype[jnr+0];
536
537             /**************************
538              * CALCULATE INTERACTIONS *
539              **************************/
540
541             r00              = rsq00*rinv00;
542
543             qq00             = iq0*jq0;
544             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
545             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
546             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
547
548             /* Calculate table index by multiplying r with table scale and truncate to integer */
549             rt               = r00*vftabscale;
550             vfitab           = rt;
551             vfeps            = rt-vfitab;
552             vfitab           = 1*4*vfitab;
553
554             /* CUBIC SPLINE TABLE ELECTROSTATICS */
555             F                = vftab[vfitab+1];
556             Geps             = vfeps*vftab[vfitab+2];
557             Heps2            = vfeps*vfeps*vftab[vfitab+3];
558             Fp               = F+Geps+Heps2;
559             FF               = Fp+Geps+2.0*Heps2;
560             felec            = -qq00*FF*vftabscale*rinv00;
561
562             /* BUCKINGHAM DISPERSION/REPULSION */
563             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
564             vvdw6            = c6_00*rinvsix;
565             br               = cexp2_00*r00;
566             vvdwexp          = cexp1_00*exp(-br);
567             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
568
569             fscal            = felec+fvdw;
570
571             /* Calculate temporary vectorial force */
572             tx               = fscal*dx00;
573             ty               = fscal*dy00;
574             tz               = fscal*dz00;
575
576             /* Update vectorial force */
577             fix0            += tx;
578             fiy0            += ty;
579             fiz0            += tz;
580             f[j_coord_offset+DIM*0+XX] -= tx;
581             f[j_coord_offset+DIM*0+YY] -= ty;
582             f[j_coord_offset+DIM*0+ZZ] -= tz;
583
584             /**************************
585              * CALCULATE INTERACTIONS *
586              **************************/
587
588             r10              = rsq10*rinv10;
589
590             qq10             = iq1*jq0;
591
592             /* Calculate table index by multiplying r with table scale and truncate to integer */
593             rt               = r10*vftabscale;
594             vfitab           = rt;
595             vfeps            = rt-vfitab;
596             vfitab           = 1*4*vfitab;
597
598             /* CUBIC SPLINE TABLE ELECTROSTATICS */
599             F                = vftab[vfitab+1];
600             Geps             = vfeps*vftab[vfitab+2];
601             Heps2            = vfeps*vfeps*vftab[vfitab+3];
602             Fp               = F+Geps+Heps2;
603             FF               = Fp+Geps+2.0*Heps2;
604             felec            = -qq10*FF*vftabscale*rinv10;
605
606             fscal            = felec;
607
608             /* Calculate temporary vectorial force */
609             tx               = fscal*dx10;
610             ty               = fscal*dy10;
611             tz               = fscal*dz10;
612
613             /* Update vectorial force */
614             fix1            += tx;
615             fiy1            += ty;
616             fiz1            += tz;
617             f[j_coord_offset+DIM*0+XX] -= tx;
618             f[j_coord_offset+DIM*0+YY] -= ty;
619             f[j_coord_offset+DIM*0+ZZ] -= tz;
620
621             /**************************
622              * CALCULATE INTERACTIONS *
623              **************************/
624
625             r20              = rsq20*rinv20;
626
627             qq20             = iq2*jq0;
628
629             /* Calculate table index by multiplying r with table scale and truncate to integer */
630             rt               = r20*vftabscale;
631             vfitab           = rt;
632             vfeps            = rt-vfitab;
633             vfitab           = 1*4*vfitab;
634
635             /* CUBIC SPLINE TABLE ELECTROSTATICS */
636             F                = vftab[vfitab+1];
637             Geps             = vfeps*vftab[vfitab+2];
638             Heps2            = vfeps*vfeps*vftab[vfitab+3];
639             Fp               = F+Geps+Heps2;
640             FF               = Fp+Geps+2.0*Heps2;
641             felec            = -qq20*FF*vftabscale*rinv20;
642
643             fscal            = felec;
644
645             /* Calculate temporary vectorial force */
646             tx               = fscal*dx20;
647             ty               = fscal*dy20;
648             tz               = fscal*dz20;
649
650             /* Update vectorial force */
651             fix2            += tx;
652             fiy2            += ty;
653             fiz2            += tz;
654             f[j_coord_offset+DIM*0+XX] -= tx;
655             f[j_coord_offset+DIM*0+YY] -= ty;
656             f[j_coord_offset+DIM*0+ZZ] -= tz;
657
658             /* Inner loop uses 150 flops */
659         }
660         /* End of innermost loop */
661
662         tx = ty = tz = 0;
663         f[i_coord_offset+DIM*0+XX] += fix0;
664         f[i_coord_offset+DIM*0+YY] += fiy0;
665         f[i_coord_offset+DIM*0+ZZ] += fiz0;
666         tx                         += fix0;
667         ty                         += fiy0;
668         tz                         += fiz0;
669         f[i_coord_offset+DIM*1+XX] += fix1;
670         f[i_coord_offset+DIM*1+YY] += fiy1;
671         f[i_coord_offset+DIM*1+ZZ] += fiz1;
672         tx                         += fix1;
673         ty                         += fiy1;
674         tz                         += fiz1;
675         f[i_coord_offset+DIM*2+XX] += fix2;
676         f[i_coord_offset+DIM*2+YY] += fiy2;
677         f[i_coord_offset+DIM*2+ZZ] += fiz2;
678         tx                         += fix2;
679         ty                         += fiy2;
680         tz                         += fiz2;
681         fshift[i_shift_offset+XX]  += tx;
682         fshift[i_shift_offset+YY]  += ty;
683         fshift[i_shift_offset+ZZ]  += tz;
684
685         /* Increment number of inner iterations */
686         inneriter                  += j_index_end - j_index_start;
687
688         /* Outer loop uses 30 flops */
689     }
690
691     /* Increment number of outer iterations */
692     outeriter        += nri;
693
694     /* Update outer/inner flops */
695
696     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*150);
697 }