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