Valgrind suppression for OS X 10.9
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, 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 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_VF_c
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            Buckingham
53  * Geometry:                   Water3-Water3
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_VF_c
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     int              i_shift_offset,i_coord_offset,j_coord_offset;
67     int              j_index_start,j_index_end;
68     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
71     real             *shiftvec,*fshift,*x,*f;
72     int              vdwioffset0;
73     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
74     int              vdwioffset1;
75     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
76     int              vdwioffset2;
77     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
78     int              vdwjidx0;
79     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80     int              vdwjidx1;
81     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
82     int              vdwjidx2;
83     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85     real             dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86     real             dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93     real             velec,felec,velecsum,facel,crf,krf,krf2;
94     real             *charge;
95     int              nvdwtype;
96     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
97     int              *vdwtype;
98     real             *vdwparam;
99
100     x                = xx[0];
101     f                = ff[0];
102
103     nri              = nlist->nri;
104     iinr             = nlist->iinr;
105     jindex           = nlist->jindex;
106     jjnr             = nlist->jjnr;
107     shiftidx         = nlist->shift;
108     gid              = nlist->gid;
109     shiftvec         = fr->shift_vec[0];
110     fshift           = fr->fshift[0];
111     facel            = fr->epsfac;
112     charge           = mdatoms->chargeA;
113     krf              = fr->ic->k_rf;
114     krf2             = krf*2.0;
115     crf              = fr->ic->c_rf;
116     nvdwtype         = fr->ntype;
117     vdwparam         = fr->nbfp;
118     vdwtype          = mdatoms->typeA;
119
120     /* Setup water-specific parameters */
121     inr              = nlist->iinr[0];
122     iq0              = facel*charge[inr+0];
123     iq1              = facel*charge[inr+1];
124     iq2              = facel*charge[inr+2];
125     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
126
127     jq0              = charge[inr+0];
128     jq1              = charge[inr+1];
129     jq2              = charge[inr+2];
130     vdwjidx0         = 3*vdwtype[inr+0];
131     qq00             = iq0*jq0;
132     c6_00            = vdwparam[vdwioffset0+vdwjidx0];
133     cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
134     cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
135     qq01             = iq0*jq1;
136     qq02             = iq0*jq2;
137     qq10             = iq1*jq0;
138     qq11             = iq1*jq1;
139     qq12             = iq1*jq2;
140     qq20             = iq2*jq0;
141     qq21             = iq2*jq1;
142     qq22             = iq2*jq2;
143
144     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
145     rcutoff          = fr->rcoulomb;
146     rcutoff2         = rcutoff*rcutoff;
147
148     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
149     rvdw             = fr->rvdw;
150
151     outeriter        = 0;
152     inneriter        = 0;
153
154     /* Start outer loop over neighborlists */
155     for(iidx=0; iidx<nri; iidx++)
156     {
157         /* Load shift vector for this list */
158         i_shift_offset   = DIM*shiftidx[iidx];
159         shX              = shiftvec[i_shift_offset+XX];
160         shY              = shiftvec[i_shift_offset+YY];
161         shZ              = shiftvec[i_shift_offset+ZZ];
162
163         /* Load limits for loop over neighbors */
164         j_index_start    = jindex[iidx];
165         j_index_end      = jindex[iidx+1];
166
167         /* Get outer coordinate index */
168         inr              = iinr[iidx];
169         i_coord_offset   = DIM*inr;
170
171         /* Load i particle coords and add shift vector */
172         ix0              = shX + x[i_coord_offset+DIM*0+XX];
173         iy0              = shY + x[i_coord_offset+DIM*0+YY];
174         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
175         ix1              = shX + x[i_coord_offset+DIM*1+XX];
176         iy1              = shY + x[i_coord_offset+DIM*1+YY];
177         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
178         ix2              = shX + x[i_coord_offset+DIM*2+XX];
179         iy2              = shY + x[i_coord_offset+DIM*2+YY];
180         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
181
182         fix0             = 0.0;
183         fiy0             = 0.0;
184         fiz0             = 0.0;
185         fix1             = 0.0;
186         fiy1             = 0.0;
187         fiz1             = 0.0;
188         fix2             = 0.0;
189         fiy2             = 0.0;
190         fiz2             = 0.0;
191
192         /* Reset potential sums */
193         velecsum         = 0.0;
194         vvdwsum          = 0.0;
195
196         /* Start inner kernel loop */
197         for(jidx=j_index_start; jidx<j_index_end; jidx++)
198         {
199             /* Get j neighbor index, and coordinate index */
200             jnr              = jjnr[jidx];
201             j_coord_offset   = DIM*jnr;
202
203             /* load j atom coordinates */
204             jx0              = x[j_coord_offset+DIM*0+XX];
205             jy0              = x[j_coord_offset+DIM*0+YY];
206             jz0              = x[j_coord_offset+DIM*0+ZZ];
207             jx1              = x[j_coord_offset+DIM*1+XX];
208             jy1              = x[j_coord_offset+DIM*1+YY];
209             jz1              = x[j_coord_offset+DIM*1+ZZ];
210             jx2              = x[j_coord_offset+DIM*2+XX];
211             jy2              = x[j_coord_offset+DIM*2+YY];
212             jz2              = x[j_coord_offset+DIM*2+ZZ];
213
214             /* Calculate displacement vector */
215             dx00             = ix0 - jx0;
216             dy00             = iy0 - jy0;
217             dz00             = iz0 - jz0;
218             dx01             = ix0 - jx1;
219             dy01             = iy0 - jy1;
220             dz01             = iz0 - jz1;
221             dx02             = ix0 - jx2;
222             dy02             = iy0 - jy2;
223             dz02             = iz0 - jz2;
224             dx10             = ix1 - jx0;
225             dy10             = iy1 - jy0;
226             dz10             = iz1 - jz0;
227             dx11             = ix1 - jx1;
228             dy11             = iy1 - jy1;
229             dz11             = iz1 - jz1;
230             dx12             = ix1 - jx2;
231             dy12             = iy1 - jy2;
232             dz12             = iz1 - jz2;
233             dx20             = ix2 - jx0;
234             dy20             = iy2 - jy0;
235             dz20             = iz2 - jz0;
236             dx21             = ix2 - jx1;
237             dy21             = iy2 - jy1;
238             dz21             = iz2 - jz1;
239             dx22             = ix2 - jx2;
240             dy22             = iy2 - jy2;
241             dz22             = iz2 - jz2;
242
243             /* Calculate squared distance and things based on it */
244             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
245             rsq01            = dx01*dx01+dy01*dy01+dz01*dz01;
246             rsq02            = dx02*dx02+dy02*dy02+dz02*dz02;
247             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
248             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
249             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
250             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
251             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
252             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
253
254             rinv00           = gmx_invsqrt(rsq00);
255             rinv01           = gmx_invsqrt(rsq01);
256             rinv02           = gmx_invsqrt(rsq02);
257             rinv10           = gmx_invsqrt(rsq10);
258             rinv11           = gmx_invsqrt(rsq11);
259             rinv12           = gmx_invsqrt(rsq12);
260             rinv20           = gmx_invsqrt(rsq20);
261             rinv21           = gmx_invsqrt(rsq21);
262             rinv22           = gmx_invsqrt(rsq22);
263
264             rinvsq00         = rinv00*rinv00;
265             rinvsq01         = rinv01*rinv01;
266             rinvsq02         = rinv02*rinv02;
267             rinvsq10         = rinv10*rinv10;
268             rinvsq11         = rinv11*rinv11;
269             rinvsq12         = rinv12*rinv12;
270             rinvsq20         = rinv20*rinv20;
271             rinvsq21         = rinv21*rinv21;
272             rinvsq22         = rinv22*rinv22;
273
274             /**************************
275              * CALCULATE INTERACTIONS *
276              **************************/
277
278             if (rsq00<rcutoff2)
279             {
280
281             r00              = rsq00*rinv00;
282
283             /* REACTION-FIELD ELECTROSTATICS */
284             velec            = qq00*(rinv00+krf*rsq00-crf);
285             felec            = qq00*(rinv00*rinvsq00-krf2);
286
287             /* BUCKINGHAM DISPERSION/REPULSION */
288             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
289             vvdw6            = c6_00*rinvsix;
290             br               = cexp2_00*r00;
291             vvdwexp          = cexp1_00*exp(-br);
292             vvdw             = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
293             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
294
295             /* Update potential sums from outer loop */
296             velecsum        += velec;
297             vvdwsum         += vvdw;
298
299             fscal            = felec+fvdw;
300
301             /* Calculate temporary vectorial force */
302             tx               = fscal*dx00;
303             ty               = fscal*dy00;
304             tz               = fscal*dz00;
305
306             /* Update vectorial force */
307             fix0            += tx;
308             fiy0            += ty;
309             fiz0            += tz;
310             f[j_coord_offset+DIM*0+XX] -= tx;
311             f[j_coord_offset+DIM*0+YY] -= ty;
312             f[j_coord_offset+DIM*0+ZZ] -= tz;
313
314             }
315
316             /**************************
317              * CALCULATE INTERACTIONS *
318              **************************/
319
320             if (rsq01<rcutoff2)
321             {
322
323             /* REACTION-FIELD ELECTROSTATICS */
324             velec            = qq01*(rinv01+krf*rsq01-crf);
325             felec            = qq01*(rinv01*rinvsq01-krf2);
326
327             /* Update potential sums from outer loop */
328             velecsum        += velec;
329
330             fscal            = felec;
331
332             /* Calculate temporary vectorial force */
333             tx               = fscal*dx01;
334             ty               = fscal*dy01;
335             tz               = fscal*dz01;
336
337             /* Update vectorial force */
338             fix0            += tx;
339             fiy0            += ty;
340             fiz0            += tz;
341             f[j_coord_offset+DIM*1+XX] -= tx;
342             f[j_coord_offset+DIM*1+YY] -= ty;
343             f[j_coord_offset+DIM*1+ZZ] -= tz;
344
345             }
346
347             /**************************
348              * CALCULATE INTERACTIONS *
349              **************************/
350
351             if (rsq02<rcutoff2)
352             {
353
354             /* REACTION-FIELD ELECTROSTATICS */
355             velec            = qq02*(rinv02+krf*rsq02-crf);
356             felec            = qq02*(rinv02*rinvsq02-krf2);
357
358             /* Update potential sums from outer loop */
359             velecsum        += velec;
360
361             fscal            = felec;
362
363             /* Calculate temporary vectorial force */
364             tx               = fscal*dx02;
365             ty               = fscal*dy02;
366             tz               = fscal*dz02;
367
368             /* Update vectorial force */
369             fix0            += tx;
370             fiy0            += ty;
371             fiz0            += tz;
372             f[j_coord_offset+DIM*2+XX] -= tx;
373             f[j_coord_offset+DIM*2+YY] -= ty;
374             f[j_coord_offset+DIM*2+ZZ] -= tz;
375
376             }
377
378             /**************************
379              * CALCULATE INTERACTIONS *
380              **************************/
381
382             if (rsq10<rcutoff2)
383             {
384
385             /* REACTION-FIELD ELECTROSTATICS */
386             velec            = qq10*(rinv10+krf*rsq10-crf);
387             felec            = qq10*(rinv10*rinvsq10-krf2);
388
389             /* Update potential sums from outer loop */
390             velecsum        += velec;
391
392             fscal            = felec;
393
394             /* Calculate temporary vectorial force */
395             tx               = fscal*dx10;
396             ty               = fscal*dy10;
397             tz               = fscal*dz10;
398
399             /* Update vectorial force */
400             fix1            += tx;
401             fiy1            += ty;
402             fiz1            += tz;
403             f[j_coord_offset+DIM*0+XX] -= tx;
404             f[j_coord_offset+DIM*0+YY] -= ty;
405             f[j_coord_offset+DIM*0+ZZ] -= tz;
406
407             }
408
409             /**************************
410              * CALCULATE INTERACTIONS *
411              **************************/
412
413             if (rsq11<rcutoff2)
414             {
415
416             /* REACTION-FIELD ELECTROSTATICS */
417             velec            = qq11*(rinv11+krf*rsq11-crf);
418             felec            = qq11*(rinv11*rinvsq11-krf2);
419
420             /* Update potential sums from outer loop */
421             velecsum        += velec;
422
423             fscal            = felec;
424
425             /* Calculate temporary vectorial force */
426             tx               = fscal*dx11;
427             ty               = fscal*dy11;
428             tz               = fscal*dz11;
429
430             /* Update vectorial force */
431             fix1            += tx;
432             fiy1            += ty;
433             fiz1            += tz;
434             f[j_coord_offset+DIM*1+XX] -= tx;
435             f[j_coord_offset+DIM*1+YY] -= ty;
436             f[j_coord_offset+DIM*1+ZZ] -= tz;
437
438             }
439
440             /**************************
441              * CALCULATE INTERACTIONS *
442              **************************/
443
444             if (rsq12<rcutoff2)
445             {
446
447             /* REACTION-FIELD ELECTROSTATICS */
448             velec            = qq12*(rinv12+krf*rsq12-crf);
449             felec            = qq12*(rinv12*rinvsq12-krf2);
450
451             /* Update potential sums from outer loop */
452             velecsum        += velec;
453
454             fscal            = felec;
455
456             /* Calculate temporary vectorial force */
457             tx               = fscal*dx12;
458             ty               = fscal*dy12;
459             tz               = fscal*dz12;
460
461             /* Update vectorial force */
462             fix1            += tx;
463             fiy1            += ty;
464             fiz1            += tz;
465             f[j_coord_offset+DIM*2+XX] -= tx;
466             f[j_coord_offset+DIM*2+YY] -= ty;
467             f[j_coord_offset+DIM*2+ZZ] -= tz;
468
469             }
470
471             /**************************
472              * CALCULATE INTERACTIONS *
473              **************************/
474
475             if (rsq20<rcutoff2)
476             {
477
478             /* REACTION-FIELD ELECTROSTATICS */
479             velec            = qq20*(rinv20+krf*rsq20-crf);
480             felec            = qq20*(rinv20*rinvsq20-krf2);
481
482             /* Update potential sums from outer loop */
483             velecsum        += velec;
484
485             fscal            = felec;
486
487             /* Calculate temporary vectorial force */
488             tx               = fscal*dx20;
489             ty               = fscal*dy20;
490             tz               = fscal*dz20;
491
492             /* Update vectorial force */
493             fix2            += tx;
494             fiy2            += ty;
495             fiz2            += tz;
496             f[j_coord_offset+DIM*0+XX] -= tx;
497             f[j_coord_offset+DIM*0+YY] -= ty;
498             f[j_coord_offset+DIM*0+ZZ] -= tz;
499
500             }
501
502             /**************************
503              * CALCULATE INTERACTIONS *
504              **************************/
505
506             if (rsq21<rcutoff2)
507             {
508
509             /* REACTION-FIELD ELECTROSTATICS */
510             velec            = qq21*(rinv21+krf*rsq21-crf);
511             felec            = qq21*(rinv21*rinvsq21-krf2);
512
513             /* Update potential sums from outer loop */
514             velecsum        += velec;
515
516             fscal            = felec;
517
518             /* Calculate temporary vectorial force */
519             tx               = fscal*dx21;
520             ty               = fscal*dy21;
521             tz               = fscal*dz21;
522
523             /* Update vectorial force */
524             fix2            += tx;
525             fiy2            += ty;
526             fiz2            += tz;
527             f[j_coord_offset+DIM*1+XX] -= tx;
528             f[j_coord_offset+DIM*1+YY] -= ty;
529             f[j_coord_offset+DIM*1+ZZ] -= tz;
530
531             }
532
533             /**************************
534              * CALCULATE INTERACTIONS *
535              **************************/
536
537             if (rsq22<rcutoff2)
538             {
539
540             /* REACTION-FIELD ELECTROSTATICS */
541             velec            = qq22*(rinv22+krf*rsq22-crf);
542             felec            = qq22*(rinv22*rinvsq22-krf2);
543
544             /* Update potential sums from outer loop */
545             velecsum        += velec;
546
547             fscal            = felec;
548
549             /* Calculate temporary vectorial force */
550             tx               = fscal*dx22;
551             ty               = fscal*dy22;
552             tz               = fscal*dz22;
553
554             /* Update vectorial force */
555             fix2            += tx;
556             fiy2            += ty;
557             fiz2            += tz;
558             f[j_coord_offset+DIM*2+XX] -= tx;
559             f[j_coord_offset+DIM*2+YY] -= ty;
560             f[j_coord_offset+DIM*2+ZZ] -= tz;
561
562             }
563
564             /* Inner loop uses 349 flops */
565         }
566         /* End of innermost loop */
567
568         tx = ty = tz = 0;
569         f[i_coord_offset+DIM*0+XX] += fix0;
570         f[i_coord_offset+DIM*0+YY] += fiy0;
571         f[i_coord_offset+DIM*0+ZZ] += fiz0;
572         tx                         += fix0;
573         ty                         += fiy0;
574         tz                         += fiz0;
575         f[i_coord_offset+DIM*1+XX] += fix1;
576         f[i_coord_offset+DIM*1+YY] += fiy1;
577         f[i_coord_offset+DIM*1+ZZ] += fiz1;
578         tx                         += fix1;
579         ty                         += fiy1;
580         tz                         += fiz1;
581         f[i_coord_offset+DIM*2+XX] += fix2;
582         f[i_coord_offset+DIM*2+YY] += fiy2;
583         f[i_coord_offset+DIM*2+ZZ] += fiz2;
584         tx                         += fix2;
585         ty                         += fiy2;
586         tz                         += fiz2;
587         fshift[i_shift_offset+XX]  += tx;
588         fshift[i_shift_offset+YY]  += ty;
589         fshift[i_shift_offset+ZZ]  += tz;
590
591         ggid                        = gid[iidx];
592         /* Update potential energies */
593         kernel_data->energygrp_elec[ggid] += velecsum;
594         kernel_data->energygrp_vdw[ggid] += vvdwsum;
595
596         /* Increment number of inner iterations */
597         inneriter                  += j_index_end - j_index_start;
598
599         /* Outer loop uses 32 flops */
600     }
601
602     /* Increment number of outer iterations */
603     outeriter        += nri;
604
605     /* Update outer/inner flops */
606
607     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*349);
608 }
609 /*
610  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_F_c
611  * Electrostatics interaction: ReactionField
612  * VdW interaction:            Buckingham
613  * Geometry:                   Water3-Water3
614  * Calculate force/pot:        Force
615  */
616 void
617 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_F_c
618                     (t_nblist                    * gmx_restrict       nlist,
619                      rvec                        * gmx_restrict          xx,
620                      rvec                        * gmx_restrict          ff,
621                      t_forcerec                  * gmx_restrict          fr,
622                      t_mdatoms                   * gmx_restrict     mdatoms,
623                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
624                      t_nrnb                      * gmx_restrict        nrnb)
625 {
626     int              i_shift_offset,i_coord_offset,j_coord_offset;
627     int              j_index_start,j_index_end;
628     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
629     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
630     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
631     real             *shiftvec,*fshift,*x,*f;
632     int              vdwioffset0;
633     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
634     int              vdwioffset1;
635     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
636     int              vdwioffset2;
637     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
638     int              vdwjidx0;
639     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
640     int              vdwjidx1;
641     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
642     int              vdwjidx2;
643     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
644     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
645     real             dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
646     real             dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
647     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
648     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
649     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
650     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
651     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
652     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
653     real             velec,felec,velecsum,facel,crf,krf,krf2;
654     real             *charge;
655     int              nvdwtype;
656     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
657     int              *vdwtype;
658     real             *vdwparam;
659
660     x                = xx[0];
661     f                = ff[0];
662
663     nri              = nlist->nri;
664     iinr             = nlist->iinr;
665     jindex           = nlist->jindex;
666     jjnr             = nlist->jjnr;
667     shiftidx         = nlist->shift;
668     gid              = nlist->gid;
669     shiftvec         = fr->shift_vec[0];
670     fshift           = fr->fshift[0];
671     facel            = fr->epsfac;
672     charge           = mdatoms->chargeA;
673     krf              = fr->ic->k_rf;
674     krf2             = krf*2.0;
675     crf              = fr->ic->c_rf;
676     nvdwtype         = fr->ntype;
677     vdwparam         = fr->nbfp;
678     vdwtype          = mdatoms->typeA;
679
680     /* Setup water-specific parameters */
681     inr              = nlist->iinr[0];
682     iq0              = facel*charge[inr+0];
683     iq1              = facel*charge[inr+1];
684     iq2              = facel*charge[inr+2];
685     vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
686
687     jq0              = charge[inr+0];
688     jq1              = charge[inr+1];
689     jq2              = charge[inr+2];
690     vdwjidx0         = 3*vdwtype[inr+0];
691     qq00             = iq0*jq0;
692     c6_00            = vdwparam[vdwioffset0+vdwjidx0];
693     cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
694     cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
695     qq01             = iq0*jq1;
696     qq02             = iq0*jq2;
697     qq10             = iq1*jq0;
698     qq11             = iq1*jq1;
699     qq12             = iq1*jq2;
700     qq20             = iq2*jq0;
701     qq21             = iq2*jq1;
702     qq22             = iq2*jq2;
703
704     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
705     rcutoff          = fr->rcoulomb;
706     rcutoff2         = rcutoff*rcutoff;
707
708     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
709     rvdw             = fr->rvdw;
710
711     outeriter        = 0;
712     inneriter        = 0;
713
714     /* Start outer loop over neighborlists */
715     for(iidx=0; iidx<nri; iidx++)
716     {
717         /* Load shift vector for this list */
718         i_shift_offset   = DIM*shiftidx[iidx];
719         shX              = shiftvec[i_shift_offset+XX];
720         shY              = shiftvec[i_shift_offset+YY];
721         shZ              = shiftvec[i_shift_offset+ZZ];
722
723         /* Load limits for loop over neighbors */
724         j_index_start    = jindex[iidx];
725         j_index_end      = jindex[iidx+1];
726
727         /* Get outer coordinate index */
728         inr              = iinr[iidx];
729         i_coord_offset   = DIM*inr;
730
731         /* Load i particle coords and add shift vector */
732         ix0              = shX + x[i_coord_offset+DIM*0+XX];
733         iy0              = shY + x[i_coord_offset+DIM*0+YY];
734         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
735         ix1              = shX + x[i_coord_offset+DIM*1+XX];
736         iy1              = shY + x[i_coord_offset+DIM*1+YY];
737         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
738         ix2              = shX + x[i_coord_offset+DIM*2+XX];
739         iy2              = shY + x[i_coord_offset+DIM*2+YY];
740         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
741
742         fix0             = 0.0;
743         fiy0             = 0.0;
744         fiz0             = 0.0;
745         fix1             = 0.0;
746         fiy1             = 0.0;
747         fiz1             = 0.0;
748         fix2             = 0.0;
749         fiy2             = 0.0;
750         fiz2             = 0.0;
751
752         /* Start inner kernel loop */
753         for(jidx=j_index_start; jidx<j_index_end; jidx++)
754         {
755             /* Get j neighbor index, and coordinate index */
756             jnr              = jjnr[jidx];
757             j_coord_offset   = DIM*jnr;
758
759             /* load j atom coordinates */
760             jx0              = x[j_coord_offset+DIM*0+XX];
761             jy0              = x[j_coord_offset+DIM*0+YY];
762             jz0              = x[j_coord_offset+DIM*0+ZZ];
763             jx1              = x[j_coord_offset+DIM*1+XX];
764             jy1              = x[j_coord_offset+DIM*1+YY];
765             jz1              = x[j_coord_offset+DIM*1+ZZ];
766             jx2              = x[j_coord_offset+DIM*2+XX];
767             jy2              = x[j_coord_offset+DIM*2+YY];
768             jz2              = x[j_coord_offset+DIM*2+ZZ];
769
770             /* Calculate displacement vector */
771             dx00             = ix0 - jx0;
772             dy00             = iy0 - jy0;
773             dz00             = iz0 - jz0;
774             dx01             = ix0 - jx1;
775             dy01             = iy0 - jy1;
776             dz01             = iz0 - jz1;
777             dx02             = ix0 - jx2;
778             dy02             = iy0 - jy2;
779             dz02             = iz0 - jz2;
780             dx10             = ix1 - jx0;
781             dy10             = iy1 - jy0;
782             dz10             = iz1 - jz0;
783             dx11             = ix1 - jx1;
784             dy11             = iy1 - jy1;
785             dz11             = iz1 - jz1;
786             dx12             = ix1 - jx2;
787             dy12             = iy1 - jy2;
788             dz12             = iz1 - jz2;
789             dx20             = ix2 - jx0;
790             dy20             = iy2 - jy0;
791             dz20             = iz2 - jz0;
792             dx21             = ix2 - jx1;
793             dy21             = iy2 - jy1;
794             dz21             = iz2 - jz1;
795             dx22             = ix2 - jx2;
796             dy22             = iy2 - jy2;
797             dz22             = iz2 - jz2;
798
799             /* Calculate squared distance and things based on it */
800             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
801             rsq01            = dx01*dx01+dy01*dy01+dz01*dz01;
802             rsq02            = dx02*dx02+dy02*dy02+dz02*dz02;
803             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
804             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
805             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
806             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
807             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
808             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
809
810             rinv00           = gmx_invsqrt(rsq00);
811             rinv01           = gmx_invsqrt(rsq01);
812             rinv02           = gmx_invsqrt(rsq02);
813             rinv10           = gmx_invsqrt(rsq10);
814             rinv11           = gmx_invsqrt(rsq11);
815             rinv12           = gmx_invsqrt(rsq12);
816             rinv20           = gmx_invsqrt(rsq20);
817             rinv21           = gmx_invsqrt(rsq21);
818             rinv22           = gmx_invsqrt(rsq22);
819
820             rinvsq00         = rinv00*rinv00;
821             rinvsq01         = rinv01*rinv01;
822             rinvsq02         = rinv02*rinv02;
823             rinvsq10         = rinv10*rinv10;
824             rinvsq11         = rinv11*rinv11;
825             rinvsq12         = rinv12*rinv12;
826             rinvsq20         = rinv20*rinv20;
827             rinvsq21         = rinv21*rinv21;
828             rinvsq22         = rinv22*rinv22;
829
830             /**************************
831              * CALCULATE INTERACTIONS *
832              **************************/
833
834             if (rsq00<rcutoff2)
835             {
836
837             r00              = rsq00*rinv00;
838
839             /* REACTION-FIELD ELECTROSTATICS */
840             felec            = qq00*(rinv00*rinvsq00-krf2);
841
842             /* BUCKINGHAM DISPERSION/REPULSION */
843             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
844             vvdw6            = c6_00*rinvsix;
845             br               = cexp2_00*r00;
846             vvdwexp          = cexp1_00*exp(-br);
847             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
848
849             fscal            = felec+fvdw;
850
851             /* Calculate temporary vectorial force */
852             tx               = fscal*dx00;
853             ty               = fscal*dy00;
854             tz               = fscal*dz00;
855
856             /* Update vectorial force */
857             fix0            += tx;
858             fiy0            += ty;
859             fiz0            += tz;
860             f[j_coord_offset+DIM*0+XX] -= tx;
861             f[j_coord_offset+DIM*0+YY] -= ty;
862             f[j_coord_offset+DIM*0+ZZ] -= tz;
863
864             }
865
866             /**************************
867              * CALCULATE INTERACTIONS *
868              **************************/
869
870             if (rsq01<rcutoff2)
871             {
872
873             /* REACTION-FIELD ELECTROSTATICS */
874             felec            = qq01*(rinv01*rinvsq01-krf2);
875
876             fscal            = felec;
877
878             /* Calculate temporary vectorial force */
879             tx               = fscal*dx01;
880             ty               = fscal*dy01;
881             tz               = fscal*dz01;
882
883             /* Update vectorial force */
884             fix0            += tx;
885             fiy0            += ty;
886             fiz0            += tz;
887             f[j_coord_offset+DIM*1+XX] -= tx;
888             f[j_coord_offset+DIM*1+YY] -= ty;
889             f[j_coord_offset+DIM*1+ZZ] -= tz;
890
891             }
892
893             /**************************
894              * CALCULATE INTERACTIONS *
895              **************************/
896
897             if (rsq02<rcutoff2)
898             {
899
900             /* REACTION-FIELD ELECTROSTATICS */
901             felec            = qq02*(rinv02*rinvsq02-krf2);
902
903             fscal            = felec;
904
905             /* Calculate temporary vectorial force */
906             tx               = fscal*dx02;
907             ty               = fscal*dy02;
908             tz               = fscal*dz02;
909
910             /* Update vectorial force */
911             fix0            += tx;
912             fiy0            += ty;
913             fiz0            += tz;
914             f[j_coord_offset+DIM*2+XX] -= tx;
915             f[j_coord_offset+DIM*2+YY] -= ty;
916             f[j_coord_offset+DIM*2+ZZ] -= tz;
917
918             }
919
920             /**************************
921              * CALCULATE INTERACTIONS *
922              **************************/
923
924             if (rsq10<rcutoff2)
925             {
926
927             /* REACTION-FIELD ELECTROSTATICS */
928             felec            = qq10*(rinv10*rinvsq10-krf2);
929
930             fscal            = felec;
931
932             /* Calculate temporary vectorial force */
933             tx               = fscal*dx10;
934             ty               = fscal*dy10;
935             tz               = fscal*dz10;
936
937             /* Update vectorial force */
938             fix1            += tx;
939             fiy1            += ty;
940             fiz1            += tz;
941             f[j_coord_offset+DIM*0+XX] -= tx;
942             f[j_coord_offset+DIM*0+YY] -= ty;
943             f[j_coord_offset+DIM*0+ZZ] -= tz;
944
945             }
946
947             /**************************
948              * CALCULATE INTERACTIONS *
949              **************************/
950
951             if (rsq11<rcutoff2)
952             {
953
954             /* REACTION-FIELD ELECTROSTATICS */
955             felec            = qq11*(rinv11*rinvsq11-krf2);
956
957             fscal            = felec;
958
959             /* Calculate temporary vectorial force */
960             tx               = fscal*dx11;
961             ty               = fscal*dy11;
962             tz               = fscal*dz11;
963
964             /* Update vectorial force */
965             fix1            += tx;
966             fiy1            += ty;
967             fiz1            += tz;
968             f[j_coord_offset+DIM*1+XX] -= tx;
969             f[j_coord_offset+DIM*1+YY] -= ty;
970             f[j_coord_offset+DIM*1+ZZ] -= tz;
971
972             }
973
974             /**************************
975              * CALCULATE INTERACTIONS *
976              **************************/
977
978             if (rsq12<rcutoff2)
979             {
980
981             /* REACTION-FIELD ELECTROSTATICS */
982             felec            = qq12*(rinv12*rinvsq12-krf2);
983
984             fscal            = felec;
985
986             /* Calculate temporary vectorial force */
987             tx               = fscal*dx12;
988             ty               = fscal*dy12;
989             tz               = fscal*dz12;
990
991             /* Update vectorial force */
992             fix1            += tx;
993             fiy1            += ty;
994             fiz1            += tz;
995             f[j_coord_offset+DIM*2+XX] -= tx;
996             f[j_coord_offset+DIM*2+YY] -= ty;
997             f[j_coord_offset+DIM*2+ZZ] -= tz;
998
999             }
1000
1001             /**************************
1002              * CALCULATE INTERACTIONS *
1003              **************************/
1004
1005             if (rsq20<rcutoff2)
1006             {
1007
1008             /* REACTION-FIELD ELECTROSTATICS */
1009             felec            = qq20*(rinv20*rinvsq20-krf2);
1010
1011             fscal            = felec;
1012
1013             /* Calculate temporary vectorial force */
1014             tx               = fscal*dx20;
1015             ty               = fscal*dy20;
1016             tz               = fscal*dz20;
1017
1018             /* Update vectorial force */
1019             fix2            += tx;
1020             fiy2            += ty;
1021             fiz2            += tz;
1022             f[j_coord_offset+DIM*0+XX] -= tx;
1023             f[j_coord_offset+DIM*0+YY] -= ty;
1024             f[j_coord_offset+DIM*0+ZZ] -= tz;
1025
1026             }
1027
1028             /**************************
1029              * CALCULATE INTERACTIONS *
1030              **************************/
1031
1032             if (rsq21<rcutoff2)
1033             {
1034
1035             /* REACTION-FIELD ELECTROSTATICS */
1036             felec            = qq21*(rinv21*rinvsq21-krf2);
1037
1038             fscal            = felec;
1039
1040             /* Calculate temporary vectorial force */
1041             tx               = fscal*dx21;
1042             ty               = fscal*dy21;
1043             tz               = fscal*dz21;
1044
1045             /* Update vectorial force */
1046             fix2            += tx;
1047             fiy2            += ty;
1048             fiz2            += tz;
1049             f[j_coord_offset+DIM*1+XX] -= tx;
1050             f[j_coord_offset+DIM*1+YY] -= ty;
1051             f[j_coord_offset+DIM*1+ZZ] -= tz;
1052
1053             }
1054
1055             /**************************
1056              * CALCULATE INTERACTIONS *
1057              **************************/
1058
1059             if (rsq22<rcutoff2)
1060             {
1061
1062             /* REACTION-FIELD ELECTROSTATICS */
1063             felec            = qq22*(rinv22*rinvsq22-krf2);
1064
1065             fscal            = felec;
1066
1067             /* Calculate temporary vectorial force */
1068             tx               = fscal*dx22;
1069             ty               = fscal*dy22;
1070             tz               = fscal*dz22;
1071
1072             /* Update vectorial force */
1073             fix2            += tx;
1074             fiy2            += ty;
1075             fiz2            += tz;
1076             f[j_coord_offset+DIM*2+XX] -= tx;
1077             f[j_coord_offset+DIM*2+YY] -= ty;
1078             f[j_coord_offset+DIM*2+ZZ] -= tz;
1079
1080             }
1081
1082             /* Inner loop uses 270 flops */
1083         }
1084         /* End of innermost loop */
1085
1086         tx = ty = tz = 0;
1087         f[i_coord_offset+DIM*0+XX] += fix0;
1088         f[i_coord_offset+DIM*0+YY] += fiy0;
1089         f[i_coord_offset+DIM*0+ZZ] += fiz0;
1090         tx                         += fix0;
1091         ty                         += fiy0;
1092         tz                         += fiz0;
1093         f[i_coord_offset+DIM*1+XX] += fix1;
1094         f[i_coord_offset+DIM*1+YY] += fiy1;
1095         f[i_coord_offset+DIM*1+ZZ] += fiz1;
1096         tx                         += fix1;
1097         ty                         += fiy1;
1098         tz                         += fiz1;
1099         f[i_coord_offset+DIM*2+XX] += fix2;
1100         f[i_coord_offset+DIM*2+YY] += fiy2;
1101         f[i_coord_offset+DIM*2+ZZ] += fiz2;
1102         tx                         += fix2;
1103         ty                         += fiy2;
1104         tz                         += fiz2;
1105         fshift[i_shift_offset+XX]  += tx;
1106         fshift[i_shift_offset+YY]  += ty;
1107         fshift[i_shift_offset+ZZ]  += tz;
1108
1109         /* Increment number of inner iterations */
1110         inneriter                  += j_index_end - j_index_start;
1111
1112         /* Outer loop uses 30 flops */
1113     }
1114
1115     /* Increment number of outer iterations */
1116     outeriter        += nri;
1117
1118     /* Update outer/inner flops */
1119
1120     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*270);
1121 }