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