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_ElecRFCut_VdwLJSw_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwLJSw_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;
88 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
95 jindex = nlist->jindex;
97 shiftidx = nlist->shift;
99 shiftvec = fr->shift_vec[0];
100 fshift = fr->fshift[0];
102 charge = mdatoms->chargeA;
106 nvdwtype = fr->ntype;
108 vdwtype = mdatoms->typeA;
110 /* Setup water-specific parameters */
111 inr = nlist->iinr[0];
112 iq1 = facel*charge[inr+1];
113 iq2 = facel*charge[inr+2];
114 iq3 = facel*charge[inr+3];
115 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
120 vdwjidx0 = 2*vdwtype[inr+0];
121 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
122 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
133 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
134 rcutoff = fr->rcoulomb;
135 rcutoff2 = rcutoff*rcutoff;
137 rswitch = fr->rvdw_switch;
138 /* Setup switch parameters */
140 swV3 = -10.0/(d*d*d);
141 swV4 = 15.0/(d*d*d*d);
142 swV5 = -6.0/(d*d*d*d*d);
143 swF2 = -30.0/(d*d*d);
144 swF3 = 60.0/(d*d*d*d);
145 swF4 = -30.0/(d*d*d*d*d);
150 /* Start outer loop over neighborlists */
151 for(iidx=0; iidx<nri; iidx++)
153 /* Load shift vector for this list */
154 i_shift_offset = DIM*shiftidx[iidx];
155 shX = shiftvec[i_shift_offset+XX];
156 shY = shiftvec[i_shift_offset+YY];
157 shZ = shiftvec[i_shift_offset+ZZ];
159 /* Load limits for loop over neighbors */
160 j_index_start = jindex[iidx];
161 j_index_end = jindex[iidx+1];
163 /* Get outer coordinate index */
165 i_coord_offset = DIM*inr;
167 /* Load i particle coords and add shift vector */
168 ix0 = shX + x[i_coord_offset+DIM*0+XX];
169 iy0 = shY + x[i_coord_offset+DIM*0+YY];
170 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
171 ix1 = shX + x[i_coord_offset+DIM*1+XX];
172 iy1 = shY + x[i_coord_offset+DIM*1+YY];
173 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
174 ix2 = shX + x[i_coord_offset+DIM*2+XX];
175 iy2 = shY + x[i_coord_offset+DIM*2+YY];
176 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
177 ix3 = shX + x[i_coord_offset+DIM*3+XX];
178 iy3 = shY + x[i_coord_offset+DIM*3+YY];
179 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
194 /* Reset potential sums */
198 /* Start inner kernel loop */
199 for(jidx=j_index_start; jidx<j_index_end; jidx++)
201 /* Get j neighbor index, and coordinate index */
203 j_coord_offset = DIM*jnr;
205 /* load j atom coordinates */
206 jx0 = x[j_coord_offset+DIM*0+XX];
207 jy0 = x[j_coord_offset+DIM*0+YY];
208 jz0 = x[j_coord_offset+DIM*0+ZZ];
209 jx1 = x[j_coord_offset+DIM*1+XX];
210 jy1 = x[j_coord_offset+DIM*1+YY];
211 jz1 = x[j_coord_offset+DIM*1+ZZ];
212 jx2 = x[j_coord_offset+DIM*2+XX];
213 jy2 = x[j_coord_offset+DIM*2+YY];
214 jz2 = x[j_coord_offset+DIM*2+ZZ];
215 jx3 = x[j_coord_offset+DIM*3+XX];
216 jy3 = x[j_coord_offset+DIM*3+YY];
217 jz3 = x[j_coord_offset+DIM*3+ZZ];
219 /* Calculate displacement vector */
251 /* Calculate squared distance and things based on it */
252 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
253 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
254 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
255 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
256 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
257 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
258 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
259 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
260 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
261 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
263 rinv00 = gmx_invsqrt(rsq00);
264 rinv11 = gmx_invsqrt(rsq11);
265 rinv12 = gmx_invsqrt(rsq12);
266 rinv13 = gmx_invsqrt(rsq13);
267 rinv21 = gmx_invsqrt(rsq21);
268 rinv22 = gmx_invsqrt(rsq22);
269 rinv23 = gmx_invsqrt(rsq23);
270 rinv31 = gmx_invsqrt(rsq31);
271 rinv32 = gmx_invsqrt(rsq32);
272 rinv33 = gmx_invsqrt(rsq33);
274 rinvsq00 = rinv00*rinv00;
275 rinvsq11 = rinv11*rinv11;
276 rinvsq12 = rinv12*rinv12;
277 rinvsq13 = rinv13*rinv13;
278 rinvsq21 = rinv21*rinv21;
279 rinvsq22 = rinv22*rinv22;
280 rinvsq23 = rinv23*rinv23;
281 rinvsq31 = rinv31*rinv31;
282 rinvsq32 = rinv32*rinv32;
283 rinvsq33 = rinv33*rinv33;
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
294 /* LENNARD-JONES DISPERSION/REPULSION */
296 rinvsix = rinvsq00*rinvsq00*rinvsq00;
297 vvdw6 = c6_00*rinvsix;
298 vvdw12 = c12_00*rinvsix*rinvsix;
299 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
300 fvdw = (vvdw12-vvdw6)*rinvsq00;
303 d = (d>0.0) ? d : 0.0;
305 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
307 dsw = d2*(swF2+d*(swF3+d*swF4));
309 /* Evaluate switch function */
310 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
311 fvdw = fvdw*sw - rinv00*vvdw*dsw;
314 /* Update potential sums from outer loop */
319 /* Calculate temporary vectorial force */
324 /* Update vectorial force */
328 f[j_coord_offset+DIM*0+XX] -= tx;
329 f[j_coord_offset+DIM*0+YY] -= ty;
330 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
341 /* REACTION-FIELD ELECTROSTATICS */
342 velec = qq11*(rinv11+krf*rsq11-crf);
343 felec = qq11*(rinv11*rinvsq11-krf2);
345 /* Update potential sums from outer loop */
350 /* Calculate temporary vectorial force */
355 /* Update vectorial force */
359 f[j_coord_offset+DIM*1+XX] -= tx;
360 f[j_coord_offset+DIM*1+YY] -= ty;
361 f[j_coord_offset+DIM*1+ZZ] -= tz;
365 /**************************
366 * CALCULATE INTERACTIONS *
367 **************************/
372 /* REACTION-FIELD ELECTROSTATICS */
373 velec = qq12*(rinv12+krf*rsq12-crf);
374 felec = qq12*(rinv12*rinvsq12-krf2);
376 /* Update potential sums from outer loop */
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*2+XX] -= tx;
391 f[j_coord_offset+DIM*2+YY] -= ty;
392 f[j_coord_offset+DIM*2+ZZ] -= tz;
396 /**************************
397 * CALCULATE INTERACTIONS *
398 **************************/
403 /* REACTION-FIELD ELECTROSTATICS */
404 velec = qq13*(rinv13+krf*rsq13-crf);
405 felec = qq13*(rinv13*rinvsq13-krf2);
407 /* Update potential sums from outer loop */
412 /* Calculate temporary vectorial force */
417 /* Update vectorial force */
421 f[j_coord_offset+DIM*3+XX] -= tx;
422 f[j_coord_offset+DIM*3+YY] -= ty;
423 f[j_coord_offset+DIM*3+ZZ] -= tz;
427 /**************************
428 * CALCULATE INTERACTIONS *
429 **************************/
434 /* REACTION-FIELD ELECTROSTATICS */
435 velec = qq21*(rinv21+krf*rsq21-crf);
436 felec = qq21*(rinv21*rinvsq21-krf2);
438 /* Update potential sums from outer loop */
443 /* Calculate temporary vectorial force */
448 /* Update vectorial force */
452 f[j_coord_offset+DIM*1+XX] -= tx;
453 f[j_coord_offset+DIM*1+YY] -= ty;
454 f[j_coord_offset+DIM*1+ZZ] -= tz;
458 /**************************
459 * CALCULATE INTERACTIONS *
460 **************************/
465 /* REACTION-FIELD ELECTROSTATICS */
466 velec = qq22*(rinv22+krf*rsq22-crf);
467 felec = qq22*(rinv22*rinvsq22-krf2);
469 /* Update potential sums from outer loop */
474 /* Calculate temporary vectorial force */
479 /* Update vectorial force */
483 f[j_coord_offset+DIM*2+XX] -= tx;
484 f[j_coord_offset+DIM*2+YY] -= ty;
485 f[j_coord_offset+DIM*2+ZZ] -= tz;
489 /**************************
490 * CALCULATE INTERACTIONS *
491 **************************/
496 /* REACTION-FIELD ELECTROSTATICS */
497 velec = qq23*(rinv23+krf*rsq23-crf);
498 felec = qq23*(rinv23*rinvsq23-krf2);
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;
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
527 /* REACTION-FIELD ELECTROSTATICS */
528 velec = qq31*(rinv31+krf*rsq31-crf);
529 felec = qq31*(rinv31*rinvsq31-krf2);
531 /* Update potential sums from outer loop */
536 /* Calculate temporary vectorial force */
541 /* Update vectorial force */
545 f[j_coord_offset+DIM*1+XX] -= tx;
546 f[j_coord_offset+DIM*1+YY] -= ty;
547 f[j_coord_offset+DIM*1+ZZ] -= tz;
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
558 /* REACTION-FIELD ELECTROSTATICS */
559 velec = qq32*(rinv32+krf*rsq32-crf);
560 felec = qq32*(rinv32*rinvsq32-krf2);
562 /* Update potential sums from outer loop */
567 /* Calculate temporary vectorial force */
572 /* Update vectorial force */
576 f[j_coord_offset+DIM*2+XX] -= tx;
577 f[j_coord_offset+DIM*2+YY] -= ty;
578 f[j_coord_offset+DIM*2+ZZ] -= tz;
582 /**************************
583 * CALCULATE INTERACTIONS *
584 **************************/
589 /* REACTION-FIELD ELECTROSTATICS */
590 velec = qq33*(rinv33+krf*rsq33-crf);
591 felec = qq33*(rinv33*rinvsq33-krf2);
593 /* Update potential sums from outer loop */
598 /* Calculate temporary vectorial force */
603 /* Update vectorial force */
607 f[j_coord_offset+DIM*3+XX] -= tx;
608 f[j_coord_offset+DIM*3+YY] -= ty;
609 f[j_coord_offset+DIM*3+ZZ] -= tz;
613 /* Inner loop uses 332 flops */
615 /* End of innermost loop */
618 f[i_coord_offset+DIM*0+XX] += fix0;
619 f[i_coord_offset+DIM*0+YY] += fiy0;
620 f[i_coord_offset+DIM*0+ZZ] += fiz0;
624 f[i_coord_offset+DIM*1+XX] += fix1;
625 f[i_coord_offset+DIM*1+YY] += fiy1;
626 f[i_coord_offset+DIM*1+ZZ] += fiz1;
630 f[i_coord_offset+DIM*2+XX] += fix2;
631 f[i_coord_offset+DIM*2+YY] += fiy2;
632 f[i_coord_offset+DIM*2+ZZ] += fiz2;
636 f[i_coord_offset+DIM*3+XX] += fix3;
637 f[i_coord_offset+DIM*3+YY] += fiy3;
638 f[i_coord_offset+DIM*3+ZZ] += fiz3;
642 fshift[i_shift_offset+XX] += tx;
643 fshift[i_shift_offset+YY] += ty;
644 fshift[i_shift_offset+ZZ] += tz;
647 /* Update potential energies */
648 kernel_data->energygrp_elec[ggid] += velecsum;
649 kernel_data->energygrp_vdw[ggid] += vvdwsum;
651 /* Increment number of inner iterations */
652 inneriter += j_index_end - j_index_start;
654 /* Outer loop uses 41 flops */
657 /* Increment number of outer iterations */
660 /* Update outer/inner flops */
662 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*332);
665 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4W4_F_c
666 * Electrostatics interaction: ReactionField
667 * VdW interaction: LennardJones
668 * Geometry: Water4-Water4
669 * Calculate force/pot: Force
672 nb_kernel_ElecRFCut_VdwLJSw_GeomW4W4_F_c
673 (t_nblist * gmx_restrict nlist,
674 rvec * gmx_restrict xx,
675 rvec * gmx_restrict ff,
676 t_forcerec * gmx_restrict fr,
677 t_mdatoms * gmx_restrict mdatoms,
678 nb_kernel_data_t * gmx_restrict kernel_data,
679 t_nrnb * gmx_restrict nrnb)
681 int i_shift_offset,i_coord_offset,j_coord_offset;
682 int j_index_start,j_index_end;
683 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
684 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
685 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
686 real *shiftvec,*fshift,*x,*f;
688 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
690 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
692 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
694 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
696 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
698 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
700 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
702 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
703 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
704 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
705 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
706 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
707 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
708 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
709 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
710 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
711 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
712 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
713 real velec,felec,velecsum,facel,crf,krf,krf2;
716 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
719 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
726 jindex = nlist->jindex;
728 shiftidx = nlist->shift;
730 shiftvec = fr->shift_vec[0];
731 fshift = fr->fshift[0];
733 charge = mdatoms->chargeA;
737 nvdwtype = fr->ntype;
739 vdwtype = mdatoms->typeA;
741 /* Setup water-specific parameters */
742 inr = nlist->iinr[0];
743 iq1 = facel*charge[inr+1];
744 iq2 = facel*charge[inr+2];
745 iq3 = facel*charge[inr+3];
746 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
751 vdwjidx0 = 2*vdwtype[inr+0];
752 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
753 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
764 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
765 rcutoff = fr->rcoulomb;
766 rcutoff2 = rcutoff*rcutoff;
768 rswitch = fr->rvdw_switch;
769 /* Setup switch parameters */
771 swV3 = -10.0/(d*d*d);
772 swV4 = 15.0/(d*d*d*d);
773 swV5 = -6.0/(d*d*d*d*d);
774 swF2 = -30.0/(d*d*d);
775 swF3 = 60.0/(d*d*d*d);
776 swF4 = -30.0/(d*d*d*d*d);
781 /* Start outer loop over neighborlists */
782 for(iidx=0; iidx<nri; iidx++)
784 /* Load shift vector for this list */
785 i_shift_offset = DIM*shiftidx[iidx];
786 shX = shiftvec[i_shift_offset+XX];
787 shY = shiftvec[i_shift_offset+YY];
788 shZ = shiftvec[i_shift_offset+ZZ];
790 /* Load limits for loop over neighbors */
791 j_index_start = jindex[iidx];
792 j_index_end = jindex[iidx+1];
794 /* Get outer coordinate index */
796 i_coord_offset = DIM*inr;
798 /* Load i particle coords and add shift vector */
799 ix0 = shX + x[i_coord_offset+DIM*0+XX];
800 iy0 = shY + x[i_coord_offset+DIM*0+YY];
801 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
802 ix1 = shX + x[i_coord_offset+DIM*1+XX];
803 iy1 = shY + x[i_coord_offset+DIM*1+YY];
804 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
805 ix2 = shX + x[i_coord_offset+DIM*2+XX];
806 iy2 = shY + x[i_coord_offset+DIM*2+YY];
807 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
808 ix3 = shX + x[i_coord_offset+DIM*3+XX];
809 iy3 = shY + x[i_coord_offset+DIM*3+YY];
810 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
825 /* Start inner kernel loop */
826 for(jidx=j_index_start; jidx<j_index_end; jidx++)
828 /* Get j neighbor index, and coordinate index */
830 j_coord_offset = DIM*jnr;
832 /* load j atom coordinates */
833 jx0 = x[j_coord_offset+DIM*0+XX];
834 jy0 = x[j_coord_offset+DIM*0+YY];
835 jz0 = x[j_coord_offset+DIM*0+ZZ];
836 jx1 = x[j_coord_offset+DIM*1+XX];
837 jy1 = x[j_coord_offset+DIM*1+YY];
838 jz1 = x[j_coord_offset+DIM*1+ZZ];
839 jx2 = x[j_coord_offset+DIM*2+XX];
840 jy2 = x[j_coord_offset+DIM*2+YY];
841 jz2 = x[j_coord_offset+DIM*2+ZZ];
842 jx3 = x[j_coord_offset+DIM*3+XX];
843 jy3 = x[j_coord_offset+DIM*3+YY];
844 jz3 = x[j_coord_offset+DIM*3+ZZ];
846 /* Calculate displacement vector */
878 /* Calculate squared distance and things based on it */
879 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
880 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
881 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
882 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
883 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
884 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
885 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
886 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
887 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
888 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
890 rinv00 = gmx_invsqrt(rsq00);
891 rinv11 = gmx_invsqrt(rsq11);
892 rinv12 = gmx_invsqrt(rsq12);
893 rinv13 = gmx_invsqrt(rsq13);
894 rinv21 = gmx_invsqrt(rsq21);
895 rinv22 = gmx_invsqrt(rsq22);
896 rinv23 = gmx_invsqrt(rsq23);
897 rinv31 = gmx_invsqrt(rsq31);
898 rinv32 = gmx_invsqrt(rsq32);
899 rinv33 = gmx_invsqrt(rsq33);
901 rinvsq00 = rinv00*rinv00;
902 rinvsq11 = rinv11*rinv11;
903 rinvsq12 = rinv12*rinv12;
904 rinvsq13 = rinv13*rinv13;
905 rinvsq21 = rinv21*rinv21;
906 rinvsq22 = rinv22*rinv22;
907 rinvsq23 = rinv23*rinv23;
908 rinvsq31 = rinv31*rinv31;
909 rinvsq32 = rinv32*rinv32;
910 rinvsq33 = rinv33*rinv33;
912 /**************************
913 * CALCULATE INTERACTIONS *
914 **************************/
921 /* LENNARD-JONES DISPERSION/REPULSION */
923 rinvsix = rinvsq00*rinvsq00*rinvsq00;
924 vvdw6 = c6_00*rinvsix;
925 vvdw12 = c12_00*rinvsix*rinvsix;
926 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
927 fvdw = (vvdw12-vvdw6)*rinvsq00;
930 d = (d>0.0) ? d : 0.0;
932 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
934 dsw = d2*(swF2+d*(swF3+d*swF4));
936 /* Evaluate switch function */
937 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
938 fvdw = fvdw*sw - rinv00*vvdw*dsw;
942 /* Calculate temporary vectorial force */
947 /* Update vectorial force */
951 f[j_coord_offset+DIM*0+XX] -= tx;
952 f[j_coord_offset+DIM*0+YY] -= ty;
953 f[j_coord_offset+DIM*0+ZZ] -= tz;
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
964 /* REACTION-FIELD ELECTROSTATICS */
965 felec = qq11*(rinv11*rinvsq11-krf2);
969 /* Calculate temporary vectorial force */
974 /* Update vectorial force */
978 f[j_coord_offset+DIM*1+XX] -= tx;
979 f[j_coord_offset+DIM*1+YY] -= ty;
980 f[j_coord_offset+DIM*1+ZZ] -= tz;
984 /**************************
985 * CALCULATE INTERACTIONS *
986 **************************/
991 /* REACTION-FIELD ELECTROSTATICS */
992 felec = qq12*(rinv12*rinvsq12-krf2);
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 **************************/
1018 /* REACTION-FIELD ELECTROSTATICS */
1019 felec = qq13*(rinv13*rinvsq13-krf2);
1023 /* Calculate temporary vectorial force */
1028 /* Update vectorial force */
1032 f[j_coord_offset+DIM*3+XX] -= tx;
1033 f[j_coord_offset+DIM*3+YY] -= ty;
1034 f[j_coord_offset+DIM*3+ZZ] -= tz;
1038 /**************************
1039 * CALCULATE INTERACTIONS *
1040 **************************/
1045 /* REACTION-FIELD ELECTROSTATICS */
1046 felec = qq21*(rinv21*rinvsq21-krf2);
1050 /* Calculate temporary vectorial force */
1055 /* Update vectorial force */
1059 f[j_coord_offset+DIM*1+XX] -= tx;
1060 f[j_coord_offset+DIM*1+YY] -= ty;
1061 f[j_coord_offset+DIM*1+ZZ] -= tz;
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1072 /* REACTION-FIELD ELECTROSTATICS */
1073 felec = qq22*(rinv22*rinvsq22-krf2);
1077 /* Calculate temporary vectorial force */
1082 /* Update vectorial force */
1086 f[j_coord_offset+DIM*2+XX] -= tx;
1087 f[j_coord_offset+DIM*2+YY] -= ty;
1088 f[j_coord_offset+DIM*2+ZZ] -= tz;
1092 /**************************
1093 * CALCULATE INTERACTIONS *
1094 **************************/
1099 /* REACTION-FIELD ELECTROSTATICS */
1100 felec = qq23*(rinv23*rinvsq23-krf2);
1104 /* Calculate temporary vectorial force */
1109 /* Update vectorial force */
1113 f[j_coord_offset+DIM*3+XX] -= tx;
1114 f[j_coord_offset+DIM*3+YY] -= ty;
1115 f[j_coord_offset+DIM*3+ZZ] -= tz;
1119 /**************************
1120 * CALCULATE INTERACTIONS *
1121 **************************/
1126 /* REACTION-FIELD ELECTROSTATICS */
1127 felec = qq31*(rinv31*rinvsq31-krf2);
1131 /* Calculate temporary vectorial force */
1136 /* Update vectorial force */
1140 f[j_coord_offset+DIM*1+XX] -= tx;
1141 f[j_coord_offset+DIM*1+YY] -= ty;
1142 f[j_coord_offset+DIM*1+ZZ] -= tz;
1146 /**************************
1147 * CALCULATE INTERACTIONS *
1148 **************************/
1153 /* REACTION-FIELD ELECTROSTATICS */
1154 felec = qq32*(rinv32*rinvsq32-krf2);
1158 /* Calculate temporary vectorial force */
1163 /* Update vectorial force */
1167 f[j_coord_offset+DIM*2+XX] -= tx;
1168 f[j_coord_offset+DIM*2+YY] -= ty;
1169 f[j_coord_offset+DIM*2+ZZ] -= tz;
1173 /**************************
1174 * CALCULATE INTERACTIONS *
1175 **************************/
1180 /* REACTION-FIELD ELECTROSTATICS */
1181 felec = qq33*(rinv33*rinvsq33-krf2);
1185 /* Calculate temporary vectorial force */
1190 /* Update vectorial force */
1194 f[j_coord_offset+DIM*3+XX] -= tx;
1195 f[j_coord_offset+DIM*3+YY] -= ty;
1196 f[j_coord_offset+DIM*3+ZZ] -= tz;
1200 /* Inner loop uses 285 flops */
1202 /* End of innermost loop */
1205 f[i_coord_offset+DIM*0+XX] += fix0;
1206 f[i_coord_offset+DIM*0+YY] += fiy0;
1207 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1211 f[i_coord_offset+DIM*1+XX] += fix1;
1212 f[i_coord_offset+DIM*1+YY] += fiy1;
1213 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1217 f[i_coord_offset+DIM*2+XX] += fix2;
1218 f[i_coord_offset+DIM*2+YY] += fiy2;
1219 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1223 f[i_coord_offset+DIM*3+XX] += fix3;
1224 f[i_coord_offset+DIM*3+YY] += fiy3;
1225 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1229 fshift[i_shift_offset+XX] += tx;
1230 fshift[i_shift_offset+YY] += ty;
1231 fshift[i_shift_offset+ZZ] += tz;
1233 /* Increment number of inner iterations */
1234 inneriter += j_index_end - j_index_start;
1236 /* Outer loop uses 39 flops */
1239 /* Increment number of outer iterations */
1242 /* Update outer/inner flops */
1244 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*285);