2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwBhamSh_GeomW4P1_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
66 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
67 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
68 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
69 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
70 real velec,felec,velecsum,facel,crf,krf,krf2;
73 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
77 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
85 jindex = nlist->jindex;
87 shiftidx = nlist->shift;
89 shiftvec = fr->shift_vec[0];
90 fshift = fr->fshift[0];
92 charge = mdatoms->chargeA;
95 vdwtype = mdatoms->typeA;
97 sh_ewald = fr->ic->sh_ewald;
98 ewtab = fr->ic->tabq_coul_FDV0;
99 ewtabscale = fr->ic->tabq_scale;
100 ewtabhalfspace = 0.5/ewtabscale;
102 /* Setup water-specific parameters */
103 inr = nlist->iinr[0];
104 iq1 = facel*charge[inr+1];
105 iq2 = facel*charge[inr+2];
106 iq3 = facel*charge[inr+3];
107 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
109 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
110 rcutoff = fr->rcoulomb;
111 rcutoff2 = rcutoff*rcutoff;
113 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
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];
146 ix3 = shX + x[i_coord_offset+DIM*3+XX];
147 iy3 = shY + x[i_coord_offset+DIM*3+YY];
148 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
163 /* Reset potential sums */
167 /* Start inner kernel loop */
168 for(jidx=j_index_start; jidx<j_index_end; jidx++)
170 /* Get j neighbor index, and coordinate index */
172 j_coord_offset = DIM*jnr;
174 /* load j atom coordinates */
175 jx0 = x[j_coord_offset+DIM*0+XX];
176 jy0 = x[j_coord_offset+DIM*0+YY];
177 jz0 = x[j_coord_offset+DIM*0+ZZ];
179 /* Calculate displacement vector */
193 /* Calculate squared distance and things based on it */
194 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
195 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
196 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
197 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
199 rinv00 = gmx_invsqrt(rsq00);
200 rinv10 = gmx_invsqrt(rsq10);
201 rinv20 = gmx_invsqrt(rsq20);
202 rinv30 = gmx_invsqrt(rsq30);
204 rinvsq00 = rinv00*rinv00;
205 rinvsq10 = rinv10*rinv10;
206 rinvsq20 = rinv20*rinv20;
207 rinvsq30 = rinv30*rinv30;
209 /* Load parameters for j particles */
211 vdwjidx0 = 3*vdwtype[jnr+0];
213 /**************************
214 * CALCULATE INTERACTIONS *
215 **************************/
222 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
223 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
224 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
226 /* BUCKINGHAM DISPERSION/REPULSION */
227 rinvsix = rinvsq00*rinvsq00*rinvsq00;
228 vvdw6 = c6_00*rinvsix;
230 vvdwexp = cexp1_00*exp(-br);
231 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
232 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
234 /* Update potential sums from outer loop */
239 /* Calculate temporary vectorial force */
244 /* Update vectorial force */
248 f[j_coord_offset+DIM*0+XX] -= tx;
249 f[j_coord_offset+DIM*0+YY] -= ty;
250 f[j_coord_offset+DIM*0+ZZ] -= tz;
254 /**************************
255 * CALCULATE INTERACTIONS *
256 **************************/
265 /* EWALD ELECTROSTATICS */
267 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
268 ewrt = r10*ewtabscale;
272 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
273 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
274 felec = qq10*rinv10*(rinvsq10-felec);
276 /* Update potential sums from outer loop */
281 /* Calculate temporary vectorial force */
286 /* Update vectorial force */
290 f[j_coord_offset+DIM*0+XX] -= tx;
291 f[j_coord_offset+DIM*0+YY] -= ty;
292 f[j_coord_offset+DIM*0+ZZ] -= tz;
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
307 /* EWALD ELECTROSTATICS */
309 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
310 ewrt = r20*ewtabscale;
314 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
315 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
316 felec = qq20*rinv20*(rinvsq20-felec);
318 /* Update potential sums from outer loop */
323 /* Calculate temporary vectorial force */
328 /* Update vectorial force */
332 f[j_coord_offset+DIM*0+XX] -= tx;
333 f[j_coord_offset+DIM*0+YY] -= ty;
334 f[j_coord_offset+DIM*0+ZZ] -= tz;
338 /**************************
339 * CALCULATE INTERACTIONS *
340 **************************/
349 /* EWALD ELECTROSTATICS */
351 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
352 ewrt = r30*ewtabscale;
356 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
357 velec = qq30*((rinv30-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
358 felec = qq30*rinv30*(rinvsq30-felec);
360 /* Update potential sums from outer loop */
365 /* Calculate temporary vectorial force */
370 /* Update vectorial force */
374 f[j_coord_offset+DIM*0+XX] -= tx;
375 f[j_coord_offset+DIM*0+YY] -= ty;
376 f[j_coord_offset+DIM*0+ZZ] -= tz;
380 /* Inner loop uses 218 flops */
382 /* End of innermost loop */
385 f[i_coord_offset+DIM*0+XX] += fix0;
386 f[i_coord_offset+DIM*0+YY] += fiy0;
387 f[i_coord_offset+DIM*0+ZZ] += fiz0;
391 f[i_coord_offset+DIM*1+XX] += fix1;
392 f[i_coord_offset+DIM*1+YY] += fiy1;
393 f[i_coord_offset+DIM*1+ZZ] += fiz1;
397 f[i_coord_offset+DIM*2+XX] += fix2;
398 f[i_coord_offset+DIM*2+YY] += fiy2;
399 f[i_coord_offset+DIM*2+ZZ] += fiz2;
403 f[i_coord_offset+DIM*3+XX] += fix3;
404 f[i_coord_offset+DIM*3+YY] += fiy3;
405 f[i_coord_offset+DIM*3+ZZ] += fiz3;
409 fshift[i_shift_offset+XX] += tx;
410 fshift[i_shift_offset+YY] += ty;
411 fshift[i_shift_offset+ZZ] += tz;
414 /* Update potential energies */
415 kernel_data->energygrp_elec[ggid] += velecsum;
416 kernel_data->energygrp_vdw[ggid] += vvdwsum;
418 /* Increment number of inner iterations */
419 inneriter += j_index_end - j_index_start;
421 /* Outer loop uses 41 flops */
424 /* Increment number of outer iterations */
427 /* Update outer/inner flops */
429 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*218);
432 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW4P1_F_c
433 * Electrostatics interaction: Ewald
434 * VdW interaction: Buckingham
435 * Geometry: Water4-Particle
436 * Calculate force/pot: Force
439 nb_kernel_ElecEwSh_VdwBhamSh_GeomW4P1_F_c
440 (t_nblist * gmx_restrict nlist,
441 rvec * gmx_restrict xx,
442 rvec * gmx_restrict ff,
443 t_forcerec * gmx_restrict fr,
444 t_mdatoms * gmx_restrict mdatoms,
445 nb_kernel_data_t * gmx_restrict kernel_data,
446 t_nrnb * gmx_restrict nrnb)
448 int i_shift_offset,i_coord_offset,j_coord_offset;
449 int j_index_start,j_index_end;
450 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
451 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
452 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
453 real *shiftvec,*fshift,*x,*f;
455 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
457 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
459 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
461 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
463 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
464 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
465 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
466 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
467 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
468 real velec,felec,velecsum,facel,crf,krf,krf2;
471 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
475 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
483 jindex = nlist->jindex;
485 shiftidx = nlist->shift;
487 shiftvec = fr->shift_vec[0];
488 fshift = fr->fshift[0];
490 charge = mdatoms->chargeA;
491 nvdwtype = fr->ntype;
493 vdwtype = mdatoms->typeA;
495 sh_ewald = fr->ic->sh_ewald;
496 ewtab = fr->ic->tabq_coul_F;
497 ewtabscale = fr->ic->tabq_scale;
498 ewtabhalfspace = 0.5/ewtabscale;
500 /* Setup water-specific parameters */
501 inr = nlist->iinr[0];
502 iq1 = facel*charge[inr+1];
503 iq2 = facel*charge[inr+2];
504 iq3 = facel*charge[inr+3];
505 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
507 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
508 rcutoff = fr->rcoulomb;
509 rcutoff2 = rcutoff*rcutoff;
511 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
517 /* Start outer loop over neighborlists */
518 for(iidx=0; iidx<nri; iidx++)
520 /* Load shift vector for this list */
521 i_shift_offset = DIM*shiftidx[iidx];
522 shX = shiftvec[i_shift_offset+XX];
523 shY = shiftvec[i_shift_offset+YY];
524 shZ = shiftvec[i_shift_offset+ZZ];
526 /* Load limits for loop over neighbors */
527 j_index_start = jindex[iidx];
528 j_index_end = jindex[iidx+1];
530 /* Get outer coordinate index */
532 i_coord_offset = DIM*inr;
534 /* Load i particle coords and add shift vector */
535 ix0 = shX + x[i_coord_offset+DIM*0+XX];
536 iy0 = shY + x[i_coord_offset+DIM*0+YY];
537 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
538 ix1 = shX + x[i_coord_offset+DIM*1+XX];
539 iy1 = shY + x[i_coord_offset+DIM*1+YY];
540 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
541 ix2 = shX + x[i_coord_offset+DIM*2+XX];
542 iy2 = shY + x[i_coord_offset+DIM*2+YY];
543 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
544 ix3 = shX + x[i_coord_offset+DIM*3+XX];
545 iy3 = shY + x[i_coord_offset+DIM*3+YY];
546 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
561 /* Start inner kernel loop */
562 for(jidx=j_index_start; jidx<j_index_end; jidx++)
564 /* Get j neighbor index, and coordinate index */
566 j_coord_offset = DIM*jnr;
568 /* load j atom coordinates */
569 jx0 = x[j_coord_offset+DIM*0+XX];
570 jy0 = x[j_coord_offset+DIM*0+YY];
571 jz0 = x[j_coord_offset+DIM*0+ZZ];
573 /* Calculate displacement vector */
587 /* Calculate squared distance and things based on it */
588 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
589 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
590 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
591 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
593 rinv00 = gmx_invsqrt(rsq00);
594 rinv10 = gmx_invsqrt(rsq10);
595 rinv20 = gmx_invsqrt(rsq20);
596 rinv30 = gmx_invsqrt(rsq30);
598 rinvsq00 = rinv00*rinv00;
599 rinvsq10 = rinv10*rinv10;
600 rinvsq20 = rinv20*rinv20;
601 rinvsq30 = rinv30*rinv30;
603 /* Load parameters for j particles */
605 vdwjidx0 = 3*vdwtype[jnr+0];
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
616 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
617 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
618 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
620 /* BUCKINGHAM DISPERSION/REPULSION */
621 rinvsix = rinvsq00*rinvsq00*rinvsq00;
622 vvdw6 = c6_00*rinvsix;
624 vvdwexp = cexp1_00*exp(-br);
625 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
629 /* Calculate temporary vectorial force */
634 /* Update vectorial force */
638 f[j_coord_offset+DIM*0+XX] -= tx;
639 f[j_coord_offset+DIM*0+YY] -= ty;
640 f[j_coord_offset+DIM*0+ZZ] -= tz;
644 /**************************
645 * CALCULATE INTERACTIONS *
646 **************************/
655 /* EWALD ELECTROSTATICS */
657 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
658 ewrt = r10*ewtabscale;
661 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
662 felec = qq10*rinv10*(rinvsq10-felec);
666 /* Calculate temporary vectorial force */
671 /* Update vectorial force */
675 f[j_coord_offset+DIM*0+XX] -= tx;
676 f[j_coord_offset+DIM*0+YY] -= ty;
677 f[j_coord_offset+DIM*0+ZZ] -= tz;
681 /**************************
682 * CALCULATE INTERACTIONS *
683 **************************/
692 /* EWALD ELECTROSTATICS */
694 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
695 ewrt = r20*ewtabscale;
698 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
699 felec = qq20*rinv20*(rinvsq20-felec);
703 /* Calculate temporary vectorial force */
708 /* Update vectorial force */
712 f[j_coord_offset+DIM*0+XX] -= tx;
713 f[j_coord_offset+DIM*0+YY] -= ty;
714 f[j_coord_offset+DIM*0+ZZ] -= tz;
718 /**************************
719 * CALCULATE INTERACTIONS *
720 **************************/
729 /* EWALD ELECTROSTATICS */
731 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
732 ewrt = r30*ewtabscale;
735 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
736 felec = qq30*rinv30*(rinvsq30-felec);
740 /* Calculate temporary vectorial force */
745 /* Update vectorial force */
749 f[j_coord_offset+DIM*0+XX] -= tx;
750 f[j_coord_offset+DIM*0+YY] -= ty;
751 f[j_coord_offset+DIM*0+ZZ] -= tz;
755 /* Inner loop uses 160 flops */
757 /* End of innermost loop */
760 f[i_coord_offset+DIM*0+XX] += fix0;
761 f[i_coord_offset+DIM*0+YY] += fiy0;
762 f[i_coord_offset+DIM*0+ZZ] += fiz0;
766 f[i_coord_offset+DIM*1+XX] += fix1;
767 f[i_coord_offset+DIM*1+YY] += fiy1;
768 f[i_coord_offset+DIM*1+ZZ] += fiz1;
772 f[i_coord_offset+DIM*2+XX] += fix2;
773 f[i_coord_offset+DIM*2+YY] += fiy2;
774 f[i_coord_offset+DIM*2+ZZ] += fiz2;
778 f[i_coord_offset+DIM*3+XX] += fix3;
779 f[i_coord_offset+DIM*3+YY] += fiy3;
780 f[i_coord_offset+DIM*3+ZZ] += fiz3;
784 fshift[i_shift_offset+XX] += tx;
785 fshift[i_shift_offset+YY] += ty;
786 fshift[i_shift_offset+ZZ] += tz;
788 /* Increment number of inner iterations */
789 inneriter += j_index_end - j_index_start;
791 /* Outer loop uses 39 flops */
794 /* Increment number of outer iterations */
797 /* Update outer/inner flops */
799 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*160);