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