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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwNone_GeomW3P1_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
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 iq0 = facel*charge[inr+0];
111 iq1 = facel*charge[inr+1];
112 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
136 iy0 = shY + x[i_coord_offset+DIM*0+YY];
137 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
138 ix1 = shX + x[i_coord_offset+DIM*1+XX];
139 iy1 = shY + x[i_coord_offset+DIM*1+YY];
140 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
141 ix2 = shX + x[i_coord_offset+DIM*2+XX];
142 iy2 = shY + x[i_coord_offset+DIM*2+YY];
143 iz2 = shZ + x[i_coord_offset+DIM*2+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 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
183 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
184 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
186 rinv00 = gmx_invsqrt(rsq00);
187 rinv10 = gmx_invsqrt(rsq10);
188 rinv20 = gmx_invsqrt(rsq20);
190 rinvsq00 = rinv00*rinv00;
191 rinvsq10 = rinv10*rinv10;
192 rinvsq20 = rinv20*rinv20;
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 = r00*ewtabscale;
212 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
213 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
214 felec = qq00*rinv00*(rinvsq00-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 = r10*ewtabscale;
249 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
250 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
251 felec = qq10*rinv10*(rinvsq10-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 = r20*ewtabscale;
286 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
287 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
288 felec = qq20*rinv20*(rinvsq20-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*0+XX] += fix0;
314 f[i_coord_offset+DIM*0+YY] += fiy0;
315 f[i_coord_offset+DIM*0+ZZ] += fiz0;
319 f[i_coord_offset+DIM*1+XX] += fix1;
320 f[i_coord_offset+DIM*1+YY] += fiy1;
321 f[i_coord_offset+DIM*1+ZZ] += fiz1;
325 f[i_coord_offset+DIM*2+XX] += fix2;
326 f[i_coord_offset+DIM*2+YY] += fiy2;
327 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3_VF,outeriter*31 + inneriter*123);
353 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3P1_F_c
354 * Electrostatics interaction: Ewald
355 * VdW interaction: None
356 * Geometry: Water3-Particle
357 * Calculate force/pot: Force
360 nb_kernel_ElecEw_VdwNone_GeomW3P1_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
378 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
380 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
382 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
383 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
384 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
385 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
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 iq0 = facel*charge[inr+0];
414 iq1 = facel*charge[inr+1];
415 iq2 = facel*charge[inr+2];
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 ix0 = shX + x[i_coord_offset+DIM*0+XX];
439 iy0 = shY + x[i_coord_offset+DIM*0+YY];
440 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
441 ix1 = shX + x[i_coord_offset+DIM*1+XX];
442 iy1 = shY + x[i_coord_offset+DIM*1+YY];
443 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
444 ix2 = shX + x[i_coord_offset+DIM*2+XX];
445 iy2 = shY + x[i_coord_offset+DIM*2+YY];
446 iz2 = shZ + x[i_coord_offset+DIM*2+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 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
483 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
484 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
486 rinv00 = gmx_invsqrt(rsq00);
487 rinv10 = gmx_invsqrt(rsq10);
488 rinv20 = gmx_invsqrt(rsq20);
490 rinvsq00 = rinv00*rinv00;
491 rinvsq10 = rinv10*rinv10;
492 rinvsq20 = rinv20*rinv20;
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 = r00*ewtabscale;
511 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
512 felec = qq00*rinv00*(rinvsq00-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 = r10*ewtabscale;
543 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
544 felec = qq10*rinv10*(rinvsq10-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 = r20*ewtabscale;
575 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
576 felec = qq20*rinv20*(rinvsq20-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*0+XX] += fix0;
599 f[i_coord_offset+DIM*0+YY] += fiy0;
600 f[i_coord_offset+DIM*0+ZZ] += fiz0;
604 f[i_coord_offset+DIM*1+XX] += fix1;
605 f[i_coord_offset+DIM*1+YY] += fiy1;
606 f[i_coord_offset+DIM*1+ZZ] += fiz1;
610 f[i_coord_offset+DIM*2+XX] += fix2;
611 f[i_coord_offset+DIM*2+YY] += fiy2;
612 f[i_coord_offset+DIM*2+ZZ] += fiz2;
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_W3_F,outeriter*30 + inneriter*102);