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