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