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_VdwLJ_GeomW4P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwLJ_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 = 2*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 rinv10 = gmx_invsqrt(rsq10);
193 rinv20 = gmx_invsqrt(rsq20);
194 rinv30 = gmx_invsqrt(rsq30);
196 rinvsq00 = 1.0/rsq00;
197 rinvsq10 = rinv10*rinv10;
198 rinvsq20 = rinv20*rinv20;
199 rinvsq30 = rinv30*rinv30;
201 /* Load parameters for j particles */
203 vdwjidx0 = 2*vdwtype[jnr+0];
205 /**************************
206 * CALCULATE INTERACTIONS *
207 **************************/
209 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
210 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
212 /* LENNARD-JONES DISPERSION/REPULSION */
214 rinvsix = rinvsq00*rinvsq00*rinvsq00;
215 vvdw6 = c6_00*rinvsix;
216 vvdw12 = c12_00*rinvsix*rinvsix;
217 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
218 fvdw = (vvdw12-vvdw6)*rinvsq00;
220 /* Update potential sums from outer loop */
225 /* Calculate temporary vectorial force */
230 /* Update vectorial force */
234 f[j_coord_offset+DIM*0+XX] -= tx;
235 f[j_coord_offset+DIM*0+YY] -= ty;
236 f[j_coord_offset+DIM*0+ZZ] -= tz;
238 /**************************
239 * CALCULATE INTERACTIONS *
240 **************************/
246 /* EWALD ELECTROSTATICS */
248 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
249 ewrt = r10*ewtabscale;
253 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
254 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
255 felec = qq10*rinv10*(rinvsq10-felec);
257 /* Update potential sums from outer loop */
262 /* Calculate temporary vectorial force */
267 /* Update vectorial force */
271 f[j_coord_offset+DIM*0+XX] -= tx;
272 f[j_coord_offset+DIM*0+YY] -= ty;
273 f[j_coord_offset+DIM*0+ZZ] -= tz;
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
283 /* EWALD ELECTROSTATICS */
285 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
286 ewrt = r20*ewtabscale;
290 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
291 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
292 felec = qq20*rinv20*(rinvsq20-felec);
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 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
320 /* EWALD ELECTROSTATICS */
322 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
323 ewrt = r30*ewtabscale;
327 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
328 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
329 felec = qq30*rinv30*(rinvsq30-felec);
331 /* Update potential sums from outer loop */
336 /* Calculate temporary vectorial force */
341 /* Update vectorial force */
345 f[j_coord_offset+DIM*0+XX] -= tx;
346 f[j_coord_offset+DIM*0+YY] -= ty;
347 f[j_coord_offset+DIM*0+ZZ] -= tz;
349 /* Inner loop uses 155 flops */
351 /* End of innermost loop */
354 f[i_coord_offset+DIM*0+XX] += fix0;
355 f[i_coord_offset+DIM*0+YY] += fiy0;
356 f[i_coord_offset+DIM*0+ZZ] += fiz0;
360 f[i_coord_offset+DIM*1+XX] += fix1;
361 f[i_coord_offset+DIM*1+YY] += fiy1;
362 f[i_coord_offset+DIM*1+ZZ] += fiz1;
366 f[i_coord_offset+DIM*2+XX] += fix2;
367 f[i_coord_offset+DIM*2+YY] += fiy2;
368 f[i_coord_offset+DIM*2+ZZ] += fiz2;
372 f[i_coord_offset+DIM*3+XX] += fix3;
373 f[i_coord_offset+DIM*3+YY] += fiy3;
374 f[i_coord_offset+DIM*3+ZZ] += fiz3;
378 fshift[i_shift_offset+XX] += tx;
379 fshift[i_shift_offset+YY] += ty;
380 fshift[i_shift_offset+ZZ] += tz;
383 /* Update potential energies */
384 kernel_data->energygrp_elec[ggid] += velecsum;
385 kernel_data->energygrp_vdw[ggid] += vvdwsum;
387 /* Increment number of inner iterations */
388 inneriter += j_index_end - j_index_start;
390 /* Outer loop uses 41 flops */
393 /* Increment number of outer iterations */
396 /* Update outer/inner flops */
398 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*155);
401 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW4P1_F_c
402 * Electrostatics interaction: Ewald
403 * VdW interaction: LennardJones
404 * Geometry: Water4-Particle
405 * Calculate force/pot: Force
408 nb_kernel_ElecEw_VdwLJ_GeomW4P1_F_c
409 (t_nblist * gmx_restrict nlist,
410 rvec * gmx_restrict xx,
411 rvec * gmx_restrict ff,
412 t_forcerec * gmx_restrict fr,
413 t_mdatoms * gmx_restrict mdatoms,
414 nb_kernel_data_t * gmx_restrict kernel_data,
415 t_nrnb * gmx_restrict nrnb)
417 int i_shift_offset,i_coord_offset,j_coord_offset;
418 int j_index_start,j_index_end;
419 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
420 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
421 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
422 real *shiftvec,*fshift,*x,*f;
424 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
426 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
428 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
430 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
432 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
433 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
434 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
435 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
436 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
437 real velec,felec,velecsum,facel,crf,krf,krf2;
440 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
444 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
452 jindex = nlist->jindex;
454 shiftidx = nlist->shift;
456 shiftvec = fr->shift_vec[0];
457 fshift = fr->fshift[0];
459 charge = mdatoms->chargeA;
460 nvdwtype = fr->ntype;
462 vdwtype = mdatoms->typeA;
464 sh_ewald = fr->ic->sh_ewald;
465 ewtab = fr->ic->tabq_coul_F;
466 ewtabscale = fr->ic->tabq_scale;
467 ewtabhalfspace = 0.5/ewtabscale;
469 /* Setup water-specific parameters */
470 inr = nlist->iinr[0];
471 iq1 = facel*charge[inr+1];
472 iq2 = facel*charge[inr+2];
473 iq3 = facel*charge[inr+3];
474 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
479 /* Start outer loop over neighborlists */
480 for(iidx=0; iidx<nri; iidx++)
482 /* Load shift vector for this list */
483 i_shift_offset = DIM*shiftidx[iidx];
484 shX = shiftvec[i_shift_offset+XX];
485 shY = shiftvec[i_shift_offset+YY];
486 shZ = shiftvec[i_shift_offset+ZZ];
488 /* Load limits for loop over neighbors */
489 j_index_start = jindex[iidx];
490 j_index_end = jindex[iidx+1];
492 /* Get outer coordinate index */
494 i_coord_offset = DIM*inr;
496 /* Load i particle coords and add shift vector */
497 ix0 = shX + x[i_coord_offset+DIM*0+XX];
498 iy0 = shY + x[i_coord_offset+DIM*0+YY];
499 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
500 ix1 = shX + x[i_coord_offset+DIM*1+XX];
501 iy1 = shY + x[i_coord_offset+DIM*1+YY];
502 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
503 ix2 = shX + x[i_coord_offset+DIM*2+XX];
504 iy2 = shY + x[i_coord_offset+DIM*2+YY];
505 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
506 ix3 = shX + x[i_coord_offset+DIM*3+XX];
507 iy3 = shY + x[i_coord_offset+DIM*3+YY];
508 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
523 /* Start inner kernel loop */
524 for(jidx=j_index_start; jidx<j_index_end; jidx++)
526 /* Get j neighbor index, and coordinate index */
528 j_coord_offset = DIM*jnr;
530 /* load j atom coordinates */
531 jx0 = x[j_coord_offset+DIM*0+XX];
532 jy0 = x[j_coord_offset+DIM*0+YY];
533 jz0 = x[j_coord_offset+DIM*0+ZZ];
535 /* Calculate displacement vector */
549 /* Calculate squared distance and things based on it */
550 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
551 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
552 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
553 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
555 rinv10 = gmx_invsqrt(rsq10);
556 rinv20 = gmx_invsqrt(rsq20);
557 rinv30 = gmx_invsqrt(rsq30);
559 rinvsq00 = 1.0/rsq00;
560 rinvsq10 = rinv10*rinv10;
561 rinvsq20 = rinv20*rinv20;
562 rinvsq30 = rinv30*rinv30;
564 /* Load parameters for j particles */
566 vdwjidx0 = 2*vdwtype[jnr+0];
568 /**************************
569 * CALCULATE INTERACTIONS *
570 **************************/
572 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
573 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
575 /* LENNARD-JONES DISPERSION/REPULSION */
577 rinvsix = rinvsq00*rinvsq00*rinvsq00;
578 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
582 /* Calculate temporary vectorial force */
587 /* Update vectorial force */
591 f[j_coord_offset+DIM*0+XX] -= tx;
592 f[j_coord_offset+DIM*0+YY] -= ty;
593 f[j_coord_offset+DIM*0+ZZ] -= tz;
595 /**************************
596 * CALCULATE INTERACTIONS *
597 **************************/
603 /* EWALD ELECTROSTATICS */
605 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
606 ewrt = r10*ewtabscale;
609 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
610 felec = qq10*rinv10*(rinvsq10-felec);
614 /* Calculate temporary vectorial force */
619 /* Update vectorial force */
623 f[j_coord_offset+DIM*0+XX] -= tx;
624 f[j_coord_offset+DIM*0+YY] -= ty;
625 f[j_coord_offset+DIM*0+ZZ] -= tz;
627 /**************************
628 * CALCULATE INTERACTIONS *
629 **************************/
635 /* EWALD ELECTROSTATICS */
637 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
638 ewrt = r20*ewtabscale;
641 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
642 felec = qq20*rinv20*(rinvsq20-felec);
646 /* Calculate temporary vectorial force */
651 /* Update vectorial force */
655 f[j_coord_offset+DIM*0+XX] -= tx;
656 f[j_coord_offset+DIM*0+YY] -= ty;
657 f[j_coord_offset+DIM*0+ZZ] -= tz;
659 /**************************
660 * CALCULATE INTERACTIONS *
661 **************************/
667 /* EWALD ELECTROSTATICS */
669 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
670 ewrt = r30*ewtabscale;
673 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
674 felec = qq30*rinv30*(rinvsq30-felec);
678 /* Calculate temporary vectorial force */
683 /* Update vectorial force */
687 f[j_coord_offset+DIM*0+XX] -= tx;
688 f[j_coord_offset+DIM*0+YY] -= ty;
689 f[j_coord_offset+DIM*0+ZZ] -= tz;
691 /* Inner loop uses 129 flops */
693 /* End of innermost loop */
696 f[i_coord_offset+DIM*0+XX] += fix0;
697 f[i_coord_offset+DIM*0+YY] += fiy0;
698 f[i_coord_offset+DIM*0+ZZ] += fiz0;
702 f[i_coord_offset+DIM*1+XX] += fix1;
703 f[i_coord_offset+DIM*1+YY] += fiy1;
704 f[i_coord_offset+DIM*1+ZZ] += fiz1;
708 f[i_coord_offset+DIM*2+XX] += fix2;
709 f[i_coord_offset+DIM*2+YY] += fiy2;
710 f[i_coord_offset+DIM*2+ZZ] += fiz2;
714 f[i_coord_offset+DIM*3+XX] += fix3;
715 f[i_coord_offset+DIM*3+YY] += fiy3;
716 f[i_coord_offset+DIM*3+ZZ] += fiz3;
720 fshift[i_shift_offset+XX] += tx;
721 fshift[i_shift_offset+YY] += ty;
722 fshift[i_shift_offset+ZZ] += tz;
724 /* Increment number of inner iterations */
725 inneriter += j_index_end - j_index_start;
727 /* Outer loop uses 39 flops */
730 /* Increment number of outer iterations */
733 /* Update outer/inner flops */
735 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*129);