Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRF_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_ElecRF_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_ElecRF_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     outeriter        = 0;
96     inneriter        = 0;
97
98     /* Start outer loop over neighborlists */
99     for(iidx=0; iidx<nri; iidx++)
100     {
101         /* Load shift vector for this list */
102         i_shift_offset   = DIM*shiftidx[iidx];
103         shX              = shiftvec[i_shift_offset+XX];
104         shY              = shiftvec[i_shift_offset+YY];
105         shZ              = shiftvec[i_shift_offset+ZZ];
106
107         /* Load limits for loop over neighbors */
108         j_index_start    = jindex[iidx];
109         j_index_end      = jindex[iidx+1];
110
111         /* Get outer coordinate index */
112         inr              = iinr[iidx];
113         i_coord_offset   = DIM*inr;
114
115         /* Load i particle coords and add shift vector */
116         ix0              = shX + x[i_coord_offset+DIM*0+XX];
117         iy0              = shY + x[i_coord_offset+DIM*0+YY];
118         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
119
120         fix0             = 0.0;
121         fiy0             = 0.0;
122         fiz0             = 0.0;
123
124         /* Load parameters for i particles */
125         iq0              = facel*charge[inr+0];
126
127         /* Reset potential sums */
128         velecsum         = 0.0;
129
130         /* Start inner kernel loop */
131         for(jidx=j_index_start; jidx<j_index_end; jidx++)
132         {
133             /* Get j neighbor index, and coordinate index */
134             jnr              = jjnr[jidx];
135             j_coord_offset   = DIM*jnr;
136
137             /* load j atom coordinates */
138             jx0              = x[j_coord_offset+DIM*0+XX];
139             jy0              = x[j_coord_offset+DIM*0+YY];
140             jz0              = x[j_coord_offset+DIM*0+ZZ];
141
142             /* Calculate displacement vector */
143             dx00             = ix0 - jx0;
144             dy00             = iy0 - jy0;
145             dz00             = iz0 - jz0;
146
147             /* Calculate squared distance and things based on it */
148             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
149
150             rinv00           = gmx_invsqrt(rsq00);
151
152             rinvsq00         = rinv00*rinv00;
153
154             /* Load parameters for j particles */
155             jq0              = charge[jnr+0];
156
157             /**************************
158              * CALCULATE INTERACTIONS *
159              **************************/
160
161             qq00             = iq0*jq0;
162
163             /* REACTION-FIELD ELECTROSTATICS */
164             velec            = qq00*(rinv00+krf*rsq00-crf);
165             felec            = qq00*(rinv00*rinvsq00-krf2);
166
167             /* Update potential sums from outer loop */
168             velecsum        += velec;
169
170             fscal            = felec;
171
172             /* Calculate temporary vectorial force */
173             tx               = fscal*dx00;
174             ty               = fscal*dy00;
175             tz               = fscal*dz00;
176
177             /* Update vectorial force */
178             fix0            += tx;
179             fiy0            += ty;
180             fiz0            += tz;
181             f[j_coord_offset+DIM*0+XX] -= tx;
182             f[j_coord_offset+DIM*0+YY] -= ty;
183             f[j_coord_offset+DIM*0+ZZ] -= tz;
184
185             /* Inner loop uses 32 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_elec[ggid] += velecsum;
203
204         /* Increment number of inner iterations */
205         inneriter                  += j_index_end - j_index_start;
206
207         /* Outer loop uses 14 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_ELEC_VF,outeriter*14 + inneriter*32);
216 }
217 /*
218  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomP1P1_F_c
219  * Electrostatics interaction: ReactionField
220  * VdW interaction:            None
221  * Geometry:                   Particle-Particle
222  * Calculate force/pot:        Force
223  */
224 void
225 nb_kernel_ElecRF_VdwNone_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_unused * 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     real             velec,felec,velecsum,facel,crf,krf,krf2;
246     real             *charge;
247
248     x                = xx[0];
249     f                = ff[0];
250
251     nri              = nlist->nri;
252     iinr             = nlist->iinr;
253     jindex           = nlist->jindex;
254     jjnr             = nlist->jjnr;
255     shiftidx         = nlist->shift;
256     gid              = nlist->gid;
257     shiftvec         = fr->shift_vec[0];
258     fshift           = fr->fshift[0];
259     facel            = fr->epsfac;
260     charge           = mdatoms->chargeA;
261     krf              = fr->ic->k_rf;
262     krf2             = krf*2.0;
263     crf              = fr->ic->c_rf;
264
265     outeriter        = 0;
266     inneriter        = 0;
267
268     /* Start outer loop over neighborlists */
269     for(iidx=0; iidx<nri; iidx++)
270     {
271         /* Load shift vector for this list */
272         i_shift_offset   = DIM*shiftidx[iidx];
273         shX              = shiftvec[i_shift_offset+XX];
274         shY              = shiftvec[i_shift_offset+YY];
275         shZ              = shiftvec[i_shift_offset+ZZ];
276
277         /* Load limits for loop over neighbors */
278         j_index_start    = jindex[iidx];
279         j_index_end      = jindex[iidx+1];
280
281         /* Get outer coordinate index */
282         inr              = iinr[iidx];
283         i_coord_offset   = DIM*inr;
284
285         /* Load i particle coords and add shift vector */
286         ix0              = shX + x[i_coord_offset+DIM*0+XX];
287         iy0              = shY + x[i_coord_offset+DIM*0+YY];
288         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
289
290         fix0             = 0.0;
291         fiy0             = 0.0;
292         fiz0             = 0.0;
293
294         /* Load parameters for i particles */
295         iq0              = facel*charge[inr+0];
296
297         /* Start inner kernel loop */
298         for(jidx=j_index_start; jidx<j_index_end; jidx++)
299         {
300             /* Get j neighbor index, and coordinate index */
301             jnr              = jjnr[jidx];
302             j_coord_offset   = DIM*jnr;
303
304             /* load j atom coordinates */
305             jx0              = x[j_coord_offset+DIM*0+XX];
306             jy0              = x[j_coord_offset+DIM*0+YY];
307             jz0              = x[j_coord_offset+DIM*0+ZZ];
308
309             /* Calculate displacement vector */
310             dx00             = ix0 - jx0;
311             dy00             = iy0 - jy0;
312             dz00             = iz0 - jz0;
313
314             /* Calculate squared distance and things based on it */
315             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
316
317             rinv00           = gmx_invsqrt(rsq00);
318
319             rinvsq00         = rinv00*rinv00;
320
321             /* Load parameters for j particles */
322             jq0              = charge[jnr+0];
323
324             /**************************
325              * CALCULATE INTERACTIONS *
326              **************************/
327
328             qq00             = iq0*jq0;
329
330             /* REACTION-FIELD ELECTROSTATICS */
331             felec            = qq00*(rinv00*rinvsq00-krf2);
332
333             fscal            = felec;
334
335             /* Calculate temporary vectorial force */
336             tx               = fscal*dx00;
337             ty               = fscal*dy00;
338             tz               = fscal*dz00;
339
340             /* Update vectorial force */
341             fix0            += tx;
342             fiy0            += ty;
343             fiz0            += tz;
344             f[j_coord_offset+DIM*0+XX] -= tx;
345             f[j_coord_offset+DIM*0+YY] -= ty;
346             f[j_coord_offset+DIM*0+ZZ] -= tz;
347
348             /* Inner loop uses 27 flops */
349         }
350         /* End of innermost loop */
351
352         tx = ty = tz = 0;
353         f[i_coord_offset+DIM*0+XX] += fix0;
354         f[i_coord_offset+DIM*0+YY] += fiy0;
355         f[i_coord_offset+DIM*0+ZZ] += fiz0;
356         tx                         += fix0;
357         ty                         += fiy0;
358         tz                         += fiz0;
359         fshift[i_shift_offset+XX]  += tx;
360         fshift[i_shift_offset+YY]  += ty;
361         fshift[i_shift_offset+ZZ]  += tz;
362
363         /* Increment number of inner iterations */
364         inneriter                  += j_index_end - j_index_start;
365
366         /* Outer loop uses 13 flops */
367     }
368
369     /* Increment number of outer iterations */
370     outeriter        += nri;
371
372     /* Update outer/inner flops */
373
374     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*27);
375 }