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