2 * This file is part of the GROMACS molecular simulation package.
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.
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.
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.
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.
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.
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.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3P1_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_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)
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;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
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;
84 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
99 charge = mdatoms->chargeA;
101 sh_ewald = fr->ic->sh_ewald;
102 ewtab = fr->ic->tabq_coul_FDV0;
103 ewtabscale = fr->ic->tabq_scale;
104 ewtabhalfspace = 0.5/ewtabscale;
106 /* Setup water-specific parameters */
107 inr = nlist->iinr[0];
108 iq0 = facel*charge[inr+0];
109 iq1 = facel*charge[inr+1];
110 iq2 = facel*charge[inr+2];
112 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
113 rcutoff = fr->rcoulomb;
114 rcutoff2 = rcutoff*rcutoff;
119 /* Start outer loop over neighborlists */
120 for(iidx=0; iidx<nri; iidx++)
122 /* Load shift vector for this list */
123 i_shift_offset = DIM*shiftidx[iidx];
124 shX = shiftvec[i_shift_offset+XX];
125 shY = shiftvec[i_shift_offset+YY];
126 shZ = shiftvec[i_shift_offset+ZZ];
128 /* Load limits for loop over neighbors */
129 j_index_start = jindex[iidx];
130 j_index_end = jindex[iidx+1];
132 /* Get outer coordinate index */
134 i_coord_offset = DIM*inr;
136 /* Load i particle coords and add shift vector */
137 ix0 = shX + x[i_coord_offset+DIM*0+XX];
138 iy0 = shY + x[i_coord_offset+DIM*0+YY];
139 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
140 ix1 = shX + x[i_coord_offset+DIM*1+XX];
141 iy1 = shY + x[i_coord_offset+DIM*1+YY];
142 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
143 ix2 = shX + x[i_coord_offset+DIM*2+XX];
144 iy2 = shY + x[i_coord_offset+DIM*2+YY];
145 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
157 /* Reset potential sums */
160 /* Start inner kernel loop */
161 for(jidx=j_index_start; jidx<j_index_end; jidx++)
163 /* Get j neighbor index, and coordinate index */
165 j_coord_offset = DIM*jnr;
167 /* load j atom coordinates */
168 jx0 = x[j_coord_offset+DIM*0+XX];
169 jy0 = x[j_coord_offset+DIM*0+YY];
170 jz0 = x[j_coord_offset+DIM*0+ZZ];
172 /* Calculate displacement vector */
183 /* Calculate squared distance and things based on it */
184 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
185 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
186 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
188 rinv00 = gmx_invsqrt(rsq00);
189 rinv10 = gmx_invsqrt(rsq10);
190 rinv20 = gmx_invsqrt(rsq20);
192 rinvsq00 = rinv00*rinv00;
193 rinvsq10 = rinv10*rinv10;
194 rinvsq20 = rinv20*rinv20;
196 /* Load parameters for j particles */
199 /**************************
200 * CALCULATE INTERACTIONS *
201 **************************/
210 /* EWALD ELECTROSTATICS */
212 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
213 ewrt = r00*ewtabscale;
217 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
218 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
219 felec = qq00*rinv00*(rinvsq00-felec);
221 /* Update potential sums from outer loop */
226 /* Calculate temporary vectorial force */
231 /* Update vectorial force */
235 f[j_coord_offset+DIM*0+XX] -= tx;
236 f[j_coord_offset+DIM*0+YY] -= ty;
237 f[j_coord_offset+DIM*0+ZZ] -= tz;
241 /**************************
242 * CALCULATE INTERACTIONS *
243 **************************/
252 /* EWALD ELECTROSTATICS */
254 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
255 ewrt = r10*ewtabscale;
259 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
260 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
261 felec = qq10*rinv10*(rinvsq10-felec);
263 /* Update potential sums from outer loop */
268 /* Calculate temporary vectorial force */
273 /* Update vectorial force */
277 f[j_coord_offset+DIM*0+XX] -= tx;
278 f[j_coord_offset+DIM*0+YY] -= ty;
279 f[j_coord_offset+DIM*0+ZZ] -= tz;
283 /**************************
284 * CALCULATE INTERACTIONS *
285 **************************/
294 /* EWALD ELECTROSTATICS */
296 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
297 ewrt = r20*ewtabscale;
301 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
302 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
303 felec = qq20*rinv20*(rinvsq20-felec);
305 /* Update potential sums from outer loop */
310 /* Calculate temporary vectorial force */
315 /* Update vectorial force */
319 f[j_coord_offset+DIM*0+XX] -= tx;
320 f[j_coord_offset+DIM*0+YY] -= ty;
321 f[j_coord_offset+DIM*0+ZZ] -= tz;
325 /* Inner loop uses 126 flops */
327 /* End of innermost loop */
330 f[i_coord_offset+DIM*0+XX] += fix0;
331 f[i_coord_offset+DIM*0+YY] += fiy0;
332 f[i_coord_offset+DIM*0+ZZ] += fiz0;
336 f[i_coord_offset+DIM*1+XX] += fix1;
337 f[i_coord_offset+DIM*1+YY] += fiy1;
338 f[i_coord_offset+DIM*1+ZZ] += fiz1;
342 f[i_coord_offset+DIM*2+XX] += fix2;
343 f[i_coord_offset+DIM*2+YY] += fiy2;
344 f[i_coord_offset+DIM*2+ZZ] += fiz2;
348 fshift[i_shift_offset+XX] += tx;
349 fshift[i_shift_offset+YY] += ty;
350 fshift[i_shift_offset+ZZ] += tz;
353 /* Update potential energies */
354 kernel_data->energygrp_elec[ggid] += velecsum;
356 /* Increment number of inner iterations */
357 inneriter += j_index_end - j_index_start;
359 /* Outer loop uses 31 flops */
362 /* Increment number of outer iterations */
365 /* Update outer/inner flops */
367 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*126);
370 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_c
371 * Electrostatics interaction: Ewald
372 * VdW interaction: None
373 * Geometry: Water3-Particle
374 * Calculate force/pot: Force
377 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_c
378 (t_nblist * gmx_restrict nlist,
379 rvec * gmx_restrict xx,
380 rvec * gmx_restrict ff,
381 t_forcerec * gmx_restrict fr,
382 t_mdatoms * gmx_restrict mdatoms,
383 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
384 t_nrnb * gmx_restrict nrnb)
386 int i_shift_offset,i_coord_offset,j_coord_offset;
387 int j_index_start,j_index_end;
388 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
389 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
390 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
391 real *shiftvec,*fshift,*x,*f;
393 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
395 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
397 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
399 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
400 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
401 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
402 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
403 real velec,felec,velecsum,facel,crf,krf,krf2;
406 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
414 jindex = nlist->jindex;
416 shiftidx = nlist->shift;
418 shiftvec = fr->shift_vec[0];
419 fshift = fr->fshift[0];
421 charge = mdatoms->chargeA;
423 sh_ewald = fr->ic->sh_ewald;
424 ewtab = fr->ic->tabq_coul_F;
425 ewtabscale = fr->ic->tabq_scale;
426 ewtabhalfspace = 0.5/ewtabscale;
428 /* Setup water-specific parameters */
429 inr = nlist->iinr[0];
430 iq0 = facel*charge[inr+0];
431 iq1 = facel*charge[inr+1];
432 iq2 = facel*charge[inr+2];
434 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
435 rcutoff = fr->rcoulomb;
436 rcutoff2 = rcutoff*rcutoff;
441 /* Start outer loop over neighborlists */
442 for(iidx=0; iidx<nri; iidx++)
444 /* Load shift vector for this list */
445 i_shift_offset = DIM*shiftidx[iidx];
446 shX = shiftvec[i_shift_offset+XX];
447 shY = shiftvec[i_shift_offset+YY];
448 shZ = shiftvec[i_shift_offset+ZZ];
450 /* Load limits for loop over neighbors */
451 j_index_start = jindex[iidx];
452 j_index_end = jindex[iidx+1];
454 /* Get outer coordinate index */
456 i_coord_offset = DIM*inr;
458 /* Load i particle coords and add shift vector */
459 ix0 = shX + x[i_coord_offset+DIM*0+XX];
460 iy0 = shY + x[i_coord_offset+DIM*0+YY];
461 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
462 ix1 = shX + x[i_coord_offset+DIM*1+XX];
463 iy1 = shY + x[i_coord_offset+DIM*1+YY];
464 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
465 ix2 = shX + x[i_coord_offset+DIM*2+XX];
466 iy2 = shY + x[i_coord_offset+DIM*2+YY];
467 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
479 /* Start inner kernel loop */
480 for(jidx=j_index_start; jidx<j_index_end; jidx++)
482 /* Get j neighbor index, and coordinate index */
484 j_coord_offset = DIM*jnr;
486 /* load j atom coordinates */
487 jx0 = x[j_coord_offset+DIM*0+XX];
488 jy0 = x[j_coord_offset+DIM*0+YY];
489 jz0 = x[j_coord_offset+DIM*0+ZZ];
491 /* Calculate displacement vector */
502 /* Calculate squared distance and things based on it */
503 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
504 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
505 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
507 rinv00 = gmx_invsqrt(rsq00);
508 rinv10 = gmx_invsqrt(rsq10);
509 rinv20 = gmx_invsqrt(rsq20);
511 rinvsq00 = rinv00*rinv00;
512 rinvsq10 = rinv10*rinv10;
513 rinvsq20 = rinv20*rinv20;
515 /* Load parameters for j particles */
518 /**************************
519 * CALCULATE INTERACTIONS *
520 **************************/
529 /* EWALD ELECTROSTATICS */
531 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
532 ewrt = r00*ewtabscale;
535 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
536 felec = qq00*rinv00*(rinvsq00-felec);
540 /* Calculate temporary vectorial force */
545 /* Update vectorial force */
549 f[j_coord_offset+DIM*0+XX] -= tx;
550 f[j_coord_offset+DIM*0+YY] -= ty;
551 f[j_coord_offset+DIM*0+ZZ] -= tz;
555 /**************************
556 * CALCULATE INTERACTIONS *
557 **************************/
566 /* EWALD ELECTROSTATICS */
568 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
569 ewrt = r10*ewtabscale;
572 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
573 felec = qq10*rinv10*(rinvsq10-felec);
577 /* Calculate temporary vectorial force */
582 /* Update vectorial force */
586 f[j_coord_offset+DIM*0+XX] -= tx;
587 f[j_coord_offset+DIM*0+YY] -= ty;
588 f[j_coord_offset+DIM*0+ZZ] -= tz;
592 /**************************
593 * CALCULATE INTERACTIONS *
594 **************************/
603 /* EWALD ELECTROSTATICS */
605 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
606 ewrt = r20*ewtabscale;
609 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
610 felec = qq20*rinv20*(rinvsq20-felec);
614 /* Calculate temporary vectorial force */
619 /* Update vectorial force */
623 f[j_coord_offset+DIM*0+XX] -= tx;
624 f[j_coord_offset+DIM*0+YY] -= ty;
625 f[j_coord_offset+DIM*0+ZZ] -= tz;
629 /* Inner loop uses 102 flops */
631 /* End of innermost loop */
634 f[i_coord_offset+DIM*0+XX] += fix0;
635 f[i_coord_offset+DIM*0+YY] += fiy0;
636 f[i_coord_offset+DIM*0+ZZ] += fiz0;
640 f[i_coord_offset+DIM*1+XX] += fix1;
641 f[i_coord_offset+DIM*1+YY] += fiy1;
642 f[i_coord_offset+DIM*1+ZZ] += fiz1;
646 f[i_coord_offset+DIM*2+XX] += fix2;
647 f[i_coord_offset+DIM*2+YY] += fiy2;
648 f[i_coord_offset+DIM*2+ZZ] += fiz2;
652 fshift[i_shift_offset+XX] += tx;
653 fshift[i_shift_offset+YY] += ty;
654 fshift[i_shift_offset+ZZ] += tz;
656 /* Increment number of inner iterations */
657 inneriter += j_index_end - j_index_start;
659 /* Outer loop uses 30 flops */
662 /* Increment number of outer iterations */
665 /* Update outer/inner flops */
667 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*102);