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_ElecEwSh_VdwBhamSh_GeomW3P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwBhamSh_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
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 sh_ewald = fr->ic->sh_ewald;
95 ewtab = fr->ic->tabq_coul_FDV0;
96 ewtabscale = fr->ic->tabq_scale;
97 ewtabhalfspace = 0.5/ewtabscale;
99 /* Setup water-specific parameters */
100 inr = nlist->iinr[0];
101 iq0 = facel*charge[inr+0];
102 iq1 = facel*charge[inr+1];
103 iq2 = facel*charge[inr+2];
104 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
106 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
107 rcutoff = fr->rcoulomb;
108 rcutoff2 = rcutoff*rcutoff;
110 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
116 /* Start outer loop over neighborlists */
117 for(iidx=0; iidx<nri; iidx++)
119 /* Load shift vector for this list */
120 i_shift_offset = DIM*shiftidx[iidx];
121 shX = shiftvec[i_shift_offset+XX];
122 shY = shiftvec[i_shift_offset+YY];
123 shZ = shiftvec[i_shift_offset+ZZ];
125 /* Load limits for loop over neighbors */
126 j_index_start = jindex[iidx];
127 j_index_end = jindex[iidx+1];
129 /* Get outer coordinate index */
131 i_coord_offset = DIM*inr;
133 /* Load i particle coords and add shift vector */
134 ix0 = shX + x[i_coord_offset+DIM*0+XX];
135 iy0 = shY + x[i_coord_offset+DIM*0+YY];
136 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
137 ix1 = shX + x[i_coord_offset+DIM*1+XX];
138 iy1 = shY + x[i_coord_offset+DIM*1+YY];
139 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
140 ix2 = shX + x[i_coord_offset+DIM*2+XX];
141 iy2 = shY + x[i_coord_offset+DIM*2+YY];
142 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
154 /* Reset potential sums */
158 /* Start inner kernel loop */
159 for(jidx=j_index_start; jidx<j_index_end; jidx++)
161 /* Get j neighbor index, and coordinate index */
163 j_coord_offset = DIM*jnr;
165 /* load j atom coordinates */
166 jx0 = x[j_coord_offset+DIM*0+XX];
167 jy0 = x[j_coord_offset+DIM*0+YY];
168 jz0 = x[j_coord_offset+DIM*0+ZZ];
170 /* Calculate displacement vector */
181 /* Calculate squared distance and things based on it */
182 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
183 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
184 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
186 rinv00 = gmx_invsqrt(rsq00);
187 rinv10 = gmx_invsqrt(rsq10);
188 rinv20 = gmx_invsqrt(rsq20);
190 rinvsq00 = rinv00*rinv00;
191 rinvsq10 = rinv10*rinv10;
192 rinvsq20 = rinv20*rinv20;
194 /* Load parameters for j particles */
196 vdwjidx0 = 3*vdwtype[jnr+0];
198 /**************************
199 * CALCULATE INTERACTIONS *
200 **************************/
208 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
209 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
210 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
212 /* EWALD ELECTROSTATICS */
214 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
215 ewrt = r00*ewtabscale;
219 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
220 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
221 felec = qq00*rinv00*(rinvsq00-felec);
223 /* BUCKINGHAM DISPERSION/REPULSION */
224 rinvsix = rinvsq00*rinvsq00*rinvsq00;
225 vvdw6 = c6_00*rinvsix;
227 vvdwexp = cexp1_00*exp(-br);
228 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
229 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
231 /* Update potential sums from outer loop */
237 /* Calculate temporary vectorial force */
242 /* Update vectorial force */
246 f[j_coord_offset+DIM*0+XX] -= tx;
247 f[j_coord_offset+DIM*0+YY] -= ty;
248 f[j_coord_offset+DIM*0+ZZ] -= tz;
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
263 /* EWALD ELECTROSTATICS */
265 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
266 ewrt = r10*ewtabscale;
270 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
271 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
272 felec = qq10*rinv10*(rinvsq10-felec);
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;
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
305 /* EWALD ELECTROSTATICS */
307 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
308 ewrt = r20*ewtabscale;
312 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
313 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
314 felec = qq20*rinv20*(rinvsq20-felec);
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
336 /* Inner loop uses 195 flops */
338 /* End of innermost loop */
341 f[i_coord_offset+DIM*0+XX] += fix0;
342 f[i_coord_offset+DIM*0+YY] += fiy0;
343 f[i_coord_offset+DIM*0+ZZ] += fiz0;
347 f[i_coord_offset+DIM*1+XX] += fix1;
348 f[i_coord_offset+DIM*1+YY] += fiy1;
349 f[i_coord_offset+DIM*1+ZZ] += fiz1;
353 f[i_coord_offset+DIM*2+XX] += fix2;
354 f[i_coord_offset+DIM*2+YY] += fiy2;
355 f[i_coord_offset+DIM*2+ZZ] += fiz2;
359 fshift[i_shift_offset+XX] += tx;
360 fshift[i_shift_offset+YY] += ty;
361 fshift[i_shift_offset+ZZ] += tz;
364 /* Update potential energies */
365 kernel_data->energygrp_elec[ggid] += velecsum;
366 kernel_data->energygrp_vdw[ggid] += vvdwsum;
368 /* Increment number of inner iterations */
369 inneriter += j_index_end - j_index_start;
371 /* Outer loop uses 32 flops */
374 /* Increment number of outer iterations */
377 /* Update outer/inner flops */
379 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*195);
382 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwBhamSh_GeomW3P1_F_c
383 * Electrostatics interaction: Ewald
384 * VdW interaction: Buckingham
385 * Geometry: Water3-Particle
386 * Calculate force/pot: Force
389 nb_kernel_ElecEwSh_VdwBhamSh_GeomW3P1_F_c
390 (t_nblist * gmx_restrict nlist,
391 rvec * gmx_restrict xx,
392 rvec * gmx_restrict ff,
393 t_forcerec * gmx_restrict fr,
394 t_mdatoms * gmx_restrict mdatoms,
395 nb_kernel_data_t * gmx_restrict kernel_data,
396 t_nrnb * gmx_restrict nrnb)
398 int i_shift_offset,i_coord_offset,j_coord_offset;
399 int j_index_start,j_index_end;
400 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
401 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
402 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
403 real *shiftvec,*fshift,*x,*f;
405 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
407 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
409 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
411 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
412 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
413 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
414 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
415 real velec,felec,velecsum,facel,crf,krf,krf2;
418 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
422 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
430 jindex = nlist->jindex;
432 shiftidx = nlist->shift;
434 shiftvec = fr->shift_vec[0];
435 fshift = fr->fshift[0];
437 charge = mdatoms->chargeA;
438 nvdwtype = fr->ntype;
440 vdwtype = mdatoms->typeA;
442 sh_ewald = fr->ic->sh_ewald;
443 ewtab = fr->ic->tabq_coul_F;
444 ewtabscale = fr->ic->tabq_scale;
445 ewtabhalfspace = 0.5/ewtabscale;
447 /* Setup water-specific parameters */
448 inr = nlist->iinr[0];
449 iq0 = facel*charge[inr+0];
450 iq1 = facel*charge[inr+1];
451 iq2 = facel*charge[inr+2];
452 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
454 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
455 rcutoff = fr->rcoulomb;
456 rcutoff2 = rcutoff*rcutoff;
458 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
464 /* Start outer loop over neighborlists */
465 for(iidx=0; iidx<nri; iidx++)
467 /* Load shift vector for this list */
468 i_shift_offset = DIM*shiftidx[iidx];
469 shX = shiftvec[i_shift_offset+XX];
470 shY = shiftvec[i_shift_offset+YY];
471 shZ = shiftvec[i_shift_offset+ZZ];
473 /* Load limits for loop over neighbors */
474 j_index_start = jindex[iidx];
475 j_index_end = jindex[iidx+1];
477 /* Get outer coordinate index */
479 i_coord_offset = DIM*inr;
481 /* Load i particle coords and add shift vector */
482 ix0 = shX + x[i_coord_offset+DIM*0+XX];
483 iy0 = shY + x[i_coord_offset+DIM*0+YY];
484 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
485 ix1 = shX + x[i_coord_offset+DIM*1+XX];
486 iy1 = shY + x[i_coord_offset+DIM*1+YY];
487 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
488 ix2 = shX + x[i_coord_offset+DIM*2+XX];
489 iy2 = shY + x[i_coord_offset+DIM*2+YY];
490 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
502 /* Start inner kernel loop */
503 for(jidx=j_index_start; jidx<j_index_end; jidx++)
505 /* Get j neighbor index, and coordinate index */
507 j_coord_offset = DIM*jnr;
509 /* load j atom coordinates */
510 jx0 = x[j_coord_offset+DIM*0+XX];
511 jy0 = x[j_coord_offset+DIM*0+YY];
512 jz0 = x[j_coord_offset+DIM*0+ZZ];
514 /* Calculate displacement vector */
525 /* Calculate squared distance and things based on it */
526 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
527 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
528 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
530 rinv00 = gmx_invsqrt(rsq00);
531 rinv10 = gmx_invsqrt(rsq10);
532 rinv20 = gmx_invsqrt(rsq20);
534 rinvsq00 = rinv00*rinv00;
535 rinvsq10 = rinv10*rinv10;
536 rinvsq20 = rinv20*rinv20;
538 /* Load parameters for j particles */
540 vdwjidx0 = 3*vdwtype[jnr+0];
542 /**************************
543 * CALCULATE INTERACTIONS *
544 **************************/
552 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
553 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
554 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
556 /* EWALD ELECTROSTATICS */
558 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
559 ewrt = r00*ewtabscale;
562 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
563 felec = qq00*rinv00*(rinvsq00-felec);
565 /* BUCKINGHAM DISPERSION/REPULSION */
566 rinvsix = rinvsq00*rinvsq00*rinvsq00;
567 vvdw6 = c6_00*rinvsix;
569 vvdwexp = cexp1_00*exp(-br);
570 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
574 /* Calculate temporary vectorial force */
579 /* Update vectorial force */
583 f[j_coord_offset+DIM*0+XX] -= tx;
584 f[j_coord_offset+DIM*0+YY] -= ty;
585 f[j_coord_offset+DIM*0+ZZ] -= tz;
589 /**************************
590 * CALCULATE INTERACTIONS *
591 **************************/
600 /* EWALD ELECTROSTATICS */
602 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
603 ewrt = r10*ewtabscale;
606 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
607 felec = qq10*rinv10*(rinvsq10-felec);
611 /* Calculate temporary vectorial force */
616 /* Update vectorial force */
620 f[j_coord_offset+DIM*0+XX] -= tx;
621 f[j_coord_offset+DIM*0+YY] -= ty;
622 f[j_coord_offset+DIM*0+ZZ] -= tz;
626 /**************************
627 * CALCULATE INTERACTIONS *
628 **************************/
637 /* EWALD ELECTROSTATICS */
639 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
640 ewrt = r20*ewtabscale;
643 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
644 felec = qq20*rinv20*(rinvsq20-felec);
648 /* Calculate temporary vectorial force */
653 /* Update vectorial force */
657 f[j_coord_offset+DIM*0+XX] -= tx;
658 f[j_coord_offset+DIM*0+YY] -= ty;
659 f[j_coord_offset+DIM*0+ZZ] -= tz;
663 /* Inner loop uses 137 flops */
665 /* End of innermost loop */
668 f[i_coord_offset+DIM*0+XX] += fix0;
669 f[i_coord_offset+DIM*0+YY] += fiy0;
670 f[i_coord_offset+DIM*0+ZZ] += fiz0;
674 f[i_coord_offset+DIM*1+XX] += fix1;
675 f[i_coord_offset+DIM*1+YY] += fiy1;
676 f[i_coord_offset+DIM*1+ZZ] += fiz1;
680 f[i_coord_offset+DIM*2+XX] += fix2;
681 f[i_coord_offset+DIM*2+YY] += fiy2;
682 f[i_coord_offset+DIM*2+ZZ] += fiz2;
686 fshift[i_shift_offset+XX] += tx;
687 fshift[i_shift_offset+YY] += ty;
688 fshift[i_shift_offset+ZZ] += tz;
690 /* Increment number of inner iterations */
691 inneriter += j_index_end - j_index_start;
693 /* Outer loop uses 30 flops */
696 /* Increment number of outer iterations */
699 /* Update outer/inner flops */
701 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*137);