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