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