97ce5781f2ebbf9c599844f2082c5b2d9e508642
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecNone_VdwBhamSh_GeomP1P1_c.c
1 /*
2  * Note: this file was generated by the Gromacs c kernel generator.
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  * Copyright (c) 2001-2012, The GROMACS Development Team
9  *
10  * Gromacs is a library for molecular simulation and trajectory analysis,
11  * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12  * a full list of developers and information, check out http://www.gromacs.org
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License as published by the Free
16  * Software Foundation; either version 2 of the License, or (at your option) any
17  * later version.
18  *
19  * To help fund GROMACS development, we humbly ask that you cite
20  * the papers people have written on it - you can find them on the website.
21  */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <math.h>
27
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
30 #include "vec.h"
31 #include "nrnb.h"
32
33 /*
34  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwBhamSh_GeomP1P1_VF_c
35  * Electrostatics interaction: None
36  * VdW interaction:            Buckingham
37  * Geometry:                   Particle-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecNone_VdwBhamSh_GeomP1P1_VF_c
42                     (t_nblist * gmx_restrict                nlist,
43                      rvec * gmx_restrict                    xx,
44                      rvec * gmx_restrict                    ff,
45                      t_forcerec * gmx_restrict              fr,
46                      t_mdatoms * gmx_restrict               mdatoms,
47                      nb_kernel_data_t * gmx_restrict        kernel_data,
48                      t_nrnb * gmx_restrict                  nrnb)
49 {
50     int              i_shift_offset,i_coord_offset,j_coord_offset;
51     int              j_index_start,j_index_end;
52     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
55     real             *shiftvec,*fshift,*x,*f;
56     int              vdwioffset0;
57     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
58     int              vdwjidx0;
59     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
60     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
61     int              nvdwtype;
62     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
63     int              *vdwtype;
64     real             *vdwparam;
65
66     x                = xx[0];
67     f                = ff[0];
68
69     nri              = nlist->nri;
70     iinr             = nlist->iinr;
71     jindex           = nlist->jindex;
72     jjnr             = nlist->jjnr;
73     shiftidx         = nlist->shift;
74     gid              = nlist->gid;
75     shiftvec         = fr->shift_vec[0];
76     fshift           = fr->fshift[0];
77     nvdwtype         = fr->ntype;
78     vdwparam         = fr->nbfp;
79     vdwtype          = mdatoms->typeA;
80
81     rcutoff          = fr->rvdw;
82     rcutoff2         = rcutoff*rcutoff;
83
84     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
85     rvdw             = fr->rvdw;
86
87     outeriter        = 0;
88     inneriter        = 0;
89
90     /* Start outer loop over neighborlists */
91     for(iidx=0; iidx<nri; iidx++)
92     {
93         /* Load shift vector for this list */
94         i_shift_offset   = DIM*shiftidx[iidx];
95         shX              = shiftvec[i_shift_offset+XX];
96         shY              = shiftvec[i_shift_offset+YY];
97         shZ              = shiftvec[i_shift_offset+ZZ];
98
99         /* Load limits for loop over neighbors */
100         j_index_start    = jindex[iidx];
101         j_index_end      = jindex[iidx+1];
102
103         /* Get outer coordinate index */
104         inr              = iinr[iidx];
105         i_coord_offset   = DIM*inr;
106
107         /* Load i particle coords and add shift vector */
108         ix0              = shX + x[i_coord_offset+DIM*0+XX];
109         iy0              = shY + x[i_coord_offset+DIM*0+YY];
110         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
111
112         fix0             = 0.0;
113         fiy0             = 0.0;
114         fiz0             = 0.0;
115
116         /* Load parameters for i particles */
117         vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
118
119         /* Reset potential sums */
120         vvdwsum          = 0.0;
121
122         /* Start inner kernel loop */
123         for(jidx=j_index_start; jidx<j_index_end; jidx++)
124         {
125             /* Get j neighbor index, and coordinate index */
126             jnr              = jjnr[jidx];
127             j_coord_offset   = DIM*jnr;
128
129             /* load j atom coordinates */
130             jx0              = x[j_coord_offset+DIM*0+XX];
131             jy0              = x[j_coord_offset+DIM*0+YY];
132             jz0              = x[j_coord_offset+DIM*0+ZZ];
133
134             /* Calculate displacement vector */
135             dx00             = ix0 - jx0;
136             dy00             = iy0 - jy0;
137             dz00             = iz0 - jz0;
138
139             /* Calculate squared distance and things based on it */
140             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
141
142             rinv00           = gmx_invsqrt(rsq00);
143
144             rinvsq00         = rinv00*rinv00;
145
146             /* Load parameters for j particles */
147             vdwjidx0         = 3*vdwtype[jnr+0];
148
149             /**************************
150              * CALCULATE INTERACTIONS *
151              **************************/
152
153             if (rsq00<rcutoff2)
154             {
155
156             r00              = rsq00*rinv00;
157
158             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
159             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
160             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
161
162             /* BUCKINGHAM DISPERSION/REPULSION */
163             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
164             vvdw6            = c6_00*rinvsix;
165             br               = cexp2_00*r00;
166             vvdwexp          = cexp1_00*exp(-br);
167             vvdw             = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
168             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
169
170             /* Update potential sums from outer loop */
171             vvdwsum         += vvdw;
172
173             fscal            = fvdw;
174
175             /* Calculate temporary vectorial force */
176             tx               = fscal*dx00;
177             ty               = fscal*dy00;
178             tz               = fscal*dz00;
179
180             /* Update vectorial force */
181             fix0            += tx;
182             fiy0            += ty;
183             fiz0            += tz;
184             f[j_coord_offset+DIM*0+XX] -= tx;
185             f[j_coord_offset+DIM*0+YY] -= ty;
186             f[j_coord_offset+DIM*0+ZZ] -= tz;
187
188             }
189
190             /* Inner loop uses 92 flops */
191         }
192         /* End of innermost loop */
193
194         tx = ty = tz = 0;
195         f[i_coord_offset+DIM*0+XX] += fix0;
196         f[i_coord_offset+DIM*0+YY] += fiy0;
197         f[i_coord_offset+DIM*0+ZZ] += fiz0;
198         tx                         += fix0;
199         ty                         += fiy0;
200         tz                         += fiz0;
201         fshift[i_shift_offset+XX]  += tx;
202         fshift[i_shift_offset+YY]  += ty;
203         fshift[i_shift_offset+ZZ]  += tz;
204
205         ggid                        = gid[iidx];
206         /* Update potential energies */
207         kernel_data->energygrp_vdw[ggid] += vvdwsum;
208
209         /* Increment number of inner iterations */
210         inneriter                  += j_index_end - j_index_start;
211
212         /* Outer loop uses 13 flops */
213     }
214
215     /* Increment number of outer iterations */
216     outeriter        += nri;
217
218     /* Update outer/inner flops */
219
220     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*92);
221 }
222 /*
223  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwBhamSh_GeomP1P1_F_c
224  * Electrostatics interaction: None
225  * VdW interaction:            Buckingham
226  * Geometry:                   Particle-Particle
227  * Calculate force/pot:        Force
228  */
229 void
230 nb_kernel_ElecNone_VdwBhamSh_GeomP1P1_F_c
231                     (t_nblist * gmx_restrict                nlist,
232                      rvec * gmx_restrict                    xx,
233                      rvec * gmx_restrict                    ff,
234                      t_forcerec * gmx_restrict              fr,
235                      t_mdatoms * gmx_restrict               mdatoms,
236                      nb_kernel_data_t * gmx_restrict        kernel_data,
237                      t_nrnb * gmx_restrict                  nrnb)
238 {
239     int              i_shift_offset,i_coord_offset,j_coord_offset;
240     int              j_index_start,j_index_end;
241     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
242     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
243     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
244     real             *shiftvec,*fshift,*x,*f;
245     int              vdwioffset0;
246     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
247     int              vdwjidx0;
248     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
249     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
250     int              nvdwtype;
251     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
252     int              *vdwtype;
253     real             *vdwparam;
254
255     x                = xx[0];
256     f                = ff[0];
257
258     nri              = nlist->nri;
259     iinr             = nlist->iinr;
260     jindex           = nlist->jindex;
261     jjnr             = nlist->jjnr;
262     shiftidx         = nlist->shift;
263     gid              = nlist->gid;
264     shiftvec         = fr->shift_vec[0];
265     fshift           = fr->fshift[0];
266     nvdwtype         = fr->ntype;
267     vdwparam         = fr->nbfp;
268     vdwtype          = mdatoms->typeA;
269
270     rcutoff          = fr->rvdw;
271     rcutoff2         = rcutoff*rcutoff;
272
273     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
274     rvdw             = fr->rvdw;
275
276     outeriter        = 0;
277     inneriter        = 0;
278
279     /* Start outer loop over neighborlists */
280     for(iidx=0; iidx<nri; iidx++)
281     {
282         /* Load shift vector for this list */
283         i_shift_offset   = DIM*shiftidx[iidx];
284         shX              = shiftvec[i_shift_offset+XX];
285         shY              = shiftvec[i_shift_offset+YY];
286         shZ              = shiftvec[i_shift_offset+ZZ];
287
288         /* Load limits for loop over neighbors */
289         j_index_start    = jindex[iidx];
290         j_index_end      = jindex[iidx+1];
291
292         /* Get outer coordinate index */
293         inr              = iinr[iidx];
294         i_coord_offset   = DIM*inr;
295
296         /* Load i particle coords and add shift vector */
297         ix0              = shX + x[i_coord_offset+DIM*0+XX];
298         iy0              = shY + x[i_coord_offset+DIM*0+YY];
299         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
300
301         fix0             = 0.0;
302         fiy0             = 0.0;
303         fiz0             = 0.0;
304
305         /* Load parameters for i particles */
306         vdwioffset0      = 3*nvdwtype*vdwtype[inr+0];
307
308         /* Start inner kernel loop */
309         for(jidx=j_index_start; jidx<j_index_end; jidx++)
310         {
311             /* Get j neighbor index, and coordinate index */
312             jnr              = jjnr[jidx];
313             j_coord_offset   = DIM*jnr;
314
315             /* load j atom coordinates */
316             jx0              = x[j_coord_offset+DIM*0+XX];
317             jy0              = x[j_coord_offset+DIM*0+YY];
318             jz0              = x[j_coord_offset+DIM*0+ZZ];
319
320             /* Calculate displacement vector */
321             dx00             = ix0 - jx0;
322             dy00             = iy0 - jy0;
323             dz00             = iz0 - jz0;
324
325             /* Calculate squared distance and things based on it */
326             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
327
328             rinv00           = gmx_invsqrt(rsq00);
329
330             rinvsq00         = rinv00*rinv00;
331
332             /* Load parameters for j particles */
333             vdwjidx0         = 3*vdwtype[jnr+0];
334
335             /**************************
336              * CALCULATE INTERACTIONS *
337              **************************/
338
339             if (rsq00<rcutoff2)
340             {
341
342             r00              = rsq00*rinv00;
343
344             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
345             cexp1_00         = vdwparam[vdwioffset0+vdwjidx0+1];
346             cexp2_00         = vdwparam[vdwioffset0+vdwjidx0+2];
347
348             /* BUCKINGHAM DISPERSION/REPULSION */
349             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
350             vvdw6            = c6_00*rinvsix;
351             br               = cexp2_00*r00;
352             vvdwexp          = cexp1_00*exp(-br);
353             fvdw             = (br*vvdwexp-vvdw6)*rinvsq00;
354
355             fscal            = fvdw;
356
357             /* Calculate temporary vectorial force */
358             tx               = fscal*dx00;
359             ty               = fscal*dy00;
360             tz               = fscal*dz00;
361
362             /* Update vectorial force */
363             fix0            += tx;
364             fiy0            += ty;
365             fiz0            += tz;
366             f[j_coord_offset+DIM*0+XX] -= tx;
367             f[j_coord_offset+DIM*0+YY] -= ty;
368             f[j_coord_offset+DIM*0+ZZ] -= tz;
369
370             }
371
372             /* Inner loop uses 58 flops */
373         }
374         /* End of innermost loop */
375
376         tx = ty = tz = 0;
377         f[i_coord_offset+DIM*0+XX] += fix0;
378         f[i_coord_offset+DIM*0+YY] += fiy0;
379         f[i_coord_offset+DIM*0+ZZ] += fiz0;
380         tx                         += fix0;
381         ty                         += fiy0;
382         tz                         += fiz0;
383         fshift[i_shift_offset+XX]  += tx;
384         fshift[i_shift_offset+YY]  += ty;
385         fshift[i_shift_offset+ZZ]  += tz;
386
387         /* Increment number of inner iterations */
388         inneriter                  += j_index_end - j_index_start;
389
390         /* Outer loop uses 12 flops */
391     }
392
393     /* Increment number of outer iterations */
394     outeriter        += nri;
395
396     /* Update outer/inner flops */
397
398     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*58);
399 }