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