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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
103 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
121 vdwtype = mdatoms->typeA;
123 vftab = kernel_data->table_elec->data;
124 vftabscale = kernel_data->table_elec->scale;
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq1 = facel*charge[inr+1];
129 iq2 = facel*charge[inr+2];
130 iq3 = facel*charge[inr+3];
131 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
136 vdwjidx0 = 2*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
152 /* Start outer loop over neighborlists */
153 for(iidx=0; iidx<nri; iidx++)
155 /* Load shift vector for this list */
156 i_shift_offset = DIM*shiftidx[iidx];
157 shX = shiftvec[i_shift_offset+XX];
158 shY = shiftvec[i_shift_offset+YY];
159 shZ = shiftvec[i_shift_offset+ZZ];
161 /* Load limits for loop over neighbors */
162 j_index_start = jindex[iidx];
163 j_index_end = jindex[iidx+1];
165 /* Get outer coordinate index */
167 i_coord_offset = DIM*inr;
169 /* Load i particle coords and add shift vector */
170 ix0 = shX + x[i_coord_offset+DIM*0+XX];
171 iy0 = shY + x[i_coord_offset+DIM*0+YY];
172 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
173 ix1 = shX + x[i_coord_offset+DIM*1+XX];
174 iy1 = shY + x[i_coord_offset+DIM*1+YY];
175 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
176 ix2 = shX + x[i_coord_offset+DIM*2+XX];
177 iy2 = shY + x[i_coord_offset+DIM*2+YY];
178 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
179 ix3 = shX + x[i_coord_offset+DIM*3+XX];
180 iy3 = shY + x[i_coord_offset+DIM*3+YY];
181 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
196 /* Reset potential sums */
200 /* Start inner kernel loop */
201 for(jidx=j_index_start; jidx<j_index_end; jidx++)
203 /* Get j neighbor index, and coordinate index */
205 j_coord_offset = DIM*jnr;
207 /* load j atom coordinates */
208 jx0 = x[j_coord_offset+DIM*0+XX];
209 jy0 = x[j_coord_offset+DIM*0+YY];
210 jz0 = x[j_coord_offset+DIM*0+ZZ];
211 jx1 = x[j_coord_offset+DIM*1+XX];
212 jy1 = x[j_coord_offset+DIM*1+YY];
213 jz1 = x[j_coord_offset+DIM*1+ZZ];
214 jx2 = x[j_coord_offset+DIM*2+XX];
215 jy2 = x[j_coord_offset+DIM*2+YY];
216 jz2 = x[j_coord_offset+DIM*2+ZZ];
217 jx3 = x[j_coord_offset+DIM*3+XX];
218 jy3 = x[j_coord_offset+DIM*3+YY];
219 jz3 = x[j_coord_offset+DIM*3+ZZ];
221 /* Calculate displacement vector */
253 /* Calculate squared distance and things based on it */
254 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
255 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
256 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
257 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
258 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
259 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
260 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
261 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
262 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
263 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
265 rinv11 = gmx_invsqrt(rsq11);
266 rinv12 = gmx_invsqrt(rsq12);
267 rinv13 = gmx_invsqrt(rsq13);
268 rinv21 = gmx_invsqrt(rsq21);
269 rinv22 = gmx_invsqrt(rsq22);
270 rinv23 = gmx_invsqrt(rsq23);
271 rinv31 = gmx_invsqrt(rsq31);
272 rinv32 = gmx_invsqrt(rsq32);
273 rinv33 = gmx_invsqrt(rsq33);
275 rinvsq00 = 1.0/rsq00;
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
281 /* LENNARD-JONES DISPERSION/REPULSION */
283 rinvsix = rinvsq00*rinvsq00*rinvsq00;
284 vvdw6 = c6_00*rinvsix;
285 vvdw12 = c12_00*rinvsix*rinvsix;
286 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
287 fvdw = (vvdw12-vvdw6)*rinvsq00;
289 /* Update potential sums from outer loop */
294 /* Calculate temporary vectorial force */
299 /* Update vectorial force */
303 f[j_coord_offset+DIM*0+XX] -= tx;
304 f[j_coord_offset+DIM*0+YY] -= ty;
305 f[j_coord_offset+DIM*0+ZZ] -= tz;
307 /**************************
308 * CALCULATE INTERACTIONS *
309 **************************/
313 /* Calculate table index by multiplying r with table scale and truncate to integer */
319 /* CUBIC SPLINE TABLE ELECTROSTATICS */
322 Geps = vfeps*vftab[vfitab+2];
323 Heps2 = vfeps*vfeps*vftab[vfitab+3];
327 FF = Fp+Geps+2.0*Heps2;
328 felec = -qq11*FF*vftabscale*rinv11;
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 /* Calculate table index by multiplying r with table scale and truncate to integer */
360 /* CUBIC SPLINE TABLE ELECTROSTATICS */
363 Geps = vfeps*vftab[vfitab+2];
364 Heps2 = vfeps*vfeps*vftab[vfitab+3];
368 FF = Fp+Geps+2.0*Heps2;
369 felec = -qq12*FF*vftabscale*rinv12;
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;
389 /**************************
390 * CALCULATE INTERACTIONS *
391 **************************/
395 /* Calculate table index by multiplying r with table scale and truncate to integer */
401 /* CUBIC SPLINE TABLE ELECTROSTATICS */
404 Geps = vfeps*vftab[vfitab+2];
405 Heps2 = vfeps*vfeps*vftab[vfitab+3];
409 FF = Fp+Geps+2.0*Heps2;
410 felec = -qq13*FF*vftabscale*rinv13;
412 /* Update potential sums from outer loop */
417 /* Calculate temporary vectorial force */
422 /* Update vectorial force */
426 f[j_coord_offset+DIM*3+XX] -= tx;
427 f[j_coord_offset+DIM*3+YY] -= ty;
428 f[j_coord_offset+DIM*3+ZZ] -= tz;
430 /**************************
431 * CALCULATE INTERACTIONS *
432 **************************/
436 /* Calculate table index by multiplying r with table scale and truncate to integer */
442 /* CUBIC SPLINE TABLE ELECTROSTATICS */
445 Geps = vfeps*vftab[vfitab+2];
446 Heps2 = vfeps*vfeps*vftab[vfitab+3];
450 FF = Fp+Geps+2.0*Heps2;
451 felec = -qq21*FF*vftabscale*rinv21;
453 /* Update potential sums from outer loop */
458 /* Calculate temporary vectorial force */
463 /* Update vectorial force */
467 f[j_coord_offset+DIM*1+XX] -= tx;
468 f[j_coord_offset+DIM*1+YY] -= ty;
469 f[j_coord_offset+DIM*1+ZZ] -= tz;
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
477 /* Calculate table index by multiplying r with table scale and truncate to integer */
483 /* CUBIC SPLINE TABLE ELECTROSTATICS */
486 Geps = vfeps*vftab[vfitab+2];
487 Heps2 = vfeps*vfeps*vftab[vfitab+3];
491 FF = Fp+Geps+2.0*Heps2;
492 felec = -qq22*FF*vftabscale*rinv22;
494 /* Update potential sums from outer loop */
499 /* Calculate temporary vectorial force */
504 /* Update vectorial force */
508 f[j_coord_offset+DIM*2+XX] -= tx;
509 f[j_coord_offset+DIM*2+YY] -= ty;
510 f[j_coord_offset+DIM*2+ZZ] -= tz;
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
518 /* Calculate table index by multiplying r with table scale and truncate to integer */
524 /* CUBIC SPLINE TABLE ELECTROSTATICS */
527 Geps = vfeps*vftab[vfitab+2];
528 Heps2 = vfeps*vfeps*vftab[vfitab+3];
532 FF = Fp+Geps+2.0*Heps2;
533 felec = -qq23*FF*vftabscale*rinv23;
535 /* Update potential sums from outer loop */
540 /* Calculate temporary vectorial force */
545 /* Update vectorial force */
549 f[j_coord_offset+DIM*3+XX] -= tx;
550 f[j_coord_offset+DIM*3+YY] -= ty;
551 f[j_coord_offset+DIM*3+ZZ] -= tz;
553 /**************************
554 * CALCULATE INTERACTIONS *
555 **************************/
559 /* Calculate table index by multiplying r with table scale and truncate to integer */
565 /* CUBIC SPLINE TABLE ELECTROSTATICS */
568 Geps = vfeps*vftab[vfitab+2];
569 Heps2 = vfeps*vfeps*vftab[vfitab+3];
573 FF = Fp+Geps+2.0*Heps2;
574 felec = -qq31*FF*vftabscale*rinv31;
576 /* Update potential sums from outer loop */
581 /* Calculate temporary vectorial force */
586 /* Update vectorial force */
590 f[j_coord_offset+DIM*1+XX] -= tx;
591 f[j_coord_offset+DIM*1+YY] -= ty;
592 f[j_coord_offset+DIM*1+ZZ] -= tz;
594 /**************************
595 * CALCULATE INTERACTIONS *
596 **************************/
600 /* Calculate table index by multiplying r with table scale and truncate to integer */
606 /* CUBIC SPLINE TABLE ELECTROSTATICS */
609 Geps = vfeps*vftab[vfitab+2];
610 Heps2 = vfeps*vfeps*vftab[vfitab+3];
614 FF = Fp+Geps+2.0*Heps2;
615 felec = -qq32*FF*vftabscale*rinv32;
617 /* Update potential sums from outer loop */
622 /* Calculate temporary vectorial force */
627 /* Update vectorial force */
631 f[j_coord_offset+DIM*2+XX] -= tx;
632 f[j_coord_offset+DIM*2+YY] -= ty;
633 f[j_coord_offset+DIM*2+ZZ] -= tz;
635 /**************************
636 * CALCULATE INTERACTIONS *
637 **************************/
641 /* Calculate table index by multiplying r with table scale and truncate to integer */
647 /* CUBIC SPLINE TABLE ELECTROSTATICS */
650 Geps = vfeps*vftab[vfitab+2];
651 Heps2 = vfeps*vfeps*vftab[vfitab+3];
655 FF = Fp+Geps+2.0*Heps2;
656 felec = -qq33*FF*vftabscale*rinv33;
658 /* Update potential sums from outer loop */
663 /* Calculate temporary vectorial force */
668 /* Update vectorial force */
672 f[j_coord_offset+DIM*3+XX] -= tx;
673 f[j_coord_offset+DIM*3+YY] -= ty;
674 f[j_coord_offset+DIM*3+ZZ] -= tz;
676 /* Inner loop uses 401 flops */
678 /* End of innermost loop */
681 f[i_coord_offset+DIM*0+XX] += fix0;
682 f[i_coord_offset+DIM*0+YY] += fiy0;
683 f[i_coord_offset+DIM*0+ZZ] += fiz0;
687 f[i_coord_offset+DIM*1+XX] += fix1;
688 f[i_coord_offset+DIM*1+YY] += fiy1;
689 f[i_coord_offset+DIM*1+ZZ] += fiz1;
693 f[i_coord_offset+DIM*2+XX] += fix2;
694 f[i_coord_offset+DIM*2+YY] += fiy2;
695 f[i_coord_offset+DIM*2+ZZ] += fiz2;
699 f[i_coord_offset+DIM*3+XX] += fix3;
700 f[i_coord_offset+DIM*3+YY] += fiy3;
701 f[i_coord_offset+DIM*3+ZZ] += fiz3;
705 fshift[i_shift_offset+XX] += tx;
706 fshift[i_shift_offset+YY] += ty;
707 fshift[i_shift_offset+ZZ] += tz;
710 /* Update potential energies */
711 kernel_data->energygrp_elec[ggid] += velecsum;
712 kernel_data->energygrp_vdw[ggid] += vvdwsum;
714 /* Increment number of inner iterations */
715 inneriter += j_index_end - j_index_start;
717 /* Outer loop uses 41 flops */
720 /* Increment number of outer iterations */
723 /* Update outer/inner flops */
725 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*401);
728 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_F_c
729 * Electrostatics interaction: CubicSplineTable
730 * VdW interaction: LennardJones
731 * Geometry: Water4-Water4
732 * Calculate force/pot: Force
735 nb_kernel_ElecCSTab_VdwLJ_GeomW4W4_F_c
736 (t_nblist * gmx_restrict nlist,
737 rvec * gmx_restrict xx,
738 rvec * gmx_restrict ff,
739 t_forcerec * gmx_restrict fr,
740 t_mdatoms * gmx_restrict mdatoms,
741 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
742 t_nrnb * gmx_restrict nrnb)
744 int i_shift_offset,i_coord_offset,j_coord_offset;
745 int j_index_start,j_index_end;
746 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
747 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
748 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
749 real *shiftvec,*fshift,*x,*f;
751 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
753 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
755 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
757 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
759 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
761 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
763 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
765 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
766 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
767 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
768 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
769 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
770 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
771 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
772 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
773 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
774 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
775 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
776 real velec,felec,velecsum,facel,crf,krf,krf2;
779 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
783 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
791 jindex = nlist->jindex;
793 shiftidx = nlist->shift;
795 shiftvec = fr->shift_vec[0];
796 fshift = fr->fshift[0];
798 charge = mdatoms->chargeA;
799 nvdwtype = fr->ntype;
801 vdwtype = mdatoms->typeA;
803 vftab = kernel_data->table_elec->data;
804 vftabscale = kernel_data->table_elec->scale;
806 /* Setup water-specific parameters */
807 inr = nlist->iinr[0];
808 iq1 = facel*charge[inr+1];
809 iq2 = facel*charge[inr+2];
810 iq3 = facel*charge[inr+3];
811 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
816 vdwjidx0 = 2*vdwtype[inr+0];
817 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
818 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
832 /* Start outer loop over neighborlists */
833 for(iidx=0; iidx<nri; iidx++)
835 /* Load shift vector for this list */
836 i_shift_offset = DIM*shiftidx[iidx];
837 shX = shiftvec[i_shift_offset+XX];
838 shY = shiftvec[i_shift_offset+YY];
839 shZ = shiftvec[i_shift_offset+ZZ];
841 /* Load limits for loop over neighbors */
842 j_index_start = jindex[iidx];
843 j_index_end = jindex[iidx+1];
845 /* Get outer coordinate index */
847 i_coord_offset = DIM*inr;
849 /* Load i particle coords and add shift vector */
850 ix0 = shX + x[i_coord_offset+DIM*0+XX];
851 iy0 = shY + x[i_coord_offset+DIM*0+YY];
852 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
853 ix1 = shX + x[i_coord_offset+DIM*1+XX];
854 iy1 = shY + x[i_coord_offset+DIM*1+YY];
855 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
856 ix2 = shX + x[i_coord_offset+DIM*2+XX];
857 iy2 = shY + x[i_coord_offset+DIM*2+YY];
858 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
859 ix3 = shX + x[i_coord_offset+DIM*3+XX];
860 iy3 = shY + x[i_coord_offset+DIM*3+YY];
861 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
876 /* Start inner kernel loop */
877 for(jidx=j_index_start; jidx<j_index_end; jidx++)
879 /* Get j neighbor index, and coordinate index */
881 j_coord_offset = DIM*jnr;
883 /* load j atom coordinates */
884 jx0 = x[j_coord_offset+DIM*0+XX];
885 jy0 = x[j_coord_offset+DIM*0+YY];
886 jz0 = x[j_coord_offset+DIM*0+ZZ];
887 jx1 = x[j_coord_offset+DIM*1+XX];
888 jy1 = x[j_coord_offset+DIM*1+YY];
889 jz1 = x[j_coord_offset+DIM*1+ZZ];
890 jx2 = x[j_coord_offset+DIM*2+XX];
891 jy2 = x[j_coord_offset+DIM*2+YY];
892 jz2 = x[j_coord_offset+DIM*2+ZZ];
893 jx3 = x[j_coord_offset+DIM*3+XX];
894 jy3 = x[j_coord_offset+DIM*3+YY];
895 jz3 = x[j_coord_offset+DIM*3+ZZ];
897 /* Calculate displacement vector */
929 /* Calculate squared distance and things based on it */
930 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
931 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
932 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
933 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
934 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
935 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
936 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
937 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
938 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
939 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
941 rinv11 = gmx_invsqrt(rsq11);
942 rinv12 = gmx_invsqrt(rsq12);
943 rinv13 = gmx_invsqrt(rsq13);
944 rinv21 = gmx_invsqrt(rsq21);
945 rinv22 = gmx_invsqrt(rsq22);
946 rinv23 = gmx_invsqrt(rsq23);
947 rinv31 = gmx_invsqrt(rsq31);
948 rinv32 = gmx_invsqrt(rsq32);
949 rinv33 = gmx_invsqrt(rsq33);
951 rinvsq00 = 1.0/rsq00;
953 /**************************
954 * CALCULATE INTERACTIONS *
955 **************************/
957 /* LENNARD-JONES DISPERSION/REPULSION */
959 rinvsix = rinvsq00*rinvsq00*rinvsq00;
960 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
964 /* Calculate temporary vectorial force */
969 /* Update vectorial force */
973 f[j_coord_offset+DIM*0+XX] -= tx;
974 f[j_coord_offset+DIM*0+YY] -= ty;
975 f[j_coord_offset+DIM*0+ZZ] -= tz;
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
983 /* Calculate table index by multiplying r with table scale and truncate to integer */
989 /* CUBIC SPLINE TABLE ELECTROSTATICS */
991 Geps = vfeps*vftab[vfitab+2];
992 Heps2 = vfeps*vfeps*vftab[vfitab+3];
994 FF = Fp+Geps+2.0*Heps2;
995 felec = -qq11*FF*vftabscale*rinv11;
999 /* Calculate temporary vectorial force */
1004 /* Update vectorial force */
1008 f[j_coord_offset+DIM*1+XX] -= tx;
1009 f[j_coord_offset+DIM*1+YY] -= ty;
1010 f[j_coord_offset+DIM*1+ZZ] -= tz;
1012 /**************************
1013 * CALCULATE INTERACTIONS *
1014 **************************/
1018 /* Calculate table index by multiplying r with table scale and truncate to integer */
1019 rt = r12*vftabscale;
1022 vfitab = 1*4*vfitab;
1024 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1025 F = vftab[vfitab+1];
1026 Geps = vfeps*vftab[vfitab+2];
1027 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1029 FF = Fp+Geps+2.0*Heps2;
1030 felec = -qq12*FF*vftabscale*rinv12;
1034 /* Calculate temporary vectorial force */
1039 /* Update vectorial force */
1043 f[j_coord_offset+DIM*2+XX] -= tx;
1044 f[j_coord_offset+DIM*2+YY] -= ty;
1045 f[j_coord_offset+DIM*2+ZZ] -= tz;
1047 /**************************
1048 * CALCULATE INTERACTIONS *
1049 **************************/
1053 /* Calculate table index by multiplying r with table scale and truncate to integer */
1054 rt = r13*vftabscale;
1057 vfitab = 1*4*vfitab;
1059 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1060 F = vftab[vfitab+1];
1061 Geps = vfeps*vftab[vfitab+2];
1062 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1064 FF = Fp+Geps+2.0*Heps2;
1065 felec = -qq13*FF*vftabscale*rinv13;
1069 /* Calculate temporary vectorial force */
1074 /* Update vectorial force */
1078 f[j_coord_offset+DIM*3+XX] -= tx;
1079 f[j_coord_offset+DIM*3+YY] -= ty;
1080 f[j_coord_offset+DIM*3+ZZ] -= tz;
1082 /**************************
1083 * CALCULATE INTERACTIONS *
1084 **************************/
1088 /* Calculate table index by multiplying r with table scale and truncate to integer */
1089 rt = r21*vftabscale;
1092 vfitab = 1*4*vfitab;
1094 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1095 F = vftab[vfitab+1];
1096 Geps = vfeps*vftab[vfitab+2];
1097 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1099 FF = Fp+Geps+2.0*Heps2;
1100 felec = -qq21*FF*vftabscale*rinv21;
1104 /* Calculate temporary vectorial force */
1109 /* Update vectorial force */
1113 f[j_coord_offset+DIM*1+XX] -= tx;
1114 f[j_coord_offset+DIM*1+YY] -= ty;
1115 f[j_coord_offset+DIM*1+ZZ] -= tz;
1117 /**************************
1118 * CALCULATE INTERACTIONS *
1119 **************************/
1123 /* Calculate table index by multiplying r with table scale and truncate to integer */
1124 rt = r22*vftabscale;
1127 vfitab = 1*4*vfitab;
1129 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1130 F = vftab[vfitab+1];
1131 Geps = vfeps*vftab[vfitab+2];
1132 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1134 FF = Fp+Geps+2.0*Heps2;
1135 felec = -qq22*FF*vftabscale*rinv22;
1139 /* Calculate temporary vectorial force */
1144 /* Update vectorial force */
1148 f[j_coord_offset+DIM*2+XX] -= tx;
1149 f[j_coord_offset+DIM*2+YY] -= ty;
1150 f[j_coord_offset+DIM*2+ZZ] -= tz;
1152 /**************************
1153 * CALCULATE INTERACTIONS *
1154 **************************/
1158 /* Calculate table index by multiplying r with table scale and truncate to integer */
1159 rt = r23*vftabscale;
1162 vfitab = 1*4*vfitab;
1164 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1165 F = vftab[vfitab+1];
1166 Geps = vfeps*vftab[vfitab+2];
1167 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1169 FF = Fp+Geps+2.0*Heps2;
1170 felec = -qq23*FF*vftabscale*rinv23;
1174 /* Calculate temporary vectorial force */
1179 /* Update vectorial force */
1183 f[j_coord_offset+DIM*3+XX] -= tx;
1184 f[j_coord_offset+DIM*3+YY] -= ty;
1185 f[j_coord_offset+DIM*3+ZZ] -= tz;
1187 /**************************
1188 * CALCULATE INTERACTIONS *
1189 **************************/
1193 /* Calculate table index by multiplying r with table scale and truncate to integer */
1194 rt = r31*vftabscale;
1197 vfitab = 1*4*vfitab;
1199 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1200 F = vftab[vfitab+1];
1201 Geps = vfeps*vftab[vfitab+2];
1202 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1204 FF = Fp+Geps+2.0*Heps2;
1205 felec = -qq31*FF*vftabscale*rinv31;
1209 /* Calculate temporary vectorial force */
1214 /* Update vectorial force */
1218 f[j_coord_offset+DIM*1+XX] -= tx;
1219 f[j_coord_offset+DIM*1+YY] -= ty;
1220 f[j_coord_offset+DIM*1+ZZ] -= tz;
1222 /**************************
1223 * CALCULATE INTERACTIONS *
1224 **************************/
1228 /* Calculate table index by multiplying r with table scale and truncate to integer */
1229 rt = r32*vftabscale;
1232 vfitab = 1*4*vfitab;
1234 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1235 F = vftab[vfitab+1];
1236 Geps = vfeps*vftab[vfitab+2];
1237 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1239 FF = Fp+Geps+2.0*Heps2;
1240 felec = -qq32*FF*vftabscale*rinv32;
1244 /* Calculate temporary vectorial force */
1249 /* Update vectorial force */
1253 f[j_coord_offset+DIM*2+XX] -= tx;
1254 f[j_coord_offset+DIM*2+YY] -= ty;
1255 f[j_coord_offset+DIM*2+ZZ] -= tz;
1257 /**************************
1258 * CALCULATE INTERACTIONS *
1259 **************************/
1263 /* Calculate table index by multiplying r with table scale and truncate to integer */
1264 rt = r33*vftabscale;
1267 vfitab = 1*4*vfitab;
1269 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1270 F = vftab[vfitab+1];
1271 Geps = vfeps*vftab[vfitab+2];
1272 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1274 FF = Fp+Geps+2.0*Heps2;
1275 felec = -qq33*FF*vftabscale*rinv33;
1279 /* Calculate temporary vectorial force */
1284 /* Update vectorial force */
1288 f[j_coord_offset+DIM*3+XX] -= tx;
1289 f[j_coord_offset+DIM*3+YY] -= ty;
1290 f[j_coord_offset+DIM*3+ZZ] -= tz;
1292 /* Inner loop uses 360 flops */
1294 /* End of innermost loop */
1297 f[i_coord_offset+DIM*0+XX] += fix0;
1298 f[i_coord_offset+DIM*0+YY] += fiy0;
1299 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1303 f[i_coord_offset+DIM*1+XX] += fix1;
1304 f[i_coord_offset+DIM*1+YY] += fiy1;
1305 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1309 f[i_coord_offset+DIM*2+XX] += fix2;
1310 f[i_coord_offset+DIM*2+YY] += fiy2;
1311 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1315 f[i_coord_offset+DIM*3+XX] += fix3;
1316 f[i_coord_offset+DIM*3+YY] += fiy3;
1317 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1321 fshift[i_shift_offset+XX] += tx;
1322 fshift[i_shift_offset+YY] += ty;
1323 fshift[i_shift_offset+ZZ] += tz;
1325 /* Increment number of inner iterations */
1326 inneriter += j_index_end - j_index_start;
1328 /* Outer loop uses 39 flops */
1331 /* Increment number of outer iterations */
1334 /* Update outer/inner flops */
1336 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*360);