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_GeomW3W3_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwLJ_GeomW3W3_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;
65 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
67 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
68 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
69 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
70 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
71 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
72 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
73 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
74 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
75 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
76 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
84 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
99 charge = mdatoms->chargeA;
100 nvdwtype = fr->ntype;
102 vdwtype = mdatoms->typeA;
104 sh_ewald = fr->ic->sh_ewald;
105 ewtab = fr->ic->tabq_coul_FDV0;
106 ewtabscale = fr->ic->tabq_scale;
107 ewtabhalfspace = 0.5/ewtabscale;
109 /* Setup water-specific parameters */
110 inr = nlist->iinr[0];
111 iq0 = facel*charge[inr+0];
112 iq1 = facel*charge[inr+1];
113 iq2 = facel*charge[inr+2];
114 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
119 vdwjidx0 = 2*vdwtype[inr+0];
121 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
122 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
140 shX = shiftvec[i_shift_offset+XX];
141 shY = shiftvec[i_shift_offset+YY];
142 shZ = shiftvec[i_shift_offset+ZZ];
144 /* Load limits for loop over neighbors */
145 j_index_start = jindex[iidx];
146 j_index_end = jindex[iidx+1];
148 /* Get outer coordinate index */
150 i_coord_offset = DIM*inr;
152 /* Load i particle coords and add shift vector */
153 ix0 = shX + x[i_coord_offset+DIM*0+XX];
154 iy0 = shY + x[i_coord_offset+DIM*0+YY];
155 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
156 ix1 = shX + x[i_coord_offset+DIM*1+XX];
157 iy1 = shY + x[i_coord_offset+DIM*1+YY];
158 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
159 ix2 = shX + x[i_coord_offset+DIM*2+XX];
160 iy2 = shY + x[i_coord_offset+DIM*2+YY];
161 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
173 /* Reset potential sums */
177 /* Start inner kernel loop */
178 for(jidx=j_index_start; jidx<j_index_end; jidx++)
180 /* Get j neighbor index, and coordinate index */
182 j_coord_offset = DIM*jnr;
184 /* load j atom coordinates */
185 jx0 = x[j_coord_offset+DIM*0+XX];
186 jy0 = x[j_coord_offset+DIM*0+YY];
187 jz0 = x[j_coord_offset+DIM*0+ZZ];
188 jx1 = x[j_coord_offset+DIM*1+XX];
189 jy1 = x[j_coord_offset+DIM*1+YY];
190 jz1 = x[j_coord_offset+DIM*1+ZZ];
191 jx2 = x[j_coord_offset+DIM*2+XX];
192 jy2 = x[j_coord_offset+DIM*2+YY];
193 jz2 = x[j_coord_offset+DIM*2+ZZ];
195 /* Calculate displacement vector */
224 /* Calculate squared distance and things based on it */
225 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
226 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
227 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
228 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
229 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
230 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
231 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
232 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
233 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
235 rinv00 = gmx_invsqrt(rsq00);
236 rinv01 = gmx_invsqrt(rsq01);
237 rinv02 = gmx_invsqrt(rsq02);
238 rinv10 = gmx_invsqrt(rsq10);
239 rinv11 = gmx_invsqrt(rsq11);
240 rinv12 = gmx_invsqrt(rsq12);
241 rinv20 = gmx_invsqrt(rsq20);
242 rinv21 = gmx_invsqrt(rsq21);
243 rinv22 = gmx_invsqrt(rsq22);
245 rinvsq00 = rinv00*rinv00;
246 rinvsq01 = rinv01*rinv01;
247 rinvsq02 = rinv02*rinv02;
248 rinvsq10 = rinv10*rinv10;
249 rinvsq11 = rinv11*rinv11;
250 rinvsq12 = rinv12*rinv12;
251 rinvsq20 = rinv20*rinv20;
252 rinvsq21 = rinv21*rinv21;
253 rinvsq22 = rinv22*rinv22;
255 /**************************
256 * CALCULATE INTERACTIONS *
257 **************************/
261 /* EWALD ELECTROSTATICS */
263 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
264 ewrt = r00*ewtabscale;
268 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
269 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
270 felec = qq00*rinv00*(rinvsq00-felec);
272 /* LENNARD-JONES DISPERSION/REPULSION */
274 rinvsix = rinvsq00*rinvsq00*rinvsq00;
275 vvdw6 = c6_00*rinvsix;
276 vvdw12 = c12_00*rinvsix*rinvsix;
277 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
278 fvdw = (vvdw12-vvdw6)*rinvsq00;
280 /* Update potential sums from outer loop */
286 /* Calculate temporary vectorial force */
291 /* Update vectorial force */
295 f[j_coord_offset+DIM*0+XX] -= tx;
296 f[j_coord_offset+DIM*0+YY] -= ty;
297 f[j_coord_offset+DIM*0+ZZ] -= tz;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
305 /* EWALD ELECTROSTATICS */
307 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
308 ewrt = r01*ewtabscale;
312 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
313 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
314 felec = qq01*rinv01*(rinvsq01-felec);
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*1+XX] -= tx;
331 f[j_coord_offset+DIM*1+YY] -= ty;
332 f[j_coord_offset+DIM*1+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
340 /* EWALD ELECTROSTATICS */
342 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
343 ewrt = r02*ewtabscale;
347 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
348 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
349 felec = qq02*rinv02*(rinvsq02-felec);
351 /* Update potential sums from outer loop */
356 /* Calculate temporary vectorial force */
361 /* Update vectorial force */
365 f[j_coord_offset+DIM*2+XX] -= tx;
366 f[j_coord_offset+DIM*2+YY] -= ty;
367 f[j_coord_offset+DIM*2+ZZ] -= tz;
369 /**************************
370 * CALCULATE INTERACTIONS *
371 **************************/
375 /* EWALD ELECTROSTATICS */
377 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
378 ewrt = r10*ewtabscale;
382 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
383 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
384 felec = qq10*rinv10*(rinvsq10-felec);
386 /* Update potential sums from outer loop */
391 /* Calculate temporary vectorial force */
396 /* Update vectorial force */
400 f[j_coord_offset+DIM*0+XX] -= tx;
401 f[j_coord_offset+DIM*0+YY] -= ty;
402 f[j_coord_offset+DIM*0+ZZ] -= tz;
404 /**************************
405 * CALCULATE INTERACTIONS *
406 **************************/
410 /* EWALD ELECTROSTATICS */
412 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
413 ewrt = r11*ewtabscale;
417 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
418 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
419 felec = qq11*rinv11*(rinvsq11-felec);
421 /* Update potential sums from outer loop */
426 /* Calculate temporary vectorial force */
431 /* Update vectorial force */
435 f[j_coord_offset+DIM*1+XX] -= tx;
436 f[j_coord_offset+DIM*1+YY] -= ty;
437 f[j_coord_offset+DIM*1+ZZ] -= tz;
439 /**************************
440 * CALCULATE INTERACTIONS *
441 **************************/
445 /* EWALD ELECTROSTATICS */
447 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
448 ewrt = r12*ewtabscale;
452 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
453 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
454 felec = qq12*rinv12*(rinvsq12-felec);
456 /* Update potential sums from outer loop */
461 /* Calculate temporary vectorial force */
466 /* Update vectorial force */
470 f[j_coord_offset+DIM*2+XX] -= tx;
471 f[j_coord_offset+DIM*2+YY] -= ty;
472 f[j_coord_offset+DIM*2+ZZ] -= tz;
474 /**************************
475 * CALCULATE INTERACTIONS *
476 **************************/
480 /* EWALD ELECTROSTATICS */
482 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
483 ewrt = r20*ewtabscale;
487 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
488 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
489 felec = qq20*rinv20*(rinvsq20-felec);
491 /* Update potential sums from outer loop */
496 /* Calculate temporary vectorial force */
501 /* Update vectorial force */
505 f[j_coord_offset+DIM*0+XX] -= tx;
506 f[j_coord_offset+DIM*0+YY] -= ty;
507 f[j_coord_offset+DIM*0+ZZ] -= tz;
509 /**************************
510 * CALCULATE INTERACTIONS *
511 **************************/
515 /* EWALD ELECTROSTATICS */
517 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
518 ewrt = r21*ewtabscale;
522 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
523 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
524 felec = qq21*rinv21*(rinvsq21-felec);
526 /* Update potential sums from outer loop */
531 /* Calculate temporary vectorial force */
536 /* Update vectorial force */
540 f[j_coord_offset+DIM*1+XX] -= tx;
541 f[j_coord_offset+DIM*1+YY] -= ty;
542 f[j_coord_offset+DIM*1+ZZ] -= tz;
544 /**************************
545 * CALCULATE INTERACTIONS *
546 **************************/
550 /* EWALD ELECTROSTATICS */
552 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
553 ewrt = r22*ewtabscale;
557 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
558 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
559 felec = qq22*rinv22*(rinvsq22-felec);
561 /* Update potential sums from outer loop */
566 /* Calculate temporary vectorial force */
571 /* Update vectorial force */
575 f[j_coord_offset+DIM*2+XX] -= tx;
576 f[j_coord_offset+DIM*2+YY] -= ty;
577 f[j_coord_offset+DIM*2+ZZ] -= tz;
579 /* Inner loop uses 372 flops */
581 /* End of innermost loop */
584 f[i_coord_offset+DIM*0+XX] += fix0;
585 f[i_coord_offset+DIM*0+YY] += fiy0;
586 f[i_coord_offset+DIM*0+ZZ] += fiz0;
590 f[i_coord_offset+DIM*1+XX] += fix1;
591 f[i_coord_offset+DIM*1+YY] += fiy1;
592 f[i_coord_offset+DIM*1+ZZ] += fiz1;
596 f[i_coord_offset+DIM*2+XX] += fix2;
597 f[i_coord_offset+DIM*2+YY] += fiy2;
598 f[i_coord_offset+DIM*2+ZZ] += fiz2;
602 fshift[i_shift_offset+XX] += tx;
603 fshift[i_shift_offset+YY] += ty;
604 fshift[i_shift_offset+ZZ] += tz;
607 /* Update potential energies */
608 kernel_data->energygrp_elec[ggid] += velecsum;
609 kernel_data->energygrp_vdw[ggid] += vvdwsum;
611 /* Increment number of inner iterations */
612 inneriter += j_index_end - j_index_start;
614 /* Outer loop uses 32 flops */
617 /* Increment number of outer iterations */
620 /* Update outer/inner flops */
622 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*372);
625 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW3W3_F_c
626 * Electrostatics interaction: Ewald
627 * VdW interaction: LennardJones
628 * Geometry: Water3-Water3
629 * Calculate force/pot: Force
632 nb_kernel_ElecEw_VdwLJ_GeomW3W3_F_c
633 (t_nblist * gmx_restrict nlist,
634 rvec * gmx_restrict xx,
635 rvec * gmx_restrict ff,
636 t_forcerec * gmx_restrict fr,
637 t_mdatoms * gmx_restrict mdatoms,
638 nb_kernel_data_t * gmx_restrict kernel_data,
639 t_nrnb * gmx_restrict nrnb)
641 int i_shift_offset,i_coord_offset,j_coord_offset;
642 int j_index_start,j_index_end;
643 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
644 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
645 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
646 real *shiftvec,*fshift,*x,*f;
648 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
650 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
652 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
654 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
656 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
658 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
659 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
660 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
661 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
662 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
663 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
664 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
665 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
666 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
667 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
668 real velec,felec,velecsum,facel,crf,krf,krf2;
671 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
675 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
683 jindex = nlist->jindex;
685 shiftidx = nlist->shift;
687 shiftvec = fr->shift_vec[0];
688 fshift = fr->fshift[0];
690 charge = mdatoms->chargeA;
691 nvdwtype = fr->ntype;
693 vdwtype = mdatoms->typeA;
695 sh_ewald = fr->ic->sh_ewald;
696 ewtab = fr->ic->tabq_coul_F;
697 ewtabscale = fr->ic->tabq_scale;
698 ewtabhalfspace = 0.5/ewtabscale;
700 /* Setup water-specific parameters */
701 inr = nlist->iinr[0];
702 iq0 = facel*charge[inr+0];
703 iq1 = facel*charge[inr+1];
704 iq2 = facel*charge[inr+2];
705 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
710 vdwjidx0 = 2*vdwtype[inr+0];
712 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
713 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
726 /* Start outer loop over neighborlists */
727 for(iidx=0; iidx<nri; iidx++)
729 /* Load shift vector for this list */
730 i_shift_offset = DIM*shiftidx[iidx];
731 shX = shiftvec[i_shift_offset+XX];
732 shY = shiftvec[i_shift_offset+YY];
733 shZ = shiftvec[i_shift_offset+ZZ];
735 /* Load limits for loop over neighbors */
736 j_index_start = jindex[iidx];
737 j_index_end = jindex[iidx+1];
739 /* Get outer coordinate index */
741 i_coord_offset = DIM*inr;
743 /* Load i particle coords and add shift vector */
744 ix0 = shX + x[i_coord_offset+DIM*0+XX];
745 iy0 = shY + x[i_coord_offset+DIM*0+YY];
746 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
747 ix1 = shX + x[i_coord_offset+DIM*1+XX];
748 iy1 = shY + x[i_coord_offset+DIM*1+YY];
749 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
750 ix2 = shX + x[i_coord_offset+DIM*2+XX];
751 iy2 = shY + x[i_coord_offset+DIM*2+YY];
752 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
764 /* Start inner kernel loop */
765 for(jidx=j_index_start; jidx<j_index_end; jidx++)
767 /* Get j neighbor index, and coordinate index */
769 j_coord_offset = DIM*jnr;
771 /* load j atom coordinates */
772 jx0 = x[j_coord_offset+DIM*0+XX];
773 jy0 = x[j_coord_offset+DIM*0+YY];
774 jz0 = x[j_coord_offset+DIM*0+ZZ];
775 jx1 = x[j_coord_offset+DIM*1+XX];
776 jy1 = x[j_coord_offset+DIM*1+YY];
777 jz1 = x[j_coord_offset+DIM*1+ZZ];
778 jx2 = x[j_coord_offset+DIM*2+XX];
779 jy2 = x[j_coord_offset+DIM*2+YY];
780 jz2 = x[j_coord_offset+DIM*2+ZZ];
782 /* Calculate displacement vector */
811 /* Calculate squared distance and things based on it */
812 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
813 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
814 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
815 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
816 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
817 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
818 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
819 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
820 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
822 rinv00 = gmx_invsqrt(rsq00);
823 rinv01 = gmx_invsqrt(rsq01);
824 rinv02 = gmx_invsqrt(rsq02);
825 rinv10 = gmx_invsqrt(rsq10);
826 rinv11 = gmx_invsqrt(rsq11);
827 rinv12 = gmx_invsqrt(rsq12);
828 rinv20 = gmx_invsqrt(rsq20);
829 rinv21 = gmx_invsqrt(rsq21);
830 rinv22 = gmx_invsqrt(rsq22);
832 rinvsq00 = rinv00*rinv00;
833 rinvsq01 = rinv01*rinv01;
834 rinvsq02 = rinv02*rinv02;
835 rinvsq10 = rinv10*rinv10;
836 rinvsq11 = rinv11*rinv11;
837 rinvsq12 = rinv12*rinv12;
838 rinvsq20 = rinv20*rinv20;
839 rinvsq21 = rinv21*rinv21;
840 rinvsq22 = rinv22*rinv22;
842 /**************************
843 * CALCULATE INTERACTIONS *
844 **************************/
848 /* EWALD ELECTROSTATICS */
850 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
851 ewrt = r00*ewtabscale;
854 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
855 felec = qq00*rinv00*(rinvsq00-felec);
857 /* LENNARD-JONES DISPERSION/REPULSION */
859 rinvsix = rinvsq00*rinvsq00*rinvsq00;
860 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
864 /* Calculate temporary vectorial force */
869 /* Update vectorial force */
873 f[j_coord_offset+DIM*0+XX] -= tx;
874 f[j_coord_offset+DIM*0+YY] -= ty;
875 f[j_coord_offset+DIM*0+ZZ] -= tz;
877 /**************************
878 * CALCULATE INTERACTIONS *
879 **************************/
883 /* EWALD ELECTROSTATICS */
885 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
886 ewrt = r01*ewtabscale;
889 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
890 felec = qq01*rinv01*(rinvsq01-felec);
894 /* Calculate temporary vectorial force */
899 /* Update vectorial force */
903 f[j_coord_offset+DIM*1+XX] -= tx;
904 f[j_coord_offset+DIM*1+YY] -= ty;
905 f[j_coord_offset+DIM*1+ZZ] -= tz;
907 /**************************
908 * CALCULATE INTERACTIONS *
909 **************************/
913 /* EWALD ELECTROSTATICS */
915 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
916 ewrt = r02*ewtabscale;
919 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
920 felec = qq02*rinv02*(rinvsq02-felec);
924 /* Calculate temporary vectorial force */
929 /* Update vectorial force */
933 f[j_coord_offset+DIM*2+XX] -= tx;
934 f[j_coord_offset+DIM*2+YY] -= ty;
935 f[j_coord_offset+DIM*2+ZZ] -= tz;
937 /**************************
938 * CALCULATE INTERACTIONS *
939 **************************/
943 /* EWALD ELECTROSTATICS */
945 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
946 ewrt = r10*ewtabscale;
949 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
950 felec = qq10*rinv10*(rinvsq10-felec);
954 /* Calculate temporary vectorial force */
959 /* Update vectorial force */
963 f[j_coord_offset+DIM*0+XX] -= tx;
964 f[j_coord_offset+DIM*0+YY] -= ty;
965 f[j_coord_offset+DIM*0+ZZ] -= tz;
967 /**************************
968 * CALCULATE INTERACTIONS *
969 **************************/
973 /* EWALD ELECTROSTATICS */
975 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
976 ewrt = r11*ewtabscale;
979 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
980 felec = qq11*rinv11*(rinvsq11-felec);
984 /* Calculate temporary vectorial force */
989 /* Update vectorial force */
993 f[j_coord_offset+DIM*1+XX] -= tx;
994 f[j_coord_offset+DIM*1+YY] -= ty;
995 f[j_coord_offset+DIM*1+ZZ] -= tz;
997 /**************************
998 * CALCULATE INTERACTIONS *
999 **************************/
1003 /* EWALD ELECTROSTATICS */
1005 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1006 ewrt = r12*ewtabscale;
1008 eweps = ewrt-ewitab;
1009 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1010 felec = qq12*rinv12*(rinvsq12-felec);
1014 /* Calculate temporary vectorial force */
1019 /* Update vectorial force */
1023 f[j_coord_offset+DIM*2+XX] -= tx;
1024 f[j_coord_offset+DIM*2+YY] -= ty;
1025 f[j_coord_offset+DIM*2+ZZ] -= tz;
1027 /**************************
1028 * CALCULATE INTERACTIONS *
1029 **************************/
1033 /* EWALD ELECTROSTATICS */
1035 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1036 ewrt = r20*ewtabscale;
1038 eweps = ewrt-ewitab;
1039 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1040 felec = qq20*rinv20*(rinvsq20-felec);
1044 /* Calculate temporary vectorial force */
1049 /* Update vectorial force */
1053 f[j_coord_offset+DIM*0+XX] -= tx;
1054 f[j_coord_offset+DIM*0+YY] -= ty;
1055 f[j_coord_offset+DIM*0+ZZ] -= tz;
1057 /**************************
1058 * CALCULATE INTERACTIONS *
1059 **************************/
1063 /* EWALD ELECTROSTATICS */
1065 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1066 ewrt = r21*ewtabscale;
1068 eweps = ewrt-ewitab;
1069 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1070 felec = qq21*rinv21*(rinvsq21-felec);
1074 /* Calculate temporary vectorial force */
1079 /* Update vectorial force */
1083 f[j_coord_offset+DIM*1+XX] -= tx;
1084 f[j_coord_offset+DIM*1+YY] -= ty;
1085 f[j_coord_offset+DIM*1+ZZ] -= tz;
1087 /**************************
1088 * CALCULATE INTERACTIONS *
1089 **************************/
1093 /* EWALD ELECTROSTATICS */
1095 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1096 ewrt = r22*ewtabscale;
1098 eweps = ewrt-ewitab;
1099 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1100 felec = qq22*rinv22*(rinvsq22-felec);
1104 /* Calculate temporary vectorial force */
1109 /* Update vectorial force */
1113 f[j_coord_offset+DIM*2+XX] -= tx;
1114 f[j_coord_offset+DIM*2+YY] -= ty;
1115 f[j_coord_offset+DIM*2+ZZ] -= tz;
1117 /* Inner loop uses 304 flops */
1119 /* End of innermost loop */
1122 f[i_coord_offset+DIM*0+XX] += fix0;
1123 f[i_coord_offset+DIM*0+YY] += fiy0;
1124 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1128 f[i_coord_offset+DIM*1+XX] += fix1;
1129 f[i_coord_offset+DIM*1+YY] += fiy1;
1130 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1134 f[i_coord_offset+DIM*2+XX] += fix2;
1135 f[i_coord_offset+DIM*2+YY] += fiy2;
1136 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1140 fshift[i_shift_offset+XX] += tx;
1141 fshift[i_shift_offset+YY] += ty;
1142 fshift[i_shift_offset+ZZ] += tz;
1144 /* Increment number of inner iterations */
1145 inneriter += j_index_end - j_index_start;
1147 /* Outer loop uses 30 flops */
1150 /* Increment number of outer iterations */
1153 /* Update outer/inner flops */
1155 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*304);