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_ElecRFCut_VdwCSTab_GeomW4P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_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];
110 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
111 rcutoff = fr->rcoulomb;
112 rcutoff2 = rcutoff*rcutoff;
117 /* Start outer loop over neighborlists */
118 for(iidx=0; iidx<nri; iidx++)
120 /* Load shift vector for this list */
121 i_shift_offset = DIM*shiftidx[iidx];
122 shX = shiftvec[i_shift_offset+XX];
123 shY = shiftvec[i_shift_offset+YY];
124 shZ = shiftvec[i_shift_offset+ZZ];
126 /* Load limits for loop over neighbors */
127 j_index_start = jindex[iidx];
128 j_index_end = jindex[iidx+1];
130 /* Get outer coordinate index */
132 i_coord_offset = DIM*inr;
134 /* Load i particle coords and add shift vector */
135 ix0 = shX + x[i_coord_offset+DIM*0+XX];
136 iy0 = shY + x[i_coord_offset+DIM*0+YY];
137 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
138 ix1 = shX + x[i_coord_offset+DIM*1+XX];
139 iy1 = shY + x[i_coord_offset+DIM*1+YY];
140 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
141 ix2 = shX + x[i_coord_offset+DIM*2+XX];
142 iy2 = shY + x[i_coord_offset+DIM*2+YY];
143 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
144 ix3 = shX + x[i_coord_offset+DIM*3+XX];
145 iy3 = shY + x[i_coord_offset+DIM*3+YY];
146 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
161 /* Reset potential sums */
165 /* Start inner kernel loop */
166 for(jidx=j_index_start; jidx<j_index_end; jidx++)
168 /* Get j neighbor index, and coordinate index */
170 j_coord_offset = DIM*jnr;
172 /* load j atom coordinates */
173 jx0 = x[j_coord_offset+DIM*0+XX];
174 jy0 = x[j_coord_offset+DIM*0+YY];
175 jz0 = x[j_coord_offset+DIM*0+ZZ];
177 /* Calculate displacement vector */
191 /* Calculate squared distance and things based on it */
192 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
193 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
194 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
195 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
197 rinv00 = gmx_invsqrt(rsq00);
198 rinv10 = gmx_invsqrt(rsq10);
199 rinv20 = gmx_invsqrt(rsq20);
200 rinv30 = gmx_invsqrt(rsq30);
202 rinvsq10 = rinv10*rinv10;
203 rinvsq20 = rinv20*rinv20;
204 rinvsq30 = rinv30*rinv30;
206 /* Load parameters for j particles */
208 vdwjidx0 = 2*vdwtype[jnr+0];
210 /**************************
211 * CALCULATE INTERACTIONS *
212 **************************/
216 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
217 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
219 /* Calculate table index by multiplying r with table scale and truncate to integer */
225 /* CUBIC SPLINE TABLE DISPERSION */
229 Geps = vfeps*vftab[vfitab+2];
230 Heps2 = vfeps*vfeps*vftab[vfitab+3];
234 FF = Fp+Geps+2.0*Heps2;
237 /* CUBIC SPLINE TABLE REPULSION */
240 Geps = vfeps*vftab[vfitab+6];
241 Heps2 = vfeps*vfeps*vftab[vfitab+7];
245 FF = Fp+Geps+2.0*Heps2;
248 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
250 /* Update potential sums from outer loop */
255 /* Calculate temporary vectorial force */
260 /* Update vectorial force */
264 f[j_coord_offset+DIM*0+XX] -= tx;
265 f[j_coord_offset+DIM*0+YY] -= ty;
266 f[j_coord_offset+DIM*0+ZZ] -= tz;
268 /**************************
269 * CALCULATE INTERACTIONS *
270 **************************/
277 /* REACTION-FIELD ELECTROSTATICS */
278 velec = qq10*(rinv10+krf*rsq10-crf);
279 felec = qq10*(rinv10*rinvsq10-krf2);
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;
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
310 /* REACTION-FIELD ELECTROSTATICS */
311 velec = qq20*(rinv20+krf*rsq20-crf);
312 felec = qq20*(rinv20*rinvsq20-krf2);
314 /* Update potential sums from outer loop */
319 /* Calculate temporary vectorial force */
324 /* Update vectorial force */
328 f[j_coord_offset+DIM*0+XX] -= tx;
329 f[j_coord_offset+DIM*0+YY] -= ty;
330 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
343 /* REACTION-FIELD ELECTROSTATICS */
344 velec = qq30*(rinv30+krf*rsq30-crf);
345 felec = qq30*(rinv30*rinvsq30-krf2);
347 /* Update potential sums from outer loop */
352 /* Calculate temporary vectorial force */
357 /* Update vectorial force */
361 f[j_coord_offset+DIM*0+XX] -= tx;
362 f[j_coord_offset+DIM*0+YY] -= ty;
363 f[j_coord_offset+DIM*0+ZZ] -= tz;
367 /* Inner loop uses 151 flops */
369 /* End of innermost loop */
372 f[i_coord_offset+DIM*0+XX] += fix0;
373 f[i_coord_offset+DIM*0+YY] += fiy0;
374 f[i_coord_offset+DIM*0+ZZ] += fiz0;
378 f[i_coord_offset+DIM*1+XX] += fix1;
379 f[i_coord_offset+DIM*1+YY] += fiy1;
380 f[i_coord_offset+DIM*1+ZZ] += fiz1;
384 f[i_coord_offset+DIM*2+XX] += fix2;
385 f[i_coord_offset+DIM*2+YY] += fiy2;
386 f[i_coord_offset+DIM*2+ZZ] += fiz2;
390 f[i_coord_offset+DIM*3+XX] += fix3;
391 f[i_coord_offset+DIM*3+YY] += fiy3;
392 f[i_coord_offset+DIM*3+ZZ] += fiz3;
396 fshift[i_shift_offset+XX] += tx;
397 fshift[i_shift_offset+YY] += ty;
398 fshift[i_shift_offset+ZZ] += tz;
401 /* Update potential energies */
402 kernel_data->energygrp_elec[ggid] += velecsum;
403 kernel_data->energygrp_vdw[ggid] += vvdwsum;
405 /* Increment number of inner iterations */
406 inneriter += j_index_end - j_index_start;
408 /* Outer loop uses 41 flops */
411 /* Increment number of outer iterations */
414 /* Update outer/inner flops */
416 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*151);
419 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_c
420 * Electrostatics interaction: ReactionField
421 * VdW interaction: CubicSplineTable
422 * Geometry: Water4-Particle
423 * Calculate force/pot: Force
426 nb_kernel_ElecRFCut_VdwCSTab_GeomW4P1_F_c
427 (t_nblist * gmx_restrict nlist,
428 rvec * gmx_restrict xx,
429 rvec * gmx_restrict ff,
430 t_forcerec * gmx_restrict fr,
431 t_mdatoms * gmx_restrict mdatoms,
432 nb_kernel_data_t * gmx_restrict kernel_data,
433 t_nrnb * gmx_restrict nrnb)
435 int i_shift_offset,i_coord_offset,j_coord_offset;
436 int j_index_start,j_index_end;
437 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
438 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
439 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
440 real *shiftvec,*fshift,*x,*f;
442 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
444 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
446 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
448 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
450 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
451 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
452 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
453 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
454 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
455 real velec,felec,velecsum,facel,crf,krf,krf2;
458 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
462 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
470 jindex = nlist->jindex;
472 shiftidx = nlist->shift;
474 shiftvec = fr->shift_vec[0];
475 fshift = fr->fshift[0];
477 charge = mdatoms->chargeA;
481 nvdwtype = fr->ntype;
483 vdwtype = mdatoms->typeA;
485 vftab = kernel_data->table_vdw->data;
486 vftabscale = kernel_data->table_vdw->scale;
488 /* Setup water-specific parameters */
489 inr = nlist->iinr[0];
490 iq1 = facel*charge[inr+1];
491 iq2 = facel*charge[inr+2];
492 iq3 = facel*charge[inr+3];
493 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
495 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
496 rcutoff = fr->rcoulomb;
497 rcutoff2 = rcutoff*rcutoff;
502 /* Start outer loop over neighborlists */
503 for(iidx=0; iidx<nri; iidx++)
505 /* Load shift vector for this list */
506 i_shift_offset = DIM*shiftidx[iidx];
507 shX = shiftvec[i_shift_offset+XX];
508 shY = shiftvec[i_shift_offset+YY];
509 shZ = shiftvec[i_shift_offset+ZZ];
511 /* Load limits for loop over neighbors */
512 j_index_start = jindex[iidx];
513 j_index_end = jindex[iidx+1];
515 /* Get outer coordinate index */
517 i_coord_offset = DIM*inr;
519 /* Load i particle coords and add shift vector */
520 ix0 = shX + x[i_coord_offset+DIM*0+XX];
521 iy0 = shY + x[i_coord_offset+DIM*0+YY];
522 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
523 ix1 = shX + x[i_coord_offset+DIM*1+XX];
524 iy1 = shY + x[i_coord_offset+DIM*1+YY];
525 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
526 ix2 = shX + x[i_coord_offset+DIM*2+XX];
527 iy2 = shY + x[i_coord_offset+DIM*2+YY];
528 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
529 ix3 = shX + x[i_coord_offset+DIM*3+XX];
530 iy3 = shY + x[i_coord_offset+DIM*3+YY];
531 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
546 /* Start inner kernel loop */
547 for(jidx=j_index_start; jidx<j_index_end; jidx++)
549 /* Get j neighbor index, and coordinate index */
551 j_coord_offset = DIM*jnr;
553 /* load j atom coordinates */
554 jx0 = x[j_coord_offset+DIM*0+XX];
555 jy0 = x[j_coord_offset+DIM*0+YY];
556 jz0 = x[j_coord_offset+DIM*0+ZZ];
558 /* Calculate displacement vector */
572 /* Calculate squared distance and things based on it */
573 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
574 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
575 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
576 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
578 rinv00 = gmx_invsqrt(rsq00);
579 rinv10 = gmx_invsqrt(rsq10);
580 rinv20 = gmx_invsqrt(rsq20);
581 rinv30 = gmx_invsqrt(rsq30);
583 rinvsq10 = rinv10*rinv10;
584 rinvsq20 = rinv20*rinv20;
585 rinvsq30 = rinv30*rinv30;
587 /* Load parameters for j particles */
589 vdwjidx0 = 2*vdwtype[jnr+0];
591 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
597 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
598 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
600 /* Calculate table index by multiplying r with table scale and truncate to integer */
606 /* CUBIC SPLINE TABLE DISPERSION */
610 Geps = vfeps*vftab[vfitab+2];
611 Heps2 = vfeps*vfeps*vftab[vfitab+3];
613 FF = Fp+Geps+2.0*Heps2;
616 /* CUBIC SPLINE TABLE REPULSION */
619 Geps = vfeps*vftab[vfitab+6];
620 Heps2 = vfeps*vfeps*vftab[vfitab+7];
622 FF = Fp+Geps+2.0*Heps2;
624 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
628 /* Calculate temporary vectorial force */
633 /* Update vectorial force */
637 f[j_coord_offset+DIM*0+XX] -= tx;
638 f[j_coord_offset+DIM*0+YY] -= ty;
639 f[j_coord_offset+DIM*0+ZZ] -= tz;
641 /**************************
642 * CALCULATE INTERACTIONS *
643 **************************/
650 /* REACTION-FIELD ELECTROSTATICS */
651 felec = qq10*(rinv10*rinvsq10-krf2);
655 /* Calculate temporary vectorial force */
660 /* Update vectorial force */
664 f[j_coord_offset+DIM*0+XX] -= tx;
665 f[j_coord_offset+DIM*0+YY] -= ty;
666 f[j_coord_offset+DIM*0+ZZ] -= tz;
670 /**************************
671 * CALCULATE INTERACTIONS *
672 **************************/
679 /* REACTION-FIELD ELECTROSTATICS */
680 felec = qq20*(rinv20*rinvsq20-krf2);
684 /* Calculate temporary vectorial force */
689 /* Update vectorial force */
693 f[j_coord_offset+DIM*0+XX] -= tx;
694 f[j_coord_offset+DIM*0+YY] -= ty;
695 f[j_coord_offset+DIM*0+ZZ] -= tz;
699 /**************************
700 * CALCULATE INTERACTIONS *
701 **************************/
708 /* REACTION-FIELD ELECTROSTATICS */
709 felec = qq30*(rinv30*rinvsq30-krf2);
713 /* Calculate temporary vectorial force */
718 /* Update vectorial force */
722 f[j_coord_offset+DIM*0+XX] -= tx;
723 f[j_coord_offset+DIM*0+YY] -= ty;
724 f[j_coord_offset+DIM*0+ZZ] -= tz;
728 /* Inner loop uses 128 flops */
730 /* End of innermost loop */
733 f[i_coord_offset+DIM*0+XX] += fix0;
734 f[i_coord_offset+DIM*0+YY] += fiy0;
735 f[i_coord_offset+DIM*0+ZZ] += fiz0;
739 f[i_coord_offset+DIM*1+XX] += fix1;
740 f[i_coord_offset+DIM*1+YY] += fiy1;
741 f[i_coord_offset+DIM*1+ZZ] += fiz1;
745 f[i_coord_offset+DIM*2+XX] += fix2;
746 f[i_coord_offset+DIM*2+YY] += fiy2;
747 f[i_coord_offset+DIM*2+ZZ] += fiz2;
751 f[i_coord_offset+DIM*3+XX] += fix3;
752 f[i_coord_offset+DIM*3+YY] += fiy3;
753 f[i_coord_offset+DIM*3+ZZ] += fiz3;
757 fshift[i_shift_offset+XX] += tx;
758 fshift[i_shift_offset+YY] += ty;
759 fshift[i_shift_offset+ZZ] += tz;
761 /* Increment number of inner iterations */
762 inneriter += j_index_end - j_index_start;
764 /* Outer loop uses 39 flops */
767 /* Increment number of outer iterations */
770 /* Update outer/inner flops */
772 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*128);