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_VdwBhamSw_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwBhamSw_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 = 3*nvdwtype*vdwtype[inr+0];
120 vdwjidx0 = 3*vdwtype[inr+0];
121 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
122 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
123 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
134 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
135 rcutoff = fr->rcoulomb;
136 rcutoff2 = rcutoff*rcutoff;
138 rswitch = fr->rvdw_switch;
139 /* Setup switch parameters */
141 swV3 = -10.0/(d*d*d);
142 swV4 = 15.0/(d*d*d*d);
143 swV5 = -6.0/(d*d*d*d*d);
144 swF2 = -30.0/(d*d*d);
145 swF3 = 60.0/(d*d*d*d);
146 swF4 = -30.0/(d*d*d*d*d);
151 /* Start outer loop over neighborlists */
152 for(iidx=0; iidx<nri; iidx++)
154 /* Load shift vector for this list */
155 i_shift_offset = DIM*shiftidx[iidx];
156 shX = shiftvec[i_shift_offset+XX];
157 shY = shiftvec[i_shift_offset+YY];
158 shZ = shiftvec[i_shift_offset+ZZ];
160 /* Load limits for loop over neighbors */
161 j_index_start = jindex[iidx];
162 j_index_end = jindex[iidx+1];
164 /* Get outer coordinate index */
166 i_coord_offset = DIM*inr;
168 /* Load i particle coords and add shift vector */
169 ix0 = shX + x[i_coord_offset+DIM*0+XX];
170 iy0 = shY + x[i_coord_offset+DIM*0+YY];
171 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
172 ix1 = shX + x[i_coord_offset+DIM*1+XX];
173 iy1 = shY + x[i_coord_offset+DIM*1+YY];
174 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
175 ix2 = shX + x[i_coord_offset+DIM*2+XX];
176 iy2 = shY + x[i_coord_offset+DIM*2+YY];
177 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
178 ix3 = shX + x[i_coord_offset+DIM*3+XX];
179 iy3 = shY + x[i_coord_offset+DIM*3+YY];
180 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
195 /* Reset potential sums */
199 /* Start inner kernel loop */
200 for(jidx=j_index_start; jidx<j_index_end; jidx++)
202 /* Get j neighbor index, and coordinate index */
204 j_coord_offset = DIM*jnr;
206 /* load j atom coordinates */
207 jx0 = x[j_coord_offset+DIM*0+XX];
208 jy0 = x[j_coord_offset+DIM*0+YY];
209 jz0 = x[j_coord_offset+DIM*0+ZZ];
210 jx1 = x[j_coord_offset+DIM*1+XX];
211 jy1 = x[j_coord_offset+DIM*1+YY];
212 jz1 = x[j_coord_offset+DIM*1+ZZ];
213 jx2 = x[j_coord_offset+DIM*2+XX];
214 jy2 = x[j_coord_offset+DIM*2+YY];
215 jz2 = x[j_coord_offset+DIM*2+ZZ];
216 jx3 = x[j_coord_offset+DIM*3+XX];
217 jy3 = x[j_coord_offset+DIM*3+YY];
218 jz3 = x[j_coord_offset+DIM*3+ZZ];
220 /* Calculate displacement vector */
252 /* Calculate squared distance and things based on it */
253 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
254 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
255 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
256 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
257 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
258 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
259 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
260 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
261 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
262 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
264 rinv00 = gmx_invsqrt(rsq00);
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 = rinv00*rinv00;
276 rinvsq11 = rinv11*rinv11;
277 rinvsq12 = rinv12*rinv12;
278 rinvsq13 = rinv13*rinv13;
279 rinvsq21 = rinv21*rinv21;
280 rinvsq22 = rinv22*rinv22;
281 rinvsq23 = rinv23*rinv23;
282 rinvsq31 = rinv31*rinv31;
283 rinvsq32 = rinv32*rinv32;
284 rinvsq33 = rinv33*rinv33;
286 /**************************
287 * CALCULATE INTERACTIONS *
288 **************************/
295 /* BUCKINGHAM DISPERSION/REPULSION */
296 rinvsix = rinvsq00*rinvsq00*rinvsq00;
297 vvdw6 = c6_00*rinvsix;
299 vvdwexp = cexp1_00*exp(-br);
300 vvdw = vvdwexp - vvdw6*(1.0/6.0);
301 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
304 d = (d>0.0) ? d : 0.0;
306 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
308 dsw = d2*(swF2+d*(swF3+d*swF4));
310 /* Evaluate switch function */
311 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
312 fvdw = fvdw*sw - rinv00*vvdw*dsw;
315 /* Update potential sums from outer loop */
320 /* Calculate temporary vectorial force */
325 /* Update vectorial force */
329 f[j_coord_offset+DIM*0+XX] -= tx;
330 f[j_coord_offset+DIM*0+YY] -= ty;
331 f[j_coord_offset+DIM*0+ZZ] -= tz;
335 /**************************
336 * CALCULATE INTERACTIONS *
337 **************************/
342 /* REACTION-FIELD ELECTROSTATICS */
343 velec = qq11*(rinv11+krf*rsq11-crf);
344 felec = qq11*(rinv11*rinvsq11-krf2);
346 /* Update potential sums from outer loop */
351 /* Calculate temporary vectorial force */
356 /* Update vectorial force */
360 f[j_coord_offset+DIM*1+XX] -= tx;
361 f[j_coord_offset+DIM*1+YY] -= ty;
362 f[j_coord_offset+DIM*1+ZZ] -= tz;
366 /**************************
367 * CALCULATE INTERACTIONS *
368 **************************/
373 /* REACTION-FIELD ELECTROSTATICS */
374 velec = qq12*(rinv12+krf*rsq12-crf);
375 felec = qq12*(rinv12*rinvsq12-krf2);
377 /* Update potential sums from outer loop */
382 /* Calculate temporary vectorial force */
387 /* Update vectorial force */
391 f[j_coord_offset+DIM*2+XX] -= tx;
392 f[j_coord_offset+DIM*2+YY] -= ty;
393 f[j_coord_offset+DIM*2+ZZ] -= tz;
397 /**************************
398 * CALCULATE INTERACTIONS *
399 **************************/
404 /* REACTION-FIELD ELECTROSTATICS */
405 velec = qq13*(rinv13+krf*rsq13-crf);
406 felec = qq13*(rinv13*rinvsq13-krf2);
408 /* Update potential sums from outer loop */
413 /* Calculate temporary vectorial force */
418 /* Update vectorial force */
422 f[j_coord_offset+DIM*3+XX] -= tx;
423 f[j_coord_offset+DIM*3+YY] -= ty;
424 f[j_coord_offset+DIM*3+ZZ] -= tz;
428 /**************************
429 * CALCULATE INTERACTIONS *
430 **************************/
435 /* REACTION-FIELD ELECTROSTATICS */
436 velec = qq21*(rinv21+krf*rsq21-crf);
437 felec = qq21*(rinv21*rinvsq21-krf2);
439 /* Update potential sums from outer loop */
444 /* Calculate temporary vectorial force */
449 /* Update vectorial force */
453 f[j_coord_offset+DIM*1+XX] -= tx;
454 f[j_coord_offset+DIM*1+YY] -= ty;
455 f[j_coord_offset+DIM*1+ZZ] -= tz;
459 /**************************
460 * CALCULATE INTERACTIONS *
461 **************************/
466 /* REACTION-FIELD ELECTROSTATICS */
467 velec = qq22*(rinv22+krf*rsq22-crf);
468 felec = qq22*(rinv22*rinvsq22-krf2);
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;
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
497 /* REACTION-FIELD ELECTROSTATICS */
498 velec = qq23*(rinv23+krf*rsq23-crf);
499 felec = qq23*(rinv23*rinvsq23-krf2);
501 /* Update potential sums from outer loop */
506 /* Calculate temporary vectorial force */
511 /* Update vectorial force */
515 f[j_coord_offset+DIM*3+XX] -= tx;
516 f[j_coord_offset+DIM*3+YY] -= ty;
517 f[j_coord_offset+DIM*3+ZZ] -= tz;
521 /**************************
522 * CALCULATE INTERACTIONS *
523 **************************/
528 /* REACTION-FIELD ELECTROSTATICS */
529 velec = qq31*(rinv31+krf*rsq31-crf);
530 felec = qq31*(rinv31*rinvsq31-krf2);
532 /* Update potential sums from outer loop */
537 /* Calculate temporary vectorial force */
542 /* Update vectorial force */
546 f[j_coord_offset+DIM*1+XX] -= tx;
547 f[j_coord_offset+DIM*1+YY] -= ty;
548 f[j_coord_offset+DIM*1+ZZ] -= tz;
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
559 /* REACTION-FIELD ELECTROSTATICS */
560 velec = qq32*(rinv32+krf*rsq32-crf);
561 felec = qq32*(rinv32*rinvsq32-krf2);
563 /* Update potential sums from outer loop */
568 /* Calculate temporary vectorial force */
573 /* Update vectorial force */
577 f[j_coord_offset+DIM*2+XX] -= tx;
578 f[j_coord_offset+DIM*2+YY] -= ty;
579 f[j_coord_offset+DIM*2+ZZ] -= tz;
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
590 /* REACTION-FIELD ELECTROSTATICS */
591 velec = qq33*(rinv33+krf*rsq33-crf);
592 felec = qq33*(rinv33*rinvsq33-krf2);
594 /* Update potential sums from outer loop */
599 /* Calculate temporary vectorial force */
604 /* Update vectorial force */
608 f[j_coord_offset+DIM*3+XX] -= tx;
609 f[j_coord_offset+DIM*3+YY] -= ty;
610 f[j_coord_offset+DIM*3+ZZ] -= tz;
614 /* Inner loop uses 358 flops */
616 /* End of innermost loop */
619 f[i_coord_offset+DIM*0+XX] += fix0;
620 f[i_coord_offset+DIM*0+YY] += fiy0;
621 f[i_coord_offset+DIM*0+ZZ] += fiz0;
625 f[i_coord_offset+DIM*1+XX] += fix1;
626 f[i_coord_offset+DIM*1+YY] += fiy1;
627 f[i_coord_offset+DIM*1+ZZ] += fiz1;
631 f[i_coord_offset+DIM*2+XX] += fix2;
632 f[i_coord_offset+DIM*2+YY] += fiy2;
633 f[i_coord_offset+DIM*2+ZZ] += fiz2;
637 f[i_coord_offset+DIM*3+XX] += fix3;
638 f[i_coord_offset+DIM*3+YY] += fiy3;
639 f[i_coord_offset+DIM*3+ZZ] += fiz3;
643 fshift[i_shift_offset+XX] += tx;
644 fshift[i_shift_offset+YY] += ty;
645 fshift[i_shift_offset+ZZ] += tz;
648 /* Update potential energies */
649 kernel_data->energygrp_elec[ggid] += velecsum;
650 kernel_data->energygrp_vdw[ggid] += vvdwsum;
652 /* Increment number of inner iterations */
653 inneriter += j_index_end - j_index_start;
655 /* Outer loop uses 41 flops */
658 /* Increment number of outer iterations */
661 /* Update outer/inner flops */
663 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*358);
666 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
667 * Electrostatics interaction: ReactionField
668 * VdW interaction: Buckingham
669 * Geometry: Water4-Water4
670 * Calculate force/pot: Force
673 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
674 (t_nblist * gmx_restrict nlist,
675 rvec * gmx_restrict xx,
676 rvec * gmx_restrict ff,
677 t_forcerec * gmx_restrict fr,
678 t_mdatoms * gmx_restrict mdatoms,
679 nb_kernel_data_t * gmx_restrict kernel_data,
680 t_nrnb * gmx_restrict nrnb)
682 int i_shift_offset,i_coord_offset,j_coord_offset;
683 int j_index_start,j_index_end;
684 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
685 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
686 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
687 real *shiftvec,*fshift,*x,*f;
689 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
691 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
693 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
695 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
697 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
699 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
701 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
703 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
704 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
705 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
706 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
707 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
708 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
709 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
710 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
711 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
712 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
713 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
714 real velec,felec,velecsum,facel,crf,krf,krf2;
717 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
720 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
727 jindex = nlist->jindex;
729 shiftidx = nlist->shift;
731 shiftvec = fr->shift_vec[0];
732 fshift = fr->fshift[0];
734 charge = mdatoms->chargeA;
738 nvdwtype = fr->ntype;
740 vdwtype = mdatoms->typeA;
742 /* Setup water-specific parameters */
743 inr = nlist->iinr[0];
744 iq1 = facel*charge[inr+1];
745 iq2 = facel*charge[inr+2];
746 iq3 = facel*charge[inr+3];
747 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
752 vdwjidx0 = 3*vdwtype[inr+0];
753 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
754 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
755 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
766 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
767 rcutoff = fr->rcoulomb;
768 rcutoff2 = rcutoff*rcutoff;
770 rswitch = fr->rvdw_switch;
771 /* Setup switch parameters */
773 swV3 = -10.0/(d*d*d);
774 swV4 = 15.0/(d*d*d*d);
775 swV5 = -6.0/(d*d*d*d*d);
776 swF2 = -30.0/(d*d*d);
777 swF3 = 60.0/(d*d*d*d);
778 swF4 = -30.0/(d*d*d*d*d);
783 /* Start outer loop over neighborlists */
784 for(iidx=0; iidx<nri; iidx++)
786 /* Load shift vector for this list */
787 i_shift_offset = DIM*shiftidx[iidx];
788 shX = shiftvec[i_shift_offset+XX];
789 shY = shiftvec[i_shift_offset+YY];
790 shZ = shiftvec[i_shift_offset+ZZ];
792 /* Load limits for loop over neighbors */
793 j_index_start = jindex[iidx];
794 j_index_end = jindex[iidx+1];
796 /* Get outer coordinate index */
798 i_coord_offset = DIM*inr;
800 /* Load i particle coords and add shift vector */
801 ix0 = shX + x[i_coord_offset+DIM*0+XX];
802 iy0 = shY + x[i_coord_offset+DIM*0+YY];
803 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
804 ix1 = shX + x[i_coord_offset+DIM*1+XX];
805 iy1 = shY + x[i_coord_offset+DIM*1+YY];
806 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
807 ix2 = shX + x[i_coord_offset+DIM*2+XX];
808 iy2 = shY + x[i_coord_offset+DIM*2+YY];
809 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
810 ix3 = shX + x[i_coord_offset+DIM*3+XX];
811 iy3 = shY + x[i_coord_offset+DIM*3+YY];
812 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
827 /* Start inner kernel loop */
828 for(jidx=j_index_start; jidx<j_index_end; jidx++)
830 /* Get j neighbor index, and coordinate index */
832 j_coord_offset = DIM*jnr;
834 /* load j atom coordinates */
835 jx0 = x[j_coord_offset+DIM*0+XX];
836 jy0 = x[j_coord_offset+DIM*0+YY];
837 jz0 = x[j_coord_offset+DIM*0+ZZ];
838 jx1 = x[j_coord_offset+DIM*1+XX];
839 jy1 = x[j_coord_offset+DIM*1+YY];
840 jz1 = x[j_coord_offset+DIM*1+ZZ];
841 jx2 = x[j_coord_offset+DIM*2+XX];
842 jy2 = x[j_coord_offset+DIM*2+YY];
843 jz2 = x[j_coord_offset+DIM*2+ZZ];
844 jx3 = x[j_coord_offset+DIM*3+XX];
845 jy3 = x[j_coord_offset+DIM*3+YY];
846 jz3 = x[j_coord_offset+DIM*3+ZZ];
848 /* Calculate displacement vector */
880 /* Calculate squared distance and things based on it */
881 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
882 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
883 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
884 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
885 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
886 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
887 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
888 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
889 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
890 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
892 rinv00 = gmx_invsqrt(rsq00);
893 rinv11 = gmx_invsqrt(rsq11);
894 rinv12 = gmx_invsqrt(rsq12);
895 rinv13 = gmx_invsqrt(rsq13);
896 rinv21 = gmx_invsqrt(rsq21);
897 rinv22 = gmx_invsqrt(rsq22);
898 rinv23 = gmx_invsqrt(rsq23);
899 rinv31 = gmx_invsqrt(rsq31);
900 rinv32 = gmx_invsqrt(rsq32);
901 rinv33 = gmx_invsqrt(rsq33);
903 rinvsq00 = rinv00*rinv00;
904 rinvsq11 = rinv11*rinv11;
905 rinvsq12 = rinv12*rinv12;
906 rinvsq13 = rinv13*rinv13;
907 rinvsq21 = rinv21*rinv21;
908 rinvsq22 = rinv22*rinv22;
909 rinvsq23 = rinv23*rinv23;
910 rinvsq31 = rinv31*rinv31;
911 rinvsq32 = rinv32*rinv32;
912 rinvsq33 = rinv33*rinv33;
914 /**************************
915 * CALCULATE INTERACTIONS *
916 **************************/
923 /* BUCKINGHAM DISPERSION/REPULSION */
924 rinvsix = rinvsq00*rinvsq00*rinvsq00;
925 vvdw6 = c6_00*rinvsix;
927 vvdwexp = cexp1_00*exp(-br);
928 vvdw = vvdwexp - vvdw6*(1.0/6.0);
929 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
932 d = (d>0.0) ? d : 0.0;
934 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
936 dsw = d2*(swF2+d*(swF3+d*swF4));
938 /* Evaluate switch function */
939 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
940 fvdw = fvdw*sw - rinv00*vvdw*dsw;
944 /* Calculate temporary vectorial force */
949 /* Update vectorial force */
953 f[j_coord_offset+DIM*0+XX] -= tx;
954 f[j_coord_offset+DIM*0+YY] -= ty;
955 f[j_coord_offset+DIM*0+ZZ] -= tz;
959 /**************************
960 * CALCULATE INTERACTIONS *
961 **************************/
966 /* REACTION-FIELD ELECTROSTATICS */
967 felec = qq11*(rinv11*rinvsq11-krf2);
971 /* Calculate temporary vectorial force */
976 /* Update vectorial force */
980 f[j_coord_offset+DIM*1+XX] -= tx;
981 f[j_coord_offset+DIM*1+YY] -= ty;
982 f[j_coord_offset+DIM*1+ZZ] -= tz;
986 /**************************
987 * CALCULATE INTERACTIONS *
988 **************************/
993 /* REACTION-FIELD ELECTROSTATICS */
994 felec = qq12*(rinv12*rinvsq12-krf2);
998 /* Calculate temporary vectorial force */
1003 /* Update vectorial force */
1007 f[j_coord_offset+DIM*2+XX] -= tx;
1008 f[j_coord_offset+DIM*2+YY] -= ty;
1009 f[j_coord_offset+DIM*2+ZZ] -= tz;
1013 /**************************
1014 * CALCULATE INTERACTIONS *
1015 **************************/
1020 /* REACTION-FIELD ELECTROSTATICS */
1021 felec = qq13*(rinv13*rinvsq13-krf2);
1025 /* Calculate temporary vectorial force */
1030 /* Update vectorial force */
1034 f[j_coord_offset+DIM*3+XX] -= tx;
1035 f[j_coord_offset+DIM*3+YY] -= ty;
1036 f[j_coord_offset+DIM*3+ZZ] -= tz;
1040 /**************************
1041 * CALCULATE INTERACTIONS *
1042 **************************/
1047 /* REACTION-FIELD ELECTROSTATICS */
1048 felec = qq21*(rinv21*rinvsq21-krf2);
1052 /* Calculate temporary vectorial force */
1057 /* Update vectorial force */
1061 f[j_coord_offset+DIM*1+XX] -= tx;
1062 f[j_coord_offset+DIM*1+YY] -= ty;
1063 f[j_coord_offset+DIM*1+ZZ] -= tz;
1067 /**************************
1068 * CALCULATE INTERACTIONS *
1069 **************************/
1074 /* REACTION-FIELD ELECTROSTATICS */
1075 felec = qq22*(rinv22*rinvsq22-krf2);
1079 /* Calculate temporary vectorial force */
1084 /* Update vectorial force */
1088 f[j_coord_offset+DIM*2+XX] -= tx;
1089 f[j_coord_offset+DIM*2+YY] -= ty;
1090 f[j_coord_offset+DIM*2+ZZ] -= tz;
1094 /**************************
1095 * CALCULATE INTERACTIONS *
1096 **************************/
1101 /* REACTION-FIELD ELECTROSTATICS */
1102 felec = qq23*(rinv23*rinvsq23-krf2);
1106 /* Calculate temporary vectorial force */
1111 /* Update vectorial force */
1115 f[j_coord_offset+DIM*3+XX] -= tx;
1116 f[j_coord_offset+DIM*3+YY] -= ty;
1117 f[j_coord_offset+DIM*3+ZZ] -= tz;
1121 /**************************
1122 * CALCULATE INTERACTIONS *
1123 **************************/
1128 /* REACTION-FIELD ELECTROSTATICS */
1129 felec = qq31*(rinv31*rinvsq31-krf2);
1133 /* Calculate temporary vectorial force */
1138 /* Update vectorial force */
1142 f[j_coord_offset+DIM*1+XX] -= tx;
1143 f[j_coord_offset+DIM*1+YY] -= ty;
1144 f[j_coord_offset+DIM*1+ZZ] -= tz;
1148 /**************************
1149 * CALCULATE INTERACTIONS *
1150 **************************/
1155 /* REACTION-FIELD ELECTROSTATICS */
1156 felec = qq32*(rinv32*rinvsq32-krf2);
1160 /* Calculate temporary vectorial force */
1165 /* Update vectorial force */
1169 f[j_coord_offset+DIM*2+XX] -= tx;
1170 f[j_coord_offset+DIM*2+YY] -= ty;
1171 f[j_coord_offset+DIM*2+ZZ] -= tz;
1175 /**************************
1176 * CALCULATE INTERACTIONS *
1177 **************************/
1182 /* REACTION-FIELD ELECTROSTATICS */
1183 felec = qq33*(rinv33*rinvsq33-krf2);
1187 /* Calculate temporary vectorial force */
1192 /* Update vectorial force */
1196 f[j_coord_offset+DIM*3+XX] -= tx;
1197 f[j_coord_offset+DIM*3+YY] -= ty;
1198 f[j_coord_offset+DIM*3+ZZ] -= tz;
1202 /* Inner loop uses 311 flops */
1204 /* End of innermost loop */
1207 f[i_coord_offset+DIM*0+XX] += fix0;
1208 f[i_coord_offset+DIM*0+YY] += fiy0;
1209 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1213 f[i_coord_offset+DIM*1+XX] += fix1;
1214 f[i_coord_offset+DIM*1+YY] += fiy1;
1215 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1219 f[i_coord_offset+DIM*2+XX] += fix2;
1220 f[i_coord_offset+DIM*2+YY] += fiy2;
1221 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1225 f[i_coord_offset+DIM*3+XX] += fix3;
1226 f[i_coord_offset+DIM*3+YY] += fiy3;
1227 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1231 fshift[i_shift_offset+XX] += tx;
1232 fshift[i_shift_offset+YY] += ty;
1233 fshift[i_shift_offset+ZZ] += tz;
1235 /* Increment number of inner iterations */
1236 inneriter += j_index_end - j_index_start;
1238 /* Outer loop uses 39 flops */
1241 /* Increment number of outer iterations */
1244 /* Update outer/inner flops */
1246 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*311);