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_ElecEw_VdwBham_GeomW4P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwBham_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
85 jindex = nlist->jindex;
87 shiftidx = nlist->shift;
89 shiftvec = fr->shift_vec[0];
90 fshift = fr->fshift[0];
92 charge = mdatoms->chargeA;
95 vdwtype = mdatoms->typeA;
97 sh_ewald = fr->ic->sh_ewald;
98 ewtab = fr->ic->tabq_coul_FDV0;
99 ewtabscale = fr->ic->tabq_scale;
100 ewtabhalfspace = 0.5/ewtabscale;
102 /* Setup water-specific parameters */
103 inr = nlist->iinr[0];
104 iq1 = facel*charge[inr+1];
105 iq2 = facel*charge[inr+2];
106 iq3 = facel*charge[inr+3];
107 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
112 /* Start outer loop over neighborlists */
113 for(iidx=0; iidx<nri; iidx++)
115 /* Load shift vector for this list */
116 i_shift_offset = DIM*shiftidx[iidx];
117 shX = shiftvec[i_shift_offset+XX];
118 shY = shiftvec[i_shift_offset+YY];
119 shZ = shiftvec[i_shift_offset+ZZ];
121 /* Load limits for loop over neighbors */
122 j_index_start = jindex[iidx];
123 j_index_end = jindex[iidx+1];
125 /* Get outer coordinate index */
127 i_coord_offset = DIM*inr;
129 /* Load i particle coords and add shift vector */
130 ix0 = shX + x[i_coord_offset+DIM*0+XX];
131 iy0 = shY + x[i_coord_offset+DIM*0+YY];
132 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
133 ix1 = shX + x[i_coord_offset+DIM*1+XX];
134 iy1 = shY + x[i_coord_offset+DIM*1+YY];
135 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
136 ix2 = shX + x[i_coord_offset+DIM*2+XX];
137 iy2 = shY + x[i_coord_offset+DIM*2+YY];
138 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
139 ix3 = shX + x[i_coord_offset+DIM*3+XX];
140 iy3 = shY + x[i_coord_offset+DIM*3+YY];
141 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
156 /* Reset potential sums */
160 /* Start inner kernel loop */
161 for(jidx=j_index_start; jidx<j_index_end; jidx++)
163 /* Get j neighbor index, and coordinate index */
165 j_coord_offset = DIM*jnr;
167 /* load j atom coordinates */
168 jx0 = x[j_coord_offset+DIM*0+XX];
169 jy0 = x[j_coord_offset+DIM*0+YY];
170 jz0 = x[j_coord_offset+DIM*0+ZZ];
172 /* Calculate displacement vector */
186 /* Calculate squared distance and things based on it */
187 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
188 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
189 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
190 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
192 rinv00 = gmx_invsqrt(rsq00);
193 rinv10 = gmx_invsqrt(rsq10);
194 rinv20 = gmx_invsqrt(rsq20);
195 rinv30 = gmx_invsqrt(rsq30);
197 rinvsq00 = rinv00*rinv00;
198 rinvsq10 = rinv10*rinv10;
199 rinvsq20 = rinv20*rinv20;
200 rinvsq30 = rinv30*rinv30;
202 /* Load parameters for j particles */
204 vdwjidx0 = 3*vdwtype[jnr+0];
206 /**************************
207 * CALCULATE INTERACTIONS *
208 **************************/
212 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
213 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
214 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
216 /* BUCKINGHAM DISPERSION/REPULSION */
217 rinvsix = rinvsq00*rinvsq00*rinvsq00;
218 vvdw6 = c6_00*rinvsix;
220 vvdwexp = cexp1_00*exp(-br);
221 vvdw = vvdwexp - vvdw6*(1.0/6.0);
222 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
224 /* Update potential sums from outer loop */
229 /* Calculate temporary vectorial force */
234 /* Update vectorial force */
238 f[j_coord_offset+DIM*0+XX] -= tx;
239 f[j_coord_offset+DIM*0+YY] -= ty;
240 f[j_coord_offset+DIM*0+ZZ] -= tz;
242 /**************************
243 * CALCULATE INTERACTIONS *
244 **************************/
250 /* EWALD ELECTROSTATICS */
252 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
253 ewrt = r10*ewtabscale;
257 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
258 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
259 felec = qq10*rinv10*(rinvsq10-felec);
261 /* Update potential sums from outer loop */
266 /* Calculate temporary vectorial force */
271 /* Update vectorial force */
275 f[j_coord_offset+DIM*0+XX] -= tx;
276 f[j_coord_offset+DIM*0+YY] -= ty;
277 f[j_coord_offset+DIM*0+ZZ] -= tz;
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
287 /* EWALD ELECTROSTATICS */
289 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
290 ewrt = r20*ewtabscale;
294 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
295 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
296 felec = qq20*rinv20*(rinvsq20-felec);
298 /* Update potential sums from outer loop */
303 /* Calculate temporary vectorial force */
308 /* Update vectorial force */
312 f[j_coord_offset+DIM*0+XX] -= tx;
313 f[j_coord_offset+DIM*0+YY] -= ty;
314 f[j_coord_offset+DIM*0+ZZ] -= tz;
316 /**************************
317 * CALCULATE INTERACTIONS *
318 **************************/
324 /* EWALD ELECTROSTATICS */
326 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
327 ewrt = r30*ewtabscale;
331 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
332 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
333 felec = qq30*rinv30*(rinvsq30-felec);
335 /* Update potential sums from outer loop */
340 /* Calculate temporary vectorial force */
345 /* Update vectorial force */
349 f[j_coord_offset+DIM*0+XX] -= tx;
350 f[j_coord_offset+DIM*0+YY] -= ty;
351 f[j_coord_offset+DIM*0+ZZ] -= tz;
353 /* Inner loop uses 184 flops */
355 /* End of innermost loop */
358 f[i_coord_offset+DIM*0+XX] += fix0;
359 f[i_coord_offset+DIM*0+YY] += fiy0;
360 f[i_coord_offset+DIM*0+ZZ] += fiz0;
364 f[i_coord_offset+DIM*1+XX] += fix1;
365 f[i_coord_offset+DIM*1+YY] += fiy1;
366 f[i_coord_offset+DIM*1+ZZ] += fiz1;
370 f[i_coord_offset+DIM*2+XX] += fix2;
371 f[i_coord_offset+DIM*2+YY] += fiy2;
372 f[i_coord_offset+DIM*2+ZZ] += fiz2;
376 f[i_coord_offset+DIM*3+XX] += fix3;
377 f[i_coord_offset+DIM*3+YY] += fiy3;
378 f[i_coord_offset+DIM*3+ZZ] += fiz3;
382 fshift[i_shift_offset+XX] += tx;
383 fshift[i_shift_offset+YY] += ty;
384 fshift[i_shift_offset+ZZ] += tz;
387 /* Update potential energies */
388 kernel_data->energygrp_elec[ggid] += velecsum;
389 kernel_data->energygrp_vdw[ggid] += vvdwsum;
391 /* Increment number of inner iterations */
392 inneriter += j_index_end - j_index_start;
394 /* Outer loop uses 41 flops */
397 /* Increment number of outer iterations */
400 /* Update outer/inner flops */
402 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*184);
405 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW4P1_F_c
406 * Electrostatics interaction: Ewald
407 * VdW interaction: Buckingham
408 * Geometry: Water4-Particle
409 * Calculate force/pot: Force
412 nb_kernel_ElecEw_VdwBham_GeomW4P1_F_c
413 (t_nblist * gmx_restrict nlist,
414 rvec * gmx_restrict xx,
415 rvec * gmx_restrict ff,
416 t_forcerec * gmx_restrict fr,
417 t_mdatoms * gmx_restrict mdatoms,
418 nb_kernel_data_t * gmx_restrict kernel_data,
419 t_nrnb * gmx_restrict nrnb)
421 int i_shift_offset,i_coord_offset,j_coord_offset;
422 int j_index_start,j_index_end;
423 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
424 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
425 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
426 real *shiftvec,*fshift,*x,*f;
428 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
430 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
432 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
434 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
436 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
437 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
438 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
439 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
440 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
441 real velec,felec,velecsum,facel,crf,krf,krf2;
444 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
448 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
456 jindex = nlist->jindex;
458 shiftidx = nlist->shift;
460 shiftvec = fr->shift_vec[0];
461 fshift = fr->fshift[0];
463 charge = mdatoms->chargeA;
464 nvdwtype = fr->ntype;
466 vdwtype = mdatoms->typeA;
468 sh_ewald = fr->ic->sh_ewald;
469 ewtab = fr->ic->tabq_coul_F;
470 ewtabscale = fr->ic->tabq_scale;
471 ewtabhalfspace = 0.5/ewtabscale;
473 /* Setup water-specific parameters */
474 inr = nlist->iinr[0];
475 iq1 = facel*charge[inr+1];
476 iq2 = facel*charge[inr+2];
477 iq3 = facel*charge[inr+3];
478 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
483 /* Start outer loop over neighborlists */
484 for(iidx=0; iidx<nri; iidx++)
486 /* Load shift vector for this list */
487 i_shift_offset = DIM*shiftidx[iidx];
488 shX = shiftvec[i_shift_offset+XX];
489 shY = shiftvec[i_shift_offset+YY];
490 shZ = shiftvec[i_shift_offset+ZZ];
492 /* Load limits for loop over neighbors */
493 j_index_start = jindex[iidx];
494 j_index_end = jindex[iidx+1];
496 /* Get outer coordinate index */
498 i_coord_offset = DIM*inr;
500 /* Load i particle coords and add shift vector */
501 ix0 = shX + x[i_coord_offset+DIM*0+XX];
502 iy0 = shY + x[i_coord_offset+DIM*0+YY];
503 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
504 ix1 = shX + x[i_coord_offset+DIM*1+XX];
505 iy1 = shY + x[i_coord_offset+DIM*1+YY];
506 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
507 ix2 = shX + x[i_coord_offset+DIM*2+XX];
508 iy2 = shY + x[i_coord_offset+DIM*2+YY];
509 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
510 ix3 = shX + x[i_coord_offset+DIM*3+XX];
511 iy3 = shY + x[i_coord_offset+DIM*3+YY];
512 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
527 /* Start inner kernel loop */
528 for(jidx=j_index_start; jidx<j_index_end; jidx++)
530 /* Get j neighbor index, and coordinate index */
532 j_coord_offset = DIM*jnr;
534 /* load j atom coordinates */
535 jx0 = x[j_coord_offset+DIM*0+XX];
536 jy0 = x[j_coord_offset+DIM*0+YY];
537 jz0 = x[j_coord_offset+DIM*0+ZZ];
539 /* Calculate displacement vector */
553 /* Calculate squared distance and things based on it */
554 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
555 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
556 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
557 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
559 rinv00 = gmx_invsqrt(rsq00);
560 rinv10 = gmx_invsqrt(rsq10);
561 rinv20 = gmx_invsqrt(rsq20);
562 rinv30 = gmx_invsqrt(rsq30);
564 rinvsq00 = rinv00*rinv00;
565 rinvsq10 = rinv10*rinv10;
566 rinvsq20 = rinv20*rinv20;
567 rinvsq30 = rinv30*rinv30;
569 /* Load parameters for j particles */
571 vdwjidx0 = 3*vdwtype[jnr+0];
573 /**************************
574 * CALCULATE INTERACTIONS *
575 **************************/
579 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
580 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
581 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
583 /* BUCKINGHAM DISPERSION/REPULSION */
584 rinvsix = rinvsq00*rinvsq00*rinvsq00;
585 vvdw6 = c6_00*rinvsix;
587 vvdwexp = cexp1_00*exp(-br);
588 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
592 /* Calculate temporary vectorial force */
597 /* Update vectorial force */
601 f[j_coord_offset+DIM*0+XX] -= tx;
602 f[j_coord_offset+DIM*0+YY] -= ty;
603 f[j_coord_offset+DIM*0+ZZ] -= tz;
605 /**************************
606 * CALCULATE INTERACTIONS *
607 **************************/
613 /* EWALD ELECTROSTATICS */
615 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
616 ewrt = r10*ewtabscale;
619 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
620 felec = qq10*rinv10*(rinvsq10-felec);
624 /* Calculate temporary vectorial force */
629 /* Update vectorial force */
633 f[j_coord_offset+DIM*0+XX] -= tx;
634 f[j_coord_offset+DIM*0+YY] -= ty;
635 f[j_coord_offset+DIM*0+ZZ] -= tz;
637 /**************************
638 * CALCULATE INTERACTIONS *
639 **************************/
645 /* EWALD ELECTROSTATICS */
647 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
648 ewrt = r20*ewtabscale;
651 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
652 felec = qq20*rinv20*(rinvsq20-felec);
656 /* Calculate temporary vectorial force */
661 /* Update vectorial force */
665 f[j_coord_offset+DIM*0+XX] -= tx;
666 f[j_coord_offset+DIM*0+YY] -= ty;
667 f[j_coord_offset+DIM*0+ZZ] -= tz;
669 /**************************
670 * CALCULATE INTERACTIONS *
671 **************************/
677 /* EWALD ELECTROSTATICS */
679 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
680 ewrt = r30*ewtabscale;
683 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
684 felec = qq30*rinv30*(rinvsq30-felec);
688 /* Calculate temporary vectorial force */
693 /* Update vectorial force */
697 f[j_coord_offset+DIM*0+XX] -= tx;
698 f[j_coord_offset+DIM*0+YY] -= ty;
699 f[j_coord_offset+DIM*0+ZZ] -= tz;
701 /* Inner loop uses 160 flops */
703 /* End of innermost loop */
706 f[i_coord_offset+DIM*0+XX] += fix0;
707 f[i_coord_offset+DIM*0+YY] += fiy0;
708 f[i_coord_offset+DIM*0+ZZ] += fiz0;
712 f[i_coord_offset+DIM*1+XX] += fix1;
713 f[i_coord_offset+DIM*1+YY] += fiy1;
714 f[i_coord_offset+DIM*1+ZZ] += fiz1;
718 f[i_coord_offset+DIM*2+XX] += fix2;
719 f[i_coord_offset+DIM*2+YY] += fiy2;
720 f[i_coord_offset+DIM*2+ZZ] += fiz2;
724 f[i_coord_offset+DIM*3+XX] += fix3;
725 f[i_coord_offset+DIM*3+YY] += fiy3;
726 f[i_coord_offset+DIM*3+ZZ] += fiz3;
730 fshift[i_shift_offset+XX] += tx;
731 fshift[i_shift_offset+YY] += ty;
732 fshift[i_shift_offset+ZZ] += tz;
734 /* Increment number of inner iterations */
735 inneriter += j_index_end - j_index_start;
737 /* Outer loop uses 39 flops */
740 /* Increment number of outer iterations */
743 /* Update outer/inner flops */
745 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*160);