Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecNone_VdwLJSw_GeomP1P1_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_ElecNone_VdwLJSw_GeomP1P1_VF_c
49  * Electrostatics interaction: None
50  * VdW interaction:            LennardJones
51  * Geometry:                   Particle-Particle
52  * Calculate force/pot:        PotentialAndForce
53  */
54 void
55 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_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              vdwjidx0;
73     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
75     int              nvdwtype;
76     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
77     int              *vdwtype;
78     real             *vdwparam;
79     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
80
81     x                = xx[0];
82     f                = ff[0];
83
84     nri              = nlist->nri;
85     iinr             = nlist->iinr;
86     jindex           = nlist->jindex;
87     jjnr             = nlist->jjnr;
88     shiftidx         = nlist->shift;
89     gid              = nlist->gid;
90     shiftvec         = fr->shift_vec[0];
91     fshift           = fr->fshift[0];
92     nvdwtype         = fr->ntype;
93     vdwparam         = fr->nbfp;
94     vdwtype          = mdatoms->typeA;
95
96     rcutoff          = fr->rvdw;
97     rcutoff2         = rcutoff*rcutoff;
98
99     rswitch          = fr->rvdw_switch;
100     /* Setup switch parameters */
101     d                = rcutoff-rswitch;
102     swV3             = -10.0/(d*d*d);
103     swV4             =  15.0/(d*d*d*d);
104     swV5             =  -6.0/(d*d*d*d*d);
105     swF2             = -30.0/(d*d*d);
106     swF3             =  60.0/(d*d*d*d);
107     swF4             = -30.0/(d*d*d*d*d);
108
109     outeriter        = 0;
110     inneriter        = 0;
111
112     /* Start outer loop over neighborlists */
113     for(iidx=0; iidx<nri; iidx++)
114     {
115         /* Load shift vector for this list */
116         i_shift_offset   = DIM*shiftidx[iidx];
117         shX              = shiftvec[i_shift_offset+XX];
118         shY              = shiftvec[i_shift_offset+YY];
119         shZ              = shiftvec[i_shift_offset+ZZ];
120
121         /* Load limits for loop over neighbors */
122         j_index_start    = jindex[iidx];
123         j_index_end      = jindex[iidx+1];
124
125         /* Get outer coordinate index */
126         inr              = iinr[iidx];
127         i_coord_offset   = DIM*inr;
128
129         /* Load i particle coords and add shift vector */
130         ix0              = shX + x[i_coord_offset+DIM*0+XX];
131         iy0              = shY + x[i_coord_offset+DIM*0+YY];
132         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
133
134         fix0             = 0.0;
135         fiy0             = 0.0;
136         fiz0             = 0.0;
137
138         /* Load parameters for i particles */
139         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
140
141         /* Reset potential sums */
142         vvdwsum          = 0.0;
143
144         /* Start inner kernel loop */
145         for(jidx=j_index_start; jidx<j_index_end; jidx++)
146         {
147             /* Get j neighbor index, and coordinate index */
148             jnr              = jjnr[jidx];
149             j_coord_offset   = DIM*jnr;
150
151             /* load j atom coordinates */
152             jx0              = x[j_coord_offset+DIM*0+XX];
153             jy0              = x[j_coord_offset+DIM*0+YY];
154             jz0              = x[j_coord_offset+DIM*0+ZZ];
155
156             /* Calculate displacement vector */
157             dx00             = ix0 - jx0;
158             dy00             = iy0 - jy0;
159             dz00             = iz0 - jz0;
160
161             /* Calculate squared distance and things based on it */
162             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
163
164             rinv00           = gmx_invsqrt(rsq00);
165
166             rinvsq00         = rinv00*rinv00;
167
168             /* Load parameters for j particles */
169             vdwjidx0         = 2*vdwtype[jnr+0];
170
171             /**************************
172              * CALCULATE INTERACTIONS *
173              **************************/
174
175             if (rsq00<rcutoff2)
176             {
177
178             r00              = rsq00*rinv00;
179
180             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
181             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
182
183             /* LENNARD-JONES DISPERSION/REPULSION */
184
185             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
186             vvdw6            = c6_00*rinvsix;
187             vvdw12           = c12_00*rinvsix*rinvsix;
188             vvdw             = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
189             fvdw             = (vvdw12-vvdw6)*rinvsq00;
190
191             d                = r00-rswitch;
192             d                = (d>0.0) ? d : 0.0;
193             d2               = d*d;
194             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
195
196             dsw              = d2*(swF2+d*(swF3+d*swF4));
197
198             /* Evaluate switch function */
199             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
200             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
201             vvdw            *= sw;
202
203             /* Update potential sums from outer loop */
204             vvdwsum         += vvdw;
205
206             fscal            = fvdw;
207
208             /* Calculate temporary vectorial force */
209             tx               = fscal*dx00;
210             ty               = fscal*dy00;
211             tz               = fscal*dz00;
212
213             /* Update vectorial force */
214             fix0            += tx;
215             fiy0            += ty;
216             fiz0            += tz;
217             f[j_coord_offset+DIM*0+XX] -= tx;
218             f[j_coord_offset+DIM*0+YY] -= ty;
219             f[j_coord_offset+DIM*0+ZZ] -= tz;
220
221             }
222
223             /* Inner loop uses 53 flops */
224         }
225         /* End of innermost loop */
226
227         tx = ty = tz = 0;
228         f[i_coord_offset+DIM*0+XX] += fix0;
229         f[i_coord_offset+DIM*0+YY] += fiy0;
230         f[i_coord_offset+DIM*0+ZZ] += fiz0;
231         tx                         += fix0;
232         ty                         += fiy0;
233         tz                         += fiz0;
234         fshift[i_shift_offset+XX]  += tx;
235         fshift[i_shift_offset+YY]  += ty;
236         fshift[i_shift_offset+ZZ]  += tz;
237
238         ggid                        = gid[iidx];
239         /* Update potential energies */
240         kernel_data->energygrp_vdw[ggid] += vvdwsum;
241
242         /* Increment number of inner iterations */
243         inneriter                  += j_index_end - j_index_start;
244
245         /* Outer loop uses 13 flops */
246     }
247
248     /* Increment number of outer iterations */
249     outeriter        += nri;
250
251     /* Update outer/inner flops */
252
253     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*53);
254 }
255 /*
256  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_c
257  * Electrostatics interaction: None
258  * VdW interaction:            LennardJones
259  * Geometry:                   Particle-Particle
260  * Calculate force/pot:        Force
261  */
262 void
263 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_c
264                     (t_nblist                    * gmx_restrict       nlist,
265                      rvec                        * gmx_restrict          xx,
266                      rvec                        * gmx_restrict          ff,
267                      t_forcerec                  * gmx_restrict          fr,
268                      t_mdatoms                   * gmx_restrict     mdatoms,
269                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
270                      t_nrnb                      * gmx_restrict        nrnb)
271 {
272     int              i_shift_offset,i_coord_offset,j_coord_offset;
273     int              j_index_start,j_index_end;
274     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
275     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
276     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
277     real             *shiftvec,*fshift,*x,*f;
278     int              vdwioffset0;
279     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
280     int              vdwjidx0;
281     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
282     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
283     int              nvdwtype;
284     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
285     int              *vdwtype;
286     real             *vdwparam;
287     real             rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
288
289     x                = xx[0];
290     f                = ff[0];
291
292     nri              = nlist->nri;
293     iinr             = nlist->iinr;
294     jindex           = nlist->jindex;
295     jjnr             = nlist->jjnr;
296     shiftidx         = nlist->shift;
297     gid              = nlist->gid;
298     shiftvec         = fr->shift_vec[0];
299     fshift           = fr->fshift[0];
300     nvdwtype         = fr->ntype;
301     vdwparam         = fr->nbfp;
302     vdwtype          = mdatoms->typeA;
303
304     rcutoff          = fr->rvdw;
305     rcutoff2         = rcutoff*rcutoff;
306
307     rswitch          = fr->rvdw_switch;
308     /* Setup switch parameters */
309     d                = rcutoff-rswitch;
310     swV3             = -10.0/(d*d*d);
311     swV4             =  15.0/(d*d*d*d);
312     swV5             =  -6.0/(d*d*d*d*d);
313     swF2             = -30.0/(d*d*d);
314     swF3             =  60.0/(d*d*d*d);
315     swF4             = -30.0/(d*d*d*d*d);
316
317     outeriter        = 0;
318     inneriter        = 0;
319
320     /* Start outer loop over neighborlists */
321     for(iidx=0; iidx<nri; iidx++)
322     {
323         /* Load shift vector for this list */
324         i_shift_offset   = DIM*shiftidx[iidx];
325         shX              = shiftvec[i_shift_offset+XX];
326         shY              = shiftvec[i_shift_offset+YY];
327         shZ              = shiftvec[i_shift_offset+ZZ];
328
329         /* Load limits for loop over neighbors */
330         j_index_start    = jindex[iidx];
331         j_index_end      = jindex[iidx+1];
332
333         /* Get outer coordinate index */
334         inr              = iinr[iidx];
335         i_coord_offset   = DIM*inr;
336
337         /* Load i particle coords and add shift vector */
338         ix0              = shX + x[i_coord_offset+DIM*0+XX];
339         iy0              = shY + x[i_coord_offset+DIM*0+YY];
340         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
341
342         fix0             = 0.0;
343         fiy0             = 0.0;
344         fiz0             = 0.0;
345
346         /* Load parameters for i particles */
347         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
348
349         /* Start inner kernel loop */
350         for(jidx=j_index_start; jidx<j_index_end; jidx++)
351         {
352             /* Get j neighbor index, and coordinate index */
353             jnr              = jjnr[jidx];
354             j_coord_offset   = DIM*jnr;
355
356             /* load j atom coordinates */
357             jx0              = x[j_coord_offset+DIM*0+XX];
358             jy0              = x[j_coord_offset+DIM*0+YY];
359             jz0              = x[j_coord_offset+DIM*0+ZZ];
360
361             /* Calculate displacement vector */
362             dx00             = ix0 - jx0;
363             dy00             = iy0 - jy0;
364             dz00             = iz0 - jz0;
365
366             /* Calculate squared distance and things based on it */
367             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
368
369             rinv00           = gmx_invsqrt(rsq00);
370
371             rinvsq00         = rinv00*rinv00;
372
373             /* Load parameters for j particles */
374             vdwjidx0         = 2*vdwtype[jnr+0];
375
376             /**************************
377              * CALCULATE INTERACTIONS *
378              **************************/
379
380             if (rsq00<rcutoff2)
381             {
382
383             r00              = rsq00*rinv00;
384
385             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
386             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
387
388             /* LENNARD-JONES DISPERSION/REPULSION */
389
390             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
391             vvdw6            = c6_00*rinvsix;
392             vvdw12           = c12_00*rinvsix*rinvsix;
393             vvdw             = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
394             fvdw             = (vvdw12-vvdw6)*rinvsq00;
395
396             d                = r00-rswitch;
397             d                = (d>0.0) ? d : 0.0;
398             d2               = d*d;
399             sw               = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
400
401             dsw              = d2*(swF2+d*(swF3+d*swF4));
402
403             /* Evaluate switch function */
404             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
405             fvdw             = fvdw*sw - rinv00*vvdw*dsw;
406
407             fscal            = fvdw;
408
409             /* Calculate temporary vectorial force */
410             tx               = fscal*dx00;
411             ty               = fscal*dy00;
412             tz               = fscal*dz00;
413
414             /* Update vectorial force */
415             fix0            += tx;
416             fiy0            += ty;
417             fiz0            += tz;
418             f[j_coord_offset+DIM*0+XX] -= tx;
419             f[j_coord_offset+DIM*0+YY] -= ty;
420             f[j_coord_offset+DIM*0+ZZ] -= tz;
421
422             }
423
424             /* Inner loop uses 51 flops */
425         }
426         /* End of innermost loop */
427
428         tx = ty = tz = 0;
429         f[i_coord_offset+DIM*0+XX] += fix0;
430         f[i_coord_offset+DIM*0+YY] += fiy0;
431         f[i_coord_offset+DIM*0+ZZ] += fiz0;
432         tx                         += fix0;
433         ty                         += fiy0;
434         tz                         += fiz0;
435         fshift[i_shift_offset+XX]  += tx;
436         fshift[i_shift_offset+YY]  += ty;
437         fshift[i_shift_offset+ZZ]  += tz;
438
439         /* Increment number of inner iterations */
440         inneriter                  += j_index_end - j_index_start;
441
442         /* Outer loop uses 12 flops */
443     }
444
445     /* Increment number of outer iterations */
446     outeriter        += nri;
447
448     /* Update outer/inner flops */
449
450     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*51);
451 }