Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwNone_GeomW3P1_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS c kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
46
47 /*
48  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomW3P1_VF_c
49  * Electrostatics interaction: CubicSplineTable
50  * VdW interaction:            None
51  * Geometry:                   Water3-Particle
52  * Calculate force/pot:        PotentialAndForce
53  */
54 void
55 nb_kernel_ElecCSTab_VdwNone_GeomW3P1_VF_c
56                     (t_nblist                    * gmx_restrict       nlist,
57                      rvec                        * gmx_restrict          xx,
58                      rvec                        * gmx_restrict          ff,
59                      t_forcerec                  * gmx_restrict          fr,
60                      t_mdatoms                   * gmx_restrict     mdatoms,
61                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62                      t_nrnb                      * gmx_restrict        nrnb)
63 {
64     int              i_shift_offset,i_coord_offset,j_coord_offset;
65     int              j_index_start,j_index_end;
66     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
69     real             *shiftvec,*fshift,*x,*f;
70     int              vdwioffset0;
71     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72     int              vdwioffset1;
73     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74     int              vdwioffset2;
75     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76     int              vdwjidx0;
77     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81     real             velec,felec,velecsum,facel,crf,krf,krf2;
82     real             *charge;
83     int              vfitab;
84     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
85     real             *vftab;
86
87     x                = xx[0];
88     f                = ff[0];
89
90     nri              = nlist->nri;
91     iinr             = nlist->iinr;
92     jindex           = nlist->jindex;
93     jjnr             = nlist->jjnr;
94     shiftidx         = nlist->shift;
95     gid              = nlist->gid;
96     shiftvec         = fr->shift_vec[0];
97     fshift           = fr->fshift[0];
98     facel            = fr->epsfac;
99     charge           = mdatoms->chargeA;
100
101     vftab            = kernel_data->table_elec->data;
102     vftabscale       = kernel_data->table_elec->scale;
103
104     /* Setup water-specific parameters */
105     inr              = nlist->iinr[0];
106     iq0              = facel*charge[inr+0];
107     iq1              = facel*charge[inr+1];
108     iq2              = facel*charge[inr+2];
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
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
151         /* Reset potential sums */
152         velecsum         = 0.0;
153
154         /* Start inner kernel loop */
155         for(jidx=j_index_start; jidx<j_index_end; jidx++)
156         {
157             /* Get j neighbor index, and coordinate index */
158             jnr              = jjnr[jidx];
159             j_coord_offset   = DIM*jnr;
160
161             /* load j atom coordinates */
162             jx0              = x[j_coord_offset+DIM*0+XX];
163             jy0              = x[j_coord_offset+DIM*0+YY];
164             jz0              = x[j_coord_offset+DIM*0+ZZ];
165
166             /* Calculate displacement vector */
167             dx00             = ix0 - jx0;
168             dy00             = iy0 - jy0;
169             dz00             = iz0 - jz0;
170             dx10             = ix1 - jx0;
171             dy10             = iy1 - jy0;
172             dz10             = iz1 - jz0;
173             dx20             = ix2 - jx0;
174             dy20             = iy2 - jy0;
175             dz20             = iz2 - jz0;
176
177             /* Calculate squared distance and things based on it */
178             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
179             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
180             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
181
182             rinv00           = gmx_invsqrt(rsq00);
183             rinv10           = gmx_invsqrt(rsq10);
184             rinv20           = gmx_invsqrt(rsq20);
185
186             /* Load parameters for j particles */
187             jq0              = charge[jnr+0];
188
189             /**************************
190              * CALCULATE INTERACTIONS *
191              **************************/
192
193             r00              = rsq00*rinv00;
194
195             qq00             = iq0*jq0;
196
197             /* Calculate table index by multiplying r with table scale and truncate to integer */
198             rt               = r00*vftabscale;
199             vfitab           = rt;
200             vfeps            = rt-vfitab;
201             vfitab           = 1*4*vfitab;
202
203             /* CUBIC SPLINE TABLE ELECTROSTATICS */
204             Y                = vftab[vfitab];
205             F                = vftab[vfitab+1];
206             Geps             = vfeps*vftab[vfitab+2];
207             Heps2            = vfeps*vfeps*vftab[vfitab+3];
208             Fp               = F+Geps+Heps2;
209             VV               = Y+vfeps*Fp;
210             velec            = qq00*VV;
211             FF               = Fp+Geps+2.0*Heps2;
212             felec            = -qq00*FF*vftabscale*rinv00;
213
214             /* Update potential sums from outer loop */
215             velecsum        += velec;
216
217             fscal            = felec;
218
219             /* Calculate temporary vectorial force */
220             tx               = fscal*dx00;
221             ty               = fscal*dy00;
222             tz               = fscal*dz00;
223
224             /* Update vectorial force */
225             fix0            += tx;
226             fiy0            += ty;
227             fiz0            += tz;
228             f[j_coord_offset+DIM*0+XX] -= tx;
229             f[j_coord_offset+DIM*0+YY] -= ty;
230             f[j_coord_offset+DIM*0+ZZ] -= tz;
231
232             /**************************
233              * CALCULATE INTERACTIONS *
234              **************************/
235
236             r10              = rsq10*rinv10;
237
238             qq10             = iq1*jq0;
239
240             /* Calculate table index by multiplying r with table scale and truncate to integer */
241             rt               = r10*vftabscale;
242             vfitab           = rt;
243             vfeps            = rt-vfitab;
244             vfitab           = 1*4*vfitab;
245
246             /* CUBIC SPLINE TABLE ELECTROSTATICS */
247             Y                = vftab[vfitab];
248             F                = vftab[vfitab+1];
249             Geps             = vfeps*vftab[vfitab+2];
250             Heps2            = vfeps*vfeps*vftab[vfitab+3];
251             Fp               = F+Geps+Heps2;
252             VV               = Y+vfeps*Fp;
253             velec            = qq10*VV;
254             FF               = Fp+Geps+2.0*Heps2;
255             felec            = -qq10*FF*vftabscale*rinv10;
256
257             /* Update potential sums from outer loop */
258             velecsum        += velec;
259
260             fscal            = felec;
261
262             /* Calculate temporary vectorial force */
263             tx               = fscal*dx10;
264             ty               = fscal*dy10;
265             tz               = fscal*dz10;
266
267             /* Update vectorial force */
268             fix1            += tx;
269             fiy1            += ty;
270             fiz1            += tz;
271             f[j_coord_offset+DIM*0+XX] -= tx;
272             f[j_coord_offset+DIM*0+YY] -= ty;
273             f[j_coord_offset+DIM*0+ZZ] -= tz;
274
275             /**************************
276              * CALCULATE INTERACTIONS *
277              **************************/
278
279             r20              = rsq20*rinv20;
280
281             qq20             = iq2*jq0;
282
283             /* Calculate table index by multiplying r with table scale and truncate to integer */
284             rt               = r20*vftabscale;
285             vfitab           = rt;
286             vfeps            = rt-vfitab;
287             vfitab           = 1*4*vfitab;
288
289             /* CUBIC SPLINE TABLE ELECTROSTATICS */
290             Y                = vftab[vfitab];
291             F                = vftab[vfitab+1];
292             Geps             = vfeps*vftab[vfitab+2];
293             Heps2            = vfeps*vfeps*vftab[vfitab+3];
294             Fp               = F+Geps+Heps2;
295             VV               = Y+vfeps*Fp;
296             velec            = qq20*VV;
297             FF               = Fp+Geps+2.0*Heps2;
298             felec            = -qq20*FF*vftabscale*rinv20;
299
300             /* Update potential sums from outer loop */
301             velecsum        += velec;
302
303             fscal            = felec;
304
305             /* Calculate temporary vectorial force */
306             tx               = fscal*dx20;
307             ty               = fscal*dy20;
308             tz               = fscal*dz20;
309
310             /* Update vectorial force */
311             fix2            += tx;
312             fiy2            += ty;
313             fiz2            += tz;
314             f[j_coord_offset+DIM*0+XX] -= tx;
315             f[j_coord_offset+DIM*0+YY] -= ty;
316             f[j_coord_offset+DIM*0+ZZ] -= tz;
317
318             /* Inner loop uses 126 flops */
319         }
320         /* End of innermost loop */
321
322         tx = ty = tz = 0;
323         f[i_coord_offset+DIM*0+XX] += fix0;
324         f[i_coord_offset+DIM*0+YY] += fiy0;
325         f[i_coord_offset+DIM*0+ZZ] += fiz0;
326         tx                         += fix0;
327         ty                         += fiy0;
328         tz                         += fiz0;
329         f[i_coord_offset+DIM*1+XX] += fix1;
330         f[i_coord_offset+DIM*1+YY] += fiy1;
331         f[i_coord_offset+DIM*1+ZZ] += fiz1;
332         tx                         += fix1;
333         ty                         += fiy1;
334         tz                         += fiz1;
335         f[i_coord_offset+DIM*2+XX] += fix2;
336         f[i_coord_offset+DIM*2+YY] += fiy2;
337         f[i_coord_offset+DIM*2+ZZ] += fiz2;
338         tx                         += fix2;
339         ty                         += fiy2;
340         tz                         += fiz2;
341         fshift[i_shift_offset+XX]  += tx;
342         fshift[i_shift_offset+YY]  += ty;
343         fshift[i_shift_offset+ZZ]  += tz;
344
345         ggid                        = gid[iidx];
346         /* Update potential energies */
347         kernel_data->energygrp_elec[ggid] += velecsum;
348
349         /* Increment number of inner iterations */
350         inneriter                  += j_index_end - j_index_start;
351
352         /* Outer loop uses 31 flops */
353     }
354
355     /* Increment number of outer iterations */
356     outeriter        += nri;
357
358     /* Update outer/inner flops */
359
360     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*126);
361 }
362 /*
363  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomW3P1_F_c
364  * Electrostatics interaction: CubicSplineTable
365  * VdW interaction:            None
366  * Geometry:                   Water3-Particle
367  * Calculate force/pot:        Force
368  */
369 void
370 nb_kernel_ElecCSTab_VdwNone_GeomW3P1_F_c
371                     (t_nblist                    * gmx_restrict       nlist,
372                      rvec                        * gmx_restrict          xx,
373                      rvec                        * gmx_restrict          ff,
374                      t_forcerec                  * gmx_restrict          fr,
375                      t_mdatoms                   * gmx_restrict     mdatoms,
376                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
377                      t_nrnb                      * gmx_restrict        nrnb)
378 {
379     int              i_shift_offset,i_coord_offset,j_coord_offset;
380     int              j_index_start,j_index_end;
381     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
382     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
383     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
384     real             *shiftvec,*fshift,*x,*f;
385     int              vdwioffset0;
386     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
387     int              vdwioffset1;
388     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
389     int              vdwioffset2;
390     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
391     int              vdwjidx0;
392     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
393     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
394     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
395     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
396     real             velec,felec,velecsum,facel,crf,krf,krf2;
397     real             *charge;
398     int              vfitab;
399     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
400     real             *vftab;
401
402     x                = xx[0];
403     f                = ff[0];
404
405     nri              = nlist->nri;
406     iinr             = nlist->iinr;
407     jindex           = nlist->jindex;
408     jjnr             = nlist->jjnr;
409     shiftidx         = nlist->shift;
410     gid              = nlist->gid;
411     shiftvec         = fr->shift_vec[0];
412     fshift           = fr->fshift[0];
413     facel            = fr->epsfac;
414     charge           = mdatoms->chargeA;
415
416     vftab            = kernel_data->table_elec->data;
417     vftabscale       = kernel_data->table_elec->scale;
418
419     /* Setup water-specific parameters */
420     inr              = nlist->iinr[0];
421     iq0              = facel*charge[inr+0];
422     iq1              = facel*charge[inr+1];
423     iq2              = facel*charge[inr+2];
424
425     outeriter        = 0;
426     inneriter        = 0;
427
428     /* Start outer loop over neighborlists */
429     for(iidx=0; iidx<nri; iidx++)
430     {
431         /* Load shift vector for this list */
432         i_shift_offset   = DIM*shiftidx[iidx];
433         shX              = shiftvec[i_shift_offset+XX];
434         shY              = shiftvec[i_shift_offset+YY];
435         shZ              = shiftvec[i_shift_offset+ZZ];
436
437         /* Load limits for loop over neighbors */
438         j_index_start    = jindex[iidx];
439         j_index_end      = jindex[iidx+1];
440
441         /* Get outer coordinate index */
442         inr              = iinr[iidx];
443         i_coord_offset   = DIM*inr;
444
445         /* Load i particle coords and add shift vector */
446         ix0              = shX + x[i_coord_offset+DIM*0+XX];
447         iy0              = shY + x[i_coord_offset+DIM*0+YY];
448         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
449         ix1              = shX + x[i_coord_offset+DIM*1+XX];
450         iy1              = shY + x[i_coord_offset+DIM*1+YY];
451         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
452         ix2              = shX + x[i_coord_offset+DIM*2+XX];
453         iy2              = shY + x[i_coord_offset+DIM*2+YY];
454         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
455
456         fix0             = 0.0;
457         fiy0             = 0.0;
458         fiz0             = 0.0;
459         fix1             = 0.0;
460         fiy1             = 0.0;
461         fiz1             = 0.0;
462         fix2             = 0.0;
463         fiy2             = 0.0;
464         fiz2             = 0.0;
465
466         /* Start inner kernel loop */
467         for(jidx=j_index_start; jidx<j_index_end; jidx++)
468         {
469             /* Get j neighbor index, and coordinate index */
470             jnr              = jjnr[jidx];
471             j_coord_offset   = DIM*jnr;
472
473             /* load j atom coordinates */
474             jx0              = x[j_coord_offset+DIM*0+XX];
475             jy0              = x[j_coord_offset+DIM*0+YY];
476             jz0              = x[j_coord_offset+DIM*0+ZZ];
477
478             /* Calculate displacement vector */
479             dx00             = ix0 - jx0;
480             dy00             = iy0 - jy0;
481             dz00             = iz0 - jz0;
482             dx10             = ix1 - jx0;
483             dy10             = iy1 - jy0;
484             dz10             = iz1 - jz0;
485             dx20             = ix2 - jx0;
486             dy20             = iy2 - jy0;
487             dz20             = iz2 - jz0;
488
489             /* Calculate squared distance and things based on it */
490             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
491             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
492             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
493
494             rinv00           = gmx_invsqrt(rsq00);
495             rinv10           = gmx_invsqrt(rsq10);
496             rinv20           = gmx_invsqrt(rsq20);
497
498             /* Load parameters for j particles */
499             jq0              = charge[jnr+0];
500
501             /**************************
502              * CALCULATE INTERACTIONS *
503              **************************/
504
505             r00              = rsq00*rinv00;
506
507             qq00             = iq0*jq0;
508
509             /* Calculate table index by multiplying r with table scale and truncate to integer */
510             rt               = r00*vftabscale;
511             vfitab           = rt;
512             vfeps            = rt-vfitab;
513             vfitab           = 1*4*vfitab;
514
515             /* CUBIC SPLINE TABLE ELECTROSTATICS */
516             F                = vftab[vfitab+1];
517             Geps             = vfeps*vftab[vfitab+2];
518             Heps2            = vfeps*vfeps*vftab[vfitab+3];
519             Fp               = F+Geps+Heps2;
520             FF               = Fp+Geps+2.0*Heps2;
521             felec            = -qq00*FF*vftabscale*rinv00;
522
523             fscal            = felec;
524
525             /* Calculate temporary vectorial force */
526             tx               = fscal*dx00;
527             ty               = fscal*dy00;
528             tz               = fscal*dz00;
529
530             /* Update vectorial force */
531             fix0            += tx;
532             fiy0            += ty;
533             fiz0            += tz;
534             f[j_coord_offset+DIM*0+XX] -= tx;
535             f[j_coord_offset+DIM*0+YY] -= ty;
536             f[j_coord_offset+DIM*0+ZZ] -= tz;
537
538             /**************************
539              * CALCULATE INTERACTIONS *
540              **************************/
541
542             r10              = rsq10*rinv10;
543
544             qq10             = iq1*jq0;
545
546             /* Calculate table index by multiplying r with table scale and truncate to integer */
547             rt               = r10*vftabscale;
548             vfitab           = rt;
549             vfeps            = rt-vfitab;
550             vfitab           = 1*4*vfitab;
551
552             /* CUBIC SPLINE TABLE ELECTROSTATICS */
553             F                = vftab[vfitab+1];
554             Geps             = vfeps*vftab[vfitab+2];
555             Heps2            = vfeps*vfeps*vftab[vfitab+3];
556             Fp               = F+Geps+Heps2;
557             FF               = Fp+Geps+2.0*Heps2;
558             felec            = -qq10*FF*vftabscale*rinv10;
559
560             fscal            = felec;
561
562             /* Calculate temporary vectorial force */
563             tx               = fscal*dx10;
564             ty               = fscal*dy10;
565             tz               = fscal*dz10;
566
567             /* Update vectorial force */
568             fix1            += tx;
569             fiy1            += ty;
570             fiz1            += tz;
571             f[j_coord_offset+DIM*0+XX] -= tx;
572             f[j_coord_offset+DIM*0+YY] -= ty;
573             f[j_coord_offset+DIM*0+ZZ] -= tz;
574
575             /**************************
576              * CALCULATE INTERACTIONS *
577              **************************/
578
579             r20              = rsq20*rinv20;
580
581             qq20             = iq2*jq0;
582
583             /* Calculate table index by multiplying r with table scale and truncate to integer */
584             rt               = r20*vftabscale;
585             vfitab           = rt;
586             vfeps            = rt-vfitab;
587             vfitab           = 1*4*vfitab;
588
589             /* CUBIC SPLINE TABLE ELECTROSTATICS */
590             F                = vftab[vfitab+1];
591             Geps             = vfeps*vftab[vfitab+2];
592             Heps2            = vfeps*vfeps*vftab[vfitab+3];
593             Fp               = F+Geps+Heps2;
594             FF               = Fp+Geps+2.0*Heps2;
595             felec            = -qq20*FF*vftabscale*rinv20;
596
597             fscal            = felec;
598
599             /* Calculate temporary vectorial force */
600             tx               = fscal*dx20;
601             ty               = fscal*dy20;
602             tz               = fscal*dz20;
603
604             /* Update vectorial force */
605             fix2            += tx;
606             fiy2            += ty;
607             fiz2            += 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             /* Inner loop uses 114 flops */
613         }
614         /* End of innermost loop */
615
616         tx = ty = tz = 0;
617         f[i_coord_offset+DIM*0+XX] += fix0;
618         f[i_coord_offset+DIM*0+YY] += fiy0;
619         f[i_coord_offset+DIM*0+ZZ] += fiz0;
620         tx                         += fix0;
621         ty                         += fiy0;
622         tz                         += fiz0;
623         f[i_coord_offset+DIM*1+XX] += fix1;
624         f[i_coord_offset+DIM*1+YY] += fiy1;
625         f[i_coord_offset+DIM*1+ZZ] += fiz1;
626         tx                         += fix1;
627         ty                         += fiy1;
628         tz                         += fiz1;
629         f[i_coord_offset+DIM*2+XX] += fix2;
630         f[i_coord_offset+DIM*2+YY] += fiy2;
631         f[i_coord_offset+DIM*2+ZZ] += fiz2;
632         tx                         += fix2;
633         ty                         += fiy2;
634         tz                         += fiz2;
635         fshift[i_shift_offset+XX]  += tx;
636         fshift[i_shift_offset+YY]  += ty;
637         fshift[i_shift_offset+ZZ]  += tz;
638
639         /* Increment number of inner iterations */
640         inneriter                  += j_index_end - j_index_start;
641
642         /* Outer loop uses 30 flops */
643     }
644
645     /* Increment number of outer iterations */
646     outeriter        += nri;
647
648     /* Update outer/inner flops */
649
650     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*114);
651 }