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