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_GeomW3P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: CubicSplineTable
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_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];
110 /* Start outer loop over neighborlists */
111 for(iidx=0; iidx<nri; iidx++)
113 /* Load shift vector for this list */
114 i_shift_offset = DIM*shiftidx[iidx];
115 shX = shiftvec[i_shift_offset+XX];
116 shY = shiftvec[i_shift_offset+YY];
117 shZ = shiftvec[i_shift_offset+ZZ];
119 /* Load limits for loop over neighbors */
120 j_index_start = jindex[iidx];
121 j_index_end = jindex[iidx+1];
123 /* Get outer coordinate index */
125 i_coord_offset = DIM*inr;
127 /* Load i particle coords and add shift vector */
128 ix0 = shX + x[i_coord_offset+DIM*0+XX];
129 iy0 = shY + x[i_coord_offset+DIM*0+YY];
130 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
131 ix1 = shX + x[i_coord_offset+DIM*1+XX];
132 iy1 = shY + x[i_coord_offset+DIM*1+YY];
133 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
134 ix2 = shX + x[i_coord_offset+DIM*2+XX];
135 iy2 = shY + x[i_coord_offset+DIM*2+YY];
136 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
148 /* Reset potential sums */
152 /* Start inner kernel loop */
153 for(jidx=j_index_start; jidx<j_index_end; jidx++)
155 /* Get j neighbor index, and coordinate index */
157 j_coord_offset = DIM*jnr;
159 /* load j atom coordinates */
160 jx0 = x[j_coord_offset+DIM*0+XX];
161 jy0 = x[j_coord_offset+DIM*0+YY];
162 jz0 = x[j_coord_offset+DIM*0+ZZ];
164 /* Calculate displacement vector */
175 /* Calculate squared distance and things based on it */
176 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
177 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
178 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
180 rinv00 = gmx_invsqrt(rsq00);
181 rinv10 = gmx_invsqrt(rsq10);
182 rinv20 = gmx_invsqrt(rsq20);
184 rinvsq00 = rinv00*rinv00;
185 rinvsq10 = rinv10*rinv10;
186 rinvsq20 = rinv20*rinv20;
188 /* Load parameters for j particles */
190 vdwjidx0 = 2*vdwtype[jnr+0];
192 /**************************
193 * CALCULATE INTERACTIONS *
194 **************************/
199 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
200 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
202 /* Calculate table index by multiplying r with table scale and truncate to integer */
208 /* REACTION-FIELD ELECTROSTATICS */
209 velec = qq00*(rinv00+krf*rsq00-crf);
210 felec = qq00*(rinv00*rinvsq00-krf2);
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 **************************/
262 /* REACTION-FIELD ELECTROSTATICS */
263 velec = qq10*(rinv10+krf*rsq10-crf);
264 felec = qq10*(rinv10*rinvsq10-krf2);
266 /* Update potential sums from outer loop */
271 /* Calculate temporary vectorial force */
276 /* Update vectorial force */
280 f[j_coord_offset+DIM*0+XX] -= tx;
281 f[j_coord_offset+DIM*0+YY] -= ty;
282 f[j_coord_offset+DIM*0+ZZ] -= tz;
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
290 /* REACTION-FIELD ELECTROSTATICS */
291 velec = qq20*(rinv20+krf*rsq20-crf);
292 felec = qq20*(rinv20*rinvsq20-krf2);
294 /* Update potential sums from outer loop */
299 /* Calculate temporary vectorial force */
304 /* Update vectorial force */
308 f[j_coord_offset+DIM*0+XX] -= tx;
309 f[j_coord_offset+DIM*0+YY] -= ty;
310 f[j_coord_offset+DIM*0+ZZ] -= tz;
312 /* Inner loop uses 130 flops */
314 /* End of innermost loop */
317 f[i_coord_offset+DIM*0+XX] += fix0;
318 f[i_coord_offset+DIM*0+YY] += fiy0;
319 f[i_coord_offset+DIM*0+ZZ] += fiz0;
323 f[i_coord_offset+DIM*1+XX] += fix1;
324 f[i_coord_offset+DIM*1+YY] += fiy1;
325 f[i_coord_offset+DIM*1+ZZ] += fiz1;
329 f[i_coord_offset+DIM*2+XX] += fix2;
330 f[i_coord_offset+DIM*2+YY] += fiy2;
331 f[i_coord_offset+DIM*2+ZZ] += fiz2;
335 fshift[i_shift_offset+XX] += tx;
336 fshift[i_shift_offset+YY] += ty;
337 fshift[i_shift_offset+ZZ] += tz;
340 /* Update potential energies */
341 kernel_data->energygrp_elec[ggid] += velecsum;
342 kernel_data->energygrp_vdw[ggid] += vvdwsum;
344 /* Increment number of inner iterations */
345 inneriter += j_index_end - j_index_start;
347 /* Outer loop uses 32 flops */
350 /* Increment number of outer iterations */
353 /* Update outer/inner flops */
355 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*130);
358 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_c
359 * Electrostatics interaction: ReactionField
360 * VdW interaction: CubicSplineTable
361 * Geometry: Water3-Particle
362 * Calculate force/pot: Force
365 nb_kernel_ElecRF_VdwCSTab_GeomW3P1_F_c
366 (t_nblist * gmx_restrict nlist,
367 rvec * gmx_restrict xx,
368 rvec * gmx_restrict ff,
369 t_forcerec * gmx_restrict fr,
370 t_mdatoms * gmx_restrict mdatoms,
371 nb_kernel_data_t * gmx_restrict kernel_data,
372 t_nrnb * gmx_restrict nrnb)
374 int i_shift_offset,i_coord_offset,j_coord_offset;
375 int j_index_start,j_index_end;
376 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
377 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
378 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
379 real *shiftvec,*fshift,*x,*f;
381 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
383 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
385 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
387 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
388 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
389 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
390 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
391 real velec,felec,velecsum,facel,crf,krf,krf2;
394 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
398 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
406 jindex = nlist->jindex;
408 shiftidx = nlist->shift;
410 shiftvec = fr->shift_vec[0];
411 fshift = fr->fshift[0];
413 charge = mdatoms->chargeA;
417 nvdwtype = fr->ntype;
419 vdwtype = mdatoms->typeA;
421 vftab = kernel_data->table_vdw->data;
422 vftabscale = kernel_data->table_vdw->scale;
424 /* Setup water-specific parameters */
425 inr = nlist->iinr[0];
426 iq0 = facel*charge[inr+0];
427 iq1 = facel*charge[inr+1];
428 iq2 = facel*charge[inr+2];
429 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
434 /* Start outer loop over neighborlists */
435 for(iidx=0; iidx<nri; iidx++)
437 /* Load shift vector for this list */
438 i_shift_offset = DIM*shiftidx[iidx];
439 shX = shiftvec[i_shift_offset+XX];
440 shY = shiftvec[i_shift_offset+YY];
441 shZ = shiftvec[i_shift_offset+ZZ];
443 /* Load limits for loop over neighbors */
444 j_index_start = jindex[iidx];
445 j_index_end = jindex[iidx+1];
447 /* Get outer coordinate index */
449 i_coord_offset = DIM*inr;
451 /* Load i particle coords and add shift vector */
452 ix0 = shX + x[i_coord_offset+DIM*0+XX];
453 iy0 = shY + x[i_coord_offset+DIM*0+YY];
454 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
455 ix1 = shX + x[i_coord_offset+DIM*1+XX];
456 iy1 = shY + x[i_coord_offset+DIM*1+YY];
457 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
458 ix2 = shX + x[i_coord_offset+DIM*2+XX];
459 iy2 = shY + x[i_coord_offset+DIM*2+YY];
460 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
472 /* Start inner kernel loop */
473 for(jidx=j_index_start; jidx<j_index_end; jidx++)
475 /* Get j neighbor index, and coordinate index */
477 j_coord_offset = DIM*jnr;
479 /* load j atom coordinates */
480 jx0 = x[j_coord_offset+DIM*0+XX];
481 jy0 = x[j_coord_offset+DIM*0+YY];
482 jz0 = x[j_coord_offset+DIM*0+ZZ];
484 /* Calculate displacement vector */
495 /* Calculate squared distance and things based on it */
496 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
497 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
498 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
500 rinv00 = gmx_invsqrt(rsq00);
501 rinv10 = gmx_invsqrt(rsq10);
502 rinv20 = gmx_invsqrt(rsq20);
504 rinvsq00 = rinv00*rinv00;
505 rinvsq10 = rinv10*rinv10;
506 rinvsq20 = rinv20*rinv20;
508 /* Load parameters for j particles */
510 vdwjidx0 = 2*vdwtype[jnr+0];
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
519 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
520 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
522 /* Calculate table index by multiplying r with table scale and truncate to integer */
528 /* REACTION-FIELD ELECTROSTATICS */
529 felec = qq00*(rinv00*rinvsq00-krf2);
531 /* CUBIC SPLINE TABLE DISPERSION */
534 Geps = vfeps*vftab[vfitab+2];
535 Heps2 = vfeps*vfeps*vftab[vfitab+3];
537 FF = Fp+Geps+2.0*Heps2;
540 /* CUBIC SPLINE TABLE REPULSION */
542 Geps = vfeps*vftab[vfitab+6];
543 Heps2 = vfeps*vfeps*vftab[vfitab+7];
545 FF = Fp+Geps+2.0*Heps2;
547 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
551 /* Calculate temporary vectorial force */
556 /* Update vectorial force */
560 f[j_coord_offset+DIM*0+XX] -= tx;
561 f[j_coord_offset+DIM*0+YY] -= ty;
562 f[j_coord_offset+DIM*0+ZZ] -= tz;
564 /**************************
565 * CALCULATE INTERACTIONS *
566 **************************/
570 /* REACTION-FIELD ELECTROSTATICS */
571 felec = qq10*(rinv10*rinvsq10-krf2);
575 /* Calculate temporary vectorial force */
580 /* Update vectorial force */
584 f[j_coord_offset+DIM*0+XX] -= tx;
585 f[j_coord_offset+DIM*0+YY] -= ty;
586 f[j_coord_offset+DIM*0+ZZ] -= tz;
588 /**************************
589 * CALCULATE INTERACTIONS *
590 **************************/
594 /* REACTION-FIELD ELECTROSTATICS */
595 felec = qq20*(rinv20*rinvsq20-krf2);
599 /* Calculate temporary vectorial force */
604 /* Update vectorial force */
608 f[j_coord_offset+DIM*0+XX] -= tx;
609 f[j_coord_offset+DIM*0+YY] -= ty;
610 f[j_coord_offset+DIM*0+ZZ] -= tz;
612 /* Inner loop uses 107 flops */
614 /* End of innermost loop */
617 f[i_coord_offset+DIM*0+XX] += fix0;
618 f[i_coord_offset+DIM*0+YY] += fiy0;
619 f[i_coord_offset+DIM*0+ZZ] += fiz0;
623 f[i_coord_offset+DIM*1+XX] += fix1;
624 f[i_coord_offset+DIM*1+YY] += fiy1;
625 f[i_coord_offset+DIM*1+ZZ] += fiz1;
629 f[i_coord_offset+DIM*2+XX] += fix2;
630 f[i_coord_offset+DIM*2+YY] += fiy2;
631 f[i_coord_offset+DIM*2+ZZ] += fiz2;
635 fshift[i_shift_offset+XX] += tx;
636 fshift[i_shift_offset+YY] += ty;
637 fshift[i_shift_offset+ZZ] += tz;
639 /* Increment number of inner iterations */
640 inneriter += j_index_end - j_index_start;
642 /* Outer loop uses 30 flops */
645 /* Increment number of outer iterations */
648 /* Update outer/inner flops */
650 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*107);