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_ElecCSTab_VdwLJ_GeomW4P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwLJ_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 rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
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 vftab = kernel_data->table_elec->data;
98 vftabscale = kernel_data->table_elec->scale;
100 /* Setup water-specific parameters */
101 inr = nlist->iinr[0];
102 iq1 = facel*charge[inr+1];
103 iq2 = facel*charge[inr+2];
104 iq3 = facel*charge[inr+3];
105 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
110 /* Start outer loop over neighborlists */
111 for(iidx=0; iidx<nri; iidx++)
113 /* Load shift vector for this list */
114 i_shift_offset = DIM*shiftidx[iidx];
115 shX = shiftvec[i_shift_offset+XX];
116 shY = shiftvec[i_shift_offset+YY];
117 shZ = shiftvec[i_shift_offset+ZZ];
119 /* Load limits for loop over neighbors */
120 j_index_start = jindex[iidx];
121 j_index_end = jindex[iidx+1];
123 /* Get outer coordinate index */
125 i_coord_offset = DIM*inr;
127 /* Load i particle coords and add shift vector */
128 ix0 = shX + x[i_coord_offset+DIM*0+XX];
129 iy0 = shY + x[i_coord_offset+DIM*0+YY];
130 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
131 ix1 = shX + x[i_coord_offset+DIM*1+XX];
132 iy1 = shY + x[i_coord_offset+DIM*1+YY];
133 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
134 ix2 = shX + x[i_coord_offset+DIM*2+XX];
135 iy2 = shY + x[i_coord_offset+DIM*2+YY];
136 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
137 ix3 = shX + x[i_coord_offset+DIM*3+XX];
138 iy3 = shY + x[i_coord_offset+DIM*3+YY];
139 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
154 /* 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 */
184 /* Calculate squared distance and things based on it */
185 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
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 rinvsq00 = 1.0/rsq00;
196 /* Load parameters for j particles */
198 vdwjidx0 = 2*vdwtype[jnr+0];
200 /**************************
201 * CALCULATE INTERACTIONS *
202 **************************/
204 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
205 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
207 /* LENNARD-JONES DISPERSION/REPULSION */
209 rinvsix = rinvsq00*rinvsq00*rinvsq00;
210 vvdw6 = c6_00*rinvsix;
211 vvdw12 = c12_00*rinvsix*rinvsix;
212 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
213 fvdw = (vvdw12-vvdw6)*rinvsq00;
215 /* Update potential sums from outer loop */
220 /* Calculate temporary vectorial force */
225 /* Update vectorial force */
229 f[j_coord_offset+DIM*0+XX] -= tx;
230 f[j_coord_offset+DIM*0+YY] -= ty;
231 f[j_coord_offset+DIM*0+ZZ] -= tz;
233 /**************************
234 * CALCULATE INTERACTIONS *
235 **************************/
241 /* Calculate table index by multiplying r with table scale and truncate to integer */
247 /* CUBIC SPLINE TABLE ELECTROSTATICS */
250 Geps = vfeps*vftab[vfitab+2];
251 Heps2 = vfeps*vfeps*vftab[vfitab+3];
255 FF = Fp+Geps+2.0*Heps2;
256 felec = -qq10*FF*vftabscale*rinv10;
258 /* Update potential sums from outer loop */
263 /* Calculate temporary vectorial force */
268 /* Update vectorial force */
272 f[j_coord_offset+DIM*0+XX] -= tx;
273 f[j_coord_offset+DIM*0+YY] -= ty;
274 f[j_coord_offset+DIM*0+ZZ] -= tz;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
284 /* Calculate table index by multiplying r with table scale and truncate to integer */
290 /* CUBIC SPLINE TABLE ELECTROSTATICS */
293 Geps = vfeps*vftab[vfitab+2];
294 Heps2 = vfeps*vfeps*vftab[vfitab+3];
298 FF = Fp+Geps+2.0*Heps2;
299 felec = -qq20*FF*vftabscale*rinv20;
301 /* Update potential sums from outer loop */
306 /* Calculate temporary vectorial force */
311 /* Update vectorial force */
315 f[j_coord_offset+DIM*0+XX] -= tx;
316 f[j_coord_offset+DIM*0+YY] -= ty;
317 f[j_coord_offset+DIM*0+ZZ] -= tz;
319 /**************************
320 * CALCULATE INTERACTIONS *
321 **************************/
327 /* Calculate table index by multiplying r with table scale and truncate to integer */
333 /* CUBIC SPLINE TABLE ELECTROSTATICS */
336 Geps = vfeps*vftab[vfitab+2];
337 Heps2 = vfeps*vfeps*vftab[vfitab+3];
341 FF = Fp+Geps+2.0*Heps2;
342 felec = -qq30*FF*vftabscale*rinv30;
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*0+XX] -= tx;
359 f[j_coord_offset+DIM*0+YY] -= ty;
360 f[j_coord_offset+DIM*0+ZZ] -= tz;
362 /* Inner loop uses 158 flops */
364 /* End of innermost loop */
367 f[i_coord_offset+DIM*0+XX] += fix0;
368 f[i_coord_offset+DIM*0+YY] += fiy0;
369 f[i_coord_offset+DIM*0+ZZ] += fiz0;
373 f[i_coord_offset+DIM*1+XX] += fix1;
374 f[i_coord_offset+DIM*1+YY] += fiy1;
375 f[i_coord_offset+DIM*1+ZZ] += fiz1;
379 f[i_coord_offset+DIM*2+XX] += fix2;
380 f[i_coord_offset+DIM*2+YY] += fiy2;
381 f[i_coord_offset+DIM*2+ZZ] += fiz2;
385 f[i_coord_offset+DIM*3+XX] += fix3;
386 f[i_coord_offset+DIM*3+YY] += fiy3;
387 f[i_coord_offset+DIM*3+ZZ] += fiz3;
391 fshift[i_shift_offset+XX] += tx;
392 fshift[i_shift_offset+YY] += ty;
393 fshift[i_shift_offset+ZZ] += tz;
396 /* Update potential energies */
397 kernel_data->energygrp_elec[ggid] += velecsum;
398 kernel_data->energygrp_vdw[ggid] += vvdwsum;
400 /* Increment number of inner iterations */
401 inneriter += j_index_end - j_index_start;
403 /* Outer loop uses 41 flops */
406 /* Increment number of outer iterations */
409 /* Update outer/inner flops */
411 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*158);
414 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4P1_F_c
415 * Electrostatics interaction: CubicSplineTable
416 * VdW interaction: LennardJones
417 * Geometry: Water4-Particle
418 * Calculate force/pot: Force
421 nb_kernel_ElecCSTab_VdwLJ_GeomW4P1_F_c
422 (t_nblist * gmx_restrict nlist,
423 rvec * gmx_restrict xx,
424 rvec * gmx_restrict ff,
425 t_forcerec * gmx_restrict fr,
426 t_mdatoms * gmx_restrict mdatoms,
427 nb_kernel_data_t * gmx_restrict kernel_data,
428 t_nrnb * gmx_restrict nrnb)
430 int i_shift_offset,i_coord_offset,j_coord_offset;
431 int j_index_start,j_index_end;
432 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
433 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
434 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
435 real *shiftvec,*fshift,*x,*f;
437 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
439 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
441 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
443 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
445 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
446 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
447 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
448 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
449 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
450 real velec,felec,velecsum,facel,crf,krf,krf2;
453 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
457 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
465 jindex = nlist->jindex;
467 shiftidx = nlist->shift;
469 shiftvec = fr->shift_vec[0];
470 fshift = fr->fshift[0];
472 charge = mdatoms->chargeA;
473 nvdwtype = fr->ntype;
475 vdwtype = mdatoms->typeA;
477 vftab = kernel_data->table_elec->data;
478 vftabscale = kernel_data->table_elec->scale;
480 /* Setup water-specific parameters */
481 inr = nlist->iinr[0];
482 iq1 = facel*charge[inr+1];
483 iq2 = facel*charge[inr+2];
484 iq3 = facel*charge[inr+3];
485 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
490 /* Start outer loop over neighborlists */
491 for(iidx=0; iidx<nri; iidx++)
493 /* Load shift vector for this list */
494 i_shift_offset = DIM*shiftidx[iidx];
495 shX = shiftvec[i_shift_offset+XX];
496 shY = shiftvec[i_shift_offset+YY];
497 shZ = shiftvec[i_shift_offset+ZZ];
499 /* Load limits for loop over neighbors */
500 j_index_start = jindex[iidx];
501 j_index_end = jindex[iidx+1];
503 /* Get outer coordinate index */
505 i_coord_offset = DIM*inr;
507 /* Load i particle coords and add shift vector */
508 ix0 = shX + x[i_coord_offset+DIM*0+XX];
509 iy0 = shY + x[i_coord_offset+DIM*0+YY];
510 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
511 ix1 = shX + x[i_coord_offset+DIM*1+XX];
512 iy1 = shY + x[i_coord_offset+DIM*1+YY];
513 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
514 ix2 = shX + x[i_coord_offset+DIM*2+XX];
515 iy2 = shY + x[i_coord_offset+DIM*2+YY];
516 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
517 ix3 = shX + x[i_coord_offset+DIM*3+XX];
518 iy3 = shY + x[i_coord_offset+DIM*3+YY];
519 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
534 /* Start inner kernel loop */
535 for(jidx=j_index_start; jidx<j_index_end; jidx++)
537 /* Get j neighbor index, and coordinate index */
539 j_coord_offset = DIM*jnr;
541 /* load j atom coordinates */
542 jx0 = x[j_coord_offset+DIM*0+XX];
543 jy0 = x[j_coord_offset+DIM*0+YY];
544 jz0 = x[j_coord_offset+DIM*0+ZZ];
546 /* Calculate displacement vector */
560 /* Calculate squared distance and things based on it */
561 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
562 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
563 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
564 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
566 rinv10 = gmx_invsqrt(rsq10);
567 rinv20 = gmx_invsqrt(rsq20);
568 rinv30 = gmx_invsqrt(rsq30);
570 rinvsq00 = 1.0/rsq00;
572 /* Load parameters for j particles */
574 vdwjidx0 = 2*vdwtype[jnr+0];
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
580 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
581 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
583 /* LENNARD-JONES DISPERSION/REPULSION */
585 rinvsix = rinvsq00*rinvsq00*rinvsq00;
586 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
590 /* Calculate temporary vectorial force */
595 /* Update vectorial force */
599 f[j_coord_offset+DIM*0+XX] -= tx;
600 f[j_coord_offset+DIM*0+YY] -= ty;
601 f[j_coord_offset+DIM*0+ZZ] -= tz;
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
611 /* Calculate table index by multiplying r with table scale and truncate to integer */
617 /* CUBIC SPLINE TABLE ELECTROSTATICS */
619 Geps = vfeps*vftab[vfitab+2];
620 Heps2 = vfeps*vfeps*vftab[vfitab+3];
622 FF = Fp+Geps+2.0*Heps2;
623 felec = -qq10*FF*vftabscale*rinv10;
627 /* Calculate temporary vectorial force */
632 /* Update vectorial force */
636 f[j_coord_offset+DIM*0+XX] -= tx;
637 f[j_coord_offset+DIM*0+YY] -= ty;
638 f[j_coord_offset+DIM*0+ZZ] -= tz;
640 /**************************
641 * CALCULATE INTERACTIONS *
642 **************************/
648 /* Calculate table index by multiplying r with table scale and truncate to integer */
654 /* CUBIC SPLINE TABLE ELECTROSTATICS */
656 Geps = vfeps*vftab[vfitab+2];
657 Heps2 = vfeps*vfeps*vftab[vfitab+3];
659 FF = Fp+Geps+2.0*Heps2;
660 felec = -qq20*FF*vftabscale*rinv20;
664 /* Calculate temporary vectorial force */
669 /* Update vectorial force */
673 f[j_coord_offset+DIM*0+XX] -= tx;
674 f[j_coord_offset+DIM*0+YY] -= ty;
675 f[j_coord_offset+DIM*0+ZZ] -= tz;
677 /**************************
678 * CALCULATE INTERACTIONS *
679 **************************/
685 /* Calculate table index by multiplying r with table scale and truncate to integer */
691 /* CUBIC SPLINE TABLE ELECTROSTATICS */
693 Geps = vfeps*vftab[vfitab+2];
694 Heps2 = vfeps*vfeps*vftab[vfitab+3];
696 FF = Fp+Geps+2.0*Heps2;
697 felec = -qq30*FF*vftabscale*rinv30;
701 /* Calculate temporary vectorial force */
706 /* Update vectorial force */
710 f[j_coord_offset+DIM*0+XX] -= tx;
711 f[j_coord_offset+DIM*0+YY] -= ty;
712 f[j_coord_offset+DIM*0+ZZ] -= tz;
714 /* Inner loop uses 141 flops */
716 /* End of innermost loop */
719 f[i_coord_offset+DIM*0+XX] += fix0;
720 f[i_coord_offset+DIM*0+YY] += fiy0;
721 f[i_coord_offset+DIM*0+ZZ] += fiz0;
725 f[i_coord_offset+DIM*1+XX] += fix1;
726 f[i_coord_offset+DIM*1+YY] += fiy1;
727 f[i_coord_offset+DIM*1+ZZ] += fiz1;
731 f[i_coord_offset+DIM*2+XX] += fix2;
732 f[i_coord_offset+DIM*2+YY] += fiy2;
733 f[i_coord_offset+DIM*2+ZZ] += fiz2;
737 f[i_coord_offset+DIM*3+XX] += fix3;
738 f[i_coord_offset+DIM*3+YY] += fiy3;
739 f[i_coord_offset+DIM*3+ZZ] += fiz3;
743 fshift[i_shift_offset+XX] += tx;
744 fshift[i_shift_offset+YY] += ty;
745 fshift[i_shift_offset+ZZ] += tz;
747 /* Increment number of inner iterations */
748 inneriter += j_index_end - j_index_start;
750 /* Outer loop uses 39 flops */
753 /* Increment number of outer iterations */
756 /* Update outer/inner flops */
758 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*141);