2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW3W3_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwLJ_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
113 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 sh_ewald = fr->ic->sh_ewald;
119 ewtab = fr->ic->tabq_coul_FDV0;
120 ewtabscale = fr->ic->tabq_scale;
121 ewtabhalfspace = 0.5/ewtabscale;
123 /* Setup water-specific parameters */
124 inr = nlist->iinr[0];
125 iq0 = facel*charge[inr+0];
126 iq1 = facel*charge[inr+1];
127 iq2 = facel*charge[inr+2];
128 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
133 vdwjidx0 = 2*vdwtype[inr+0];
135 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
136 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
149 /* Start outer loop over neighborlists */
150 for(iidx=0; iidx<nri; iidx++)
152 /* Load shift vector for this list */
153 i_shift_offset = DIM*shiftidx[iidx];
154 shX = shiftvec[i_shift_offset+XX];
155 shY = shiftvec[i_shift_offset+YY];
156 shZ = shiftvec[i_shift_offset+ZZ];
158 /* Load limits for loop over neighbors */
159 j_index_start = jindex[iidx];
160 j_index_end = jindex[iidx+1];
162 /* Get outer coordinate index */
164 i_coord_offset = DIM*inr;
166 /* Load i particle coords and add shift vector */
167 ix0 = shX + x[i_coord_offset+DIM*0+XX];
168 iy0 = shY + x[i_coord_offset+DIM*0+YY];
169 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
170 ix1 = shX + x[i_coord_offset+DIM*1+XX];
171 iy1 = shY + x[i_coord_offset+DIM*1+YY];
172 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
173 ix2 = shX + x[i_coord_offset+DIM*2+XX];
174 iy2 = shY + x[i_coord_offset+DIM*2+YY];
175 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
187 /* Reset potential sums */
191 /* Start inner kernel loop */
192 for(jidx=j_index_start; jidx<j_index_end; jidx++)
194 /* Get j neighbor index, and coordinate index */
196 j_coord_offset = DIM*jnr;
198 /* load j atom coordinates */
199 jx0 = x[j_coord_offset+DIM*0+XX];
200 jy0 = x[j_coord_offset+DIM*0+YY];
201 jz0 = x[j_coord_offset+DIM*0+ZZ];
202 jx1 = x[j_coord_offset+DIM*1+XX];
203 jy1 = x[j_coord_offset+DIM*1+YY];
204 jz1 = x[j_coord_offset+DIM*1+ZZ];
205 jx2 = x[j_coord_offset+DIM*2+XX];
206 jy2 = x[j_coord_offset+DIM*2+YY];
207 jz2 = x[j_coord_offset+DIM*2+ZZ];
209 /* Calculate displacement vector */
238 /* Calculate squared distance and things based on it */
239 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
240 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
241 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
242 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
243 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
244 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
245 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
246 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
247 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
249 rinv00 = gmx_invsqrt(rsq00);
250 rinv01 = gmx_invsqrt(rsq01);
251 rinv02 = gmx_invsqrt(rsq02);
252 rinv10 = gmx_invsqrt(rsq10);
253 rinv11 = gmx_invsqrt(rsq11);
254 rinv12 = gmx_invsqrt(rsq12);
255 rinv20 = gmx_invsqrt(rsq20);
256 rinv21 = gmx_invsqrt(rsq21);
257 rinv22 = gmx_invsqrt(rsq22);
259 rinvsq00 = rinv00*rinv00;
260 rinvsq01 = rinv01*rinv01;
261 rinvsq02 = rinv02*rinv02;
262 rinvsq10 = rinv10*rinv10;
263 rinvsq11 = rinv11*rinv11;
264 rinvsq12 = rinv12*rinv12;
265 rinvsq20 = rinv20*rinv20;
266 rinvsq21 = rinv21*rinv21;
267 rinvsq22 = rinv22*rinv22;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
275 /* EWALD ELECTROSTATICS */
277 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
278 ewrt = r00*ewtabscale;
282 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
283 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
284 felec = qq00*rinv00*(rinvsq00-felec);
286 /* LENNARD-JONES DISPERSION/REPULSION */
288 rinvsix = rinvsq00*rinvsq00*rinvsq00;
289 vvdw6 = c6_00*rinvsix;
290 vvdw12 = c12_00*rinvsix*rinvsix;
291 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
292 fvdw = (vvdw12-vvdw6)*rinvsq00;
294 /* Update potential sums from outer loop */
300 /* Calculate temporary vectorial force */
305 /* Update vectorial force */
309 f[j_coord_offset+DIM*0+XX] -= tx;
310 f[j_coord_offset+DIM*0+YY] -= ty;
311 f[j_coord_offset+DIM*0+ZZ] -= tz;
313 /**************************
314 * CALCULATE INTERACTIONS *
315 **************************/
319 /* EWALD ELECTROSTATICS */
321 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
322 ewrt = r01*ewtabscale;
326 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
327 velec = qq01*(rinv01-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
328 felec = qq01*rinv01*(rinvsq01-felec);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*1+XX] -= tx;
345 f[j_coord_offset+DIM*1+YY] -= ty;
346 f[j_coord_offset+DIM*1+ZZ] -= tz;
348 /**************************
349 * CALCULATE INTERACTIONS *
350 **************************/
354 /* EWALD ELECTROSTATICS */
356 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
357 ewrt = r02*ewtabscale;
361 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
362 velec = qq02*(rinv02-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
363 felec = qq02*rinv02*(rinvsq02-felec);
365 /* Update potential sums from outer loop */
370 /* Calculate temporary vectorial force */
375 /* Update vectorial force */
379 f[j_coord_offset+DIM*2+XX] -= tx;
380 f[j_coord_offset+DIM*2+YY] -= ty;
381 f[j_coord_offset+DIM*2+ZZ] -= tz;
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
389 /* EWALD ELECTROSTATICS */
391 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
392 ewrt = r10*ewtabscale;
396 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
397 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
398 felec = qq10*rinv10*(rinvsq10-felec);
400 /* Update potential sums from outer loop */
405 /* Calculate temporary vectorial force */
410 /* Update vectorial force */
414 f[j_coord_offset+DIM*0+XX] -= tx;
415 f[j_coord_offset+DIM*0+YY] -= ty;
416 f[j_coord_offset+DIM*0+ZZ] -= tz;
418 /**************************
419 * CALCULATE INTERACTIONS *
420 **************************/
424 /* EWALD ELECTROSTATICS */
426 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
427 ewrt = r11*ewtabscale;
431 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
432 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
433 felec = qq11*rinv11*(rinvsq11-felec);
435 /* Update potential sums from outer loop */
440 /* Calculate temporary vectorial force */
445 /* Update vectorial force */
449 f[j_coord_offset+DIM*1+XX] -= tx;
450 f[j_coord_offset+DIM*1+YY] -= ty;
451 f[j_coord_offset+DIM*1+ZZ] -= tz;
453 /**************************
454 * CALCULATE INTERACTIONS *
455 **************************/
459 /* EWALD ELECTROSTATICS */
461 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
462 ewrt = r12*ewtabscale;
466 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
467 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
468 felec = qq12*rinv12*(rinvsq12-felec);
470 /* Update potential sums from outer loop */
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f[j_coord_offset+DIM*2+XX] -= tx;
485 f[j_coord_offset+DIM*2+YY] -= ty;
486 f[j_coord_offset+DIM*2+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
494 /* EWALD ELECTROSTATICS */
496 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
497 ewrt = r20*ewtabscale;
501 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
502 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
503 felec = qq20*rinv20*(rinvsq20-felec);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*0+XX] -= tx;
520 f[j_coord_offset+DIM*0+YY] -= ty;
521 f[j_coord_offset+DIM*0+ZZ] -= tz;
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
529 /* EWALD ELECTROSTATICS */
531 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
532 ewrt = r21*ewtabscale;
536 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
537 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
538 felec = qq21*rinv21*(rinvsq21-felec);
540 /* Update potential sums from outer loop */
545 /* Calculate temporary vectorial force */
550 /* Update vectorial force */
554 f[j_coord_offset+DIM*1+XX] -= tx;
555 f[j_coord_offset+DIM*1+YY] -= ty;
556 f[j_coord_offset+DIM*1+ZZ] -= tz;
558 /**************************
559 * CALCULATE INTERACTIONS *
560 **************************/
564 /* EWALD ELECTROSTATICS */
566 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
567 ewrt = r22*ewtabscale;
571 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
572 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
573 felec = qq22*rinv22*(rinvsq22-felec);
575 /* Update potential sums from outer loop */
580 /* Calculate temporary vectorial force */
585 /* Update vectorial force */
589 f[j_coord_offset+DIM*2+XX] -= tx;
590 f[j_coord_offset+DIM*2+YY] -= ty;
591 f[j_coord_offset+DIM*2+ZZ] -= tz;
593 /* Inner loop uses 372 flops */
595 /* End of innermost loop */
598 f[i_coord_offset+DIM*0+XX] += fix0;
599 f[i_coord_offset+DIM*0+YY] += fiy0;
600 f[i_coord_offset+DIM*0+ZZ] += fiz0;
604 f[i_coord_offset+DIM*1+XX] += fix1;
605 f[i_coord_offset+DIM*1+YY] += fiy1;
606 f[i_coord_offset+DIM*1+ZZ] += fiz1;
610 f[i_coord_offset+DIM*2+XX] += fix2;
611 f[i_coord_offset+DIM*2+YY] += fiy2;
612 f[i_coord_offset+DIM*2+ZZ] += fiz2;
616 fshift[i_shift_offset+XX] += tx;
617 fshift[i_shift_offset+YY] += ty;
618 fshift[i_shift_offset+ZZ] += tz;
621 /* Update potential energies */
622 kernel_data->energygrp_elec[ggid] += velecsum;
623 kernel_data->energygrp_vdw[ggid] += vvdwsum;
625 /* Increment number of inner iterations */
626 inneriter += j_index_end - j_index_start;
628 /* Outer loop uses 32 flops */
631 /* Increment number of outer iterations */
634 /* Update outer/inner flops */
636 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*372);
639 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW3W3_F_c
640 * Electrostatics interaction: Ewald
641 * VdW interaction: LennardJones
642 * Geometry: Water3-Water3
643 * Calculate force/pot: Force
646 nb_kernel_ElecEw_VdwLJ_GeomW3W3_F_c
647 (t_nblist * gmx_restrict nlist,
648 rvec * gmx_restrict xx,
649 rvec * gmx_restrict ff,
650 t_forcerec * gmx_restrict fr,
651 t_mdatoms * gmx_restrict mdatoms,
652 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
653 t_nrnb * gmx_restrict nrnb)
655 int i_shift_offset,i_coord_offset,j_coord_offset;
656 int j_index_start,j_index_end;
657 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
658 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
659 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
660 real *shiftvec,*fshift,*x,*f;
662 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
664 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
666 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
668 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
670 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
672 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
673 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
674 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
675 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
676 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
677 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
678 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
679 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
680 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
681 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
682 real velec,felec,velecsum,facel,crf,krf,krf2;
685 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
689 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
697 jindex = nlist->jindex;
699 shiftidx = nlist->shift;
701 shiftvec = fr->shift_vec[0];
702 fshift = fr->fshift[0];
704 charge = mdatoms->chargeA;
705 nvdwtype = fr->ntype;
707 vdwtype = mdatoms->typeA;
709 sh_ewald = fr->ic->sh_ewald;
710 ewtab = fr->ic->tabq_coul_F;
711 ewtabscale = fr->ic->tabq_scale;
712 ewtabhalfspace = 0.5/ewtabscale;
714 /* Setup water-specific parameters */
715 inr = nlist->iinr[0];
716 iq0 = facel*charge[inr+0];
717 iq1 = facel*charge[inr+1];
718 iq2 = facel*charge[inr+2];
719 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
724 vdwjidx0 = 2*vdwtype[inr+0];
726 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
727 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
740 /* Start outer loop over neighborlists */
741 for(iidx=0; iidx<nri; iidx++)
743 /* Load shift vector for this list */
744 i_shift_offset = DIM*shiftidx[iidx];
745 shX = shiftvec[i_shift_offset+XX];
746 shY = shiftvec[i_shift_offset+YY];
747 shZ = shiftvec[i_shift_offset+ZZ];
749 /* Load limits for loop over neighbors */
750 j_index_start = jindex[iidx];
751 j_index_end = jindex[iidx+1];
753 /* Get outer coordinate index */
755 i_coord_offset = DIM*inr;
757 /* Load i particle coords and add shift vector */
758 ix0 = shX + x[i_coord_offset+DIM*0+XX];
759 iy0 = shY + x[i_coord_offset+DIM*0+YY];
760 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
761 ix1 = shX + x[i_coord_offset+DIM*1+XX];
762 iy1 = shY + x[i_coord_offset+DIM*1+YY];
763 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
764 ix2 = shX + x[i_coord_offset+DIM*2+XX];
765 iy2 = shY + x[i_coord_offset+DIM*2+YY];
766 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
778 /* Start inner kernel loop */
779 for(jidx=j_index_start; jidx<j_index_end; jidx++)
781 /* Get j neighbor index, and coordinate index */
783 j_coord_offset = DIM*jnr;
785 /* load j atom coordinates */
786 jx0 = x[j_coord_offset+DIM*0+XX];
787 jy0 = x[j_coord_offset+DIM*0+YY];
788 jz0 = x[j_coord_offset+DIM*0+ZZ];
789 jx1 = x[j_coord_offset+DIM*1+XX];
790 jy1 = x[j_coord_offset+DIM*1+YY];
791 jz1 = x[j_coord_offset+DIM*1+ZZ];
792 jx2 = x[j_coord_offset+DIM*2+XX];
793 jy2 = x[j_coord_offset+DIM*2+YY];
794 jz2 = x[j_coord_offset+DIM*2+ZZ];
796 /* Calculate displacement vector */
825 /* Calculate squared distance and things based on it */
826 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
827 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
828 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
829 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
830 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
831 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
832 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
833 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
834 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
836 rinv00 = gmx_invsqrt(rsq00);
837 rinv01 = gmx_invsqrt(rsq01);
838 rinv02 = gmx_invsqrt(rsq02);
839 rinv10 = gmx_invsqrt(rsq10);
840 rinv11 = gmx_invsqrt(rsq11);
841 rinv12 = gmx_invsqrt(rsq12);
842 rinv20 = gmx_invsqrt(rsq20);
843 rinv21 = gmx_invsqrt(rsq21);
844 rinv22 = gmx_invsqrt(rsq22);
846 rinvsq00 = rinv00*rinv00;
847 rinvsq01 = rinv01*rinv01;
848 rinvsq02 = rinv02*rinv02;
849 rinvsq10 = rinv10*rinv10;
850 rinvsq11 = rinv11*rinv11;
851 rinvsq12 = rinv12*rinv12;
852 rinvsq20 = rinv20*rinv20;
853 rinvsq21 = rinv21*rinv21;
854 rinvsq22 = rinv22*rinv22;
856 /**************************
857 * CALCULATE INTERACTIONS *
858 **************************/
862 /* EWALD ELECTROSTATICS */
864 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
865 ewrt = r00*ewtabscale;
868 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
869 felec = qq00*rinv00*(rinvsq00-felec);
871 /* LENNARD-JONES DISPERSION/REPULSION */
873 rinvsix = rinvsq00*rinvsq00*rinvsq00;
874 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
878 /* Calculate temporary vectorial force */
883 /* Update vectorial force */
887 f[j_coord_offset+DIM*0+XX] -= tx;
888 f[j_coord_offset+DIM*0+YY] -= ty;
889 f[j_coord_offset+DIM*0+ZZ] -= tz;
891 /**************************
892 * CALCULATE INTERACTIONS *
893 **************************/
897 /* EWALD ELECTROSTATICS */
899 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
900 ewrt = r01*ewtabscale;
903 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
904 felec = qq01*rinv01*(rinvsq01-felec);
908 /* Calculate temporary vectorial force */
913 /* Update vectorial force */
917 f[j_coord_offset+DIM*1+XX] -= tx;
918 f[j_coord_offset+DIM*1+YY] -= ty;
919 f[j_coord_offset+DIM*1+ZZ] -= tz;
921 /**************************
922 * CALCULATE INTERACTIONS *
923 **************************/
927 /* EWALD ELECTROSTATICS */
929 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
930 ewrt = r02*ewtabscale;
933 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
934 felec = qq02*rinv02*(rinvsq02-felec);
938 /* Calculate temporary vectorial force */
943 /* Update vectorial force */
947 f[j_coord_offset+DIM*2+XX] -= tx;
948 f[j_coord_offset+DIM*2+YY] -= ty;
949 f[j_coord_offset+DIM*2+ZZ] -= tz;
951 /**************************
952 * CALCULATE INTERACTIONS *
953 **************************/
957 /* EWALD ELECTROSTATICS */
959 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
960 ewrt = r10*ewtabscale;
963 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
964 felec = qq10*rinv10*(rinvsq10-felec);
968 /* Calculate temporary vectorial force */
973 /* Update vectorial force */
977 f[j_coord_offset+DIM*0+XX] -= tx;
978 f[j_coord_offset+DIM*0+YY] -= ty;
979 f[j_coord_offset+DIM*0+ZZ] -= tz;
981 /**************************
982 * CALCULATE INTERACTIONS *
983 **************************/
987 /* EWALD ELECTROSTATICS */
989 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
990 ewrt = r11*ewtabscale;
993 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
994 felec = qq11*rinv11*(rinvsq11-felec);
998 /* Calculate temporary vectorial force */
1003 /* Update vectorial force */
1007 f[j_coord_offset+DIM*1+XX] -= tx;
1008 f[j_coord_offset+DIM*1+YY] -= ty;
1009 f[j_coord_offset+DIM*1+ZZ] -= tz;
1011 /**************************
1012 * CALCULATE INTERACTIONS *
1013 **************************/
1017 /* EWALD ELECTROSTATICS */
1019 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1020 ewrt = r12*ewtabscale;
1022 eweps = ewrt-ewitab;
1023 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1024 felec = qq12*rinv12*(rinvsq12-felec);
1028 /* Calculate temporary vectorial force */
1033 /* Update vectorial force */
1037 f[j_coord_offset+DIM*2+XX] -= tx;
1038 f[j_coord_offset+DIM*2+YY] -= ty;
1039 f[j_coord_offset+DIM*2+ZZ] -= tz;
1041 /**************************
1042 * CALCULATE INTERACTIONS *
1043 **************************/
1047 /* EWALD ELECTROSTATICS */
1049 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1050 ewrt = r20*ewtabscale;
1052 eweps = ewrt-ewitab;
1053 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1054 felec = qq20*rinv20*(rinvsq20-felec);
1058 /* Calculate temporary vectorial force */
1063 /* Update vectorial force */
1067 f[j_coord_offset+DIM*0+XX] -= tx;
1068 f[j_coord_offset+DIM*0+YY] -= ty;
1069 f[j_coord_offset+DIM*0+ZZ] -= tz;
1071 /**************************
1072 * CALCULATE INTERACTIONS *
1073 **************************/
1077 /* EWALD ELECTROSTATICS */
1079 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1080 ewrt = r21*ewtabscale;
1082 eweps = ewrt-ewitab;
1083 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1084 felec = qq21*rinv21*(rinvsq21-felec);
1088 /* Calculate temporary vectorial force */
1093 /* Update vectorial force */
1097 f[j_coord_offset+DIM*1+XX] -= tx;
1098 f[j_coord_offset+DIM*1+YY] -= ty;
1099 f[j_coord_offset+DIM*1+ZZ] -= tz;
1101 /**************************
1102 * CALCULATE INTERACTIONS *
1103 **************************/
1107 /* EWALD ELECTROSTATICS */
1109 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1110 ewrt = r22*ewtabscale;
1112 eweps = ewrt-ewitab;
1113 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1114 felec = qq22*rinv22*(rinvsq22-felec);
1118 /* Calculate temporary vectorial force */
1123 /* Update vectorial force */
1127 f[j_coord_offset+DIM*2+XX] -= tx;
1128 f[j_coord_offset+DIM*2+YY] -= ty;
1129 f[j_coord_offset+DIM*2+ZZ] -= tz;
1131 /* Inner loop uses 304 flops */
1133 /* End of innermost loop */
1136 f[i_coord_offset+DIM*0+XX] += fix0;
1137 f[i_coord_offset+DIM*0+YY] += fiy0;
1138 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1142 f[i_coord_offset+DIM*1+XX] += fix1;
1143 f[i_coord_offset+DIM*1+YY] += fiy1;
1144 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1148 f[i_coord_offset+DIM*2+XX] += fix2;
1149 f[i_coord_offset+DIM*2+YY] += fiy2;
1150 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1154 fshift[i_shift_offset+XX] += tx;
1155 fshift[i_shift_offset+YY] += ty;
1156 fshift[i_shift_offset+ZZ] += tz;
1158 /* Increment number of inner iterations */
1159 inneriter += j_index_end - j_index_start;
1161 /* Outer loop uses 30 flops */
1164 /* Increment number of outer iterations */
1167 /* Update outer/inner flops */
1169 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*304);