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_GeomW3P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_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;
95 vdwtype = mdatoms->typeA;
97 vftab = kernel_data->table_vdw->data;
98 vftabscale = kernel_data->table_vdw->scale;
100 /* Setup water-specific parameters */
101 inr = nlist->iinr[0];
102 iq0 = facel*charge[inr+0];
103 iq1 = facel*charge[inr+1];
104 iq2 = facel*charge[inr+2];
105 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
107 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
108 rcutoff = fr->rcoulomb;
109 rcutoff2 = rcutoff*rcutoff;
114 /* Start outer loop over neighborlists */
115 for(iidx=0; iidx<nri; iidx++)
117 /* Load shift vector for this list */
118 i_shift_offset = DIM*shiftidx[iidx];
119 shX = shiftvec[i_shift_offset+XX];
120 shY = shiftvec[i_shift_offset+YY];
121 shZ = shiftvec[i_shift_offset+ZZ];
123 /* Load limits for loop over neighbors */
124 j_index_start = jindex[iidx];
125 j_index_end = jindex[iidx+1];
127 /* Get outer coordinate index */
129 i_coord_offset = DIM*inr;
131 /* Load i particle coords and add shift vector */
132 ix0 = shX + x[i_coord_offset+DIM*0+XX];
133 iy0 = shY + x[i_coord_offset+DIM*0+YY];
134 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
135 ix1 = shX + x[i_coord_offset+DIM*1+XX];
136 iy1 = shY + x[i_coord_offset+DIM*1+YY];
137 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
138 ix2 = shX + x[i_coord_offset+DIM*2+XX];
139 iy2 = shY + x[i_coord_offset+DIM*2+YY];
140 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
152 /* Reset potential sums */
156 /* Start inner kernel loop */
157 for(jidx=j_index_start; jidx<j_index_end; jidx++)
159 /* Get j neighbor index, and coordinate index */
161 j_coord_offset = DIM*jnr;
163 /* load j atom coordinates */
164 jx0 = x[j_coord_offset+DIM*0+XX];
165 jy0 = x[j_coord_offset+DIM*0+YY];
166 jz0 = x[j_coord_offset+DIM*0+ZZ];
168 /* Calculate displacement vector */
179 /* Calculate squared distance and things based on it */
180 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
181 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
182 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
184 rinv00 = gmx_invsqrt(rsq00);
185 rinv10 = gmx_invsqrt(rsq10);
186 rinv20 = gmx_invsqrt(rsq20);
188 rinvsq00 = rinv00*rinv00;
189 rinvsq10 = rinv10*rinv10;
190 rinvsq20 = rinv20*rinv20;
192 /* Load parameters for j particles */
194 vdwjidx0 = 2*vdwtype[jnr+0];
196 /**************************
197 * CALCULATE INTERACTIONS *
198 **************************/
206 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
207 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
209 /* Calculate table index by multiplying r with table scale and truncate to integer */
215 /* REACTION-FIELD ELECTROSTATICS */
216 velec = qq00*(rinv00+krf*rsq00-crf);
217 felec = qq00*(rinv00*rinvsq00-krf2);
219 /* CUBIC SPLINE TABLE DISPERSION */
223 Geps = vfeps*vftab[vfitab+2];
224 Heps2 = vfeps*vfeps*vftab[vfitab+3];
228 FF = Fp+Geps+2.0*Heps2;
231 /* CUBIC SPLINE TABLE REPULSION */
234 Geps = vfeps*vftab[vfitab+6];
235 Heps2 = vfeps*vfeps*vftab[vfitab+7];
239 FF = Fp+Geps+2.0*Heps2;
242 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
244 /* Update potential sums from outer loop */
250 /* Calculate temporary vectorial force */
255 /* Update vectorial force */
259 f[j_coord_offset+DIM*0+XX] -= tx;
260 f[j_coord_offset+DIM*0+YY] -= ty;
261 f[j_coord_offset+DIM*0+ZZ] -= tz;
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
274 /* REACTION-FIELD ELECTROSTATICS */
275 velec = qq10*(rinv10+krf*rsq10-crf);
276 felec = qq10*(rinv10*rinvsq10-krf2);
278 /* Update potential sums from outer loop */
283 /* Calculate temporary vectorial force */
288 /* Update vectorial force */
292 f[j_coord_offset+DIM*0+XX] -= tx;
293 f[j_coord_offset+DIM*0+YY] -= ty;
294 f[j_coord_offset+DIM*0+ZZ] -= tz;
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
307 /* REACTION-FIELD ELECTROSTATICS */
308 velec = qq20*(rinv20+krf*rsq20-crf);
309 felec = qq20*(rinv20*rinvsq20-krf2);
311 /* Update potential sums from outer loop */
316 /* Calculate temporary vectorial force */
321 /* Update vectorial force */
325 f[j_coord_offset+DIM*0+XX] -= tx;
326 f[j_coord_offset+DIM*0+YY] -= ty;
327 f[j_coord_offset+DIM*0+ZZ] -= tz;
331 /* Inner loop uses 130 flops */
333 /* End of innermost loop */
336 f[i_coord_offset+DIM*0+XX] += fix0;
337 f[i_coord_offset+DIM*0+YY] += fiy0;
338 f[i_coord_offset+DIM*0+ZZ] += fiz0;
342 f[i_coord_offset+DIM*1+XX] += fix1;
343 f[i_coord_offset+DIM*1+YY] += fiy1;
344 f[i_coord_offset+DIM*1+ZZ] += fiz1;
348 f[i_coord_offset+DIM*2+XX] += fix2;
349 f[i_coord_offset+DIM*2+YY] += fiy2;
350 f[i_coord_offset+DIM*2+ZZ] += fiz2;
354 fshift[i_shift_offset+XX] += tx;
355 fshift[i_shift_offset+YY] += ty;
356 fshift[i_shift_offset+ZZ] += tz;
359 /* Update potential energies */
360 kernel_data->energygrp_elec[ggid] += velecsum;
361 kernel_data->energygrp_vdw[ggid] += vvdwsum;
363 /* Increment number of inner iterations */
364 inneriter += j_index_end - j_index_start;
366 /* Outer loop uses 32 flops */
369 /* Increment number of outer iterations */
372 /* Update outer/inner flops */
374 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*130);
377 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_F_c
378 * Electrostatics interaction: ReactionField
379 * VdW interaction: CubicSplineTable
380 * Geometry: Water3-Particle
381 * Calculate force/pot: Force
384 nb_kernel_ElecRFCut_VdwCSTab_GeomW3P1_F_c
385 (t_nblist * gmx_restrict nlist,
386 rvec * gmx_restrict xx,
387 rvec * gmx_restrict ff,
388 t_forcerec * gmx_restrict fr,
389 t_mdatoms * gmx_restrict mdatoms,
390 nb_kernel_data_t * gmx_restrict kernel_data,
391 t_nrnb * gmx_restrict nrnb)
393 int i_shift_offset,i_coord_offset,j_coord_offset;
394 int j_index_start,j_index_end;
395 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
396 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
397 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
398 real *shiftvec,*fshift,*x,*f;
400 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
402 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
404 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
406 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
407 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
408 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
409 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
410 real velec,felec,velecsum,facel,crf,krf,krf2;
413 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
417 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
425 jindex = nlist->jindex;
427 shiftidx = nlist->shift;
429 shiftvec = fr->shift_vec[0];
430 fshift = fr->fshift[0];
432 charge = mdatoms->chargeA;
436 nvdwtype = fr->ntype;
438 vdwtype = mdatoms->typeA;
440 vftab = kernel_data->table_vdw->data;
441 vftabscale = kernel_data->table_vdw->scale;
443 /* Setup water-specific parameters */
444 inr = nlist->iinr[0];
445 iq0 = facel*charge[inr+0];
446 iq1 = facel*charge[inr+1];
447 iq2 = facel*charge[inr+2];
448 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
450 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
451 rcutoff = fr->rcoulomb;
452 rcutoff2 = rcutoff*rcutoff;
457 /* Start outer loop over neighborlists */
458 for(iidx=0; iidx<nri; iidx++)
460 /* Load shift vector for this list */
461 i_shift_offset = DIM*shiftidx[iidx];
462 shX = shiftvec[i_shift_offset+XX];
463 shY = shiftvec[i_shift_offset+YY];
464 shZ = shiftvec[i_shift_offset+ZZ];
466 /* Load limits for loop over neighbors */
467 j_index_start = jindex[iidx];
468 j_index_end = jindex[iidx+1];
470 /* Get outer coordinate index */
472 i_coord_offset = DIM*inr;
474 /* Load i particle coords and add shift vector */
475 ix0 = shX + x[i_coord_offset+DIM*0+XX];
476 iy0 = shY + x[i_coord_offset+DIM*0+YY];
477 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
478 ix1 = shX + x[i_coord_offset+DIM*1+XX];
479 iy1 = shY + x[i_coord_offset+DIM*1+YY];
480 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
481 ix2 = shX + x[i_coord_offset+DIM*2+XX];
482 iy2 = shY + x[i_coord_offset+DIM*2+YY];
483 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
495 /* Start inner kernel loop */
496 for(jidx=j_index_start; jidx<j_index_end; jidx++)
498 /* Get j neighbor index, and coordinate index */
500 j_coord_offset = DIM*jnr;
502 /* load j atom coordinates */
503 jx0 = x[j_coord_offset+DIM*0+XX];
504 jy0 = x[j_coord_offset+DIM*0+YY];
505 jz0 = x[j_coord_offset+DIM*0+ZZ];
507 /* Calculate displacement vector */
518 /* Calculate squared distance and things based on it */
519 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
520 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
521 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
523 rinv00 = gmx_invsqrt(rsq00);
524 rinv10 = gmx_invsqrt(rsq10);
525 rinv20 = gmx_invsqrt(rsq20);
527 rinvsq00 = rinv00*rinv00;
528 rinvsq10 = rinv10*rinv10;
529 rinvsq20 = rinv20*rinv20;
531 /* Load parameters for j particles */
533 vdwjidx0 = 2*vdwtype[jnr+0];
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
545 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
546 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
548 /* Calculate table index by multiplying r with table scale and truncate to integer */
554 /* REACTION-FIELD ELECTROSTATICS */
555 felec = qq00*(rinv00*rinvsq00-krf2);
557 /* CUBIC SPLINE TABLE DISPERSION */
561 Geps = vfeps*vftab[vfitab+2];
562 Heps2 = vfeps*vfeps*vftab[vfitab+3];
564 FF = Fp+Geps+2.0*Heps2;
567 /* 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;
594 /**************************
595 * CALCULATE INTERACTIONS *
596 **************************/
603 /* REACTION-FIELD ELECTROSTATICS */
604 felec = qq10*(rinv10*rinvsq10-krf2);
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*0+XX] -= tx;
618 f[j_coord_offset+DIM*0+YY] -= ty;
619 f[j_coord_offset+DIM*0+ZZ] -= tz;
623 /**************************
624 * CALCULATE INTERACTIONS *
625 **************************/
632 /* REACTION-FIELD ELECTROSTATICS */
633 felec = qq20*(rinv20*rinvsq20-krf2);
637 /* Calculate temporary vectorial force */
642 /* Update vectorial force */
646 f[j_coord_offset+DIM*0+XX] -= tx;
647 f[j_coord_offset+DIM*0+YY] -= ty;
648 f[j_coord_offset+DIM*0+ZZ] -= tz;
652 /* Inner loop uses 107 flops */
654 /* End of innermost loop */
657 f[i_coord_offset+DIM*0+XX] += fix0;
658 f[i_coord_offset+DIM*0+YY] += fiy0;
659 f[i_coord_offset+DIM*0+ZZ] += fiz0;
663 f[i_coord_offset+DIM*1+XX] += fix1;
664 f[i_coord_offset+DIM*1+YY] += fiy1;
665 f[i_coord_offset+DIM*1+ZZ] += fiz1;
669 f[i_coord_offset+DIM*2+XX] += fix2;
670 f[i_coord_offset+DIM*2+YY] += fiy2;
671 f[i_coord_offset+DIM*2+ZZ] += fiz2;
675 fshift[i_shift_offset+XX] += tx;
676 fshift[i_shift_offset+YY] += ty;
677 fshift[i_shift_offset+ZZ] += tz;
679 /* Increment number of inner iterations */
680 inneriter += j_index_end - j_index_start;
682 /* Outer loop uses 30 flops */
685 /* Increment number of outer iterations */
688 /* Update outer/inner flops */
690 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);