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