Fix component for libcudart
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecNone_VdwLJSh_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_VdwLJSh_GeomP1P1_VF_c
35  * Electrostatics interaction: None
36  * VdW interaction:            LennardJones
37  * Geometry:                   Particle-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecNone_VdwLJSh_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      = 2*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             rinvsq00         = 1.0/rsq00;
143
144             /* Load parameters for j particles */
145             vdwjidx0         = 2*vdwtype[jnr+0];
146
147             /**************************
148              * CALCULATE INTERACTIONS *
149              **************************/
150
151             if (rsq00<rcutoff2)
152             {
153
154             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
155             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
156
157             /* LENNARD-JONES DISPERSION/REPULSION */
158
159             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
160             vvdw6            = c6_00*rinvsix;
161             vvdw12           = c12_00*rinvsix*rinvsix;
162             vvdw             = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
163             fvdw             = (vvdw12-vvdw6)*rinvsq00;
164
165             /* Update potential sums from outer loop */
166             vvdwsum         += vvdw;
167
168             fscal            = fvdw;
169
170             /* Calculate temporary vectorial force */
171             tx               = fscal*dx00;
172             ty               = fscal*dy00;
173             tz               = fscal*dz00;
174
175             /* Update vectorial force */
176             fix0            += tx;
177             fiy0            += ty;
178             fiz0            += tz;
179             f[j_coord_offset+DIM*0+XX] -= tx;
180             f[j_coord_offset+DIM*0+YY] -= ty;
181             f[j_coord_offset+DIM*0+ZZ] -= tz;
182
183             }
184
185             /* Inner loop uses 37 flops */
186         }
187         /* End of innermost loop */
188
189         tx = ty = tz = 0;
190         f[i_coord_offset+DIM*0+XX] += fix0;
191         f[i_coord_offset+DIM*0+YY] += fiy0;
192         f[i_coord_offset+DIM*0+ZZ] += fiz0;
193         tx                         += fix0;
194         ty                         += fiy0;
195         tz                         += fiz0;
196         fshift[i_shift_offset+XX]  += tx;
197         fshift[i_shift_offset+YY]  += ty;
198         fshift[i_shift_offset+ZZ]  += tz;
199
200         ggid                        = gid[iidx];
201         /* Update potential energies */
202         kernel_data->energygrp_vdw[ggid] += vvdwsum;
203
204         /* Increment number of inner iterations */
205         inneriter                  += j_index_end - j_index_start;
206
207         /* Outer loop uses 13 flops */
208     }
209
210     /* Increment number of outer iterations */
211     outeriter        += nri;
212
213     /* Update outer/inner flops */
214
215     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*37);
216 }
217 /*
218  * Gromacs nonbonded kernel:   nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_c
219  * Electrostatics interaction: None
220  * VdW interaction:            LennardJones
221  * Geometry:                   Particle-Particle
222  * Calculate force/pot:        Force
223  */
224 void
225 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_c
226                     (t_nblist * gmx_restrict                nlist,
227                      rvec * gmx_restrict                    xx,
228                      rvec * gmx_restrict                    ff,
229                      t_forcerec * gmx_restrict              fr,
230                      t_mdatoms * gmx_restrict               mdatoms,
231                      nb_kernel_data_t * gmx_restrict        kernel_data,
232                      t_nrnb * gmx_restrict                  nrnb)
233 {
234     int              i_shift_offset,i_coord_offset,j_coord_offset;
235     int              j_index_start,j_index_end;
236     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
237     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
238     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
239     real             *shiftvec,*fshift,*x,*f;
240     int              vdwioffset0;
241     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
242     int              vdwjidx0;
243     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
244     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
245     int              nvdwtype;
246     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
247     int              *vdwtype;
248     real             *vdwparam;
249
250     x                = xx[0];
251     f                = ff[0];
252
253     nri              = nlist->nri;
254     iinr             = nlist->iinr;
255     jindex           = nlist->jindex;
256     jjnr             = nlist->jjnr;
257     shiftidx         = nlist->shift;
258     gid              = nlist->gid;
259     shiftvec         = fr->shift_vec[0];
260     fshift           = fr->fshift[0];
261     nvdwtype         = fr->ntype;
262     vdwparam         = fr->nbfp;
263     vdwtype          = mdatoms->typeA;
264
265     rcutoff          = fr->rvdw;
266     rcutoff2         = rcutoff*rcutoff;
267
268     sh_vdw_invrcut6  = fr->ic->sh_invrc6;
269     rvdw             = fr->rvdw;
270
271     outeriter        = 0;
272     inneriter        = 0;
273
274     /* Start outer loop over neighborlists */
275     for(iidx=0; iidx<nri; iidx++)
276     {
277         /* Load shift vector for this list */
278         i_shift_offset   = DIM*shiftidx[iidx];
279         shX              = shiftvec[i_shift_offset+XX];
280         shY              = shiftvec[i_shift_offset+YY];
281         shZ              = shiftvec[i_shift_offset+ZZ];
282
283         /* Load limits for loop over neighbors */
284         j_index_start    = jindex[iidx];
285         j_index_end      = jindex[iidx+1];
286
287         /* Get outer coordinate index */
288         inr              = iinr[iidx];
289         i_coord_offset   = DIM*inr;
290
291         /* Load i particle coords and add shift vector */
292         ix0              = shX + x[i_coord_offset+DIM*0+XX];
293         iy0              = shY + x[i_coord_offset+DIM*0+YY];
294         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
295
296         fix0             = 0.0;
297         fiy0             = 0.0;
298         fiz0             = 0.0;
299
300         /* Load parameters for i particles */
301         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
302
303         /* Start inner kernel loop */
304         for(jidx=j_index_start; jidx<j_index_end; jidx++)
305         {
306             /* Get j neighbor index, and coordinate index */
307             jnr              = jjnr[jidx];
308             j_coord_offset   = DIM*jnr;
309
310             /* load j atom coordinates */
311             jx0              = x[j_coord_offset+DIM*0+XX];
312             jy0              = x[j_coord_offset+DIM*0+YY];
313             jz0              = x[j_coord_offset+DIM*0+ZZ];
314
315             /* Calculate displacement vector */
316             dx00             = ix0 - jx0;
317             dy00             = iy0 - jy0;
318             dz00             = iz0 - jz0;
319
320             /* Calculate squared distance and things based on it */
321             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
322
323             rinvsq00         = 1.0/rsq00;
324
325             /* Load parameters for j particles */
326             vdwjidx0         = 2*vdwtype[jnr+0];
327
328             /**************************
329              * CALCULATE INTERACTIONS *
330              **************************/
331
332             if (rsq00<rcutoff2)
333             {
334
335             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
336             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
337
338             /* LENNARD-JONES DISPERSION/REPULSION */
339
340             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
341             fvdw             = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
342
343             fscal            = fvdw;
344
345             /* Calculate temporary vectorial force */
346             tx               = fscal*dx00;
347             ty               = fscal*dy00;
348             tz               = fscal*dz00;
349
350             /* Update vectorial force */
351             fix0            += tx;
352             fiy0            += ty;
353             fiz0            += tz;
354             f[j_coord_offset+DIM*0+XX] -= tx;
355             f[j_coord_offset+DIM*0+YY] -= ty;
356             f[j_coord_offset+DIM*0+ZZ] -= tz;
357
358             }
359
360             /* Inner loop uses 27 flops */
361         }
362         /* End of innermost loop */
363
364         tx = ty = tz = 0;
365         f[i_coord_offset+DIM*0+XX] += fix0;
366         f[i_coord_offset+DIM*0+YY] += fiy0;
367         f[i_coord_offset+DIM*0+ZZ] += fiz0;
368         tx                         += fix0;
369         ty                         += fiy0;
370         tz                         += fiz0;
371         fshift[i_shift_offset+XX]  += tx;
372         fshift[i_shift_offset+YY]  += ty;
373         fshift[i_shift_offset+ZZ]  += tz;
374
375         /* Increment number of inner iterations */
376         inneriter                  += j_index_end - j_index_start;
377
378         /* Outer loop uses 12 flops */
379     }
380
381     /* Increment number of outer iterations */
382     outeriter        += nri;
383
384     /* Update outer/inner flops */
385
386     inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*27);
387 }