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_GeomW4W4_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwBham_GeomW4W4_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;
67 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
69 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
71 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
72 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
73 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
74 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
75 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
76 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
77 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
78 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
79 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
80 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
81 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
82 real velec,felec,velecsum,facel,crf,krf,krf2;
85 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
89 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
97 jindex = nlist->jindex;
99 shiftidx = nlist->shift;
101 shiftvec = fr->shift_vec[0];
102 fshift = fr->fshift[0];
104 charge = mdatoms->chargeA;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 sh_ewald = fr->ic->sh_ewald;
110 ewtab = fr->ic->tabq_coul_FDV0;
111 ewtabscale = fr->ic->tabq_scale;
112 ewtabhalfspace = 0.5/ewtabscale;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 iq3 = facel*charge[inr+3];
119 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
124 vdwjidx0 = 3*vdwtype[inr+0];
125 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
126 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
127 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
141 /* Start outer loop over neighborlists */
142 for(iidx=0; iidx<nri; iidx++)
144 /* Load shift vector for this list */
145 i_shift_offset = DIM*shiftidx[iidx];
146 shX = shiftvec[i_shift_offset+XX];
147 shY = shiftvec[i_shift_offset+YY];
148 shZ = shiftvec[i_shift_offset+ZZ];
150 /* Load limits for loop over neighbors */
151 j_index_start = jindex[iidx];
152 j_index_end = jindex[iidx+1];
154 /* Get outer coordinate index */
156 i_coord_offset = DIM*inr;
158 /* Load i particle coords and add shift vector */
159 ix0 = shX + x[i_coord_offset+DIM*0+XX];
160 iy0 = shY + x[i_coord_offset+DIM*0+YY];
161 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
162 ix1 = shX + x[i_coord_offset+DIM*1+XX];
163 iy1 = shY + x[i_coord_offset+DIM*1+YY];
164 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
165 ix2 = shX + x[i_coord_offset+DIM*2+XX];
166 iy2 = shY + x[i_coord_offset+DIM*2+YY];
167 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
168 ix3 = shX + x[i_coord_offset+DIM*3+XX];
169 iy3 = shY + x[i_coord_offset+DIM*3+YY];
170 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
185 /* Reset potential sums */
189 /* Start inner kernel loop */
190 for(jidx=j_index_start; jidx<j_index_end; jidx++)
192 /* Get j neighbor index, and coordinate index */
194 j_coord_offset = DIM*jnr;
196 /* load j atom coordinates */
197 jx0 = x[j_coord_offset+DIM*0+XX];
198 jy0 = x[j_coord_offset+DIM*0+YY];
199 jz0 = x[j_coord_offset+DIM*0+ZZ];
200 jx1 = x[j_coord_offset+DIM*1+XX];
201 jy1 = x[j_coord_offset+DIM*1+YY];
202 jz1 = x[j_coord_offset+DIM*1+ZZ];
203 jx2 = x[j_coord_offset+DIM*2+XX];
204 jy2 = x[j_coord_offset+DIM*2+YY];
205 jz2 = x[j_coord_offset+DIM*2+ZZ];
206 jx3 = x[j_coord_offset+DIM*3+XX];
207 jy3 = x[j_coord_offset+DIM*3+YY];
208 jz3 = x[j_coord_offset+DIM*3+ZZ];
210 /* Calculate displacement vector */
242 /* Calculate squared distance and things based on it */
243 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
244 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
245 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
246 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
247 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
248 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
249 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
250 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
251 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
252 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
254 rinv00 = gmx_invsqrt(rsq00);
255 rinv11 = gmx_invsqrt(rsq11);
256 rinv12 = gmx_invsqrt(rsq12);
257 rinv13 = gmx_invsqrt(rsq13);
258 rinv21 = gmx_invsqrt(rsq21);
259 rinv22 = gmx_invsqrt(rsq22);
260 rinv23 = gmx_invsqrt(rsq23);
261 rinv31 = gmx_invsqrt(rsq31);
262 rinv32 = gmx_invsqrt(rsq32);
263 rinv33 = gmx_invsqrt(rsq33);
265 rinvsq00 = rinv00*rinv00;
266 rinvsq11 = rinv11*rinv11;
267 rinvsq12 = rinv12*rinv12;
268 rinvsq13 = rinv13*rinv13;
269 rinvsq21 = rinv21*rinv21;
270 rinvsq22 = rinv22*rinv22;
271 rinvsq23 = rinv23*rinv23;
272 rinvsq31 = rinv31*rinv31;
273 rinvsq32 = rinv32*rinv32;
274 rinvsq33 = rinv33*rinv33;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
282 /* BUCKINGHAM DISPERSION/REPULSION */
283 rinvsix = rinvsq00*rinvsq00*rinvsq00;
284 vvdw6 = c6_00*rinvsix;
286 vvdwexp = cexp1_00*exp(-br);
287 vvdw = vvdwexp - vvdw6*(1.0/6.0);
288 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
290 /* Update potential sums from outer loop */
295 /* Calculate temporary vectorial force */
300 /* Update vectorial force */
304 f[j_coord_offset+DIM*0+XX] -= tx;
305 f[j_coord_offset+DIM*0+YY] -= ty;
306 f[j_coord_offset+DIM*0+ZZ] -= tz;
308 /**************************
309 * CALCULATE INTERACTIONS *
310 **************************/
314 /* EWALD ELECTROSTATICS */
316 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
317 ewrt = r11*ewtabscale;
321 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
322 velec = qq11*(rinv11-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
323 felec = qq11*rinv11*(rinvsq11-felec);
325 /* Update potential sums from outer loop */
330 /* Calculate temporary vectorial force */
335 /* Update vectorial force */
339 f[j_coord_offset+DIM*1+XX] -= tx;
340 f[j_coord_offset+DIM*1+YY] -= ty;
341 f[j_coord_offset+DIM*1+ZZ] -= tz;
343 /**************************
344 * CALCULATE INTERACTIONS *
345 **************************/
349 /* EWALD ELECTROSTATICS */
351 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
352 ewrt = r12*ewtabscale;
356 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
357 velec = qq12*(rinv12-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
358 felec = qq12*rinv12*(rinvsq12-felec);
360 /* Update potential sums from outer loop */
365 /* Calculate temporary vectorial force */
370 /* Update vectorial force */
374 f[j_coord_offset+DIM*2+XX] -= tx;
375 f[j_coord_offset+DIM*2+YY] -= ty;
376 f[j_coord_offset+DIM*2+ZZ] -= tz;
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
384 /* EWALD ELECTROSTATICS */
386 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
387 ewrt = r13*ewtabscale;
391 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
392 velec = qq13*(rinv13-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
393 felec = qq13*rinv13*(rinvsq13-felec);
395 /* Update potential sums from outer loop */
400 /* Calculate temporary vectorial force */
405 /* Update vectorial force */
409 f[j_coord_offset+DIM*3+XX] -= tx;
410 f[j_coord_offset+DIM*3+YY] -= ty;
411 f[j_coord_offset+DIM*3+ZZ] -= tz;
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
419 /* EWALD ELECTROSTATICS */
421 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
422 ewrt = r21*ewtabscale;
426 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
427 velec = qq21*(rinv21-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
428 felec = qq21*rinv21*(rinvsq21-felec);
430 /* Update potential sums from outer loop */
435 /* Calculate temporary vectorial force */
440 /* Update vectorial force */
444 f[j_coord_offset+DIM*1+XX] -= tx;
445 f[j_coord_offset+DIM*1+YY] -= ty;
446 f[j_coord_offset+DIM*1+ZZ] -= tz;
448 /**************************
449 * CALCULATE INTERACTIONS *
450 **************************/
454 /* EWALD ELECTROSTATICS */
456 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
457 ewrt = r22*ewtabscale;
461 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
462 velec = qq22*(rinv22-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
463 felec = qq22*rinv22*(rinvsq22-felec);
465 /* Update potential sums from outer loop */
470 /* Calculate temporary vectorial force */
475 /* Update vectorial force */
479 f[j_coord_offset+DIM*2+XX] -= tx;
480 f[j_coord_offset+DIM*2+YY] -= ty;
481 f[j_coord_offset+DIM*2+ZZ] -= tz;
483 /**************************
484 * CALCULATE INTERACTIONS *
485 **************************/
489 /* EWALD ELECTROSTATICS */
491 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
492 ewrt = r23*ewtabscale;
496 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
497 velec = qq23*(rinv23-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
498 felec = qq23*rinv23*(rinvsq23-felec);
500 /* Update potential sums from outer loop */
505 /* Calculate temporary vectorial force */
510 /* Update vectorial force */
514 f[j_coord_offset+DIM*3+XX] -= tx;
515 f[j_coord_offset+DIM*3+YY] -= ty;
516 f[j_coord_offset+DIM*3+ZZ] -= tz;
518 /**************************
519 * CALCULATE INTERACTIONS *
520 **************************/
524 /* EWALD ELECTROSTATICS */
526 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
527 ewrt = r31*ewtabscale;
531 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
532 velec = qq31*(rinv31-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
533 felec = qq31*rinv31*(rinvsq31-felec);
535 /* Update potential sums from outer loop */
540 /* Calculate temporary vectorial force */
545 /* Update vectorial force */
549 f[j_coord_offset+DIM*1+XX] -= tx;
550 f[j_coord_offset+DIM*1+YY] -= ty;
551 f[j_coord_offset+DIM*1+ZZ] -= tz;
553 /**************************
554 * CALCULATE INTERACTIONS *
555 **************************/
559 /* EWALD ELECTROSTATICS */
561 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
562 ewrt = r32*ewtabscale;
566 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
567 velec = qq32*(rinv32-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
568 felec = qq32*rinv32*(rinvsq32-felec);
570 /* Update potential sums from outer loop */
575 /* Calculate temporary vectorial force */
580 /* Update vectorial force */
584 f[j_coord_offset+DIM*2+XX] -= tx;
585 f[j_coord_offset+DIM*2+YY] -= ty;
586 f[j_coord_offset+DIM*2+ZZ] -= tz;
588 /**************************
589 * CALCULATE INTERACTIONS *
590 **************************/
594 /* EWALD ELECTROSTATICS */
596 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
597 ewrt = r33*ewtabscale;
601 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
602 velec = qq33*(rinv33-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
603 felec = qq33*rinv33*(rinvsq33-felec);
605 /* Update potential sums from outer loop */
610 /* Calculate temporary vectorial force */
615 /* Update vectorial force */
619 f[j_coord_offset+DIM*3+XX] -= tx;
620 f[j_coord_offset+DIM*3+YY] -= ty;
621 f[j_coord_offset+DIM*3+ZZ] -= tz;
623 /* Inner loop uses 421 flops */
625 /* End of innermost loop */
628 f[i_coord_offset+DIM*0+XX] += fix0;
629 f[i_coord_offset+DIM*0+YY] += fiy0;
630 f[i_coord_offset+DIM*0+ZZ] += fiz0;
634 f[i_coord_offset+DIM*1+XX] += fix1;
635 f[i_coord_offset+DIM*1+YY] += fiy1;
636 f[i_coord_offset+DIM*1+ZZ] += fiz1;
640 f[i_coord_offset+DIM*2+XX] += fix2;
641 f[i_coord_offset+DIM*2+YY] += fiy2;
642 f[i_coord_offset+DIM*2+ZZ] += fiz2;
646 f[i_coord_offset+DIM*3+XX] += fix3;
647 f[i_coord_offset+DIM*3+YY] += fiy3;
648 f[i_coord_offset+DIM*3+ZZ] += fiz3;
652 fshift[i_shift_offset+XX] += tx;
653 fshift[i_shift_offset+YY] += ty;
654 fshift[i_shift_offset+ZZ] += tz;
657 /* Update potential energies */
658 kernel_data->energygrp_elec[ggid] += velecsum;
659 kernel_data->energygrp_vdw[ggid] += vvdwsum;
661 /* Increment number of inner iterations */
662 inneriter += j_index_end - j_index_start;
664 /* Outer loop uses 41 flops */
667 /* Increment number of outer iterations */
670 /* Update outer/inner flops */
672 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*421);
675 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwBham_GeomW4W4_F_c
676 * Electrostatics interaction: Ewald
677 * VdW interaction: Buckingham
678 * Geometry: Water4-Water4
679 * Calculate force/pot: Force
682 nb_kernel_ElecEw_VdwBham_GeomW4W4_F_c
683 (t_nblist * gmx_restrict nlist,
684 rvec * gmx_restrict xx,
685 rvec * gmx_restrict ff,
686 t_forcerec * gmx_restrict fr,
687 t_mdatoms * gmx_restrict mdatoms,
688 nb_kernel_data_t * gmx_restrict kernel_data,
689 t_nrnb * gmx_restrict nrnb)
691 int i_shift_offset,i_coord_offset,j_coord_offset;
692 int j_index_start,j_index_end;
693 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
694 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
695 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
696 real *shiftvec,*fshift,*x,*f;
698 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
700 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
702 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
704 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
712 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
713 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
714 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
715 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
716 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
717 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
718 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
719 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
720 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
721 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
722 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
723 real velec,felec,velecsum,facel,crf,krf,krf2;
726 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
730 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
738 jindex = nlist->jindex;
740 shiftidx = nlist->shift;
742 shiftvec = fr->shift_vec[0];
743 fshift = fr->fshift[0];
745 charge = mdatoms->chargeA;
746 nvdwtype = fr->ntype;
748 vdwtype = mdatoms->typeA;
750 sh_ewald = fr->ic->sh_ewald;
751 ewtab = fr->ic->tabq_coul_F;
752 ewtabscale = fr->ic->tabq_scale;
753 ewtabhalfspace = 0.5/ewtabscale;
755 /* Setup water-specific parameters */
756 inr = nlist->iinr[0];
757 iq1 = facel*charge[inr+1];
758 iq2 = facel*charge[inr+2];
759 iq3 = facel*charge[inr+3];
760 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
765 vdwjidx0 = 3*vdwtype[inr+0];
766 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
767 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
768 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
782 /* Start outer loop over neighborlists */
783 for(iidx=0; iidx<nri; iidx++)
785 /* Load shift vector for this list */
786 i_shift_offset = DIM*shiftidx[iidx];
787 shX = shiftvec[i_shift_offset+XX];
788 shY = shiftvec[i_shift_offset+YY];
789 shZ = shiftvec[i_shift_offset+ZZ];
791 /* Load limits for loop over neighbors */
792 j_index_start = jindex[iidx];
793 j_index_end = jindex[iidx+1];
795 /* Get outer coordinate index */
797 i_coord_offset = DIM*inr;
799 /* Load i particle coords and add shift vector */
800 ix0 = shX + x[i_coord_offset+DIM*0+XX];
801 iy0 = shY + x[i_coord_offset+DIM*0+YY];
802 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
803 ix1 = shX + x[i_coord_offset+DIM*1+XX];
804 iy1 = shY + x[i_coord_offset+DIM*1+YY];
805 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
806 ix2 = shX + x[i_coord_offset+DIM*2+XX];
807 iy2 = shY + x[i_coord_offset+DIM*2+YY];
808 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
809 ix3 = shX + x[i_coord_offset+DIM*3+XX];
810 iy3 = shY + x[i_coord_offset+DIM*3+YY];
811 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
826 /* Start inner kernel loop */
827 for(jidx=j_index_start; jidx<j_index_end; jidx++)
829 /* Get j neighbor index, and coordinate index */
831 j_coord_offset = DIM*jnr;
833 /* load j atom coordinates */
834 jx0 = x[j_coord_offset+DIM*0+XX];
835 jy0 = x[j_coord_offset+DIM*0+YY];
836 jz0 = x[j_coord_offset+DIM*0+ZZ];
837 jx1 = x[j_coord_offset+DIM*1+XX];
838 jy1 = x[j_coord_offset+DIM*1+YY];
839 jz1 = x[j_coord_offset+DIM*1+ZZ];
840 jx2 = x[j_coord_offset+DIM*2+XX];
841 jy2 = x[j_coord_offset+DIM*2+YY];
842 jz2 = x[j_coord_offset+DIM*2+ZZ];
843 jx3 = x[j_coord_offset+DIM*3+XX];
844 jy3 = x[j_coord_offset+DIM*3+YY];
845 jz3 = x[j_coord_offset+DIM*3+ZZ];
847 /* Calculate displacement vector */
879 /* Calculate squared distance and things based on it */
880 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
881 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
882 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
883 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
884 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
885 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
886 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
887 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
888 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
889 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
891 rinv00 = gmx_invsqrt(rsq00);
892 rinv11 = gmx_invsqrt(rsq11);
893 rinv12 = gmx_invsqrt(rsq12);
894 rinv13 = gmx_invsqrt(rsq13);
895 rinv21 = gmx_invsqrt(rsq21);
896 rinv22 = gmx_invsqrt(rsq22);
897 rinv23 = gmx_invsqrt(rsq23);
898 rinv31 = gmx_invsqrt(rsq31);
899 rinv32 = gmx_invsqrt(rsq32);
900 rinv33 = gmx_invsqrt(rsq33);
902 rinvsq00 = rinv00*rinv00;
903 rinvsq11 = rinv11*rinv11;
904 rinvsq12 = rinv12*rinv12;
905 rinvsq13 = rinv13*rinv13;
906 rinvsq21 = rinv21*rinv21;
907 rinvsq22 = rinv22*rinv22;
908 rinvsq23 = rinv23*rinv23;
909 rinvsq31 = rinv31*rinv31;
910 rinvsq32 = rinv32*rinv32;
911 rinvsq33 = rinv33*rinv33;
913 /**************************
914 * CALCULATE INTERACTIONS *
915 **************************/
919 /* BUCKINGHAM DISPERSION/REPULSION */
920 rinvsix = rinvsq00*rinvsq00*rinvsq00;
921 vvdw6 = c6_00*rinvsix;
923 vvdwexp = cexp1_00*exp(-br);
924 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
928 /* Calculate temporary vectorial force */
933 /* Update vectorial force */
937 f[j_coord_offset+DIM*0+XX] -= tx;
938 f[j_coord_offset+DIM*0+YY] -= ty;
939 f[j_coord_offset+DIM*0+ZZ] -= tz;
941 /**************************
942 * CALCULATE INTERACTIONS *
943 **************************/
947 /* EWALD ELECTROSTATICS */
949 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
950 ewrt = r11*ewtabscale;
953 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
954 felec = qq11*rinv11*(rinvsq11-felec);
958 /* Calculate temporary vectorial force */
963 /* Update vectorial force */
967 f[j_coord_offset+DIM*1+XX] -= tx;
968 f[j_coord_offset+DIM*1+YY] -= ty;
969 f[j_coord_offset+DIM*1+ZZ] -= tz;
971 /**************************
972 * CALCULATE INTERACTIONS *
973 **************************/
977 /* EWALD ELECTROSTATICS */
979 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
980 ewrt = r12*ewtabscale;
983 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
984 felec = qq12*rinv12*(rinvsq12-felec);
988 /* Calculate temporary vectorial force */
993 /* Update vectorial force */
997 f[j_coord_offset+DIM*2+XX] -= tx;
998 f[j_coord_offset+DIM*2+YY] -= ty;
999 f[j_coord_offset+DIM*2+ZZ] -= tz;
1001 /**************************
1002 * CALCULATE INTERACTIONS *
1003 **************************/
1007 /* EWALD ELECTROSTATICS */
1009 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1010 ewrt = r13*ewtabscale;
1012 eweps = ewrt-ewitab;
1013 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1014 felec = qq13*rinv13*(rinvsq13-felec);
1018 /* Calculate temporary vectorial force */
1023 /* Update vectorial force */
1027 f[j_coord_offset+DIM*3+XX] -= tx;
1028 f[j_coord_offset+DIM*3+YY] -= ty;
1029 f[j_coord_offset+DIM*3+ZZ] -= tz;
1031 /**************************
1032 * CALCULATE INTERACTIONS *
1033 **************************/
1037 /* EWALD ELECTROSTATICS */
1039 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1040 ewrt = r21*ewtabscale;
1042 eweps = ewrt-ewitab;
1043 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1044 felec = qq21*rinv21*(rinvsq21-felec);
1048 /* Calculate temporary vectorial force */
1053 /* Update vectorial force */
1057 f[j_coord_offset+DIM*1+XX] -= tx;
1058 f[j_coord_offset+DIM*1+YY] -= ty;
1059 f[j_coord_offset+DIM*1+ZZ] -= tz;
1061 /**************************
1062 * CALCULATE INTERACTIONS *
1063 **************************/
1067 /* EWALD ELECTROSTATICS */
1069 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1070 ewrt = r22*ewtabscale;
1072 eweps = ewrt-ewitab;
1073 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1074 felec = qq22*rinv22*(rinvsq22-felec);
1078 /* Calculate temporary vectorial force */
1083 /* Update vectorial force */
1087 f[j_coord_offset+DIM*2+XX] -= tx;
1088 f[j_coord_offset+DIM*2+YY] -= ty;
1089 f[j_coord_offset+DIM*2+ZZ] -= tz;
1091 /**************************
1092 * CALCULATE INTERACTIONS *
1093 **************************/
1097 /* EWALD ELECTROSTATICS */
1099 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1100 ewrt = r23*ewtabscale;
1102 eweps = ewrt-ewitab;
1103 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1104 felec = qq23*rinv23*(rinvsq23-felec);
1108 /* Calculate temporary vectorial force */
1113 /* Update vectorial force */
1117 f[j_coord_offset+DIM*3+XX] -= tx;
1118 f[j_coord_offset+DIM*3+YY] -= ty;
1119 f[j_coord_offset+DIM*3+ZZ] -= tz;
1121 /**************************
1122 * CALCULATE INTERACTIONS *
1123 **************************/
1127 /* EWALD ELECTROSTATICS */
1129 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1130 ewrt = r31*ewtabscale;
1132 eweps = ewrt-ewitab;
1133 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1134 felec = qq31*rinv31*(rinvsq31-felec);
1138 /* Calculate temporary vectorial force */
1143 /* Update vectorial force */
1147 f[j_coord_offset+DIM*1+XX] -= tx;
1148 f[j_coord_offset+DIM*1+YY] -= ty;
1149 f[j_coord_offset+DIM*1+ZZ] -= tz;
1151 /**************************
1152 * CALCULATE INTERACTIONS *
1153 **************************/
1157 /* EWALD ELECTROSTATICS */
1159 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1160 ewrt = r32*ewtabscale;
1162 eweps = ewrt-ewitab;
1163 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1164 felec = qq32*rinv32*(rinvsq32-felec);
1168 /* Calculate temporary vectorial force */
1173 /* Update vectorial force */
1177 f[j_coord_offset+DIM*2+XX] -= tx;
1178 f[j_coord_offset+DIM*2+YY] -= ty;
1179 f[j_coord_offset+DIM*2+ZZ] -= tz;
1181 /**************************
1182 * CALCULATE INTERACTIONS *
1183 **************************/
1187 /* EWALD ELECTROSTATICS */
1189 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1190 ewrt = r33*ewtabscale;
1192 eweps = ewrt-ewitab;
1193 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
1194 felec = qq33*rinv33*(rinvsq33-felec);
1198 /* Calculate temporary vectorial force */
1203 /* Update vectorial force */
1207 f[j_coord_offset+DIM*3+XX] -= tx;
1208 f[j_coord_offset+DIM*3+YY] -= ty;
1209 f[j_coord_offset+DIM*3+ZZ] -= tz;
1211 /* Inner loop uses 355 flops */
1213 /* End of innermost loop */
1216 f[i_coord_offset+DIM*0+XX] += fix0;
1217 f[i_coord_offset+DIM*0+YY] += fiy0;
1218 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1222 f[i_coord_offset+DIM*1+XX] += fix1;
1223 f[i_coord_offset+DIM*1+YY] += fiy1;
1224 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1228 f[i_coord_offset+DIM*2+XX] += fix2;
1229 f[i_coord_offset+DIM*2+YY] += fiy2;
1230 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1234 f[i_coord_offset+DIM*3+XX] += fix3;
1235 f[i_coord_offset+DIM*3+YY] += fiy3;
1236 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1240 fshift[i_shift_offset+XX] += tx;
1241 fshift[i_shift_offset+YY] += ty;
1242 fshift[i_shift_offset+ZZ] += tz;
1244 /* Increment number of inner iterations */
1245 inneriter += j_index_end - j_index_start;
1247 /* Outer loop uses 39 flops */
1250 /* Increment number of outer iterations */
1253 /* Update outer/inner flops */
1255 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*355);