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_ElecCoul_VdwCSTab_GeomW3P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_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_vdw->data;
95 vftabscale = kernel_data->table_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 rinvsq00 = rinv00*rinv00;
182 rinvsq10 = rinv10*rinv10;
183 rinvsq20 = rinv20*rinv20;
185 /* Load parameters for j particles */
187 vdwjidx0 = 2*vdwtype[jnr+0];
189 /**************************
190 * CALCULATE INTERACTIONS *
191 **************************/
196 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
197 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
199 /* Calculate table index by multiplying r with table scale and truncate to integer */
205 /* COULOMB ELECTROSTATICS */
207 felec = velec*rinvsq00;
209 /* CUBIC SPLINE TABLE DISPERSION */
213 Geps = vfeps*vftab[vfitab+2];
214 Heps2 = vfeps*vfeps*vftab[vfitab+3];
218 FF = Fp+Geps+2.0*Heps2;
221 /* CUBIC SPLINE TABLE REPULSION */
224 Geps = vfeps*vftab[vfitab+6];
225 Heps2 = vfeps*vfeps*vftab[vfitab+7];
229 FF = Fp+Geps+2.0*Heps2;
232 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
234 /* Update potential sums from outer loop */
240 /* Calculate temporary vectorial force */
245 /* Update vectorial force */
249 f[j_coord_offset+DIM*0+XX] -= tx;
250 f[j_coord_offset+DIM*0+YY] -= ty;
251 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
259 /* COULOMB ELECTROSTATICS */
261 felec = velec*rinvsq10;
263 /* Update potential sums from outer loop */
268 /* Calculate temporary vectorial force */
273 /* Update vectorial force */
277 f[j_coord_offset+DIM*0+XX] -= tx;
278 f[j_coord_offset+DIM*0+YY] -= ty;
279 f[j_coord_offset+DIM*0+ZZ] -= tz;
281 /**************************
282 * CALCULATE INTERACTIONS *
283 **************************/
287 /* COULOMB ELECTROSTATICS */
289 felec = velec*rinvsq20;
291 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
309 /* Inner loop uses 118 flops */
311 /* End of innermost loop */
314 f[i_coord_offset+DIM*0+XX] += fix0;
315 f[i_coord_offset+DIM*0+YY] += fiy0;
316 f[i_coord_offset+DIM*0+ZZ] += fiz0;
320 f[i_coord_offset+DIM*1+XX] += fix1;
321 f[i_coord_offset+DIM*1+YY] += fiy1;
322 f[i_coord_offset+DIM*1+ZZ] += fiz1;
326 f[i_coord_offset+DIM*2+XX] += fix2;
327 f[i_coord_offset+DIM*2+YY] += fiy2;
328 f[i_coord_offset+DIM*2+ZZ] += fiz2;
332 fshift[i_shift_offset+XX] += tx;
333 fshift[i_shift_offset+YY] += ty;
334 fshift[i_shift_offset+ZZ] += tz;
337 /* Update potential energies */
338 kernel_data->energygrp_elec[ggid] += velecsum;
339 kernel_data->energygrp_vdw[ggid] += vvdwsum;
341 /* Increment number of inner iterations */
342 inneriter += j_index_end - j_index_start;
344 /* Outer loop uses 32 flops */
347 /* Increment number of outer iterations */
350 /* Update outer/inner flops */
352 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*118);
355 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
356 * Electrostatics interaction: Coulomb
357 * VdW interaction: CubicSplineTable
358 * Geometry: Water3-Particle
359 * Calculate force/pot: Force
362 nb_kernel_ElecCoul_VdwCSTab_GeomW3P1_F_c
363 (t_nblist * gmx_restrict nlist,
364 rvec * gmx_restrict xx,
365 rvec * gmx_restrict ff,
366 t_forcerec * gmx_restrict fr,
367 t_mdatoms * gmx_restrict mdatoms,
368 nb_kernel_data_t * gmx_restrict kernel_data,
369 t_nrnb * gmx_restrict nrnb)
371 int i_shift_offset,i_coord_offset,j_coord_offset;
372 int j_index_start,j_index_end;
373 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
374 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
375 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
376 real *shiftvec,*fshift,*x,*f;
378 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
380 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
382 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
384 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
385 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
386 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
387 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
388 real velec,felec,velecsum,facel,crf,krf,krf2;
391 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
395 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
403 jindex = nlist->jindex;
405 shiftidx = nlist->shift;
407 shiftvec = fr->shift_vec[0];
408 fshift = fr->fshift[0];
410 charge = mdatoms->chargeA;
411 nvdwtype = fr->ntype;
413 vdwtype = mdatoms->typeA;
415 vftab = kernel_data->table_vdw->data;
416 vftabscale = kernel_data->table_vdw->scale;
418 /* Setup water-specific parameters */
419 inr = nlist->iinr[0];
420 iq0 = facel*charge[inr+0];
421 iq1 = facel*charge[inr+1];
422 iq2 = facel*charge[inr+2];
423 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
428 /* Start outer loop over neighborlists */
429 for(iidx=0; iidx<nri; iidx++)
431 /* Load shift vector for this list */
432 i_shift_offset = DIM*shiftidx[iidx];
433 shX = shiftvec[i_shift_offset+XX];
434 shY = shiftvec[i_shift_offset+YY];
435 shZ = shiftvec[i_shift_offset+ZZ];
437 /* Load limits for loop over neighbors */
438 j_index_start = jindex[iidx];
439 j_index_end = jindex[iidx+1];
441 /* Get outer coordinate index */
443 i_coord_offset = DIM*inr;
445 /* Load i particle coords and add shift vector */
446 ix0 = shX + x[i_coord_offset+DIM*0+XX];
447 iy0 = shY + x[i_coord_offset+DIM*0+YY];
448 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
449 ix1 = shX + x[i_coord_offset+DIM*1+XX];
450 iy1 = shY + x[i_coord_offset+DIM*1+YY];
451 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
452 ix2 = shX + x[i_coord_offset+DIM*2+XX];
453 iy2 = shY + x[i_coord_offset+DIM*2+YY];
454 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
466 /* Start inner kernel loop */
467 for(jidx=j_index_start; jidx<j_index_end; jidx++)
469 /* Get j neighbor index, and coordinate index */
471 j_coord_offset = DIM*jnr;
473 /* load j atom coordinates */
474 jx0 = x[j_coord_offset+DIM*0+XX];
475 jy0 = x[j_coord_offset+DIM*0+YY];
476 jz0 = x[j_coord_offset+DIM*0+ZZ];
478 /* Calculate displacement vector */
489 /* Calculate squared distance and things based on it */
490 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
491 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
492 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
494 rinv00 = gmx_invsqrt(rsq00);
495 rinv10 = gmx_invsqrt(rsq10);
496 rinv20 = gmx_invsqrt(rsq20);
498 rinvsq00 = rinv00*rinv00;
499 rinvsq10 = rinv10*rinv10;
500 rinvsq20 = rinv20*rinv20;
502 /* Load parameters for j particles */
504 vdwjidx0 = 2*vdwtype[jnr+0];
506 /**************************
507 * CALCULATE INTERACTIONS *
508 **************************/
513 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
514 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
516 /* Calculate table index by multiplying r with table scale and truncate to integer */
522 /* COULOMB ELECTROSTATICS */
524 felec = velec*rinvsq00;
526 /* CUBIC SPLINE TABLE DISPERSION */
530 Geps = vfeps*vftab[vfitab+2];
531 Heps2 = vfeps*vfeps*vftab[vfitab+3];
533 FF = Fp+Geps+2.0*Heps2;
536 /* CUBIC SPLINE TABLE REPULSION */
539 Geps = vfeps*vftab[vfitab+6];
540 Heps2 = vfeps*vfeps*vftab[vfitab+7];
542 FF = Fp+Geps+2.0*Heps2;
544 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
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 **************************/
567 /* COULOMB ELECTROSTATICS */
569 felec = velec*rinvsq10;
573 /* Calculate temporary vectorial force */
578 /* Update vectorial force */
582 f[j_coord_offset+DIM*0+XX] -= tx;
583 f[j_coord_offset+DIM*0+YY] -= ty;
584 f[j_coord_offset+DIM*0+ZZ] -= tz;
586 /**************************
587 * CALCULATE INTERACTIONS *
588 **************************/
592 /* COULOMB ELECTROSTATICS */
594 felec = velec*rinvsq20;
598 /* Calculate temporary vectorial force */
603 /* Update vectorial force */
607 f[j_coord_offset+DIM*0+XX] -= tx;
608 f[j_coord_offset+DIM*0+YY] -= ty;
609 f[j_coord_offset+DIM*0+ZZ] -= tz;
611 /* Inner loop uses 107 flops */
613 /* End of innermost loop */
616 f[i_coord_offset+DIM*0+XX] += fix0;
617 f[i_coord_offset+DIM*0+YY] += fiy0;
618 f[i_coord_offset+DIM*0+ZZ] += fiz0;
622 f[i_coord_offset+DIM*1+XX] += fix1;
623 f[i_coord_offset+DIM*1+YY] += fiy1;
624 f[i_coord_offset+DIM*1+ZZ] += fiz1;
628 f[i_coord_offset+DIM*2+XX] += fix2;
629 f[i_coord_offset+DIM*2+YY] += fiy2;
630 f[i_coord_offset+DIM*2+ZZ] += fiz2;
634 fshift[i_shift_offset+XX] += tx;
635 fshift[i_shift_offset+YY] += ty;
636 fshift[i_shift_offset+ZZ] += tz;
638 /* Increment number of inner iterations */
639 inneriter += j_index_end - j_index_start;
641 /* Outer loop uses 30 flops */
644 /* Increment number of outer iterations */
647 /* Update outer/inner flops */
649 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);