2 * This file is part of the GROMACS molecular simulation package.
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.
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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_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)
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;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
86 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
94 jindex = nlist->jindex;
96 shiftidx = nlist->shift;
98 shiftvec = fr->shift_vec[0];
99 fshift = fr->fshift[0];
101 charge = mdatoms->chargeA;
103 sh_ewald = fr->ic->sh_ewald;
104 ewtab = fr->ic->tabq_coul_FDV0;
105 ewtabscale = fr->ic->tabq_scale;
106 ewtabhalfspace = 0.5/ewtabscale;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 iq3 = facel*charge[inr+3];
114 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
115 rcutoff = fr->rcoulomb;
116 rcutoff2 = rcutoff*rcutoff;
121 /* Start outer loop over neighborlists */
122 for(iidx=0; iidx<nri; iidx++)
124 /* Load shift vector for this list */
125 i_shift_offset = DIM*shiftidx[iidx];
126 shX = shiftvec[i_shift_offset+XX];
127 shY = shiftvec[i_shift_offset+YY];
128 shZ = shiftvec[i_shift_offset+ZZ];
130 /* Load limits for loop over neighbors */
131 j_index_start = jindex[iidx];
132 j_index_end = jindex[iidx+1];
134 /* Get outer coordinate index */
136 i_coord_offset = DIM*inr;
138 /* Load i particle coords and add shift vector */
139 ix1 = shX + x[i_coord_offset+DIM*1+XX];
140 iy1 = shY + x[i_coord_offset+DIM*1+YY];
141 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
142 ix2 = shX + x[i_coord_offset+DIM*2+XX];
143 iy2 = shY + x[i_coord_offset+DIM*2+YY];
144 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
145 ix3 = shX + x[i_coord_offset+DIM*3+XX];
146 iy3 = shY + x[i_coord_offset+DIM*3+YY];
147 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
159 /* Reset potential sums */
162 /* Start inner kernel loop */
163 for(jidx=j_index_start; jidx<j_index_end; jidx++)
165 /* Get j neighbor index, and coordinate index */
167 j_coord_offset = DIM*jnr;
169 /* load j atom coordinates */
170 jx0 = x[j_coord_offset+DIM*0+XX];
171 jy0 = x[j_coord_offset+DIM*0+YY];
172 jz0 = x[j_coord_offset+DIM*0+ZZ];
174 /* Calculate displacement vector */
185 /* Calculate squared distance and things based on it */
186 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
187 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
188 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
190 rinv10 = gmx_invsqrt(rsq10);
191 rinv20 = gmx_invsqrt(rsq20);
192 rinv30 = gmx_invsqrt(rsq30);
194 rinvsq10 = rinv10*rinv10;
195 rinvsq20 = rinv20*rinv20;
196 rinvsq30 = rinv30*rinv30;
198 /* Load parameters for j particles */
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
212 /* EWALD ELECTROSTATICS */
214 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
215 ewrt = r10*ewtabscale;
219 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
220 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
221 felec = qq10*rinv10*(rinvsq10-felec);
223 /* Update potential sums from outer loop */
228 /* Calculate temporary vectorial force */
233 /* Update vectorial force */
237 f[j_coord_offset+DIM*0+XX] -= tx;
238 f[j_coord_offset+DIM*0+YY] -= ty;
239 f[j_coord_offset+DIM*0+ZZ] -= tz;
243 /**************************
244 * CALCULATE INTERACTIONS *
245 **************************/
254 /* EWALD ELECTROSTATICS */
256 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
257 ewrt = r20*ewtabscale;
261 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
262 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
263 felec = qq20*rinv20*(rinvsq20-felec);
265 /* Update potential sums from outer loop */
270 /* Calculate temporary vectorial force */
275 /* Update vectorial force */
279 f[j_coord_offset+DIM*0+XX] -= tx;
280 f[j_coord_offset+DIM*0+YY] -= ty;
281 f[j_coord_offset+DIM*0+ZZ] -= tz;
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
296 /* EWALD ELECTROSTATICS */
298 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
299 ewrt = r30*ewtabscale;
303 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
304 velec = qq30*((rinv30-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
305 felec = qq30*rinv30*(rinvsq30-felec);
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*0+XX] -= tx;
322 f[j_coord_offset+DIM*0+YY] -= ty;
323 f[j_coord_offset+DIM*0+ZZ] -= tz;
327 /* Inner loop uses 126 flops */
329 /* End of innermost loop */
332 f[i_coord_offset+DIM*1+XX] += fix1;
333 f[i_coord_offset+DIM*1+YY] += fiy1;
334 f[i_coord_offset+DIM*1+ZZ] += fiz1;
338 f[i_coord_offset+DIM*2+XX] += fix2;
339 f[i_coord_offset+DIM*2+YY] += fiy2;
340 f[i_coord_offset+DIM*2+ZZ] += fiz2;
344 f[i_coord_offset+DIM*3+XX] += fix3;
345 f[i_coord_offset+DIM*3+YY] += fiy3;
346 f[i_coord_offset+DIM*3+ZZ] += fiz3;
350 fshift[i_shift_offset+XX] += tx;
351 fshift[i_shift_offset+YY] += ty;
352 fshift[i_shift_offset+ZZ] += tz;
355 /* Update potential energies */
356 kernel_data->energygrp_elec[ggid] += velecsum;
358 /* Increment number of inner iterations */
359 inneriter += j_index_end - j_index_start;
361 /* Outer loop uses 31 flops */
364 /* Increment number of outer iterations */
367 /* Update outer/inner flops */
369 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*126);
372 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4P1_F_c
373 * Electrostatics interaction: Ewald
374 * VdW interaction: None
375 * Geometry: Water4-Particle
376 * Calculate force/pot: Force
379 nb_kernel_ElecEwSh_VdwNone_GeomW4P1_F_c
380 (t_nblist * gmx_restrict nlist,
381 rvec * gmx_restrict xx,
382 rvec * gmx_restrict ff,
383 t_forcerec * gmx_restrict fr,
384 t_mdatoms * gmx_restrict mdatoms,
385 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
386 t_nrnb * gmx_restrict nrnb)
388 int i_shift_offset,i_coord_offset,j_coord_offset;
389 int j_index_start,j_index_end;
390 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
391 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
392 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
393 real *shiftvec,*fshift,*x,*f;
395 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
397 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
399 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
401 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
402 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
403 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
404 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
405 real velec,felec,velecsum,facel,crf,krf,krf2;
408 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
416 jindex = nlist->jindex;
418 shiftidx = nlist->shift;
420 shiftvec = fr->shift_vec[0];
421 fshift = fr->fshift[0];
423 charge = mdatoms->chargeA;
425 sh_ewald = fr->ic->sh_ewald;
426 ewtab = fr->ic->tabq_coul_F;
427 ewtabscale = fr->ic->tabq_scale;
428 ewtabhalfspace = 0.5/ewtabscale;
430 /* Setup water-specific parameters */
431 inr = nlist->iinr[0];
432 iq1 = facel*charge[inr+1];
433 iq2 = facel*charge[inr+2];
434 iq3 = facel*charge[inr+3];
436 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
437 rcutoff = fr->rcoulomb;
438 rcutoff2 = rcutoff*rcutoff;
443 /* Start outer loop over neighborlists */
444 for(iidx=0; iidx<nri; iidx++)
446 /* Load shift vector for this list */
447 i_shift_offset = DIM*shiftidx[iidx];
448 shX = shiftvec[i_shift_offset+XX];
449 shY = shiftvec[i_shift_offset+YY];
450 shZ = shiftvec[i_shift_offset+ZZ];
452 /* Load limits for loop over neighbors */
453 j_index_start = jindex[iidx];
454 j_index_end = jindex[iidx+1];
456 /* Get outer coordinate index */
458 i_coord_offset = DIM*inr;
460 /* Load i particle coords and add shift vector */
461 ix1 = shX + x[i_coord_offset+DIM*1+XX];
462 iy1 = shY + x[i_coord_offset+DIM*1+YY];
463 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
464 ix2 = shX + x[i_coord_offset+DIM*2+XX];
465 iy2 = shY + x[i_coord_offset+DIM*2+YY];
466 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
467 ix3 = shX + x[i_coord_offset+DIM*3+XX];
468 iy3 = shY + x[i_coord_offset+DIM*3+YY];
469 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
481 /* Start inner kernel loop */
482 for(jidx=j_index_start; jidx<j_index_end; jidx++)
484 /* Get j neighbor index, and coordinate index */
486 j_coord_offset = DIM*jnr;
488 /* load j atom coordinates */
489 jx0 = x[j_coord_offset+DIM*0+XX];
490 jy0 = x[j_coord_offset+DIM*0+YY];
491 jz0 = x[j_coord_offset+DIM*0+ZZ];
493 /* Calculate displacement vector */
504 /* Calculate squared distance and things based on it */
505 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
506 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
507 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
509 rinv10 = gmx_invsqrt(rsq10);
510 rinv20 = gmx_invsqrt(rsq20);
511 rinv30 = gmx_invsqrt(rsq30);
513 rinvsq10 = rinv10*rinv10;
514 rinvsq20 = rinv20*rinv20;
515 rinvsq30 = rinv30*rinv30;
517 /* Load parameters for j particles */
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
531 /* EWALD ELECTROSTATICS */
533 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
534 ewrt = r10*ewtabscale;
537 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
538 felec = qq10*rinv10*(rinvsq10-felec);
542 /* Calculate temporary vectorial force */
547 /* Update vectorial force */
551 f[j_coord_offset+DIM*0+XX] -= tx;
552 f[j_coord_offset+DIM*0+YY] -= ty;
553 f[j_coord_offset+DIM*0+ZZ] -= tz;
557 /**************************
558 * CALCULATE INTERACTIONS *
559 **************************/
568 /* EWALD ELECTROSTATICS */
570 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
571 ewrt = r20*ewtabscale;
574 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
575 felec = qq20*rinv20*(rinvsq20-felec);
579 /* Calculate temporary vectorial force */
584 /* Update vectorial force */
588 f[j_coord_offset+DIM*0+XX] -= tx;
589 f[j_coord_offset+DIM*0+YY] -= ty;
590 f[j_coord_offset+DIM*0+ZZ] -= tz;
594 /**************************
595 * CALCULATE INTERACTIONS *
596 **************************/
605 /* EWALD ELECTROSTATICS */
607 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
608 ewrt = r30*ewtabscale;
611 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
612 felec = qq30*rinv30*(rinvsq30-felec);
616 /* Calculate temporary vectorial force */
621 /* Update vectorial force */
625 f[j_coord_offset+DIM*0+XX] -= tx;
626 f[j_coord_offset+DIM*0+YY] -= ty;
627 f[j_coord_offset+DIM*0+ZZ] -= tz;
631 /* Inner loop uses 102 flops */
633 /* End of innermost loop */
636 f[i_coord_offset+DIM*1+XX] += fix1;
637 f[i_coord_offset+DIM*1+YY] += fiy1;
638 f[i_coord_offset+DIM*1+ZZ] += fiz1;
642 f[i_coord_offset+DIM*2+XX] += fix2;
643 f[i_coord_offset+DIM*2+YY] += fiy2;
644 f[i_coord_offset+DIM*2+ZZ] += fiz2;
648 f[i_coord_offset+DIM*3+XX] += fix3;
649 f[i_coord_offset+DIM*3+YY] += fiy3;
650 f[i_coord_offset+DIM*3+ZZ] += fiz3;
654 fshift[i_shift_offset+XX] += tx;
655 fshift[i_shift_offset+YY] += ty;
656 fshift[i_shift_offset+ZZ] += tz;
658 /* Increment number of inner iterations */
659 inneriter += j_index_end - j_index_start;
661 /* Outer loop uses 30 flops */
664 /* Increment number of outer iterations */
667 /* Update outer/inner flops */
669 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*102);