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 "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW3P1_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwBham_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 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
88 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
96 jindex = nlist->jindex;
98 shiftidx = nlist->shift;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
103 charge = mdatoms->chargeA;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 sh_ewald = fr->ic->sh_ewald;
109 ewtab = fr->ic->tabq_coul_FDV0;
110 ewtabscale = fr->ic->tabq_scale;
111 ewtabhalfspace = 0.5/ewtabscale;
113 /* Setup water-specific parameters */
114 inr = nlist->iinr[0];
115 iq0 = facel*charge[inr+0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
123 /* Start outer loop over neighborlists */
124 for(iidx=0; iidx<nri; iidx++)
126 /* Load shift vector for this list */
127 i_shift_offset = DIM*shiftidx[iidx];
128 shX = shiftvec[i_shift_offset+XX];
129 shY = shiftvec[i_shift_offset+YY];
130 shZ = shiftvec[i_shift_offset+ZZ];
132 /* Load limits for loop over neighbors */
133 j_index_start = jindex[iidx];
134 j_index_end = jindex[iidx+1];
136 /* Get outer coordinate index */
138 i_coord_offset = DIM*inr;
140 /* Load i particle coords and add shift vector */
141 ix0 = shX + x[i_coord_offset+DIM*0+XX];
142 iy0 = shY + x[i_coord_offset+DIM*0+YY];
143 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
144 ix1 = shX + x[i_coord_offset+DIM*1+XX];
145 iy1 = shY + x[i_coord_offset+DIM*1+YY];
146 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
147 ix2 = shX + x[i_coord_offset+DIM*2+XX];
148 iy2 = shY + x[i_coord_offset+DIM*2+YY];
149 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
161 /* Reset potential sums */
165 /* Start inner kernel loop */
166 for(jidx=j_index_start; jidx<j_index_end; jidx++)
168 /* Get j neighbor index, and coordinate index */
170 j_coord_offset = DIM*jnr;
172 /* load j atom coordinates */
173 jx0 = x[j_coord_offset+DIM*0+XX];
174 jy0 = x[j_coord_offset+DIM*0+YY];
175 jz0 = x[j_coord_offset+DIM*0+ZZ];
177 /* Calculate displacement vector */
188 /* Calculate squared distance and things based on it */
189 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
190 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
191 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
193 rinv00 = gmx_invsqrt(rsq00);
194 rinv10 = gmx_invsqrt(rsq10);
195 rinv20 = gmx_invsqrt(rsq20);
197 rinvsq00 = rinv00*rinv00;
198 rinvsq10 = rinv10*rinv10;
199 rinvsq20 = rinv20*rinv20;
201 /* Load parameters for j particles */
203 vdwjidx0 = 3*vdwtype[jnr+0];
205 /**************************
206 * CALCULATE INTERACTIONS *
207 **************************/
212 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
213 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
214 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
216 /* EWALD ELECTROSTATICS */
218 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
219 ewrt = r00*ewtabscale;
223 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
224 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
225 felec = qq00*rinv00*(rinvsq00-felec);
227 /* BUCKINGHAM DISPERSION/REPULSION */
228 rinvsix = rinvsq00*rinvsq00*rinvsq00;
229 vvdw6 = c6_00*rinvsix;
231 vvdwexp = cexp1_00*exp(-br);
232 vvdw = vvdwexp - vvdw6*(1.0/6.0);
233 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
235 /* Update potential sums from outer loop */
241 /* Calculate temporary vectorial force */
246 /* Update vectorial force */
250 f[j_coord_offset+DIM*0+XX] -= tx;
251 f[j_coord_offset+DIM*0+YY] -= ty;
252 f[j_coord_offset+DIM*0+ZZ] -= tz;
254 /**************************
255 * CALCULATE INTERACTIONS *
256 **************************/
262 /* EWALD ELECTROSTATICS */
264 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
265 ewrt = r10*ewtabscale;
269 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
270 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
271 felec = qq10*rinv10*(rinvsq10-felec);
273 /* Update potential sums from outer loop */
278 /* Calculate temporary vectorial force */
283 /* Update vectorial force */
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;
291 /**************************
292 * CALCULATE INTERACTIONS *
293 **************************/
299 /* EWALD ELECTROSTATICS */
301 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
302 ewrt = r20*ewtabscale;
306 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
307 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
308 felec = qq20*rinv20*(rinvsq20-felec);
310 /* Update potential sums from outer loop */
315 /* Calculate temporary vectorial force */
320 /* Update vectorial force */
324 f[j_coord_offset+DIM*0+XX] -= tx;
325 f[j_coord_offset+DIM*0+YY] -= ty;
326 f[j_coord_offset+DIM*0+ZZ] -= tz;
328 /* Inner loop uses 161 flops */
330 /* End of innermost loop */
333 f[i_coord_offset+DIM*0+XX] += fix0;
334 f[i_coord_offset+DIM*0+YY] += fiy0;
335 f[i_coord_offset+DIM*0+ZZ] += fiz0;
339 f[i_coord_offset+DIM*1+XX] += fix1;
340 f[i_coord_offset+DIM*1+YY] += fiy1;
341 f[i_coord_offset+DIM*1+ZZ] += fiz1;
345 f[i_coord_offset+DIM*2+XX] += fix2;
346 f[i_coord_offset+DIM*2+YY] += fiy2;
347 f[i_coord_offset+DIM*2+ZZ] += fiz2;
351 fshift[i_shift_offset+XX] += tx;
352 fshift[i_shift_offset+YY] += ty;
353 fshift[i_shift_offset+ZZ] += tz;
356 /* Update potential energies */
357 kernel_data->energygrp_elec[ggid] += velecsum;
358 kernel_data->energygrp_vdw[ggid] += vvdwsum;
360 /* Increment number of inner iterations */
361 inneriter += j_index_end - j_index_start;
363 /* Outer loop uses 32 flops */
366 /* Increment number of outer iterations */
369 /* Update outer/inner flops */
371 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*161);
374 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW3P1_F_c
375 * Electrostatics interaction: Ewald
376 * VdW interaction: Buckingham
377 * Geometry: Water3-Particle
378 * Calculate force/pot: Force
381 nb_kernel_ElecEw_VdwBham_GeomW3P1_F_c
382 (t_nblist * gmx_restrict nlist,
383 rvec * gmx_restrict xx,
384 rvec * gmx_restrict ff,
385 t_forcerec * gmx_restrict fr,
386 t_mdatoms * gmx_restrict mdatoms,
387 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
388 t_nrnb * gmx_restrict nrnb)
390 int i_shift_offset,i_coord_offset,j_coord_offset;
391 int j_index_start,j_index_end;
392 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
393 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
394 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
395 real *shiftvec,*fshift,*x,*f;
397 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
399 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
401 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
403 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
404 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
405 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
406 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
407 real velec,felec,velecsum,facel,crf,krf,krf2;
410 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
414 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
422 jindex = nlist->jindex;
424 shiftidx = nlist->shift;
426 shiftvec = fr->shift_vec[0];
427 fshift = fr->fshift[0];
429 charge = mdatoms->chargeA;
430 nvdwtype = fr->ntype;
432 vdwtype = mdatoms->typeA;
434 sh_ewald = fr->ic->sh_ewald;
435 ewtab = fr->ic->tabq_coul_F;
436 ewtabscale = fr->ic->tabq_scale;
437 ewtabhalfspace = 0.5/ewtabscale;
439 /* Setup water-specific parameters */
440 inr = nlist->iinr[0];
441 iq0 = facel*charge[inr+0];
442 iq1 = facel*charge[inr+1];
443 iq2 = facel*charge[inr+2];
444 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
449 /* Start outer loop over neighborlists */
450 for(iidx=0; iidx<nri; iidx++)
452 /* Load shift vector for this list */
453 i_shift_offset = DIM*shiftidx[iidx];
454 shX = shiftvec[i_shift_offset+XX];
455 shY = shiftvec[i_shift_offset+YY];
456 shZ = shiftvec[i_shift_offset+ZZ];
458 /* Load limits for loop over neighbors */
459 j_index_start = jindex[iidx];
460 j_index_end = jindex[iidx+1];
462 /* Get outer coordinate index */
464 i_coord_offset = DIM*inr;
466 /* Load i particle coords and add shift vector */
467 ix0 = shX + x[i_coord_offset+DIM*0+XX];
468 iy0 = shY + x[i_coord_offset+DIM*0+YY];
469 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
470 ix1 = shX + x[i_coord_offset+DIM*1+XX];
471 iy1 = shY + x[i_coord_offset+DIM*1+YY];
472 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
473 ix2 = shX + x[i_coord_offset+DIM*2+XX];
474 iy2 = shY + x[i_coord_offset+DIM*2+YY];
475 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
487 /* Start inner kernel loop */
488 for(jidx=j_index_start; jidx<j_index_end; jidx++)
490 /* Get j neighbor index, and coordinate index */
492 j_coord_offset = DIM*jnr;
494 /* load j atom coordinates */
495 jx0 = x[j_coord_offset+DIM*0+XX];
496 jy0 = x[j_coord_offset+DIM*0+YY];
497 jz0 = x[j_coord_offset+DIM*0+ZZ];
499 /* Calculate displacement vector */
510 /* Calculate squared distance and things based on it */
511 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
512 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
513 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
515 rinv00 = gmx_invsqrt(rsq00);
516 rinv10 = gmx_invsqrt(rsq10);
517 rinv20 = gmx_invsqrt(rsq20);
519 rinvsq00 = rinv00*rinv00;
520 rinvsq10 = rinv10*rinv10;
521 rinvsq20 = rinv20*rinv20;
523 /* Load parameters for j particles */
525 vdwjidx0 = 3*vdwtype[jnr+0];
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
534 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
535 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
536 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
538 /* EWALD ELECTROSTATICS */
540 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
541 ewrt = r00*ewtabscale;
544 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
545 felec = qq00*rinv00*(rinvsq00-felec);
547 /* BUCKINGHAM DISPERSION/REPULSION */
548 rinvsix = rinvsq00*rinvsq00*rinvsq00;
549 vvdw6 = c6_00*rinvsix;
551 vvdwexp = cexp1_00*exp(-br);
552 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
556 /* Calculate temporary vectorial force */
561 /* Update vectorial force */
565 f[j_coord_offset+DIM*0+XX] -= tx;
566 f[j_coord_offset+DIM*0+YY] -= ty;
567 f[j_coord_offset+DIM*0+ZZ] -= tz;
569 /**************************
570 * CALCULATE INTERACTIONS *
571 **************************/
577 /* EWALD ELECTROSTATICS */
579 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
580 ewrt = r10*ewtabscale;
583 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
584 felec = qq10*rinv10*(rinvsq10-felec);
588 /* Calculate temporary vectorial force */
593 /* Update vectorial force */
597 f[j_coord_offset+DIM*0+XX] -= tx;
598 f[j_coord_offset+DIM*0+YY] -= ty;
599 f[j_coord_offset+DIM*0+ZZ] -= tz;
601 /**************************
602 * CALCULATE INTERACTIONS *
603 **************************/
609 /* EWALD ELECTROSTATICS */
611 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
612 ewrt = r20*ewtabscale;
615 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
616 felec = qq20*rinv20*(rinvsq20-felec);
620 /* Calculate temporary vectorial force */
625 /* Update vectorial force */
629 f[j_coord_offset+DIM*0+XX] -= tx;
630 f[j_coord_offset+DIM*0+YY] -= ty;
631 f[j_coord_offset+DIM*0+ZZ] -= tz;
633 /* Inner loop uses 137 flops */
635 /* End of innermost loop */
638 f[i_coord_offset+DIM*0+XX] += fix0;
639 f[i_coord_offset+DIM*0+YY] += fiy0;
640 f[i_coord_offset+DIM*0+ZZ] += fiz0;
644 f[i_coord_offset+DIM*1+XX] += fix1;
645 f[i_coord_offset+DIM*1+YY] += fiy1;
646 f[i_coord_offset+DIM*1+ZZ] += fiz1;
650 f[i_coord_offset+DIM*2+XX] += fix2;
651 f[i_coord_offset+DIM*2+YY] += fiy2;
652 f[i_coord_offset+DIM*2+ZZ] += fiz2;
656 fshift[i_shift_offset+XX] += tx;
657 fshift[i_shift_offset+YY] += ty;
658 fshift[i_shift_offset+ZZ] += tz;
660 /* Increment number of inner iterations */
661 inneriter += j_index_end - j_index_start;
663 /* Outer loop uses 30 flops */
666 /* Increment number of outer iterations */
669 /* Update outer/inner flops */
671 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*137);