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