Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwNone_GeomP1P1_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_ElecCSTab_VdwNone_GeomP1P1_VF_c
51  * Electrostatics interaction: CubicSplineTable
52  * VdW interaction:            None
53  * Geometry:                   Particle-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecCSTab_VdwNone_GeomP1P1_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              vdwjidx0;
75     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
77     real             velec,felec,velecsum,facel,crf,krf,krf2;
78     real             *charge;
79     int              vfitab;
80     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
81     real             *vftab;
82
83     x                = xx[0];
84     f                = ff[0];
85
86     nri              = nlist->nri;
87     iinr             = nlist->iinr;
88     jindex           = nlist->jindex;
89     jjnr             = nlist->jjnr;
90     shiftidx         = nlist->shift;
91     gid              = nlist->gid;
92     shiftvec         = fr->shift_vec[0];
93     fshift           = fr->fshift[0];
94     facel            = fr->epsfac;
95     charge           = mdatoms->chargeA;
96
97     vftab            = kernel_data->table_elec->data;
98     vftabscale       = kernel_data->table_elec->scale;
99
100     outeriter        = 0;
101     inneriter        = 0;
102
103     /* Start outer loop over neighborlists */
104     for(iidx=0; iidx<nri; iidx++)
105     {
106         /* Load shift vector for this list */
107         i_shift_offset   = DIM*shiftidx[iidx];
108         shX              = shiftvec[i_shift_offset+XX];
109         shY              = shiftvec[i_shift_offset+YY];
110         shZ              = shiftvec[i_shift_offset+ZZ];
111
112         /* Load limits for loop over neighbors */
113         j_index_start    = jindex[iidx];
114         j_index_end      = jindex[iidx+1];
115
116         /* Get outer coordinate index */
117         inr              = iinr[iidx];
118         i_coord_offset   = DIM*inr;
119
120         /* Load i particle coords and add shift vector */
121         ix0              = shX + x[i_coord_offset+DIM*0+XX];
122         iy0              = shY + x[i_coord_offset+DIM*0+YY];
123         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
124
125         fix0             = 0.0;
126         fiy0             = 0.0;
127         fiz0             = 0.0;
128
129         /* Load parameters for i particles */
130         iq0              = facel*charge[inr+0];
131
132         /* Reset potential sums */
133         velecsum         = 0.0;
134
135         /* Start inner kernel loop */
136         for(jidx=j_index_start; jidx<j_index_end; jidx++)
137         {
138             /* Get j neighbor index, and coordinate index */
139             jnr              = jjnr[jidx];
140             j_coord_offset   = DIM*jnr;
141
142             /* load j atom coordinates */
143             jx0              = x[j_coord_offset+DIM*0+XX];
144             jy0              = x[j_coord_offset+DIM*0+YY];
145             jz0              = x[j_coord_offset+DIM*0+ZZ];
146
147             /* Calculate displacement vector */
148             dx00             = ix0 - jx0;
149             dy00             = iy0 - jy0;
150             dz00             = iz0 - jz0;
151
152             /* Calculate squared distance and things based on it */
153             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
154
155             rinv00           = gmx_invsqrt(rsq00);
156
157             /* Load parameters for j particles */
158             jq0              = charge[jnr+0];
159
160             /**************************
161              * CALCULATE INTERACTIONS *
162              **************************/
163
164             r00              = rsq00*rinv00;
165
166             qq00             = iq0*jq0;
167
168             /* Calculate table index by multiplying r with table scale and truncate to integer */
169             rt               = r00*vftabscale;
170             vfitab           = rt;
171             vfeps            = rt-vfitab;
172             vfitab           = 1*4*vfitab;
173
174             /* CUBIC SPLINE TABLE ELECTROSTATICS */
175             Y                = vftab[vfitab];
176             F                = vftab[vfitab+1];
177             Geps             = vfeps*vftab[vfitab+2];
178             Heps2            = vfeps*vfeps*vftab[vfitab+3];
179             Fp               = F+Geps+Heps2;
180             VV               = Y+vfeps*Fp;
181             velec            = qq00*VV;
182             FF               = Fp+Geps+2.0*Heps2;
183             felec            = -qq00*FF*vftabscale*rinv00;
184
185             /* Update potential sums from outer loop */
186             velecsum        += velec;
187
188             fscal            = felec;
189
190             /* Calculate temporary vectorial force */
191             tx               = fscal*dx00;
192             ty               = fscal*dy00;
193             tz               = fscal*dz00;
194
195             /* Update vectorial force */
196             fix0            += tx;
197             fiy0            += ty;
198             fiz0            += tz;
199             f[j_coord_offset+DIM*0+XX] -= tx;
200             f[j_coord_offset+DIM*0+YY] -= ty;
201             f[j_coord_offset+DIM*0+ZZ] -= tz;
202
203             /* Inner loop uses 42 flops */
204         }
205         /* End of innermost loop */
206
207         tx = ty = tz = 0;
208         f[i_coord_offset+DIM*0+XX] += fix0;
209         f[i_coord_offset+DIM*0+YY] += fiy0;
210         f[i_coord_offset+DIM*0+ZZ] += fiz0;
211         tx                         += fix0;
212         ty                         += fiy0;
213         tz                         += fiz0;
214         fshift[i_shift_offset+XX]  += tx;
215         fshift[i_shift_offset+YY]  += ty;
216         fshift[i_shift_offset+ZZ]  += tz;
217
218         ggid                        = gid[iidx];
219         /* Update potential energies */
220         kernel_data->energygrp_elec[ggid] += velecsum;
221
222         /* Increment number of inner iterations */
223         inneriter                  += j_index_end - j_index_start;
224
225         /* Outer loop uses 14 flops */
226     }
227
228     /* Increment number of outer iterations */
229     outeriter        += nri;
230
231     /* Update outer/inner flops */
232
233     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*14 + inneriter*42);
234 }
235 /*
236  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomP1P1_F_c
237  * Electrostatics interaction: CubicSplineTable
238  * VdW interaction:            None
239  * Geometry:                   Particle-Particle
240  * Calculate force/pot:        Force
241  */
242 void
243 nb_kernel_ElecCSTab_VdwNone_GeomP1P1_F_c
244                     (t_nblist                    * gmx_restrict       nlist,
245                      rvec                        * gmx_restrict          xx,
246                      rvec                        * gmx_restrict          ff,
247                      t_forcerec                  * gmx_restrict          fr,
248                      t_mdatoms                   * gmx_restrict     mdatoms,
249                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
250                      t_nrnb                      * gmx_restrict        nrnb)
251 {
252     int              i_shift_offset,i_coord_offset,j_coord_offset;
253     int              j_index_start,j_index_end;
254     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
255     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
256     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
257     real             *shiftvec,*fshift,*x,*f;
258     int              vdwioffset0;
259     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
260     int              vdwjidx0;
261     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
262     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
263     real             velec,felec,velecsum,facel,crf,krf,krf2;
264     real             *charge;
265     int              vfitab;
266     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
267     real             *vftab;
268
269     x                = xx[0];
270     f                = ff[0];
271
272     nri              = nlist->nri;
273     iinr             = nlist->iinr;
274     jindex           = nlist->jindex;
275     jjnr             = nlist->jjnr;
276     shiftidx         = nlist->shift;
277     gid              = nlist->gid;
278     shiftvec         = fr->shift_vec[0];
279     fshift           = fr->fshift[0];
280     facel            = fr->epsfac;
281     charge           = mdatoms->chargeA;
282
283     vftab            = kernel_data->table_elec->data;
284     vftabscale       = kernel_data->table_elec->scale;
285
286     outeriter        = 0;
287     inneriter        = 0;
288
289     /* Start outer loop over neighborlists */
290     for(iidx=0; iidx<nri; iidx++)
291     {
292         /* Load shift vector for this list */
293         i_shift_offset   = DIM*shiftidx[iidx];
294         shX              = shiftvec[i_shift_offset+XX];
295         shY              = shiftvec[i_shift_offset+YY];
296         shZ              = shiftvec[i_shift_offset+ZZ];
297
298         /* Load limits for loop over neighbors */
299         j_index_start    = jindex[iidx];
300         j_index_end      = jindex[iidx+1];
301
302         /* Get outer coordinate index */
303         inr              = iinr[iidx];
304         i_coord_offset   = DIM*inr;
305
306         /* Load i particle coords and add shift vector */
307         ix0              = shX + x[i_coord_offset+DIM*0+XX];
308         iy0              = shY + x[i_coord_offset+DIM*0+YY];
309         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
310
311         fix0             = 0.0;
312         fiy0             = 0.0;
313         fiz0             = 0.0;
314
315         /* Load parameters for i particles */
316         iq0              = facel*charge[inr+0];
317
318         /* Start inner kernel loop */
319         for(jidx=j_index_start; jidx<j_index_end; jidx++)
320         {
321             /* Get j neighbor index, and coordinate index */
322             jnr              = jjnr[jidx];
323             j_coord_offset   = DIM*jnr;
324
325             /* load j atom coordinates */
326             jx0              = x[j_coord_offset+DIM*0+XX];
327             jy0              = x[j_coord_offset+DIM*0+YY];
328             jz0              = x[j_coord_offset+DIM*0+ZZ];
329
330             /* Calculate displacement vector */
331             dx00             = ix0 - jx0;
332             dy00             = iy0 - jy0;
333             dz00             = iz0 - jz0;
334
335             /* Calculate squared distance and things based on it */
336             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
337
338             rinv00           = gmx_invsqrt(rsq00);
339
340             /* Load parameters for j particles */
341             jq0              = charge[jnr+0];
342
343             /**************************
344              * CALCULATE INTERACTIONS *
345              **************************/
346
347             r00              = rsq00*rinv00;
348
349             qq00             = iq0*jq0;
350
351             /* Calculate table index by multiplying r with table scale and truncate to integer */
352             rt               = r00*vftabscale;
353             vfitab           = rt;
354             vfeps            = rt-vfitab;
355             vfitab           = 1*4*vfitab;
356
357             /* CUBIC SPLINE TABLE ELECTROSTATICS */
358             F                = vftab[vfitab+1];
359             Geps             = vfeps*vftab[vfitab+2];
360             Heps2            = vfeps*vfeps*vftab[vfitab+3];
361             Fp               = F+Geps+Heps2;
362             FF               = Fp+Geps+2.0*Heps2;
363             felec            = -qq00*FF*vftabscale*rinv00;
364
365             fscal            = felec;
366
367             /* Calculate temporary vectorial force */
368             tx               = fscal*dx00;
369             ty               = fscal*dy00;
370             tz               = fscal*dz00;
371
372             /* Update vectorial force */
373             fix0            += tx;
374             fiy0            += ty;
375             fiz0            += tz;
376             f[j_coord_offset+DIM*0+XX] -= tx;
377             f[j_coord_offset+DIM*0+YY] -= ty;
378             f[j_coord_offset+DIM*0+ZZ] -= tz;
379
380             /* Inner loop uses 38 flops */
381         }
382         /* End of innermost loop */
383
384         tx = ty = tz = 0;
385         f[i_coord_offset+DIM*0+XX] += fix0;
386         f[i_coord_offset+DIM*0+YY] += fiy0;
387         f[i_coord_offset+DIM*0+ZZ] += fiz0;
388         tx                         += fix0;
389         ty                         += fiy0;
390         tz                         += fiz0;
391         fshift[i_shift_offset+XX]  += tx;
392         fshift[i_shift_offset+YY]  += ty;
393         fshift[i_shift_offset+ZZ]  += tz;
394
395         /* Increment number of inner iterations */
396         inneriter                  += j_index_end - j_index_start;
397
398         /* Outer loop uses 13 flops */
399     }
400
401     /* Increment number of outer iterations */
402     outeriter        += nri;
403
404     /* Update outer/inner flops */
405
406     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*38);
407 }