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_VdwBhamSh_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwBhamSh_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;
94 jindex = nlist->jindex;
96 shiftidx = nlist->shift;
98 shiftvec = fr->shift_vec[0];
99 fshift = fr->fshift[0];
101 charge = mdatoms->chargeA;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 /* Setup water-specific parameters */
110 inr = nlist->iinr[0];
111 iq1 = facel*charge[inr+1];
112 iq2 = facel*charge[inr+2];
113 iq3 = facel*charge[inr+3];
114 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
119 vdwjidx0 = 3*vdwtype[inr+0];
120 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
121 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
122 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
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 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
143 /* Start outer loop over neighborlists */
144 for(iidx=0; iidx<nri; iidx++)
146 /* Load shift vector for this list */
147 i_shift_offset = DIM*shiftidx[iidx];
148 shX = shiftvec[i_shift_offset+XX];
149 shY = shiftvec[i_shift_offset+YY];
150 shZ = shiftvec[i_shift_offset+ZZ];
152 /* Load limits for loop over neighbors */
153 j_index_start = jindex[iidx];
154 j_index_end = jindex[iidx+1];
156 /* Get outer coordinate index */
158 i_coord_offset = DIM*inr;
160 /* Load i particle coords and add shift vector */
161 ix0 = shX + x[i_coord_offset+DIM*0+XX];
162 iy0 = shY + x[i_coord_offset+DIM*0+YY];
163 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
164 ix1 = shX + x[i_coord_offset+DIM*1+XX];
165 iy1 = shY + x[i_coord_offset+DIM*1+YY];
166 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
167 ix2 = shX + x[i_coord_offset+DIM*2+XX];
168 iy2 = shY + x[i_coord_offset+DIM*2+YY];
169 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
170 ix3 = shX + x[i_coord_offset+DIM*3+XX];
171 iy3 = shY + x[i_coord_offset+DIM*3+YY];
172 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
187 /* Reset potential sums */
191 /* Start inner kernel loop */
192 for(jidx=j_index_start; jidx<j_index_end; jidx++)
194 /* Get j neighbor index, and coordinate index */
196 j_coord_offset = DIM*jnr;
198 /* load j atom coordinates */
199 jx0 = x[j_coord_offset+DIM*0+XX];
200 jy0 = x[j_coord_offset+DIM*0+YY];
201 jz0 = x[j_coord_offset+DIM*0+ZZ];
202 jx1 = x[j_coord_offset+DIM*1+XX];
203 jy1 = x[j_coord_offset+DIM*1+YY];
204 jz1 = x[j_coord_offset+DIM*1+ZZ];
205 jx2 = x[j_coord_offset+DIM*2+XX];
206 jy2 = x[j_coord_offset+DIM*2+YY];
207 jz2 = x[j_coord_offset+DIM*2+ZZ];
208 jx3 = x[j_coord_offset+DIM*3+XX];
209 jy3 = x[j_coord_offset+DIM*3+YY];
210 jz3 = x[j_coord_offset+DIM*3+ZZ];
212 /* Calculate displacement vector */
244 /* Calculate squared distance and things based on it */
245 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
246 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
247 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
248 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
249 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
250 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
251 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
252 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
253 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
254 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
256 rinv00 = gmx_invsqrt(rsq00);
257 rinv11 = gmx_invsqrt(rsq11);
258 rinv12 = gmx_invsqrt(rsq12);
259 rinv13 = gmx_invsqrt(rsq13);
260 rinv21 = gmx_invsqrt(rsq21);
261 rinv22 = gmx_invsqrt(rsq22);
262 rinv23 = gmx_invsqrt(rsq23);
263 rinv31 = gmx_invsqrt(rsq31);
264 rinv32 = gmx_invsqrt(rsq32);
265 rinv33 = gmx_invsqrt(rsq33);
267 rinvsq00 = rinv00*rinv00;
268 rinvsq11 = rinv11*rinv11;
269 rinvsq12 = rinv12*rinv12;
270 rinvsq13 = rinv13*rinv13;
271 rinvsq21 = rinv21*rinv21;
272 rinvsq22 = rinv22*rinv22;
273 rinvsq23 = rinv23*rinv23;
274 rinvsq31 = rinv31*rinv31;
275 rinvsq32 = rinv32*rinv32;
276 rinvsq33 = rinv33*rinv33;
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
287 /* BUCKINGHAM DISPERSION/REPULSION */
288 rinvsix = rinvsq00*rinvsq00*rinvsq00;
289 vvdw6 = c6_00*rinvsix;
291 vvdwexp = cexp1_00*exp(-br);
292 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
293 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
295 /* Update potential sums from outer loop */
300 /* Calculate temporary vectorial force */
305 /* Update vectorial force */
309 f[j_coord_offset+DIM*0+XX] -= tx;
310 f[j_coord_offset+DIM*0+YY] -= ty;
311 f[j_coord_offset+DIM*0+ZZ] -= tz;
315 /**************************
316 * CALCULATE INTERACTIONS *
317 **************************/
322 /* REACTION-FIELD ELECTROSTATICS */
323 velec = qq11*(rinv11+krf*rsq11-crf);
324 felec = qq11*(rinv11*rinvsq11-krf2);
326 /* Update potential sums from outer loop */
331 /* Calculate temporary vectorial force */
336 /* Update vectorial force */
340 f[j_coord_offset+DIM*1+XX] -= tx;
341 f[j_coord_offset+DIM*1+YY] -= ty;
342 f[j_coord_offset+DIM*1+ZZ] -= tz;
346 /**************************
347 * CALCULATE INTERACTIONS *
348 **************************/
353 /* REACTION-FIELD ELECTROSTATICS */
354 velec = qq12*(rinv12+krf*rsq12-crf);
355 felec = qq12*(rinv12*rinvsq12-krf2);
357 /* Update potential sums from outer loop */
362 /* Calculate temporary vectorial force */
367 /* Update vectorial force */
371 f[j_coord_offset+DIM*2+XX] -= tx;
372 f[j_coord_offset+DIM*2+YY] -= ty;
373 f[j_coord_offset+DIM*2+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
384 /* REACTION-FIELD ELECTROSTATICS */
385 velec = qq13*(rinv13+krf*rsq13-crf);
386 felec = qq13*(rinv13*rinvsq13-krf2);
388 /* Update potential sums from outer loop */
393 /* Calculate temporary vectorial force */
398 /* Update vectorial force */
402 f[j_coord_offset+DIM*3+XX] -= tx;
403 f[j_coord_offset+DIM*3+YY] -= ty;
404 f[j_coord_offset+DIM*3+ZZ] -= tz;
408 /**************************
409 * CALCULATE INTERACTIONS *
410 **************************/
415 /* REACTION-FIELD ELECTROSTATICS */
416 velec = qq21*(rinv21+krf*rsq21-crf);
417 felec = qq21*(rinv21*rinvsq21-krf2);
419 /* Update potential sums from outer loop */
424 /* Calculate temporary vectorial force */
429 /* Update vectorial force */
433 f[j_coord_offset+DIM*1+XX] -= tx;
434 f[j_coord_offset+DIM*1+YY] -= ty;
435 f[j_coord_offset+DIM*1+ZZ] -= tz;
439 /**************************
440 * CALCULATE INTERACTIONS *
441 **************************/
446 /* REACTION-FIELD ELECTROSTATICS */
447 velec = qq22*(rinv22+krf*rsq22-crf);
448 felec = qq22*(rinv22*rinvsq22-krf2);
450 /* Update potential sums from outer loop */
455 /* Calculate temporary vectorial force */
460 /* Update vectorial force */
464 f[j_coord_offset+DIM*2+XX] -= tx;
465 f[j_coord_offset+DIM*2+YY] -= ty;
466 f[j_coord_offset+DIM*2+ZZ] -= tz;
470 /**************************
471 * CALCULATE INTERACTIONS *
472 **************************/
477 /* REACTION-FIELD ELECTROSTATICS */
478 velec = qq23*(rinv23+krf*rsq23-crf);
479 felec = qq23*(rinv23*rinvsq23-krf2);
481 /* Update potential sums from outer loop */
486 /* Calculate temporary vectorial force */
491 /* Update vectorial force */
495 f[j_coord_offset+DIM*3+XX] -= tx;
496 f[j_coord_offset+DIM*3+YY] -= ty;
497 f[j_coord_offset+DIM*3+ZZ] -= tz;
501 /**************************
502 * CALCULATE INTERACTIONS *
503 **************************/
508 /* REACTION-FIELD ELECTROSTATICS */
509 velec = qq31*(rinv31+krf*rsq31-crf);
510 felec = qq31*(rinv31*rinvsq31-krf2);
512 /* Update potential sums from outer loop */
517 /* Calculate temporary vectorial force */
522 /* Update vectorial force */
526 f[j_coord_offset+DIM*1+XX] -= tx;
527 f[j_coord_offset+DIM*1+YY] -= ty;
528 f[j_coord_offset+DIM*1+ZZ] -= tz;
532 /**************************
533 * CALCULATE INTERACTIONS *
534 **************************/
539 /* REACTION-FIELD ELECTROSTATICS */
540 velec = qq32*(rinv32+krf*rsq32-crf);
541 felec = qq32*(rinv32*rinvsq32-krf2);
543 /* Update potential sums from outer loop */
548 /* Calculate temporary vectorial force */
553 /* Update vectorial force */
557 f[j_coord_offset+DIM*2+XX] -= tx;
558 f[j_coord_offset+DIM*2+YY] -= ty;
559 f[j_coord_offset+DIM*2+ZZ] -= tz;
563 /**************************
564 * CALCULATE INTERACTIONS *
565 **************************/
570 /* REACTION-FIELD ELECTROSTATICS */
571 velec = qq33*(rinv33+krf*rsq33-crf);
572 felec = qq33*(rinv33*rinvsq33-krf2);
574 /* Update potential sums from outer loop */
579 /* Calculate temporary vectorial force */
584 /* Update vectorial force */
588 f[j_coord_offset+DIM*3+XX] -= tx;
589 f[j_coord_offset+DIM*3+YY] -= ty;
590 f[j_coord_offset+DIM*3+ZZ] -= tz;
594 /* Inner loop uses 371 flops */
596 /* End of innermost loop */
599 f[i_coord_offset+DIM*0+XX] += fix0;
600 f[i_coord_offset+DIM*0+YY] += fiy0;
601 f[i_coord_offset+DIM*0+ZZ] += fiz0;
605 f[i_coord_offset+DIM*1+XX] += fix1;
606 f[i_coord_offset+DIM*1+YY] += fiy1;
607 f[i_coord_offset+DIM*1+ZZ] += fiz1;
611 f[i_coord_offset+DIM*2+XX] += fix2;
612 f[i_coord_offset+DIM*2+YY] += fiy2;
613 f[i_coord_offset+DIM*2+ZZ] += fiz2;
617 f[i_coord_offset+DIM*3+XX] += fix3;
618 f[i_coord_offset+DIM*3+YY] += fiy3;
619 f[i_coord_offset+DIM*3+ZZ] += fiz3;
623 fshift[i_shift_offset+XX] += tx;
624 fshift[i_shift_offset+YY] += ty;
625 fshift[i_shift_offset+ZZ] += tz;
628 /* Update potential energies */
629 kernel_data->energygrp_elec[ggid] += velecsum;
630 kernel_data->energygrp_vdw[ggid] += vvdwsum;
632 /* Increment number of inner iterations */
633 inneriter += j_index_end - j_index_start;
635 /* Outer loop uses 41 flops */
638 /* Increment number of outer iterations */
641 /* Update outer/inner flops */
643 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*371);
646 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW4W4_F_c
647 * Electrostatics interaction: ReactionField
648 * VdW interaction: Buckingham
649 * Geometry: Water4-Water4
650 * Calculate force/pot: Force
653 nb_kernel_ElecRFCut_VdwBhamSh_GeomW4W4_F_c
654 (t_nblist * gmx_restrict nlist,
655 rvec * gmx_restrict xx,
656 rvec * gmx_restrict ff,
657 t_forcerec * gmx_restrict fr,
658 t_mdatoms * gmx_restrict mdatoms,
659 nb_kernel_data_t * gmx_restrict kernel_data,
660 t_nrnb * gmx_restrict nrnb)
662 int i_shift_offset,i_coord_offset,j_coord_offset;
663 int j_index_start,j_index_end;
664 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
665 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
666 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
667 real *shiftvec,*fshift,*x,*f;
669 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
671 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
673 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
675 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
677 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
679 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
681 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
683 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
684 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
685 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
686 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
687 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
688 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
689 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
690 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
691 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
692 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
693 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
694 real velec,felec,velecsum,facel,crf,krf,krf2;
697 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
706 jindex = nlist->jindex;
708 shiftidx = nlist->shift;
710 shiftvec = fr->shift_vec[0];
711 fshift = fr->fshift[0];
713 charge = mdatoms->chargeA;
717 nvdwtype = fr->ntype;
719 vdwtype = mdatoms->typeA;
721 /* Setup water-specific parameters */
722 inr = nlist->iinr[0];
723 iq1 = facel*charge[inr+1];
724 iq2 = facel*charge[inr+2];
725 iq3 = facel*charge[inr+3];
726 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
731 vdwjidx0 = 3*vdwtype[inr+0];
732 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
733 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
734 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
745 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
746 rcutoff = fr->rcoulomb;
747 rcutoff2 = rcutoff*rcutoff;
749 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
755 /* Start outer loop over neighborlists */
756 for(iidx=0; iidx<nri; iidx++)
758 /* Load shift vector for this list */
759 i_shift_offset = DIM*shiftidx[iidx];
760 shX = shiftvec[i_shift_offset+XX];
761 shY = shiftvec[i_shift_offset+YY];
762 shZ = shiftvec[i_shift_offset+ZZ];
764 /* Load limits for loop over neighbors */
765 j_index_start = jindex[iidx];
766 j_index_end = jindex[iidx+1];
768 /* Get outer coordinate index */
770 i_coord_offset = DIM*inr;
772 /* Load i particle coords and add shift vector */
773 ix0 = shX + x[i_coord_offset+DIM*0+XX];
774 iy0 = shY + x[i_coord_offset+DIM*0+YY];
775 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
776 ix1 = shX + x[i_coord_offset+DIM*1+XX];
777 iy1 = shY + x[i_coord_offset+DIM*1+YY];
778 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
779 ix2 = shX + x[i_coord_offset+DIM*2+XX];
780 iy2 = shY + x[i_coord_offset+DIM*2+YY];
781 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
782 ix3 = shX + x[i_coord_offset+DIM*3+XX];
783 iy3 = shY + x[i_coord_offset+DIM*3+YY];
784 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
799 /* Start inner kernel loop */
800 for(jidx=j_index_start; jidx<j_index_end; jidx++)
802 /* Get j neighbor index, and coordinate index */
804 j_coord_offset = DIM*jnr;
806 /* load j atom coordinates */
807 jx0 = x[j_coord_offset+DIM*0+XX];
808 jy0 = x[j_coord_offset+DIM*0+YY];
809 jz0 = x[j_coord_offset+DIM*0+ZZ];
810 jx1 = x[j_coord_offset+DIM*1+XX];
811 jy1 = x[j_coord_offset+DIM*1+YY];
812 jz1 = x[j_coord_offset+DIM*1+ZZ];
813 jx2 = x[j_coord_offset+DIM*2+XX];
814 jy2 = x[j_coord_offset+DIM*2+YY];
815 jz2 = x[j_coord_offset+DIM*2+ZZ];
816 jx3 = x[j_coord_offset+DIM*3+XX];
817 jy3 = x[j_coord_offset+DIM*3+YY];
818 jz3 = x[j_coord_offset+DIM*3+ZZ];
820 /* Calculate displacement vector */
852 /* Calculate squared distance and things based on it */
853 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
854 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
855 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
856 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
857 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
858 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
859 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
860 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
861 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
862 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
864 rinv00 = gmx_invsqrt(rsq00);
865 rinv11 = gmx_invsqrt(rsq11);
866 rinv12 = gmx_invsqrt(rsq12);
867 rinv13 = gmx_invsqrt(rsq13);
868 rinv21 = gmx_invsqrt(rsq21);
869 rinv22 = gmx_invsqrt(rsq22);
870 rinv23 = gmx_invsqrt(rsq23);
871 rinv31 = gmx_invsqrt(rsq31);
872 rinv32 = gmx_invsqrt(rsq32);
873 rinv33 = gmx_invsqrt(rsq33);
875 rinvsq00 = rinv00*rinv00;
876 rinvsq11 = rinv11*rinv11;
877 rinvsq12 = rinv12*rinv12;
878 rinvsq13 = rinv13*rinv13;
879 rinvsq21 = rinv21*rinv21;
880 rinvsq22 = rinv22*rinv22;
881 rinvsq23 = rinv23*rinv23;
882 rinvsq31 = rinv31*rinv31;
883 rinvsq32 = rinv32*rinv32;
884 rinvsq33 = rinv33*rinv33;
886 /**************************
887 * CALCULATE INTERACTIONS *
888 **************************/
895 /* BUCKINGHAM DISPERSION/REPULSION */
896 rinvsix = rinvsq00*rinvsq00*rinvsq00;
897 vvdw6 = c6_00*rinvsix;
899 vvdwexp = cexp1_00*exp(-br);
900 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
904 /* Calculate temporary vectorial force */
909 /* Update vectorial force */
913 f[j_coord_offset+DIM*0+XX] -= tx;
914 f[j_coord_offset+DIM*0+YY] -= ty;
915 f[j_coord_offset+DIM*0+ZZ] -= tz;
919 /**************************
920 * CALCULATE INTERACTIONS *
921 **************************/
926 /* REACTION-FIELD ELECTROSTATICS */
927 felec = qq11*(rinv11*rinvsq11-krf2);
931 /* Calculate temporary vectorial force */
936 /* Update vectorial force */
940 f[j_coord_offset+DIM*1+XX] -= tx;
941 f[j_coord_offset+DIM*1+YY] -= ty;
942 f[j_coord_offset+DIM*1+ZZ] -= tz;
946 /**************************
947 * CALCULATE INTERACTIONS *
948 **************************/
953 /* REACTION-FIELD ELECTROSTATICS */
954 felec = qq12*(rinv12*rinvsq12-krf2);
958 /* Calculate temporary vectorial force */
963 /* Update vectorial force */
967 f[j_coord_offset+DIM*2+XX] -= tx;
968 f[j_coord_offset+DIM*2+YY] -= ty;
969 f[j_coord_offset+DIM*2+ZZ] -= tz;
973 /**************************
974 * CALCULATE INTERACTIONS *
975 **************************/
980 /* REACTION-FIELD ELECTROSTATICS */
981 felec = qq13*(rinv13*rinvsq13-krf2);
985 /* Calculate temporary vectorial force */
990 /* Update vectorial force */
994 f[j_coord_offset+DIM*3+XX] -= tx;
995 f[j_coord_offset+DIM*3+YY] -= ty;
996 f[j_coord_offset+DIM*3+ZZ] -= tz;
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1007 /* REACTION-FIELD ELECTROSTATICS */
1008 felec = qq21*(rinv21*rinvsq21-krf2);
1012 /* Calculate temporary vectorial force */
1017 /* Update vectorial force */
1021 f[j_coord_offset+DIM*1+XX] -= tx;
1022 f[j_coord_offset+DIM*1+YY] -= ty;
1023 f[j_coord_offset+DIM*1+ZZ] -= tz;
1027 /**************************
1028 * CALCULATE INTERACTIONS *
1029 **************************/
1034 /* REACTION-FIELD ELECTROSTATICS */
1035 felec = qq22*(rinv22*rinvsq22-krf2);
1039 /* Calculate temporary vectorial force */
1044 /* Update vectorial force */
1048 f[j_coord_offset+DIM*2+XX] -= tx;
1049 f[j_coord_offset+DIM*2+YY] -= ty;
1050 f[j_coord_offset+DIM*2+ZZ] -= tz;
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1061 /* REACTION-FIELD ELECTROSTATICS */
1062 felec = qq23*(rinv23*rinvsq23-krf2);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*3+XX] -= tx;
1076 f[j_coord_offset+DIM*3+YY] -= ty;
1077 f[j_coord_offset+DIM*3+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1088 /* REACTION-FIELD ELECTROSTATICS */
1089 felec = qq31*(rinv31*rinvsq31-krf2);
1093 /* Calculate temporary vectorial force */
1098 /* Update vectorial force */
1102 f[j_coord_offset+DIM*1+XX] -= tx;
1103 f[j_coord_offset+DIM*1+YY] -= ty;
1104 f[j_coord_offset+DIM*1+ZZ] -= tz;
1108 /**************************
1109 * CALCULATE INTERACTIONS *
1110 **************************/
1115 /* REACTION-FIELD ELECTROSTATICS */
1116 felec = qq32*(rinv32*rinvsq32-krf2);
1120 /* Calculate temporary vectorial force */
1125 /* Update vectorial force */
1129 f[j_coord_offset+DIM*2+XX] -= tx;
1130 f[j_coord_offset+DIM*2+YY] -= ty;
1131 f[j_coord_offset+DIM*2+ZZ] -= tz;
1135 /**************************
1136 * CALCULATE INTERACTIONS *
1137 **************************/
1142 /* REACTION-FIELD ELECTROSTATICS */
1143 felec = qq33*(rinv33*rinvsq33-krf2);
1147 /* Calculate temporary vectorial force */
1152 /* Update vectorial force */
1156 f[j_coord_offset+DIM*3+XX] -= tx;
1157 f[j_coord_offset+DIM*3+YY] -= ty;
1158 f[j_coord_offset+DIM*3+ZZ] -= tz;
1162 /* Inner loop uses 292 flops */
1164 /* End of innermost loop */
1167 f[i_coord_offset+DIM*0+XX] += fix0;
1168 f[i_coord_offset+DIM*0+YY] += fiy0;
1169 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1173 f[i_coord_offset+DIM*1+XX] += fix1;
1174 f[i_coord_offset+DIM*1+YY] += fiy1;
1175 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1179 f[i_coord_offset+DIM*2+XX] += fix2;
1180 f[i_coord_offset+DIM*2+YY] += fiy2;
1181 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1185 f[i_coord_offset+DIM*3+XX] += fix3;
1186 f[i_coord_offset+DIM*3+YY] += fiy3;
1187 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1191 fshift[i_shift_offset+XX] += tx;
1192 fshift[i_shift_offset+YY] += ty;
1193 fshift[i_shift_offset+ZZ] += tz;
1195 /* Increment number of inner iterations */
1196 inneriter += j_index_end - j_index_start;
1198 /* Outer loop uses 39 flops */
1201 /* Increment number of outer iterations */
1204 /* Update outer/inner flops */
1206 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*292);