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_ElecEw_VdwNone_GeomW4P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_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];
117 /* Start outer loop over neighborlists */
118 for(iidx=0; iidx<nri; iidx++)
120 /* Load shift vector for this list */
121 i_shift_offset = DIM*shiftidx[iidx];
122 shX = shiftvec[i_shift_offset+XX];
123 shY = shiftvec[i_shift_offset+YY];
124 shZ = shiftvec[i_shift_offset+ZZ];
126 /* Load limits for loop over neighbors */
127 j_index_start = jindex[iidx];
128 j_index_end = jindex[iidx+1];
130 /* Get outer coordinate index */
132 i_coord_offset = DIM*inr;
134 /* Load i particle coords and add shift vector */
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 ix3 = shX + x[i_coord_offset+DIM*3+XX];
142 iy3 = shY + x[i_coord_offset+DIM*3+YY];
143 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
155 /* Reset potential sums */
158 /* Start inner kernel loop */
159 for(jidx=j_index_start; jidx<j_index_end; jidx++)
161 /* Get j neighbor index, and coordinate index */
163 j_coord_offset = DIM*jnr;
165 /* load j atom coordinates */
166 jx0 = x[j_coord_offset+DIM*0+XX];
167 jy0 = x[j_coord_offset+DIM*0+YY];
168 jz0 = x[j_coord_offset+DIM*0+ZZ];
170 /* Calculate displacement vector */
181 /* Calculate squared distance and things based on it */
182 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
183 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
184 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
186 rinv10 = gmx_invsqrt(rsq10);
187 rinv20 = gmx_invsqrt(rsq20);
188 rinv30 = gmx_invsqrt(rsq30);
190 rinvsq10 = rinv10*rinv10;
191 rinvsq20 = rinv20*rinv20;
192 rinvsq30 = rinv30*rinv30;
194 /* Load parameters for j particles */
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
205 /* EWALD ELECTROSTATICS */
207 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
208 ewrt = r10*ewtabscale;
212 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
213 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
214 felec = qq10*rinv10*(rinvsq10-felec);
216 /* Update potential sums from outer loop */
221 /* Calculate temporary vectorial force */
226 /* Update vectorial force */
230 f[j_coord_offset+DIM*0+XX] -= tx;
231 f[j_coord_offset+DIM*0+YY] -= ty;
232 f[j_coord_offset+DIM*0+ZZ] -= tz;
234 /**************************
235 * CALCULATE INTERACTIONS *
236 **************************/
242 /* EWALD ELECTROSTATICS */
244 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
245 ewrt = r20*ewtabscale;
249 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
250 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
251 felec = qq20*rinv20*(rinvsq20-felec);
253 /* Update potential sums from outer loop */
258 /* Calculate temporary vectorial force */
263 /* Update vectorial force */
267 f[j_coord_offset+DIM*0+XX] -= tx;
268 f[j_coord_offset+DIM*0+YY] -= ty;
269 f[j_coord_offset+DIM*0+ZZ] -= tz;
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
279 /* EWALD ELECTROSTATICS */
281 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
282 ewrt = r30*ewtabscale;
286 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
287 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
288 felec = qq30*rinv30*(rinvsq30-felec);
290 /* Update potential sums from outer loop */
295 /* Calculate temporary vectorial force */
300 /* Update vectorial force */
304 f[j_coord_offset+DIM*0+XX] -= tx;
305 f[j_coord_offset+DIM*0+YY] -= ty;
306 f[j_coord_offset+DIM*0+ZZ] -= tz;
308 /* Inner loop uses 123 flops */
310 /* End of innermost loop */
313 f[i_coord_offset+DIM*1+XX] += fix1;
314 f[i_coord_offset+DIM*1+YY] += fiy1;
315 f[i_coord_offset+DIM*1+ZZ] += fiz1;
319 f[i_coord_offset+DIM*2+XX] += fix2;
320 f[i_coord_offset+DIM*2+YY] += fiy2;
321 f[i_coord_offset+DIM*2+ZZ] += fiz2;
325 f[i_coord_offset+DIM*3+XX] += fix3;
326 f[i_coord_offset+DIM*3+YY] += fiy3;
327 f[i_coord_offset+DIM*3+ZZ] += fiz3;
331 fshift[i_shift_offset+XX] += tx;
332 fshift[i_shift_offset+YY] += ty;
333 fshift[i_shift_offset+ZZ] += tz;
336 /* Update potential energies */
337 kernel_data->energygrp_elec[ggid] += velecsum;
339 /* Increment number of inner iterations */
340 inneriter += j_index_end - j_index_start;
342 /* Outer loop uses 31 flops */
345 /* Increment number of outer iterations */
348 /* Update outer/inner flops */
350 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*123);
353 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW4P1_F_c
354 * Electrostatics interaction: Ewald
355 * VdW interaction: None
356 * Geometry: Water4-Particle
357 * Calculate force/pot: Force
360 nb_kernel_ElecEw_VdwNone_GeomW4P1_F_c
361 (t_nblist * gmx_restrict nlist,
362 rvec * gmx_restrict xx,
363 rvec * gmx_restrict ff,
364 t_forcerec * gmx_restrict fr,
365 t_mdatoms * gmx_restrict mdatoms,
366 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
367 t_nrnb * gmx_restrict nrnb)
369 int i_shift_offset,i_coord_offset,j_coord_offset;
370 int j_index_start,j_index_end;
371 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
372 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
373 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
374 real *shiftvec,*fshift,*x,*f;
376 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
378 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
380 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
382 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
383 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
384 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
385 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
386 real velec,felec,velecsum,facel,crf,krf,krf2;
389 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
397 jindex = nlist->jindex;
399 shiftidx = nlist->shift;
401 shiftvec = fr->shift_vec[0];
402 fshift = fr->fshift[0];
404 charge = mdatoms->chargeA;
406 sh_ewald = fr->ic->sh_ewald;
407 ewtab = fr->ic->tabq_coul_F;
408 ewtabscale = fr->ic->tabq_scale;
409 ewtabhalfspace = 0.5/ewtabscale;
411 /* Setup water-specific parameters */
412 inr = nlist->iinr[0];
413 iq1 = facel*charge[inr+1];
414 iq2 = facel*charge[inr+2];
415 iq3 = facel*charge[inr+3];
420 /* Start outer loop over neighborlists */
421 for(iidx=0; iidx<nri; iidx++)
423 /* Load shift vector for this list */
424 i_shift_offset = DIM*shiftidx[iidx];
425 shX = shiftvec[i_shift_offset+XX];
426 shY = shiftvec[i_shift_offset+YY];
427 shZ = shiftvec[i_shift_offset+ZZ];
429 /* Load limits for loop over neighbors */
430 j_index_start = jindex[iidx];
431 j_index_end = jindex[iidx+1];
433 /* Get outer coordinate index */
435 i_coord_offset = DIM*inr;
437 /* Load i particle coords and add shift vector */
438 ix1 = shX + x[i_coord_offset+DIM*1+XX];
439 iy1 = shY + x[i_coord_offset+DIM*1+YY];
440 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
441 ix2 = shX + x[i_coord_offset+DIM*2+XX];
442 iy2 = shY + x[i_coord_offset+DIM*2+YY];
443 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
444 ix3 = shX + x[i_coord_offset+DIM*3+XX];
445 iy3 = shY + x[i_coord_offset+DIM*3+YY];
446 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
458 /* Start inner kernel loop */
459 for(jidx=j_index_start; jidx<j_index_end; jidx++)
461 /* Get j neighbor index, and coordinate index */
463 j_coord_offset = DIM*jnr;
465 /* load j atom coordinates */
466 jx0 = x[j_coord_offset+DIM*0+XX];
467 jy0 = x[j_coord_offset+DIM*0+YY];
468 jz0 = x[j_coord_offset+DIM*0+ZZ];
470 /* Calculate displacement vector */
481 /* Calculate squared distance and things based on it */
482 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
483 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
484 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
486 rinv10 = gmx_invsqrt(rsq10);
487 rinv20 = gmx_invsqrt(rsq20);
488 rinv30 = gmx_invsqrt(rsq30);
490 rinvsq10 = rinv10*rinv10;
491 rinvsq20 = rinv20*rinv20;
492 rinvsq30 = rinv30*rinv30;
494 /* Load parameters for j particles */
497 /**************************
498 * CALCULATE INTERACTIONS *
499 **************************/
505 /* EWALD ELECTROSTATICS */
507 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
508 ewrt = r10*ewtabscale;
511 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
512 felec = qq10*rinv10*(rinvsq10-felec);
516 /* Calculate temporary vectorial force */
521 /* Update vectorial force */
525 f[j_coord_offset+DIM*0+XX] -= tx;
526 f[j_coord_offset+DIM*0+YY] -= ty;
527 f[j_coord_offset+DIM*0+ZZ] -= tz;
529 /**************************
530 * CALCULATE INTERACTIONS *
531 **************************/
537 /* EWALD ELECTROSTATICS */
539 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
540 ewrt = r20*ewtabscale;
543 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
544 felec = qq20*rinv20*(rinvsq20-felec);
548 /* Calculate temporary vectorial force */
553 /* Update vectorial force */
557 f[j_coord_offset+DIM*0+XX] -= tx;
558 f[j_coord_offset+DIM*0+YY] -= ty;
559 f[j_coord_offset+DIM*0+ZZ] -= tz;
561 /**************************
562 * CALCULATE INTERACTIONS *
563 **************************/
569 /* EWALD ELECTROSTATICS */
571 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
572 ewrt = r30*ewtabscale;
575 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
576 felec = qq30*rinv30*(rinvsq30-felec);
580 /* Calculate temporary vectorial force */
585 /* Update vectorial force */
589 f[j_coord_offset+DIM*0+XX] -= tx;
590 f[j_coord_offset+DIM*0+YY] -= ty;
591 f[j_coord_offset+DIM*0+ZZ] -= tz;
593 /* Inner loop uses 102 flops */
595 /* End of innermost loop */
598 f[i_coord_offset+DIM*1+XX] += fix1;
599 f[i_coord_offset+DIM*1+YY] += fiy1;
600 f[i_coord_offset+DIM*1+ZZ] += fiz1;
604 f[i_coord_offset+DIM*2+XX] += fix2;
605 f[i_coord_offset+DIM*2+YY] += fiy2;
606 f[i_coord_offset+DIM*2+ZZ] += fiz2;
610 f[i_coord_offset+DIM*3+XX] += fix3;
611 f[i_coord_offset+DIM*3+YY] += fiy3;
612 f[i_coord_offset+DIM*3+ZZ] += fiz3;
616 fshift[i_shift_offset+XX] += tx;
617 fshift[i_shift_offset+YY] += ty;
618 fshift[i_shift_offset+ZZ] += tz;
620 /* Increment number of inner iterations */
621 inneriter += j_index_end - j_index_start;
623 /* Outer loop uses 30 flops */
626 /* Increment number of outer iterations */
629 /* Update outer/inner flops */
631 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*102);