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_VdwCSTab_GeomW3P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
74 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
82 jindex = nlist->jindex;
84 shiftidx = nlist->shift;
86 shiftvec = fr->shift_vec[0];
87 fshift = fr->fshift[0];
89 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 vftab = kernel_data->table_elec_vdw->data;
95 vftabscale = kernel_data->table_elec_vdw->scale;
97 /* Setup water-specific parameters */
99 iq0 = facel*charge[inr+0];
100 iq1 = facel*charge[inr+1];
101 iq2 = facel*charge[inr+2];
102 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
107 /* Start outer loop over neighborlists */
108 for(iidx=0; iidx<nri; iidx++)
110 /* Load shift vector for this list */
111 i_shift_offset = DIM*shiftidx[iidx];
112 shX = shiftvec[i_shift_offset+XX];
113 shY = shiftvec[i_shift_offset+YY];
114 shZ = shiftvec[i_shift_offset+ZZ];
116 /* Load limits for loop over neighbors */
117 j_index_start = jindex[iidx];
118 j_index_end = jindex[iidx+1];
120 /* Get outer coordinate index */
122 i_coord_offset = DIM*inr;
124 /* Load i particle coords and add shift vector */
125 ix0 = shX + x[i_coord_offset+DIM*0+XX];
126 iy0 = shY + x[i_coord_offset+DIM*0+YY];
127 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
128 ix1 = shX + x[i_coord_offset+DIM*1+XX];
129 iy1 = shY + x[i_coord_offset+DIM*1+YY];
130 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
131 ix2 = shX + x[i_coord_offset+DIM*2+XX];
132 iy2 = shY + x[i_coord_offset+DIM*2+YY];
133 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
145 /* Reset potential sums */
149 /* Start inner kernel loop */
150 for(jidx=j_index_start; jidx<j_index_end; jidx++)
152 /* Get j neighbor index, and coordinate index */
154 j_coord_offset = DIM*jnr;
156 /* load j atom coordinates */
157 jx0 = x[j_coord_offset+DIM*0+XX];
158 jy0 = x[j_coord_offset+DIM*0+YY];
159 jz0 = x[j_coord_offset+DIM*0+ZZ];
161 /* Calculate displacement vector */
172 /* Calculate squared distance and things based on it */
173 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
174 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
175 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
177 rinv00 = gmx_invsqrt(rsq00);
178 rinv10 = gmx_invsqrt(rsq10);
179 rinv20 = gmx_invsqrt(rsq20);
181 /* Load parameters for j particles */
183 vdwjidx0 = 2*vdwtype[jnr+0];
185 /**************************
186 * CALCULATE INTERACTIONS *
187 **************************/
192 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
193 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
195 /* Calculate table index by multiplying r with table scale and truncate to integer */
201 /* CUBIC SPLINE TABLE ELECTROSTATICS */
204 Geps = vfeps*vftab[vfitab+2];
205 Heps2 = vfeps*vfeps*vftab[vfitab+3];
209 FF = Fp+Geps+2.0*Heps2;
210 felec = -qq00*FF*vftabscale*rinv00;
212 /* CUBIC SPLINE TABLE DISPERSION */
216 Geps = vfeps*vftab[vfitab+2];
217 Heps2 = vfeps*vfeps*vftab[vfitab+3];
221 FF = Fp+Geps+2.0*Heps2;
224 /* CUBIC SPLINE TABLE REPULSION */
227 Geps = vfeps*vftab[vfitab+6];
228 Heps2 = vfeps*vfeps*vftab[vfitab+7];
232 FF = Fp+Geps+2.0*Heps2;
235 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
237 /* Update potential sums from outer loop */
243 /* Calculate temporary vectorial force */
248 /* Update vectorial force */
252 f[j_coord_offset+DIM*0+XX] -= tx;
253 f[j_coord_offset+DIM*0+YY] -= ty;
254 f[j_coord_offset+DIM*0+ZZ] -= tz;
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
264 /* Calculate table index by multiplying r with table scale and truncate to integer */
270 /* CUBIC SPLINE TABLE ELECTROSTATICS */
273 Geps = vfeps*vftab[vfitab+2];
274 Heps2 = vfeps*vfeps*vftab[vfitab+3];
278 FF = Fp+Geps+2.0*Heps2;
279 felec = -qq10*FF*vftabscale*rinv10;
281 /* Update potential sums from outer loop */
286 /* Calculate temporary vectorial force */
291 /* Update vectorial force */
295 f[j_coord_offset+DIM*0+XX] -= tx;
296 f[j_coord_offset+DIM*0+YY] -= ty;
297 f[j_coord_offset+DIM*0+ZZ] -= tz;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
307 /* Calculate table index by multiplying r with table scale and truncate to integer */
313 /* CUBIC SPLINE TABLE ELECTROSTATICS */
316 Geps = vfeps*vftab[vfitab+2];
317 Heps2 = vfeps*vfeps*vftab[vfitab+3];
321 FF = Fp+Geps+2.0*Heps2;
322 felec = -qq20*FF*vftabscale*rinv20;
324 /* Update potential sums from outer loop */
329 /* Calculate temporary vectorial force */
334 /* Update vectorial force */
338 f[j_coord_offset+DIM*0+XX] -= tx;
339 f[j_coord_offset+DIM*0+YY] -= ty;
340 f[j_coord_offset+DIM*0+ZZ] -= tz;
342 /* Inner loop uses 157 flops */
344 /* End of innermost loop */
347 f[i_coord_offset+DIM*0+XX] += fix0;
348 f[i_coord_offset+DIM*0+YY] += fiy0;
349 f[i_coord_offset+DIM*0+ZZ] += fiz0;
353 f[i_coord_offset+DIM*1+XX] += fix1;
354 f[i_coord_offset+DIM*1+YY] += fiy1;
355 f[i_coord_offset+DIM*1+ZZ] += fiz1;
359 f[i_coord_offset+DIM*2+XX] += fix2;
360 f[i_coord_offset+DIM*2+YY] += fiy2;
361 f[i_coord_offset+DIM*2+ZZ] += fiz2;
365 fshift[i_shift_offset+XX] += tx;
366 fshift[i_shift_offset+YY] += ty;
367 fshift[i_shift_offset+ZZ] += tz;
370 /* Update potential energies */
371 kernel_data->energygrp_elec[ggid] += velecsum;
372 kernel_data->energygrp_vdw[ggid] += vvdwsum;
374 /* Increment number of inner iterations */
375 inneriter += j_index_end - j_index_start;
377 /* Outer loop uses 32 flops */
380 /* Increment number of outer iterations */
383 /* Update outer/inner flops */
385 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*157);
388 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_F_c
389 * Electrostatics interaction: CubicSplineTable
390 * VdW interaction: CubicSplineTable
391 * Geometry: Water3-Particle
392 * Calculate force/pot: Force
395 nb_kernel_ElecCSTab_VdwCSTab_GeomW3P1_F_c
396 (t_nblist * gmx_restrict nlist,
397 rvec * gmx_restrict xx,
398 rvec * gmx_restrict ff,
399 t_forcerec * gmx_restrict fr,
400 t_mdatoms * gmx_restrict mdatoms,
401 nb_kernel_data_t * gmx_restrict kernel_data,
402 t_nrnb * gmx_restrict nrnb)
404 int i_shift_offset,i_coord_offset,j_coord_offset;
405 int j_index_start,j_index_end;
406 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
407 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
408 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
409 real *shiftvec,*fshift,*x,*f;
411 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
413 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
415 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
417 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
419 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
420 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
421 real velec,felec,velecsum,facel,crf,krf,krf2;
424 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
428 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
436 jindex = nlist->jindex;
438 shiftidx = nlist->shift;
440 shiftvec = fr->shift_vec[0];
441 fshift = fr->fshift[0];
443 charge = mdatoms->chargeA;
444 nvdwtype = fr->ntype;
446 vdwtype = mdatoms->typeA;
448 vftab = kernel_data->table_elec_vdw->data;
449 vftabscale = kernel_data->table_elec_vdw->scale;
451 /* Setup water-specific parameters */
452 inr = nlist->iinr[0];
453 iq0 = facel*charge[inr+0];
454 iq1 = facel*charge[inr+1];
455 iq2 = facel*charge[inr+2];
456 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
461 /* Start outer loop over neighborlists */
462 for(iidx=0; iidx<nri; iidx++)
464 /* Load shift vector for this list */
465 i_shift_offset = DIM*shiftidx[iidx];
466 shX = shiftvec[i_shift_offset+XX];
467 shY = shiftvec[i_shift_offset+YY];
468 shZ = shiftvec[i_shift_offset+ZZ];
470 /* Load limits for loop over neighbors */
471 j_index_start = jindex[iidx];
472 j_index_end = jindex[iidx+1];
474 /* Get outer coordinate index */
476 i_coord_offset = DIM*inr;
478 /* Load i particle coords and add shift vector */
479 ix0 = shX + x[i_coord_offset+DIM*0+XX];
480 iy0 = shY + x[i_coord_offset+DIM*0+YY];
481 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
482 ix1 = shX + x[i_coord_offset+DIM*1+XX];
483 iy1 = shY + x[i_coord_offset+DIM*1+YY];
484 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
485 ix2 = shX + x[i_coord_offset+DIM*2+XX];
486 iy2 = shY + x[i_coord_offset+DIM*2+YY];
487 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
499 /* Start inner kernel loop */
500 for(jidx=j_index_start; jidx<j_index_end; jidx++)
502 /* Get j neighbor index, and coordinate index */
504 j_coord_offset = DIM*jnr;
506 /* load j atom coordinates */
507 jx0 = x[j_coord_offset+DIM*0+XX];
508 jy0 = x[j_coord_offset+DIM*0+YY];
509 jz0 = x[j_coord_offset+DIM*0+ZZ];
511 /* Calculate displacement vector */
522 /* Calculate squared distance and things based on it */
523 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
524 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
525 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
527 rinv00 = gmx_invsqrt(rsq00);
528 rinv10 = gmx_invsqrt(rsq10);
529 rinv20 = gmx_invsqrt(rsq20);
531 /* Load parameters for j particles */
533 vdwjidx0 = 2*vdwtype[jnr+0];
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
542 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
543 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
545 /* Calculate table index by multiplying r with table scale and truncate to integer */
551 /* CUBIC SPLINE TABLE ELECTROSTATICS */
553 Geps = vfeps*vftab[vfitab+2];
554 Heps2 = vfeps*vfeps*vftab[vfitab+3];
556 FF = Fp+Geps+2.0*Heps2;
557 felec = -qq00*FF*vftabscale*rinv00;
559 /* CUBIC SPLINE TABLE DISPERSION */
562 Geps = vfeps*vftab[vfitab+2];
563 Heps2 = vfeps*vfeps*vftab[vfitab+3];
565 FF = Fp+Geps+2.0*Heps2;
568 /* CUBIC SPLINE TABLE REPULSION */
570 Geps = vfeps*vftab[vfitab+6];
571 Heps2 = vfeps*vfeps*vftab[vfitab+7];
573 FF = Fp+Geps+2.0*Heps2;
575 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
579 /* Calculate temporary vectorial force */
584 /* Update vectorial force */
588 f[j_coord_offset+DIM*0+XX] -= tx;
589 f[j_coord_offset+DIM*0+YY] -= ty;
590 f[j_coord_offset+DIM*0+ZZ] -= tz;
592 /**************************
593 * CALCULATE INTERACTIONS *
594 **************************/
600 /* Calculate table index by multiplying r with table scale and truncate to integer */
606 /* CUBIC SPLINE TABLE ELECTROSTATICS */
608 Geps = vfeps*vftab[vfitab+2];
609 Heps2 = vfeps*vfeps*vftab[vfitab+3];
611 FF = Fp+Geps+2.0*Heps2;
612 felec = -qq10*FF*vftabscale*rinv10;
616 /* Calculate temporary vectorial force */
621 /* Update vectorial force */
625 f[j_coord_offset+DIM*0+XX] -= tx;
626 f[j_coord_offset+DIM*0+YY] -= ty;
627 f[j_coord_offset+DIM*0+ZZ] -= tz;
629 /**************************
630 * CALCULATE INTERACTIONS *
631 **************************/
637 /* Calculate table index by multiplying r with table scale and truncate to integer */
643 /* CUBIC SPLINE TABLE ELECTROSTATICS */
645 Geps = vfeps*vftab[vfitab+2];
646 Heps2 = vfeps*vfeps*vftab[vfitab+3];
648 FF = Fp+Geps+2.0*Heps2;
649 felec = -qq20*FF*vftabscale*rinv20;
653 /* Calculate temporary vectorial force */
658 /* Update vectorial force */
662 f[j_coord_offset+DIM*0+XX] -= tx;
663 f[j_coord_offset+DIM*0+YY] -= ty;
664 f[j_coord_offset+DIM*0+ZZ] -= tz;
666 /* Inner loop uses 137 flops */
668 /* End of innermost loop */
671 f[i_coord_offset+DIM*0+XX] += fix0;
672 f[i_coord_offset+DIM*0+YY] += fiy0;
673 f[i_coord_offset+DIM*0+ZZ] += fiz0;
677 f[i_coord_offset+DIM*1+XX] += fix1;
678 f[i_coord_offset+DIM*1+YY] += fiy1;
679 f[i_coord_offset+DIM*1+ZZ] += fiz1;
683 f[i_coord_offset+DIM*2+XX] += fix2;
684 f[i_coord_offset+DIM*2+YY] += fiy2;
685 f[i_coord_offset+DIM*2+ZZ] += fiz2;
689 fshift[i_shift_offset+XX] += tx;
690 fshift[i_shift_offset+YY] += ty;
691 fshift[i_shift_offset+ZZ] += tz;
693 /* Increment number of inner iterations */
694 inneriter += j_index_end - j_index_start;
696 /* Outer loop uses 30 flops */
699 /* Increment number of outer iterations */
702 /* Update outer/inner flops */
704 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*137);