d08fbaebc60eb6b80545bb4fe13bf34096ef5807
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwLJ_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 "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
46
47 /*
48  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwLJ_GeomW3P1_VF_c
49  * Electrostatics interaction: CubicSplineTable
50  * VdW interaction:            LennardJones
51  * Geometry:                   Water3-Particle
52  * Calculate force/pot:        PotentialAndForce
53  */
54 void
55 nb_kernel_ElecCSTab_VdwLJ_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      = 2*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         = 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           = 1*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             /* LENNARD-JONES DISPERSION/REPULSION */
229
230             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
231             vvdw6            = c6_00*rinvsix;
232             vvdw12           = c12_00*rinvsix*rinvsix;
233             vvdw             = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
234             fvdw             = (vvdw12-vvdw6)*rinvsq00;
235
236             /* Update potential sums from outer loop */
237             velecsum        += velec;
238             vvdwsum         += vvdw;
239
240             fscal            = felec+fvdw;
241
242             /* Calculate temporary vectorial force */
243             tx               = fscal*dx00;
244             ty               = fscal*dy00;
245             tz               = fscal*dz00;
246
247             /* Update vectorial force */
248             fix0            += tx;
249             fiy0            += ty;
250             fiz0            += tz;
251             f[j_coord_offset+DIM*0+XX] -= tx;
252             f[j_coord_offset+DIM*0+YY] -= ty;
253             f[j_coord_offset+DIM*0+ZZ] -= tz;
254
255             /**************************
256              * CALCULATE INTERACTIONS *
257              **************************/
258
259             r10              = rsq10*rinv10;
260
261             qq10             = iq1*jq0;
262
263             /* Calculate table index by multiplying r with table scale and truncate to integer */
264             rt               = r10*vftabscale;
265             vfitab           = rt;
266             vfeps            = rt-vfitab;
267             vfitab           = 1*4*vfitab;
268
269             /* CUBIC SPLINE TABLE ELECTROSTATICS */
270             Y                = vftab[vfitab];
271             F                = vftab[vfitab+1];
272             Geps             = vfeps*vftab[vfitab+2];
273             Heps2            = vfeps*vfeps*vftab[vfitab+3];
274             Fp               = F+Geps+Heps2;
275             VV               = Y+vfeps*Fp;
276             velec            = qq10*VV;
277             FF               = Fp+Geps+2.0*Heps2;
278             felec            = -qq10*FF*vftabscale*rinv10;
279
280             /* Update potential sums from outer loop */
281             velecsum        += velec;
282
283             fscal            = felec;
284
285             /* Calculate temporary vectorial force */
286             tx               = fscal*dx10;
287             ty               = fscal*dy10;
288             tz               = fscal*dz10;
289
290             /* Update vectorial force */
291             fix1            += tx;
292             fiy1            += ty;
293             fiz1            += tz;
294             f[j_coord_offset+DIM*0+XX] -= tx;
295             f[j_coord_offset+DIM*0+YY] -= ty;
296             f[j_coord_offset+DIM*0+ZZ] -= tz;
297
298             /**************************
299              * CALCULATE INTERACTIONS *
300              **************************/
301
302             r20              = rsq20*rinv20;
303
304             qq20             = iq2*jq0;
305
306             /* Calculate table index by multiplying r with table scale and truncate to integer */
307             rt               = r20*vftabscale;
308             vfitab           = rt;
309             vfeps            = rt-vfitab;
310             vfitab           = 1*4*vfitab;
311
312             /* CUBIC SPLINE TABLE ELECTROSTATICS */
313             Y                = vftab[vfitab];
314             F                = vftab[vfitab+1];
315             Geps             = vfeps*vftab[vfitab+2];
316             Heps2            = vfeps*vfeps*vftab[vfitab+3];
317             Fp               = F+Geps+Heps2;
318             VV               = Y+vfeps*Fp;
319             velec            = qq20*VV;
320             FF               = Fp+Geps+2.0*Heps2;
321             felec            = -qq20*FF*vftabscale*rinv20;
322
323             /* Update potential sums from outer loop */
324             velecsum        += velec;
325
326             fscal            = felec;
327
328             /* Calculate temporary vectorial force */
329             tx               = fscal*dx20;
330             ty               = fscal*dy20;
331             tz               = fscal*dz20;
332
333             /* Update vectorial force */
334             fix2            += tx;
335             fiy2            += ty;
336             fiz2            += tz;
337             f[j_coord_offset+DIM*0+XX] -= tx;
338             f[j_coord_offset+DIM*0+YY] -= ty;
339             f[j_coord_offset+DIM*0+ZZ] -= tz;
340
341             /* Inner loop uses 139 flops */
342         }
343         /* End of innermost loop */
344
345         tx = ty = tz = 0;
346         f[i_coord_offset+DIM*0+XX] += fix0;
347         f[i_coord_offset+DIM*0+YY] += fiy0;
348         f[i_coord_offset+DIM*0+ZZ] += fiz0;
349         tx                         += fix0;
350         ty                         += fiy0;
351         tz                         += fiz0;
352         f[i_coord_offset+DIM*1+XX] += fix1;
353         f[i_coord_offset+DIM*1+YY] += fiy1;
354         f[i_coord_offset+DIM*1+ZZ] += fiz1;
355         tx                         += fix1;
356         ty                         += fiy1;
357         tz                         += fiz1;
358         f[i_coord_offset+DIM*2+XX] += fix2;
359         f[i_coord_offset+DIM*2+YY] += fiy2;
360         f[i_coord_offset+DIM*2+ZZ] += fiz2;
361         tx                         += fix2;
362         ty                         += fiy2;
363         tz                         += fiz2;
364         fshift[i_shift_offset+XX]  += tx;
365         fshift[i_shift_offset+YY]  += ty;
366         fshift[i_shift_offset+ZZ]  += tz;
367
368         ggid                        = gid[iidx];
369         /* Update potential energies */
370         kernel_data->energygrp_elec[ggid] += velecsum;
371         kernel_data->energygrp_vdw[ggid] += vvdwsum;
372
373         /* Increment number of inner iterations */
374         inneriter                  += j_index_end - j_index_start;
375
376         /* Outer loop uses 32 flops */
377     }
378
379     /* Increment number of outer iterations */
380     outeriter        += nri;
381
382     /* Update outer/inner flops */
383
384     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*139);
385 }
386 /*
387  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwLJ_GeomW3P1_F_c
388  * Electrostatics interaction: CubicSplineTable
389  * VdW interaction:            LennardJones
390  * Geometry:                   Water3-Particle
391  * Calculate force/pot:        Force
392  */
393 void
394 nb_kernel_ElecCSTab_VdwLJ_GeomW3P1_F_c
395                     (t_nblist                    * gmx_restrict       nlist,
396                      rvec                        * gmx_restrict          xx,
397                      rvec                        * gmx_restrict          ff,
398                      t_forcerec                  * gmx_restrict          fr,
399                      t_mdatoms                   * gmx_restrict     mdatoms,
400                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
401                      t_nrnb                      * gmx_restrict        nrnb)
402 {
403     int              i_shift_offset,i_coord_offset,j_coord_offset;
404     int              j_index_start,j_index_end;
405     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
406     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
407     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
408     real             *shiftvec,*fshift,*x,*f;
409     int              vdwioffset0;
410     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
411     int              vdwioffset1;
412     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
413     int              vdwioffset2;
414     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
415     int              vdwjidx0;
416     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
417     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
418     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
419     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
420     real             velec,felec,velecsum,facel,crf,krf,krf2;
421     real             *charge;
422     int              nvdwtype;
423     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
424     int              *vdwtype;
425     real             *vdwparam;
426     int              vfitab;
427     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
428     real             *vftab;
429
430     x                = xx[0];
431     f                = ff[0];
432
433     nri              = nlist->nri;
434     iinr             = nlist->iinr;
435     jindex           = nlist->jindex;
436     jjnr             = nlist->jjnr;
437     shiftidx         = nlist->shift;
438     gid              = nlist->gid;
439     shiftvec         = fr->shift_vec[0];
440     fshift           = fr->fshift[0];
441     facel            = fr->epsfac;
442     charge           = mdatoms->chargeA;
443     nvdwtype         = fr->ntype;
444     vdwparam         = fr->nbfp;
445     vdwtype          = mdatoms->typeA;
446
447     vftab            = kernel_data->table_elec->data;
448     vftabscale       = kernel_data->table_elec->scale;
449
450     /* Setup water-specific parameters */
451     inr              = nlist->iinr[0];
452     iq0              = facel*charge[inr+0];
453     iq1              = facel*charge[inr+1];
454     iq2              = facel*charge[inr+2];
455     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
456
457     outeriter        = 0;
458     inneriter        = 0;
459
460     /* Start outer loop over neighborlists */
461     for(iidx=0; iidx<nri; iidx++)
462     {
463         /* Load shift vector for this list */
464         i_shift_offset   = DIM*shiftidx[iidx];
465         shX              = shiftvec[i_shift_offset+XX];
466         shY              = shiftvec[i_shift_offset+YY];
467         shZ              = shiftvec[i_shift_offset+ZZ];
468
469         /* Load limits for loop over neighbors */
470         j_index_start    = jindex[iidx];
471         j_index_end      = jindex[iidx+1];
472
473         /* Get outer coordinate index */
474         inr              = iinr[iidx];
475         i_coord_offset   = DIM*inr;
476
477         /* Load i particle coords and add shift vector */
478         ix0              = shX + x[i_coord_offset+DIM*0+XX];
479         iy0              = shY + x[i_coord_offset+DIM*0+YY];
480         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
481         ix1              = shX + x[i_coord_offset+DIM*1+XX];
482         iy1              = shY + x[i_coord_offset+DIM*1+YY];
483         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
484         ix2              = shX + x[i_coord_offset+DIM*2+XX];
485         iy2              = shY + x[i_coord_offset+DIM*2+YY];
486         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
487
488         fix0             = 0.0;
489         fiy0             = 0.0;
490         fiz0             = 0.0;
491         fix1             = 0.0;
492         fiy1             = 0.0;
493         fiz1             = 0.0;
494         fix2             = 0.0;
495         fiy2             = 0.0;
496         fiz2             = 0.0;
497
498         /* Start inner kernel loop */
499         for(jidx=j_index_start; jidx<j_index_end; jidx++)
500         {
501             /* Get j neighbor index, and coordinate index */
502             jnr              = jjnr[jidx];
503             j_coord_offset   = DIM*jnr;
504
505             /* load j atom coordinates */
506             jx0              = x[j_coord_offset+DIM*0+XX];
507             jy0              = x[j_coord_offset+DIM*0+YY];
508             jz0              = x[j_coord_offset+DIM*0+ZZ];
509
510             /* Calculate displacement vector */
511             dx00             = ix0 - jx0;
512             dy00             = iy0 - jy0;
513             dz00             = iz0 - jz0;
514             dx10             = ix1 - jx0;
515             dy10             = iy1 - jy0;
516             dz10             = iz1 - jz0;
517             dx20             = ix2 - jx0;
518             dy20             = iy2 - jy0;
519             dz20             = iz2 - jz0;
520
521             /* Calculate squared distance and things based on it */
522             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
523             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
524             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
525
526             rinv00           = gmx_invsqrt(rsq00);
527             rinv10           = gmx_invsqrt(rsq10);
528             rinv20           = gmx_invsqrt(rsq20);
529
530             rinvsq00         = rinv00*rinv00;
531
532             /* Load parameters for j particles */
533             jq0              = charge[jnr+0];
534             vdwjidx0         = 2*vdwtype[jnr+0];
535
536             /**************************
537              * CALCULATE INTERACTIONS *
538              **************************/
539
540             r00              = rsq00*rinv00;
541
542             qq00             = iq0*jq0;
543             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
544             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
545
546             /* Calculate table index by multiplying r with table scale and truncate to integer */
547             rt               = r00*vftabscale;
548             vfitab           = rt;
549             vfeps            = rt-vfitab;
550             vfitab           = 1*4*vfitab;
551
552             /* CUBIC SPLINE TABLE ELECTROSTATICS */
553             F                = vftab[vfitab+1];
554             Geps             = vfeps*vftab[vfitab+2];
555             Heps2            = vfeps*vfeps*vftab[vfitab+3];
556             Fp               = F+Geps+Heps2;
557             FF               = Fp+Geps+2.0*Heps2;
558             felec            = -qq00*FF*vftabscale*rinv00;
559
560             /* LENNARD-JONES DISPERSION/REPULSION */
561
562             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
563             fvdw             = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
564
565             fscal            = felec+fvdw;
566
567             /* Calculate temporary vectorial force */
568             tx               = fscal*dx00;
569             ty               = fscal*dy00;
570             tz               = fscal*dz00;
571
572             /* Update vectorial force */
573             fix0            += tx;
574             fiy0            += ty;
575             fiz0            += tz;
576             f[j_coord_offset+DIM*0+XX] -= tx;
577             f[j_coord_offset+DIM*0+YY] -= ty;
578             f[j_coord_offset+DIM*0+ZZ] -= tz;
579
580             /**************************
581              * CALCULATE INTERACTIONS *
582              **************************/
583
584             r10              = rsq10*rinv10;
585
586             qq10             = iq1*jq0;
587
588             /* Calculate table index by multiplying r with table scale and truncate to integer */
589             rt               = r10*vftabscale;
590             vfitab           = rt;
591             vfeps            = rt-vfitab;
592             vfitab           = 1*4*vfitab;
593
594             /* CUBIC SPLINE TABLE ELECTROSTATICS */
595             F                = vftab[vfitab+1];
596             Geps             = vfeps*vftab[vfitab+2];
597             Heps2            = vfeps*vfeps*vftab[vfitab+3];
598             Fp               = F+Geps+Heps2;
599             FF               = Fp+Geps+2.0*Heps2;
600             felec            = -qq10*FF*vftabscale*rinv10;
601
602             fscal            = felec;
603
604             /* Calculate temporary vectorial force */
605             tx               = fscal*dx10;
606             ty               = fscal*dy10;
607             tz               = fscal*dz10;
608
609             /* Update vectorial force */
610             fix1            += tx;
611             fiy1            += ty;
612             fiz1            += tz;
613             f[j_coord_offset+DIM*0+XX] -= tx;
614             f[j_coord_offset+DIM*0+YY] -= ty;
615             f[j_coord_offset+DIM*0+ZZ] -= tz;
616
617             /**************************
618              * CALCULATE INTERACTIONS *
619              **************************/
620
621             r20              = rsq20*rinv20;
622
623             qq20             = iq2*jq0;
624
625             /* Calculate table index by multiplying r with table scale and truncate to integer */
626             rt               = r20*vftabscale;
627             vfitab           = rt;
628             vfeps            = rt-vfitab;
629             vfitab           = 1*4*vfitab;
630
631             /* CUBIC SPLINE TABLE ELECTROSTATICS */
632             F                = vftab[vfitab+1];
633             Geps             = vfeps*vftab[vfitab+2];
634             Heps2            = vfeps*vfeps*vftab[vfitab+3];
635             Fp               = F+Geps+Heps2;
636             FF               = Fp+Geps+2.0*Heps2;
637             felec            = -qq20*FF*vftabscale*rinv20;
638
639             fscal            = felec;
640
641             /* Calculate temporary vectorial force */
642             tx               = fscal*dx20;
643             ty               = fscal*dy20;
644             tz               = fscal*dz20;
645
646             /* Update vectorial force */
647             fix2            += tx;
648             fiy2            += ty;
649             fiz2            += tz;
650             f[j_coord_offset+DIM*0+XX] -= tx;
651             f[j_coord_offset+DIM*0+YY] -= ty;
652             f[j_coord_offset+DIM*0+ZZ] -= tz;
653
654             /* Inner loop uses 122 flops */
655         }
656         /* End of innermost loop */
657
658         tx = ty = tz = 0;
659         f[i_coord_offset+DIM*0+XX] += fix0;
660         f[i_coord_offset+DIM*0+YY] += fiy0;
661         f[i_coord_offset+DIM*0+ZZ] += fiz0;
662         tx                         += fix0;
663         ty                         += fiy0;
664         tz                         += fiz0;
665         f[i_coord_offset+DIM*1+XX] += fix1;
666         f[i_coord_offset+DIM*1+YY] += fiy1;
667         f[i_coord_offset+DIM*1+ZZ] += fiz1;
668         tx                         += fix1;
669         ty                         += fiy1;
670         tz                         += fiz1;
671         f[i_coord_offset+DIM*2+XX] += fix2;
672         f[i_coord_offset+DIM*2+YY] += fiy2;
673         f[i_coord_offset+DIM*2+ZZ] += fiz2;
674         tx                         += fix2;
675         ty                         += fiy2;
676         tz                         += fiz2;
677         fshift[i_shift_offset+XX]  += tx;
678         fshift[i_shift_offset+YY]  += ty;
679         fshift[i_shift_offset+ZZ]  += tz;
680
681         /* Increment number of inner iterations */
682         inneriter                  += j_index_end - j_index_start;
683
684         /* Outer loop uses 30 flops */
685     }
686
687     /* Increment number of outer iterations */
688     outeriter        += nri;
689
690     /* Update outer/inner flops */
691
692     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*122);
693 }