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_ElecRF_VdwCSTab_GeomW4P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwCSTab_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;
98 vdwtype = mdatoms->typeA;
100 vftab = kernel_data->table_vdw->data;
101 vftabscale = kernel_data->table_vdw->scale;
103 /* Setup water-specific parameters */
104 inr = nlist->iinr[0];
105 iq1 = facel*charge[inr+1];
106 iq2 = facel*charge[inr+2];
107 iq3 = facel*charge[inr+3];
108 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
113 /* Start outer loop over neighborlists */
114 for(iidx=0; iidx<nri; iidx++)
116 /* Load shift vector for this list */
117 i_shift_offset = DIM*shiftidx[iidx];
118 shX = shiftvec[i_shift_offset+XX];
119 shY = shiftvec[i_shift_offset+YY];
120 shZ = shiftvec[i_shift_offset+ZZ];
122 /* Load limits for loop over neighbors */
123 j_index_start = jindex[iidx];
124 j_index_end = jindex[iidx+1];
126 /* Get outer coordinate index */
128 i_coord_offset = DIM*inr;
130 /* Load i particle coords and add shift vector */
131 ix0 = shX + x[i_coord_offset+DIM*0+XX];
132 iy0 = shY + x[i_coord_offset+DIM*0+YY];
133 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
134 ix1 = shX + x[i_coord_offset+DIM*1+XX];
135 iy1 = shY + x[i_coord_offset+DIM*1+YY];
136 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
137 ix2 = shX + x[i_coord_offset+DIM*2+XX];
138 iy2 = shY + x[i_coord_offset+DIM*2+YY];
139 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
140 ix3 = shX + x[i_coord_offset+DIM*3+XX];
141 iy3 = shY + x[i_coord_offset+DIM*3+YY];
142 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
157 /* Reset potential sums */
161 /* Start inner kernel loop */
162 for(jidx=j_index_start; jidx<j_index_end; jidx++)
164 /* Get j neighbor index, and coordinate index */
166 j_coord_offset = DIM*jnr;
168 /* load j atom coordinates */
169 jx0 = x[j_coord_offset+DIM*0+XX];
170 jy0 = x[j_coord_offset+DIM*0+YY];
171 jz0 = x[j_coord_offset+DIM*0+ZZ];
173 /* Calculate displacement vector */
187 /* Calculate squared distance and things based on it */
188 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
189 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
190 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
191 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
193 rinv00 = gmx_invsqrt(rsq00);
194 rinv10 = gmx_invsqrt(rsq10);
195 rinv20 = gmx_invsqrt(rsq20);
196 rinv30 = gmx_invsqrt(rsq30);
198 rinvsq10 = rinv10*rinv10;
199 rinvsq20 = rinv20*rinv20;
200 rinvsq30 = rinv30*rinv30;
202 /* Load parameters for j particles */
204 vdwjidx0 = 2*vdwtype[jnr+0];
206 /**************************
207 * CALCULATE INTERACTIONS *
208 **************************/
212 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
213 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
215 /* Calculate table index by multiplying r with table scale and truncate to integer */
221 /* CUBIC SPLINE TABLE DISPERSION */
225 Geps = vfeps*vftab[vfitab+2];
226 Heps2 = vfeps*vfeps*vftab[vfitab+3];
230 FF = Fp+Geps+2.0*Heps2;
233 /* CUBIC SPLINE TABLE REPULSION */
236 Geps = vfeps*vftab[vfitab+6];
237 Heps2 = vfeps*vfeps*vftab[vfitab+7];
241 FF = Fp+Geps+2.0*Heps2;
244 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
246 /* Update potential sums from outer loop */
251 /* Calculate temporary vectorial force */
256 /* Update vectorial force */
260 f[j_coord_offset+DIM*0+XX] -= tx;
261 f[j_coord_offset+DIM*0+YY] -= ty;
262 f[j_coord_offset+DIM*0+ZZ] -= tz;
264 /**************************
265 * CALCULATE INTERACTIONS *
266 **************************/
270 /* REACTION-FIELD ELECTROSTATICS */
271 velec = qq10*(rinv10+krf*rsq10-crf);
272 felec = qq10*(rinv10*rinvsq10-krf2);
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*0+XX] -= tx;
289 f[j_coord_offset+DIM*0+YY] -= ty;
290 f[j_coord_offset+DIM*0+ZZ] -= tz;
292 /**************************
293 * CALCULATE INTERACTIONS *
294 **************************/
298 /* REACTION-FIELD ELECTROSTATICS */
299 velec = qq20*(rinv20+krf*rsq20-crf);
300 felec = qq20*(rinv20*rinvsq20-krf2);
302 /* Update potential sums from outer loop */
307 /* Calculate temporary vectorial force */
312 /* Update vectorial force */
316 f[j_coord_offset+DIM*0+XX] -= tx;
317 f[j_coord_offset+DIM*0+YY] -= ty;
318 f[j_coord_offset+DIM*0+ZZ] -= tz;
320 /**************************
321 * CALCULATE INTERACTIONS *
322 **************************/
326 /* REACTION-FIELD ELECTROSTATICS */
327 velec = qq30*(rinv30+krf*rsq30-crf);
328 felec = qq30*(rinv30*rinvsq30-krf2);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*0+XX] -= tx;
345 f[j_coord_offset+DIM*0+YY] -= ty;
346 f[j_coord_offset+DIM*0+ZZ] -= tz;
348 /* Inner loop uses 151 flops */
350 /* End of innermost loop */
353 f[i_coord_offset+DIM*0+XX] += fix0;
354 f[i_coord_offset+DIM*0+YY] += fiy0;
355 f[i_coord_offset+DIM*0+ZZ] += fiz0;
359 f[i_coord_offset+DIM*1+XX] += fix1;
360 f[i_coord_offset+DIM*1+YY] += fiy1;
361 f[i_coord_offset+DIM*1+ZZ] += fiz1;
365 f[i_coord_offset+DIM*2+XX] += fix2;
366 f[i_coord_offset+DIM*2+YY] += fiy2;
367 f[i_coord_offset+DIM*2+ZZ] += fiz2;
371 f[i_coord_offset+DIM*3+XX] += fix3;
372 f[i_coord_offset+DIM*3+YY] += fiy3;
373 f[i_coord_offset+DIM*3+ZZ] += fiz3;
377 fshift[i_shift_offset+XX] += tx;
378 fshift[i_shift_offset+YY] += ty;
379 fshift[i_shift_offset+ZZ] += tz;
382 /* Update potential energies */
383 kernel_data->energygrp_elec[ggid] += velecsum;
384 kernel_data->energygrp_vdw[ggid] += vvdwsum;
386 /* Increment number of inner iterations */
387 inneriter += j_index_end - j_index_start;
389 /* Outer loop uses 41 flops */
392 /* Increment number of outer iterations */
395 /* Update outer/inner flops */
397 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*151);
400 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW4P1_F_c
401 * Electrostatics interaction: ReactionField
402 * VdW interaction: CubicSplineTable
403 * Geometry: Water4-Particle
404 * Calculate force/pot: Force
407 nb_kernel_ElecRF_VdwCSTab_GeomW4P1_F_c
408 (t_nblist * gmx_restrict nlist,
409 rvec * gmx_restrict xx,
410 rvec * gmx_restrict ff,
411 t_forcerec * gmx_restrict fr,
412 t_mdatoms * gmx_restrict mdatoms,
413 nb_kernel_data_t * gmx_restrict kernel_data,
414 t_nrnb * gmx_restrict nrnb)
416 int i_shift_offset,i_coord_offset,j_coord_offset;
417 int j_index_start,j_index_end;
418 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
419 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
420 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
421 real *shiftvec,*fshift,*x,*f;
423 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
425 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
427 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
429 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
431 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
432 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
433 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
434 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
435 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
436 real velec,felec,velecsum,facel,crf,krf,krf2;
439 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
443 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
451 jindex = nlist->jindex;
453 shiftidx = nlist->shift;
455 shiftvec = fr->shift_vec[0];
456 fshift = fr->fshift[0];
458 charge = mdatoms->chargeA;
462 nvdwtype = fr->ntype;
464 vdwtype = mdatoms->typeA;
466 vftab = kernel_data->table_vdw->data;
467 vftabscale = kernel_data->table_vdw->scale;
469 /* Setup water-specific parameters */
470 inr = nlist->iinr[0];
471 iq1 = facel*charge[inr+1];
472 iq2 = facel*charge[inr+2];
473 iq3 = facel*charge[inr+3];
474 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
479 /* Start outer loop over neighborlists */
480 for(iidx=0; iidx<nri; iidx++)
482 /* Load shift vector for this list */
483 i_shift_offset = DIM*shiftidx[iidx];
484 shX = shiftvec[i_shift_offset+XX];
485 shY = shiftvec[i_shift_offset+YY];
486 shZ = shiftvec[i_shift_offset+ZZ];
488 /* Load limits for loop over neighbors */
489 j_index_start = jindex[iidx];
490 j_index_end = jindex[iidx+1];
492 /* Get outer coordinate index */
494 i_coord_offset = DIM*inr;
496 /* Load i particle coords and add shift vector */
497 ix0 = shX + x[i_coord_offset+DIM*0+XX];
498 iy0 = shY + x[i_coord_offset+DIM*0+YY];
499 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
500 ix1 = shX + x[i_coord_offset+DIM*1+XX];
501 iy1 = shY + x[i_coord_offset+DIM*1+YY];
502 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
503 ix2 = shX + x[i_coord_offset+DIM*2+XX];
504 iy2 = shY + x[i_coord_offset+DIM*2+YY];
505 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
506 ix3 = shX + x[i_coord_offset+DIM*3+XX];
507 iy3 = shY + x[i_coord_offset+DIM*3+YY];
508 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
523 /* Start inner kernel loop */
524 for(jidx=j_index_start; jidx<j_index_end; jidx++)
526 /* Get j neighbor index, and coordinate index */
528 j_coord_offset = DIM*jnr;
530 /* load j atom coordinates */
531 jx0 = x[j_coord_offset+DIM*0+XX];
532 jy0 = x[j_coord_offset+DIM*0+YY];
533 jz0 = x[j_coord_offset+DIM*0+ZZ];
535 /* Calculate displacement vector */
549 /* Calculate squared distance and things based on it */
550 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
551 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
552 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
553 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
555 rinv00 = gmx_invsqrt(rsq00);
556 rinv10 = gmx_invsqrt(rsq10);
557 rinv20 = gmx_invsqrt(rsq20);
558 rinv30 = gmx_invsqrt(rsq30);
560 rinvsq10 = rinv10*rinv10;
561 rinvsq20 = rinv20*rinv20;
562 rinvsq30 = rinv30*rinv30;
564 /* Load parameters for j particles */
566 vdwjidx0 = 2*vdwtype[jnr+0];
568 /**************************
569 * CALCULATE INTERACTIONS *
570 **************************/
574 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
575 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
577 /* Calculate table index by multiplying r with table scale and truncate to integer */
583 /* CUBIC SPLINE TABLE DISPERSION */
587 Geps = vfeps*vftab[vfitab+2];
588 Heps2 = vfeps*vfeps*vftab[vfitab+3];
590 FF = Fp+Geps+2.0*Heps2;
593 /* CUBIC SPLINE TABLE REPULSION */
596 Geps = vfeps*vftab[vfitab+6];
597 Heps2 = vfeps*vfeps*vftab[vfitab+7];
599 FF = Fp+Geps+2.0*Heps2;
601 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
605 /* Calculate temporary vectorial force */
610 /* Update vectorial force */
614 f[j_coord_offset+DIM*0+XX] -= tx;
615 f[j_coord_offset+DIM*0+YY] -= ty;
616 f[j_coord_offset+DIM*0+ZZ] -= tz;
618 /**************************
619 * CALCULATE INTERACTIONS *
620 **************************/
624 /* REACTION-FIELD ELECTROSTATICS */
625 felec = qq10*(rinv10*rinvsq10-krf2);
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;
642 /**************************
643 * CALCULATE INTERACTIONS *
644 **************************/
648 /* REACTION-FIELD ELECTROSTATICS */
649 felec = qq20*(rinv20*rinvsq20-krf2);
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 /**************************
667 * CALCULATE INTERACTIONS *
668 **************************/
672 /* REACTION-FIELD ELECTROSTATICS */
673 felec = qq30*(rinv30*rinvsq30-krf2);
677 /* Calculate temporary vectorial force */
682 /* Update vectorial force */
686 f[j_coord_offset+DIM*0+XX] -= tx;
687 f[j_coord_offset+DIM*0+YY] -= ty;
688 f[j_coord_offset+DIM*0+ZZ] -= tz;
690 /* Inner loop uses 128 flops */
692 /* End of innermost loop */
695 f[i_coord_offset+DIM*0+XX] += fix0;
696 f[i_coord_offset+DIM*0+YY] += fiy0;
697 f[i_coord_offset+DIM*0+ZZ] += fiz0;
701 f[i_coord_offset+DIM*1+XX] += fix1;
702 f[i_coord_offset+DIM*1+YY] += fiy1;
703 f[i_coord_offset+DIM*1+ZZ] += fiz1;
707 f[i_coord_offset+DIM*2+XX] += fix2;
708 f[i_coord_offset+DIM*2+YY] += fiy2;
709 f[i_coord_offset+DIM*2+ZZ] += fiz2;
713 f[i_coord_offset+DIM*3+XX] += fix3;
714 f[i_coord_offset+DIM*3+YY] += fiy3;
715 f[i_coord_offset+DIM*3+ZZ] += fiz3;
719 fshift[i_shift_offset+XX] += tx;
720 fshift[i_shift_offset+YY] += ty;
721 fshift[i_shift_offset+ZZ] += tz;
723 /* Increment number of inner iterations */
724 inneriter += j_index_end - j_index_start;
726 /* Outer loop uses 39 flops */
729 /* Increment number of outer iterations */
732 /* Update outer/inner flops */
734 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*128);