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