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