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_VdwLJSh_GeomW3W3_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwLJSh_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];
132 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
133 rcutoff = fr->rcoulomb;
134 rcutoff2 = rcutoff*rcutoff;
136 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
142 /* Start outer loop over neighborlists */
143 for(iidx=0; iidx<nri; iidx++)
145 /* Load shift vector for this list */
146 i_shift_offset = DIM*shiftidx[iidx];
147 shX = shiftvec[i_shift_offset+XX];
148 shY = shiftvec[i_shift_offset+YY];
149 shZ = shiftvec[i_shift_offset+ZZ];
151 /* Load limits for loop over neighbors */
152 j_index_start = jindex[iidx];
153 j_index_end = jindex[iidx+1];
155 /* Get outer coordinate index */
157 i_coord_offset = DIM*inr;
159 /* Load i particle coords and add shift vector */
160 ix0 = shX + x[i_coord_offset+DIM*0+XX];
161 iy0 = shY + x[i_coord_offset+DIM*0+YY];
162 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
163 ix1 = shX + x[i_coord_offset+DIM*1+XX];
164 iy1 = shY + x[i_coord_offset+DIM*1+YY];
165 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
166 ix2 = shX + x[i_coord_offset+DIM*2+XX];
167 iy2 = shY + x[i_coord_offset+DIM*2+YY];
168 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
180 /* Reset potential sums */
184 /* Start inner kernel loop */
185 for(jidx=j_index_start; jidx<j_index_end; jidx++)
187 /* Get j neighbor index, and coordinate index */
189 j_coord_offset = DIM*jnr;
191 /* load j atom coordinates */
192 jx0 = x[j_coord_offset+DIM*0+XX];
193 jy0 = x[j_coord_offset+DIM*0+YY];
194 jz0 = x[j_coord_offset+DIM*0+ZZ];
195 jx1 = x[j_coord_offset+DIM*1+XX];
196 jy1 = x[j_coord_offset+DIM*1+YY];
197 jz1 = x[j_coord_offset+DIM*1+ZZ];
198 jx2 = x[j_coord_offset+DIM*2+XX];
199 jy2 = x[j_coord_offset+DIM*2+YY];
200 jz2 = x[j_coord_offset+DIM*2+ZZ];
202 /* Calculate displacement vector */
231 /* Calculate squared distance and things based on it */
232 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
233 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
234 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
235 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
236 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
237 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
238 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
239 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
240 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
242 rinv00 = gmx_invsqrt(rsq00);
243 rinv01 = gmx_invsqrt(rsq01);
244 rinv02 = gmx_invsqrt(rsq02);
245 rinv10 = gmx_invsqrt(rsq10);
246 rinv11 = gmx_invsqrt(rsq11);
247 rinv12 = gmx_invsqrt(rsq12);
248 rinv20 = gmx_invsqrt(rsq20);
249 rinv21 = gmx_invsqrt(rsq21);
250 rinv22 = gmx_invsqrt(rsq22);
252 rinvsq00 = rinv00*rinv00;
253 rinvsq01 = rinv01*rinv01;
254 rinvsq02 = rinv02*rinv02;
255 rinvsq10 = rinv10*rinv10;
256 rinvsq11 = rinv11*rinv11;
257 rinvsq12 = rinv12*rinv12;
258 rinvsq20 = rinv20*rinv20;
259 rinvsq21 = rinv21*rinv21;
260 rinvsq22 = rinv22*rinv22;
262 /**************************
263 * CALCULATE INTERACTIONS *
264 **************************/
271 /* EWALD ELECTROSTATICS */
273 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
274 ewrt = r00*ewtabscale;
278 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
279 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
280 felec = qq00*rinv00*(rinvsq00-felec);
282 /* LENNARD-JONES DISPERSION/REPULSION */
284 rinvsix = rinvsq00*rinvsq00*rinvsq00;
285 vvdw6 = c6_00*rinvsix;
286 vvdw12 = c12_00*rinvsix*rinvsix;
287 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
288 fvdw = (vvdw12-vvdw6)*rinvsq00;
290 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
320 /* EWALD ELECTROSTATICS */
322 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
323 ewrt = r01*ewtabscale;
327 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
328 velec = qq01*((rinv01-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
329 felec = qq01*rinv01*(rinvsq01-felec);
331 /* Update potential sums from outer loop */
336 /* Calculate temporary vectorial force */
341 /* Update vectorial force */
345 f[j_coord_offset+DIM*1+XX] -= tx;
346 f[j_coord_offset+DIM*1+YY] -= ty;
347 f[j_coord_offset+DIM*1+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
360 /* EWALD ELECTROSTATICS */
362 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
363 ewrt = r02*ewtabscale;
367 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
368 velec = qq02*((rinv02-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
369 felec = qq02*rinv02*(rinvsq02-felec);
371 /* Update potential sums from outer loop */
376 /* Calculate temporary vectorial force */
381 /* Update vectorial force */
385 f[j_coord_offset+DIM*2+XX] -= tx;
386 f[j_coord_offset+DIM*2+YY] -= ty;
387 f[j_coord_offset+DIM*2+ZZ] -= tz;
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
400 /* EWALD ELECTROSTATICS */
402 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
403 ewrt = r10*ewtabscale;
407 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
408 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
409 felec = qq10*rinv10*(rinvsq10-felec);
411 /* Update potential sums from outer loop */
416 /* Calculate temporary vectorial force */
421 /* Update vectorial force */
425 f[j_coord_offset+DIM*0+XX] -= tx;
426 f[j_coord_offset+DIM*0+YY] -= ty;
427 f[j_coord_offset+DIM*0+ZZ] -= tz;
431 /**************************
432 * CALCULATE INTERACTIONS *
433 **************************/
440 /* EWALD ELECTROSTATICS */
442 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
443 ewrt = r11*ewtabscale;
447 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
448 velec = qq11*((rinv11-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
449 felec = qq11*rinv11*(rinvsq11-felec);
451 /* Update potential sums from outer loop */
456 /* Calculate temporary vectorial force */
461 /* Update vectorial force */
465 f[j_coord_offset+DIM*1+XX] -= tx;
466 f[j_coord_offset+DIM*1+YY] -= ty;
467 f[j_coord_offset+DIM*1+ZZ] -= tz;
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
480 /* EWALD ELECTROSTATICS */
482 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
483 ewrt = r12*ewtabscale;
487 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
488 velec = qq12*((rinv12-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
489 felec = qq12*rinv12*(rinvsq12-felec);
491 /* Update potential sums from outer loop */
496 /* Calculate temporary vectorial force */
501 /* Update vectorial force */
505 f[j_coord_offset+DIM*2+XX] -= tx;
506 f[j_coord_offset+DIM*2+YY] -= ty;
507 f[j_coord_offset+DIM*2+ZZ] -= tz;
511 /**************************
512 * CALCULATE INTERACTIONS *
513 **************************/
520 /* EWALD ELECTROSTATICS */
522 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
523 ewrt = r20*ewtabscale;
527 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
528 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
529 felec = qq20*rinv20*(rinvsq20-felec);
531 /* Update potential sums from outer loop */
536 /* Calculate temporary vectorial force */
541 /* Update vectorial force */
545 f[j_coord_offset+DIM*0+XX] -= tx;
546 f[j_coord_offset+DIM*0+YY] -= ty;
547 f[j_coord_offset+DIM*0+ZZ] -= tz;
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
560 /* EWALD ELECTROSTATICS */
562 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
563 ewrt = r21*ewtabscale;
567 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
568 velec = qq21*((rinv21-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
569 felec = qq21*rinv21*(rinvsq21-felec);
571 /* Update potential sums from outer loop */
576 /* Calculate temporary vectorial force */
581 /* Update vectorial force */
585 f[j_coord_offset+DIM*1+XX] -= tx;
586 f[j_coord_offset+DIM*1+YY] -= ty;
587 f[j_coord_offset+DIM*1+ZZ] -= tz;
591 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
600 /* EWALD ELECTROSTATICS */
602 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
603 ewrt = r22*ewtabscale;
607 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
608 velec = qq22*((rinv22-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
609 felec = qq22*rinv22*(rinvsq22-felec);
611 /* Update potential sums from outer loop */
616 /* Calculate temporary vectorial force */
621 /* Update vectorial force */
625 f[j_coord_offset+DIM*2+XX] -= tx;
626 f[j_coord_offset+DIM*2+YY] -= ty;
627 f[j_coord_offset+DIM*2+ZZ] -= tz;
631 /* Inner loop uses 386 flops */
633 /* End of innermost loop */
636 f[i_coord_offset+DIM*0+XX] += fix0;
637 f[i_coord_offset+DIM*0+YY] += fiy0;
638 f[i_coord_offset+DIM*0+ZZ] += fiz0;
642 f[i_coord_offset+DIM*1+XX] += fix1;
643 f[i_coord_offset+DIM*1+YY] += fiy1;
644 f[i_coord_offset+DIM*1+ZZ] += fiz1;
648 f[i_coord_offset+DIM*2+XX] += fix2;
649 f[i_coord_offset+DIM*2+YY] += fiy2;
650 f[i_coord_offset+DIM*2+ZZ] += fiz2;
654 fshift[i_shift_offset+XX] += tx;
655 fshift[i_shift_offset+YY] += ty;
656 fshift[i_shift_offset+ZZ] += tz;
659 /* Update potential energies */
660 kernel_data->energygrp_elec[ggid] += velecsum;
661 kernel_data->energygrp_vdw[ggid] += vvdwsum;
663 /* Increment number of inner iterations */
664 inneriter += j_index_end - j_index_start;
666 /* Outer loop uses 32 flops */
669 /* Increment number of outer iterations */
672 /* Update outer/inner flops */
674 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*386);
677 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_F_c
678 * Electrostatics interaction: Ewald
679 * VdW interaction: LennardJones
680 * Geometry: Water3-Water3
681 * Calculate force/pot: Force
684 nb_kernel_ElecEwSh_VdwLJSh_GeomW3W3_F_c
685 (t_nblist * gmx_restrict nlist,
686 rvec * gmx_restrict xx,
687 rvec * gmx_restrict ff,
688 t_forcerec * gmx_restrict fr,
689 t_mdatoms * gmx_restrict mdatoms,
690 nb_kernel_data_t * gmx_restrict kernel_data,
691 t_nrnb * gmx_restrict nrnb)
693 int i_shift_offset,i_coord_offset,j_coord_offset;
694 int j_index_start,j_index_end;
695 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
696 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
697 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
698 real *shiftvec,*fshift,*x,*f;
700 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
702 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
704 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
706 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
708 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
710 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
711 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
712 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
713 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
714 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
715 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
716 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
717 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
718 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
719 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
720 real velec,felec,velecsum,facel,crf,krf,krf2;
723 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
727 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
735 jindex = nlist->jindex;
737 shiftidx = nlist->shift;
739 shiftvec = fr->shift_vec[0];
740 fshift = fr->fshift[0];
742 charge = mdatoms->chargeA;
743 nvdwtype = fr->ntype;
745 vdwtype = mdatoms->typeA;
747 sh_ewald = fr->ic->sh_ewald;
748 ewtab = fr->ic->tabq_coul_F;
749 ewtabscale = fr->ic->tabq_scale;
750 ewtabhalfspace = 0.5/ewtabscale;
752 /* Setup water-specific parameters */
753 inr = nlist->iinr[0];
754 iq0 = facel*charge[inr+0];
755 iq1 = facel*charge[inr+1];
756 iq2 = facel*charge[inr+2];
757 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
762 vdwjidx0 = 2*vdwtype[inr+0];
764 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
765 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
775 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
776 rcutoff = fr->rcoulomb;
777 rcutoff2 = rcutoff*rcutoff;
779 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
785 /* Start outer loop over neighborlists */
786 for(iidx=0; iidx<nri; iidx++)
788 /* Load shift vector for this list */
789 i_shift_offset = DIM*shiftidx[iidx];
790 shX = shiftvec[i_shift_offset+XX];
791 shY = shiftvec[i_shift_offset+YY];
792 shZ = shiftvec[i_shift_offset+ZZ];
794 /* Load limits for loop over neighbors */
795 j_index_start = jindex[iidx];
796 j_index_end = jindex[iidx+1];
798 /* Get outer coordinate index */
800 i_coord_offset = DIM*inr;
802 /* Load i particle coords and add shift vector */
803 ix0 = shX + x[i_coord_offset+DIM*0+XX];
804 iy0 = shY + x[i_coord_offset+DIM*0+YY];
805 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
806 ix1 = shX + x[i_coord_offset+DIM*1+XX];
807 iy1 = shY + x[i_coord_offset+DIM*1+YY];
808 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
809 ix2 = shX + x[i_coord_offset+DIM*2+XX];
810 iy2 = shY + x[i_coord_offset+DIM*2+YY];
811 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
823 /* Start inner kernel loop */
824 for(jidx=j_index_start; jidx<j_index_end; jidx++)
826 /* Get j neighbor index, and coordinate index */
828 j_coord_offset = DIM*jnr;
830 /* load j atom coordinates */
831 jx0 = x[j_coord_offset+DIM*0+XX];
832 jy0 = x[j_coord_offset+DIM*0+YY];
833 jz0 = x[j_coord_offset+DIM*0+ZZ];
834 jx1 = x[j_coord_offset+DIM*1+XX];
835 jy1 = x[j_coord_offset+DIM*1+YY];
836 jz1 = x[j_coord_offset+DIM*1+ZZ];
837 jx2 = x[j_coord_offset+DIM*2+XX];
838 jy2 = x[j_coord_offset+DIM*2+YY];
839 jz2 = x[j_coord_offset+DIM*2+ZZ];
841 /* Calculate displacement vector */
870 /* Calculate squared distance and things based on it */
871 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
872 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
873 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
874 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
875 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
876 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
877 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
878 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
879 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
881 rinv00 = gmx_invsqrt(rsq00);
882 rinv01 = gmx_invsqrt(rsq01);
883 rinv02 = gmx_invsqrt(rsq02);
884 rinv10 = gmx_invsqrt(rsq10);
885 rinv11 = gmx_invsqrt(rsq11);
886 rinv12 = gmx_invsqrt(rsq12);
887 rinv20 = gmx_invsqrt(rsq20);
888 rinv21 = gmx_invsqrt(rsq21);
889 rinv22 = gmx_invsqrt(rsq22);
891 rinvsq00 = rinv00*rinv00;
892 rinvsq01 = rinv01*rinv01;
893 rinvsq02 = rinv02*rinv02;
894 rinvsq10 = rinv10*rinv10;
895 rinvsq11 = rinv11*rinv11;
896 rinvsq12 = rinv12*rinv12;
897 rinvsq20 = rinv20*rinv20;
898 rinvsq21 = rinv21*rinv21;
899 rinvsq22 = rinv22*rinv22;
901 /**************************
902 * CALCULATE INTERACTIONS *
903 **************************/
910 /* EWALD ELECTROSTATICS */
912 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
913 ewrt = r00*ewtabscale;
916 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
917 felec = qq00*rinv00*(rinvsq00-felec);
919 /* LENNARD-JONES DISPERSION/REPULSION */
921 rinvsix = rinvsq00*rinvsq00*rinvsq00;
922 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
926 /* Calculate temporary vectorial force */
931 /* Update vectorial force */
935 f[j_coord_offset+DIM*0+XX] -= tx;
936 f[j_coord_offset+DIM*0+YY] -= ty;
937 f[j_coord_offset+DIM*0+ZZ] -= tz;
941 /**************************
942 * CALCULATE INTERACTIONS *
943 **************************/
950 /* EWALD ELECTROSTATICS */
952 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
953 ewrt = r01*ewtabscale;
956 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
957 felec = qq01*rinv01*(rinvsq01-felec);
961 /* Calculate temporary vectorial force */
966 /* Update vectorial force */
970 f[j_coord_offset+DIM*1+XX] -= tx;
971 f[j_coord_offset+DIM*1+YY] -= ty;
972 f[j_coord_offset+DIM*1+ZZ] -= tz;
976 /**************************
977 * CALCULATE INTERACTIONS *
978 **************************/
985 /* EWALD ELECTROSTATICS */
987 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
988 ewrt = r02*ewtabscale;
991 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
992 felec = qq02*rinv02*(rinvsq02-felec);
996 /* Calculate temporary vectorial force */
1001 /* Update vectorial force */
1005 f[j_coord_offset+DIM*2+XX] -= tx;
1006 f[j_coord_offset+DIM*2+YY] -= ty;
1007 f[j_coord_offset+DIM*2+ZZ] -= tz;
1011 /**************************
1012 * CALCULATE INTERACTIONS *
1013 **************************/
1020 /* EWALD ELECTROSTATICS */
1022 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1023 ewrt = r10*ewtabscale;
1025 eweps = ewrt-ewitab;
1026 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1027 felec = qq10*rinv10*(rinvsq10-felec);
1031 /* Calculate temporary vectorial force */
1036 /* Update vectorial force */
1040 f[j_coord_offset+DIM*0+XX] -= tx;
1041 f[j_coord_offset+DIM*0+YY] -= ty;
1042 f[j_coord_offset+DIM*0+ZZ] -= tz;
1046 /**************************
1047 * CALCULATE INTERACTIONS *
1048 **************************/
1055 /* EWALD ELECTROSTATICS */
1057 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1058 ewrt = r11*ewtabscale;
1060 eweps = ewrt-ewitab;
1061 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1062 felec = qq11*rinv11*(rinvsq11-felec);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*1+XX] -= tx;
1076 f[j_coord_offset+DIM*1+YY] -= ty;
1077 f[j_coord_offset+DIM*1+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1090 /* EWALD ELECTROSTATICS */
1092 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1093 ewrt = r12*ewtabscale;
1095 eweps = ewrt-ewitab;
1096 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1097 felec = qq12*rinv12*(rinvsq12-felec);
1101 /* Calculate temporary vectorial force */
1106 /* Update vectorial force */
1110 f[j_coord_offset+DIM*2+XX] -= tx;
1111 f[j_coord_offset+DIM*2+YY] -= ty;
1112 f[j_coord_offset+DIM*2+ZZ] -= tz;
1116 /**************************
1117 * CALCULATE INTERACTIONS *
1118 **************************/
1125 /* EWALD ELECTROSTATICS */
1127 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1128 ewrt = r20*ewtabscale;
1130 eweps = ewrt-ewitab;
1131 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1132 felec = qq20*rinv20*(rinvsq20-felec);
1136 /* Calculate temporary vectorial force */
1141 /* Update vectorial force */
1145 f[j_coord_offset+DIM*0+XX] -= tx;
1146 f[j_coord_offset+DIM*0+YY] -= ty;
1147 f[j_coord_offset+DIM*0+ZZ] -= tz;
1151 /**************************
1152 * CALCULATE INTERACTIONS *
1153 **************************/
1160 /* EWALD ELECTROSTATICS */
1162 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1163 ewrt = r21*ewtabscale;
1165 eweps = ewrt-ewitab;
1166 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1167 felec = qq21*rinv21*(rinvsq21-felec);
1171 /* Calculate temporary vectorial force */
1176 /* Update vectorial force */
1180 f[j_coord_offset+DIM*1+XX] -= tx;
1181 f[j_coord_offset+DIM*1+YY] -= ty;
1182 f[j_coord_offset+DIM*1+ZZ] -= tz;
1186 /**************************
1187 * CALCULATE INTERACTIONS *
1188 **************************/
1195 /* EWALD ELECTROSTATICS */
1197 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1198 ewrt = r22*ewtabscale;
1200 eweps = ewrt-ewitab;
1201 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1202 felec = qq22*rinv22*(rinvsq22-felec);
1206 /* Calculate temporary vectorial force */
1211 /* Update vectorial force */
1215 f[j_coord_offset+DIM*2+XX] -= tx;
1216 f[j_coord_offset+DIM*2+YY] -= ty;
1217 f[j_coord_offset+DIM*2+ZZ] -= tz;
1221 /* Inner loop uses 304 flops */
1223 /* End of innermost loop */
1226 f[i_coord_offset+DIM*0+XX] += fix0;
1227 f[i_coord_offset+DIM*0+YY] += fiy0;
1228 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1232 f[i_coord_offset+DIM*1+XX] += fix1;
1233 f[i_coord_offset+DIM*1+YY] += fiy1;
1234 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1238 f[i_coord_offset+DIM*2+XX] += fix2;
1239 f[i_coord_offset+DIM*2+YY] += fiy2;
1240 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1244 fshift[i_shift_offset+XX] += tx;
1245 fshift[i_shift_offset+YY] += ty;
1246 fshift[i_shift_offset+ZZ] += tz;
1248 /* Increment number of inner iterations */
1249 inneriter += j_index_end - j_index_start;
1251 /* Outer loop uses 30 flops */
1254 /* Increment number of outer iterations */
1257 /* Update outer/inner flops */
1259 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*304);