Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRF_VdwNone_GeomW4P1_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_ElecRF_VdwNone_GeomW4P1_VF_c
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            None
53  * Geometry:                   Water4-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRF_VdwNone_GeomW4P1_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              vdwioffset1;
73     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74     int              vdwioffset2;
75     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76     int              vdwioffset3;
77     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
78     int              vdwjidx0;
79     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
81     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
82     real             dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
83     real             velec,felec,velecsum,facel,crf,krf,krf2;
84     real             *charge;
85
86     x                = xx[0];
87     f                = ff[0];
88
89     nri              = nlist->nri;
90     iinr             = nlist->iinr;
91     jindex           = nlist->jindex;
92     jjnr             = nlist->jjnr;
93     shiftidx         = nlist->shift;
94     gid              = nlist->gid;
95     shiftvec         = fr->shift_vec[0];
96     fshift           = fr->fshift[0];
97     facel            = fr->epsfac;
98     charge           = mdatoms->chargeA;
99     krf              = fr->ic->k_rf;
100     krf2             = krf*2.0;
101     crf              = fr->ic->c_rf;
102
103     /* Setup water-specific parameters */
104     inr              = nlist->iinr[0];
105     iq1              = facel*charge[inr+1];
106     iq2              = facel*charge[inr+2];
107     iq3              = facel*charge[inr+3];
108
109     outeriter        = 0;
110     inneriter        = 0;
111
112     /* Start outer loop over neighborlists */
113     for(iidx=0; iidx<nri; iidx++)
114     {
115         /* Load shift vector for this list */
116         i_shift_offset   = DIM*shiftidx[iidx];
117         shX              = shiftvec[i_shift_offset+XX];
118         shY              = shiftvec[i_shift_offset+YY];
119         shZ              = shiftvec[i_shift_offset+ZZ];
120
121         /* Load limits for loop over neighbors */
122         j_index_start    = jindex[iidx];
123         j_index_end      = jindex[iidx+1];
124
125         /* Get outer coordinate index */
126         inr              = iinr[iidx];
127         i_coord_offset   = DIM*inr;
128
129         /* Load i particle coords and add shift vector */
130         ix1              = shX + x[i_coord_offset+DIM*1+XX];
131         iy1              = shY + x[i_coord_offset+DIM*1+YY];
132         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
133         ix2              = shX + x[i_coord_offset+DIM*2+XX];
134         iy2              = shY + x[i_coord_offset+DIM*2+YY];
135         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
136         ix3              = shX + x[i_coord_offset+DIM*3+XX];
137         iy3              = shY + x[i_coord_offset+DIM*3+YY];
138         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
139
140         fix1             = 0.0;
141         fiy1             = 0.0;
142         fiz1             = 0.0;
143         fix2             = 0.0;
144         fiy2             = 0.0;
145         fiz2             = 0.0;
146         fix3             = 0.0;
147         fiy3             = 0.0;
148         fiz3             = 0.0;
149
150         /* Reset potential sums */
151         velecsum         = 0.0;
152
153         /* Start inner kernel loop */
154         for(jidx=j_index_start; jidx<j_index_end; jidx++)
155         {
156             /* Get j neighbor index, and coordinate index */
157             jnr              = jjnr[jidx];
158             j_coord_offset   = DIM*jnr;
159
160             /* load j atom coordinates */
161             jx0              = x[j_coord_offset+DIM*0+XX];
162             jy0              = x[j_coord_offset+DIM*0+YY];
163             jz0              = x[j_coord_offset+DIM*0+ZZ];
164
165             /* Calculate displacement vector */
166             dx10             = ix1 - jx0;
167             dy10             = iy1 - jy0;
168             dz10             = iz1 - jz0;
169             dx20             = ix2 - jx0;
170             dy20             = iy2 - jy0;
171             dz20             = iz2 - jz0;
172             dx30             = ix3 - jx0;
173             dy30             = iy3 - jy0;
174             dz30             = iz3 - jz0;
175
176             /* Calculate squared distance and things based on it */
177             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
178             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
179             rsq30            = dx30*dx30+dy30*dy30+dz30*dz30;
180
181             rinv10           = gmx_invsqrt(rsq10);
182             rinv20           = gmx_invsqrt(rsq20);
183             rinv30           = gmx_invsqrt(rsq30);
184
185             rinvsq10         = rinv10*rinv10;
186             rinvsq20         = rinv20*rinv20;
187             rinvsq30         = rinv30*rinv30;
188
189             /* Load parameters for j particles */
190             jq0              = charge[jnr+0];
191
192             /**************************
193              * CALCULATE INTERACTIONS *
194              **************************/
195
196             qq10             = iq1*jq0;
197
198             /* REACTION-FIELD ELECTROSTATICS */
199             velec            = qq10*(rinv10+krf*rsq10-crf);
200             felec            = qq10*(rinv10*rinvsq10-krf2);
201
202             /* Update potential sums from outer loop */
203             velecsum        += velec;
204
205             fscal            = felec;
206
207             /* Calculate temporary vectorial force */
208             tx               = fscal*dx10;
209             ty               = fscal*dy10;
210             tz               = fscal*dz10;
211
212             /* Update vectorial force */
213             fix1            += tx;
214             fiy1            += ty;
215             fiz1            += tz;
216             f[j_coord_offset+DIM*0+XX] -= tx;
217             f[j_coord_offset+DIM*0+YY] -= ty;
218             f[j_coord_offset+DIM*0+ZZ] -= tz;
219
220             /**************************
221              * CALCULATE INTERACTIONS *
222              **************************/
223
224             qq20             = iq2*jq0;
225
226             /* REACTION-FIELD ELECTROSTATICS */
227             velec            = qq20*(rinv20+krf*rsq20-crf);
228             felec            = qq20*(rinv20*rinvsq20-krf2);
229
230             /* Update potential sums from outer loop */
231             velecsum        += velec;
232
233             fscal            = felec;
234
235             /* Calculate temporary vectorial force */
236             tx               = fscal*dx20;
237             ty               = fscal*dy20;
238             tz               = fscal*dz20;
239
240             /* Update vectorial force */
241             fix2            += tx;
242             fiy2            += ty;
243             fiz2            += tz;
244             f[j_coord_offset+DIM*0+XX] -= tx;
245             f[j_coord_offset+DIM*0+YY] -= ty;
246             f[j_coord_offset+DIM*0+ZZ] -= tz;
247
248             /**************************
249              * CALCULATE INTERACTIONS *
250              **************************/
251
252             qq30             = iq3*jq0;
253
254             /* REACTION-FIELD ELECTROSTATICS */
255             velec            = qq30*(rinv30+krf*rsq30-crf);
256             felec            = qq30*(rinv30*rinvsq30-krf2);
257
258             /* Update potential sums from outer loop */
259             velecsum        += velec;
260
261             fscal            = felec;
262
263             /* Calculate temporary vectorial force */
264             tx               = fscal*dx30;
265             ty               = fscal*dy30;
266             tz               = fscal*dz30;
267
268             /* Update vectorial force */
269             fix3            += tx;
270             fiy3            += ty;
271             fiz3            += tz;
272             f[j_coord_offset+DIM*0+XX] -= tx;
273             f[j_coord_offset+DIM*0+YY] -= ty;
274             f[j_coord_offset+DIM*0+ZZ] -= tz;
275
276             /* Inner loop uses 96 flops */
277         }
278         /* End of innermost loop */
279
280         tx = ty = tz = 0;
281         f[i_coord_offset+DIM*1+XX] += fix1;
282         f[i_coord_offset+DIM*1+YY] += fiy1;
283         f[i_coord_offset+DIM*1+ZZ] += fiz1;
284         tx                         += fix1;
285         ty                         += fiy1;
286         tz                         += fiz1;
287         f[i_coord_offset+DIM*2+XX] += fix2;
288         f[i_coord_offset+DIM*2+YY] += fiy2;
289         f[i_coord_offset+DIM*2+ZZ] += fiz2;
290         tx                         += fix2;
291         ty                         += fiy2;
292         tz                         += fiz2;
293         f[i_coord_offset+DIM*3+XX] += fix3;
294         f[i_coord_offset+DIM*3+YY] += fiy3;
295         f[i_coord_offset+DIM*3+ZZ] += fiz3;
296         tx                         += fix3;
297         ty                         += fiy3;
298         tz                         += fiz3;
299         fshift[i_shift_offset+XX]  += tx;
300         fshift[i_shift_offset+YY]  += ty;
301         fshift[i_shift_offset+ZZ]  += tz;
302
303         ggid                        = gid[iidx];
304         /* Update potential energies */
305         kernel_data->energygrp_elec[ggid] += velecsum;
306
307         /* Increment number of inner iterations */
308         inneriter                  += j_index_end - j_index_start;
309
310         /* Outer loop uses 31 flops */
311     }
312
313     /* Increment number of outer iterations */
314     outeriter        += nri;
315
316     /* Update outer/inner flops */
317
318     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*96);
319 }
320 /*
321  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomW4P1_F_c
322  * Electrostatics interaction: ReactionField
323  * VdW interaction:            None
324  * Geometry:                   Water4-Particle
325  * Calculate force/pot:        Force
326  */
327 void
328 nb_kernel_ElecRF_VdwNone_GeomW4P1_F_c
329                     (t_nblist                    * gmx_restrict       nlist,
330                      rvec                        * gmx_restrict          xx,
331                      rvec                        * gmx_restrict          ff,
332                      t_forcerec                  * gmx_restrict          fr,
333                      t_mdatoms                   * gmx_restrict     mdatoms,
334                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
335                      t_nrnb                      * gmx_restrict        nrnb)
336 {
337     int              i_shift_offset,i_coord_offset,j_coord_offset;
338     int              j_index_start,j_index_end;
339     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
340     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
341     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
342     real             *shiftvec,*fshift,*x,*f;
343     int              vdwioffset1;
344     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
345     int              vdwioffset2;
346     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
347     int              vdwioffset3;
348     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
349     int              vdwjidx0;
350     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
351     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
352     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
353     real             dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
354     real             velec,felec,velecsum,facel,crf,krf,krf2;
355     real             *charge;
356
357     x                = xx[0];
358     f                = ff[0];
359
360     nri              = nlist->nri;
361     iinr             = nlist->iinr;
362     jindex           = nlist->jindex;
363     jjnr             = nlist->jjnr;
364     shiftidx         = nlist->shift;
365     gid              = nlist->gid;
366     shiftvec         = fr->shift_vec[0];
367     fshift           = fr->fshift[0];
368     facel            = fr->epsfac;
369     charge           = mdatoms->chargeA;
370     krf              = fr->ic->k_rf;
371     krf2             = krf*2.0;
372     crf              = fr->ic->c_rf;
373
374     /* Setup water-specific parameters */
375     inr              = nlist->iinr[0];
376     iq1              = facel*charge[inr+1];
377     iq2              = facel*charge[inr+2];
378     iq3              = facel*charge[inr+3];
379
380     outeriter        = 0;
381     inneriter        = 0;
382
383     /* Start outer loop over neighborlists */
384     for(iidx=0; iidx<nri; iidx++)
385     {
386         /* Load shift vector for this list */
387         i_shift_offset   = DIM*shiftidx[iidx];
388         shX              = shiftvec[i_shift_offset+XX];
389         shY              = shiftvec[i_shift_offset+YY];
390         shZ              = shiftvec[i_shift_offset+ZZ];
391
392         /* Load limits for loop over neighbors */
393         j_index_start    = jindex[iidx];
394         j_index_end      = jindex[iidx+1];
395
396         /* Get outer coordinate index */
397         inr              = iinr[iidx];
398         i_coord_offset   = DIM*inr;
399
400         /* Load i particle coords and add shift vector */
401         ix1              = shX + x[i_coord_offset+DIM*1+XX];
402         iy1              = shY + x[i_coord_offset+DIM*1+YY];
403         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
404         ix2              = shX + x[i_coord_offset+DIM*2+XX];
405         iy2              = shY + x[i_coord_offset+DIM*2+YY];
406         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
407         ix3              = shX + x[i_coord_offset+DIM*3+XX];
408         iy3              = shY + x[i_coord_offset+DIM*3+YY];
409         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
410
411         fix1             = 0.0;
412         fiy1             = 0.0;
413         fiz1             = 0.0;
414         fix2             = 0.0;
415         fiy2             = 0.0;
416         fiz2             = 0.0;
417         fix3             = 0.0;
418         fiy3             = 0.0;
419         fiz3             = 0.0;
420
421         /* Start inner kernel loop */
422         for(jidx=j_index_start; jidx<j_index_end; jidx++)
423         {
424             /* Get j neighbor index, and coordinate index */
425             jnr              = jjnr[jidx];
426             j_coord_offset   = DIM*jnr;
427
428             /* load j atom coordinates */
429             jx0              = x[j_coord_offset+DIM*0+XX];
430             jy0              = x[j_coord_offset+DIM*0+YY];
431             jz0              = x[j_coord_offset+DIM*0+ZZ];
432
433             /* Calculate displacement vector */
434             dx10             = ix1 - jx0;
435             dy10             = iy1 - jy0;
436             dz10             = iz1 - jz0;
437             dx20             = ix2 - jx0;
438             dy20             = iy2 - jy0;
439             dz20             = iz2 - jz0;
440             dx30             = ix3 - jx0;
441             dy30             = iy3 - jy0;
442             dz30             = iz3 - jz0;
443
444             /* Calculate squared distance and things based on it */
445             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
446             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
447             rsq30            = dx30*dx30+dy30*dy30+dz30*dz30;
448
449             rinv10           = gmx_invsqrt(rsq10);
450             rinv20           = gmx_invsqrt(rsq20);
451             rinv30           = gmx_invsqrt(rsq30);
452
453             rinvsq10         = rinv10*rinv10;
454             rinvsq20         = rinv20*rinv20;
455             rinvsq30         = rinv30*rinv30;
456
457             /* Load parameters for j particles */
458             jq0              = charge[jnr+0];
459
460             /**************************
461              * CALCULATE INTERACTIONS *
462              **************************/
463
464             qq10             = iq1*jq0;
465
466             /* REACTION-FIELD ELECTROSTATICS */
467             felec            = qq10*(rinv10*rinvsq10-krf2);
468
469             fscal            = felec;
470
471             /* Calculate temporary vectorial force */
472             tx               = fscal*dx10;
473             ty               = fscal*dy10;
474             tz               = fscal*dz10;
475
476             /* Update vectorial force */
477             fix1            += tx;
478             fiy1            += ty;
479             fiz1            += tz;
480             f[j_coord_offset+DIM*0+XX] -= tx;
481             f[j_coord_offset+DIM*0+YY] -= ty;
482             f[j_coord_offset+DIM*0+ZZ] -= tz;
483
484             /**************************
485              * CALCULATE INTERACTIONS *
486              **************************/
487
488             qq20             = iq2*jq0;
489
490             /* REACTION-FIELD ELECTROSTATICS */
491             felec            = qq20*(rinv20*rinvsq20-krf2);
492
493             fscal            = felec;
494
495             /* Calculate temporary vectorial force */
496             tx               = fscal*dx20;
497             ty               = fscal*dy20;
498             tz               = fscal*dz20;
499
500             /* Update vectorial force */
501             fix2            += tx;
502             fiy2            += ty;
503             fiz2            += tz;
504             f[j_coord_offset+DIM*0+XX] -= tx;
505             f[j_coord_offset+DIM*0+YY] -= ty;
506             f[j_coord_offset+DIM*0+ZZ] -= tz;
507
508             /**************************
509              * CALCULATE INTERACTIONS *
510              **************************/
511
512             qq30             = iq3*jq0;
513
514             /* REACTION-FIELD ELECTROSTATICS */
515             felec            = qq30*(rinv30*rinvsq30-krf2);
516
517             fscal            = felec;
518
519             /* Calculate temporary vectorial force */
520             tx               = fscal*dx30;
521             ty               = fscal*dy30;
522             tz               = fscal*dz30;
523
524             /* Update vectorial force */
525             fix3            += tx;
526             fiy3            += ty;
527             fiz3            += tz;
528             f[j_coord_offset+DIM*0+XX] -= tx;
529             f[j_coord_offset+DIM*0+YY] -= ty;
530             f[j_coord_offset+DIM*0+ZZ] -= tz;
531
532             /* Inner loop uses 81 flops */
533         }
534         /* End of innermost loop */
535
536         tx = ty = tz = 0;
537         f[i_coord_offset+DIM*1+XX] += fix1;
538         f[i_coord_offset+DIM*1+YY] += fiy1;
539         f[i_coord_offset+DIM*1+ZZ] += fiz1;
540         tx                         += fix1;
541         ty                         += fiy1;
542         tz                         += fiz1;
543         f[i_coord_offset+DIM*2+XX] += fix2;
544         f[i_coord_offset+DIM*2+YY] += fiy2;
545         f[i_coord_offset+DIM*2+ZZ] += fiz2;
546         tx                         += fix2;
547         ty                         += fiy2;
548         tz                         += fiz2;
549         f[i_coord_offset+DIM*3+XX] += fix3;
550         f[i_coord_offset+DIM*3+YY] += fiy3;
551         f[i_coord_offset+DIM*3+ZZ] += fiz3;
552         tx                         += fix3;
553         ty                         += fiy3;
554         tz                         += fiz3;
555         fshift[i_shift_offset+XX]  += tx;
556         fshift[i_shift_offset+YY]  += ty;
557         fshift[i_shift_offset+ZZ]  += tz;
558
559         /* Increment number of inner iterations */
560         inneriter                  += j_index_end - j_index_start;
561
562         /* Outer loop uses 30 flops */
563     }
564
565     /* Increment number of outer iterations */
566     outeriter        += nri;
567
568     /* Update outer/inner flops */
569
570     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*81);
571 }