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_VdwLJSh_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwLJSh_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 = 2*nvdwtype*vdwtype[inr+0];
119 vdwjidx0 = 2*vdwtype[inr+0];
120 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
121 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
132 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
133 rcutoff = fr->rcoulomb;
134 rcutoff2 = rcutoff*rcutoff;
136 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
142 /* Start outer loop over neighborlists */
143 for(iidx=0; iidx<nri; iidx++)
145 /* Load shift vector for this list */
146 i_shift_offset = DIM*shiftidx[iidx];
147 shX = shiftvec[i_shift_offset+XX];
148 shY = shiftvec[i_shift_offset+YY];
149 shZ = shiftvec[i_shift_offset+ZZ];
151 /* Load limits for loop over neighbors */
152 j_index_start = jindex[iidx];
153 j_index_end = jindex[iidx+1];
155 /* Get outer coordinate index */
157 i_coord_offset = DIM*inr;
159 /* Load i particle coords and add shift vector */
160 ix0 = shX + x[i_coord_offset+DIM*0+XX];
161 iy0 = shY + x[i_coord_offset+DIM*0+YY];
162 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
163 ix1 = shX + x[i_coord_offset+DIM*1+XX];
164 iy1 = shY + x[i_coord_offset+DIM*1+YY];
165 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
166 ix2 = shX + x[i_coord_offset+DIM*2+XX];
167 iy2 = shY + x[i_coord_offset+DIM*2+YY];
168 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
169 ix3 = shX + x[i_coord_offset+DIM*3+XX];
170 iy3 = shY + x[i_coord_offset+DIM*3+YY];
171 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
186 /* Reset potential sums */
190 /* Start inner kernel loop */
191 for(jidx=j_index_start; jidx<j_index_end; jidx++)
193 /* Get j neighbor index, and coordinate index */
195 j_coord_offset = DIM*jnr;
197 /* load j atom coordinates */
198 jx0 = x[j_coord_offset+DIM*0+XX];
199 jy0 = x[j_coord_offset+DIM*0+YY];
200 jz0 = x[j_coord_offset+DIM*0+ZZ];
201 jx1 = x[j_coord_offset+DIM*1+XX];
202 jy1 = x[j_coord_offset+DIM*1+YY];
203 jz1 = x[j_coord_offset+DIM*1+ZZ];
204 jx2 = x[j_coord_offset+DIM*2+XX];
205 jy2 = x[j_coord_offset+DIM*2+YY];
206 jz2 = x[j_coord_offset+DIM*2+ZZ];
207 jx3 = x[j_coord_offset+DIM*3+XX];
208 jy3 = x[j_coord_offset+DIM*3+YY];
209 jz3 = x[j_coord_offset+DIM*3+ZZ];
211 /* Calculate displacement vector */
243 /* Calculate squared distance and things based on it */
244 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
245 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
246 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
247 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
248 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
249 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
250 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
251 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
252 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
253 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
255 rinv11 = gmx_invsqrt(rsq11);
256 rinv12 = gmx_invsqrt(rsq12);
257 rinv13 = gmx_invsqrt(rsq13);
258 rinv21 = gmx_invsqrt(rsq21);
259 rinv22 = gmx_invsqrt(rsq22);
260 rinv23 = gmx_invsqrt(rsq23);
261 rinv31 = gmx_invsqrt(rsq31);
262 rinv32 = gmx_invsqrt(rsq32);
263 rinv33 = gmx_invsqrt(rsq33);
265 rinvsq00 = 1.0/rsq00;
266 rinvsq11 = rinv11*rinv11;
267 rinvsq12 = rinv12*rinv12;
268 rinvsq13 = rinv13*rinv13;
269 rinvsq21 = rinv21*rinv21;
270 rinvsq22 = rinv22*rinv22;
271 rinvsq23 = rinv23*rinv23;
272 rinvsq31 = rinv31*rinv31;
273 rinvsq32 = rinv32*rinv32;
274 rinvsq33 = rinv33*rinv33;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
283 /* LENNARD-JONES DISPERSION/REPULSION */
285 rinvsix = rinvsq00*rinvsq00*rinvsq00;
286 vvdw6 = c6_00*rinvsix;
287 vvdw12 = c12_00*rinvsix*rinvsix;
288 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
289 fvdw = (vvdw12-vvdw6)*rinvsq00;
291 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
318 /* REACTION-FIELD ELECTROSTATICS */
319 velec = qq11*(rinv11+krf*rsq11-crf);
320 felec = qq11*(rinv11*rinvsq11-krf2);
322 /* Update potential sums from outer loop */
327 /* Calculate temporary vectorial force */
332 /* Update vectorial force */
336 f[j_coord_offset+DIM*1+XX] -= tx;
337 f[j_coord_offset+DIM*1+YY] -= ty;
338 f[j_coord_offset+DIM*1+ZZ] -= tz;
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
349 /* REACTION-FIELD ELECTROSTATICS */
350 velec = qq12*(rinv12+krf*rsq12-crf);
351 felec = qq12*(rinv12*rinvsq12-krf2);
353 /* Update potential sums from outer loop */
358 /* Calculate temporary vectorial force */
363 /* Update vectorial force */
367 f[j_coord_offset+DIM*2+XX] -= tx;
368 f[j_coord_offset+DIM*2+YY] -= ty;
369 f[j_coord_offset+DIM*2+ZZ] -= tz;
373 /**************************
374 * CALCULATE INTERACTIONS *
375 **************************/
380 /* REACTION-FIELD ELECTROSTATICS */
381 velec = qq13*(rinv13+krf*rsq13-crf);
382 felec = qq13*(rinv13*rinvsq13-krf2);
384 /* Update potential sums from outer loop */
389 /* Calculate temporary vectorial force */
394 /* Update vectorial force */
398 f[j_coord_offset+DIM*3+XX] -= tx;
399 f[j_coord_offset+DIM*3+YY] -= ty;
400 f[j_coord_offset+DIM*3+ZZ] -= tz;
404 /**************************
405 * CALCULATE INTERACTIONS *
406 **************************/
411 /* REACTION-FIELD ELECTROSTATICS */
412 velec = qq21*(rinv21+krf*rsq21-crf);
413 felec = qq21*(rinv21*rinvsq21-krf2);
415 /* Update potential sums from outer loop */
420 /* Calculate temporary vectorial force */
425 /* Update vectorial force */
429 f[j_coord_offset+DIM*1+XX] -= tx;
430 f[j_coord_offset+DIM*1+YY] -= ty;
431 f[j_coord_offset+DIM*1+ZZ] -= tz;
435 /**************************
436 * CALCULATE INTERACTIONS *
437 **************************/
442 /* REACTION-FIELD ELECTROSTATICS */
443 velec = qq22*(rinv22+krf*rsq22-crf);
444 felec = qq22*(rinv22*rinvsq22-krf2);
446 /* Update potential sums from outer loop */
451 /* Calculate temporary vectorial force */
456 /* Update vectorial force */
460 f[j_coord_offset+DIM*2+XX] -= tx;
461 f[j_coord_offset+DIM*2+YY] -= ty;
462 f[j_coord_offset+DIM*2+ZZ] -= tz;
466 /**************************
467 * CALCULATE INTERACTIONS *
468 **************************/
473 /* REACTION-FIELD ELECTROSTATICS */
474 velec = qq23*(rinv23+krf*rsq23-crf);
475 felec = qq23*(rinv23*rinvsq23-krf2);
477 /* Update potential sums from outer loop */
482 /* Calculate temporary vectorial force */
487 /* Update vectorial force */
491 f[j_coord_offset+DIM*3+XX] -= tx;
492 f[j_coord_offset+DIM*3+YY] -= ty;
493 f[j_coord_offset+DIM*3+ZZ] -= tz;
497 /**************************
498 * CALCULATE INTERACTIONS *
499 **************************/
504 /* REACTION-FIELD ELECTROSTATICS */
505 velec = qq31*(rinv31+krf*rsq31-crf);
506 felec = qq31*(rinv31*rinvsq31-krf2);
508 /* Update potential sums from outer loop */
513 /* Calculate temporary vectorial force */
518 /* Update vectorial force */
522 f[j_coord_offset+DIM*1+XX] -= tx;
523 f[j_coord_offset+DIM*1+YY] -= ty;
524 f[j_coord_offset+DIM*1+ZZ] -= tz;
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
535 /* REACTION-FIELD ELECTROSTATICS */
536 velec = qq32*(rinv32+krf*rsq32-crf);
537 felec = qq32*(rinv32*rinvsq32-krf2);
539 /* Update potential sums from outer loop */
544 /* Calculate temporary vectorial force */
549 /* Update vectorial force */
553 f[j_coord_offset+DIM*2+XX] -= tx;
554 f[j_coord_offset+DIM*2+YY] -= ty;
555 f[j_coord_offset+DIM*2+ZZ] -= tz;
559 /**************************
560 * CALCULATE INTERACTIONS *
561 **************************/
566 /* REACTION-FIELD ELECTROSTATICS */
567 velec = qq33*(rinv33+krf*rsq33-crf);
568 felec = qq33*(rinv33*rinvsq33-krf2);
570 /* Update potential sums from outer loop */
575 /* Calculate temporary vectorial force */
580 /* Update vectorial force */
584 f[j_coord_offset+DIM*3+XX] -= tx;
585 f[j_coord_offset+DIM*3+YY] -= ty;
586 f[j_coord_offset+DIM*3+ZZ] -= tz;
590 /* Inner loop uses 316 flops */
592 /* End of innermost loop */
595 f[i_coord_offset+DIM*0+XX] += fix0;
596 f[i_coord_offset+DIM*0+YY] += fiy0;
597 f[i_coord_offset+DIM*0+ZZ] += fiz0;
601 f[i_coord_offset+DIM*1+XX] += fix1;
602 f[i_coord_offset+DIM*1+YY] += fiy1;
603 f[i_coord_offset+DIM*1+ZZ] += fiz1;
607 f[i_coord_offset+DIM*2+XX] += fix2;
608 f[i_coord_offset+DIM*2+YY] += fiy2;
609 f[i_coord_offset+DIM*2+ZZ] += fiz2;
613 f[i_coord_offset+DIM*3+XX] += fix3;
614 f[i_coord_offset+DIM*3+YY] += fiy3;
615 f[i_coord_offset+DIM*3+ZZ] += fiz3;
619 fshift[i_shift_offset+XX] += tx;
620 fshift[i_shift_offset+YY] += ty;
621 fshift[i_shift_offset+ZZ] += tz;
624 /* Update potential energies */
625 kernel_data->energygrp_elec[ggid] += velecsum;
626 kernel_data->energygrp_vdw[ggid] += vvdwsum;
628 /* Increment number of inner iterations */
629 inneriter += j_index_end - j_index_start;
631 /* Outer loop uses 41 flops */
634 /* Increment number of outer iterations */
637 /* Update outer/inner flops */
639 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*316);
642 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_c
643 * Electrostatics interaction: ReactionField
644 * VdW interaction: LennardJones
645 * Geometry: Water4-Water4
646 * Calculate force/pot: Force
649 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_c
650 (t_nblist * gmx_restrict nlist,
651 rvec * gmx_restrict xx,
652 rvec * gmx_restrict ff,
653 t_forcerec * gmx_restrict fr,
654 t_mdatoms * gmx_restrict mdatoms,
655 nb_kernel_data_t * gmx_restrict kernel_data,
656 t_nrnb * gmx_restrict nrnb)
658 int i_shift_offset,i_coord_offset,j_coord_offset;
659 int j_index_start,j_index_end;
660 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
661 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
662 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
663 real *shiftvec,*fshift,*x,*f;
665 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
667 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
669 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
671 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
673 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
675 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
677 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
679 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
680 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
681 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
682 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
683 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
684 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
685 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
686 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
687 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
688 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
689 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
690 real velec,felec,velecsum,facel,crf,krf,krf2;
693 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
702 jindex = nlist->jindex;
704 shiftidx = nlist->shift;
706 shiftvec = fr->shift_vec[0];
707 fshift = fr->fshift[0];
709 charge = mdatoms->chargeA;
713 nvdwtype = fr->ntype;
715 vdwtype = mdatoms->typeA;
717 /* Setup water-specific parameters */
718 inr = nlist->iinr[0];
719 iq1 = facel*charge[inr+1];
720 iq2 = facel*charge[inr+2];
721 iq3 = facel*charge[inr+3];
722 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
727 vdwjidx0 = 2*vdwtype[inr+0];
728 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
729 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
740 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
741 rcutoff = fr->rcoulomb;
742 rcutoff2 = rcutoff*rcutoff;
744 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
750 /* Start outer loop over neighborlists */
751 for(iidx=0; iidx<nri; iidx++)
753 /* Load shift vector for this list */
754 i_shift_offset = DIM*shiftidx[iidx];
755 shX = shiftvec[i_shift_offset+XX];
756 shY = shiftvec[i_shift_offset+YY];
757 shZ = shiftvec[i_shift_offset+ZZ];
759 /* Load limits for loop over neighbors */
760 j_index_start = jindex[iidx];
761 j_index_end = jindex[iidx+1];
763 /* Get outer coordinate index */
765 i_coord_offset = DIM*inr;
767 /* Load i particle coords and add shift vector */
768 ix0 = shX + x[i_coord_offset+DIM*0+XX];
769 iy0 = shY + x[i_coord_offset+DIM*0+YY];
770 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
771 ix1 = shX + x[i_coord_offset+DIM*1+XX];
772 iy1 = shY + x[i_coord_offset+DIM*1+YY];
773 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
774 ix2 = shX + x[i_coord_offset+DIM*2+XX];
775 iy2 = shY + x[i_coord_offset+DIM*2+YY];
776 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
777 ix3 = shX + x[i_coord_offset+DIM*3+XX];
778 iy3 = shY + x[i_coord_offset+DIM*3+YY];
779 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
794 /* Start inner kernel loop */
795 for(jidx=j_index_start; jidx<j_index_end; jidx++)
797 /* Get j neighbor index, and coordinate index */
799 j_coord_offset = DIM*jnr;
801 /* load j atom coordinates */
802 jx0 = x[j_coord_offset+DIM*0+XX];
803 jy0 = x[j_coord_offset+DIM*0+YY];
804 jz0 = x[j_coord_offset+DIM*0+ZZ];
805 jx1 = x[j_coord_offset+DIM*1+XX];
806 jy1 = x[j_coord_offset+DIM*1+YY];
807 jz1 = x[j_coord_offset+DIM*1+ZZ];
808 jx2 = x[j_coord_offset+DIM*2+XX];
809 jy2 = x[j_coord_offset+DIM*2+YY];
810 jz2 = x[j_coord_offset+DIM*2+ZZ];
811 jx3 = x[j_coord_offset+DIM*3+XX];
812 jy3 = x[j_coord_offset+DIM*3+YY];
813 jz3 = x[j_coord_offset+DIM*3+ZZ];
815 /* Calculate displacement vector */
847 /* Calculate squared distance and things based on it */
848 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
849 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
850 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
851 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
852 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
853 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
854 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
855 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
856 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
857 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
859 rinv11 = gmx_invsqrt(rsq11);
860 rinv12 = gmx_invsqrt(rsq12);
861 rinv13 = gmx_invsqrt(rsq13);
862 rinv21 = gmx_invsqrt(rsq21);
863 rinv22 = gmx_invsqrt(rsq22);
864 rinv23 = gmx_invsqrt(rsq23);
865 rinv31 = gmx_invsqrt(rsq31);
866 rinv32 = gmx_invsqrt(rsq32);
867 rinv33 = gmx_invsqrt(rsq33);
869 rinvsq00 = 1.0/rsq00;
870 rinvsq11 = rinv11*rinv11;
871 rinvsq12 = rinv12*rinv12;
872 rinvsq13 = rinv13*rinv13;
873 rinvsq21 = rinv21*rinv21;
874 rinvsq22 = rinv22*rinv22;
875 rinvsq23 = rinv23*rinv23;
876 rinvsq31 = rinv31*rinv31;
877 rinvsq32 = rinv32*rinv32;
878 rinvsq33 = rinv33*rinv33;
880 /**************************
881 * CALCULATE INTERACTIONS *
882 **************************/
887 /* LENNARD-JONES DISPERSION/REPULSION */
889 rinvsix = rinvsq00*rinvsq00*rinvsq00;
890 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
894 /* Calculate temporary vectorial force */
899 /* Update vectorial force */
903 f[j_coord_offset+DIM*0+XX] -= tx;
904 f[j_coord_offset+DIM*0+YY] -= ty;
905 f[j_coord_offset+DIM*0+ZZ] -= tz;
909 /**************************
910 * CALCULATE INTERACTIONS *
911 **************************/
916 /* REACTION-FIELD ELECTROSTATICS */
917 felec = qq11*(rinv11*rinvsq11-krf2);
921 /* Calculate temporary vectorial force */
926 /* Update vectorial force */
930 f[j_coord_offset+DIM*1+XX] -= tx;
931 f[j_coord_offset+DIM*1+YY] -= ty;
932 f[j_coord_offset+DIM*1+ZZ] -= tz;
936 /**************************
937 * CALCULATE INTERACTIONS *
938 **************************/
943 /* REACTION-FIELD ELECTROSTATICS */
944 felec = qq12*(rinv12*rinvsq12-krf2);
948 /* Calculate temporary vectorial force */
953 /* Update vectorial force */
957 f[j_coord_offset+DIM*2+XX] -= tx;
958 f[j_coord_offset+DIM*2+YY] -= ty;
959 f[j_coord_offset+DIM*2+ZZ] -= tz;
963 /**************************
964 * CALCULATE INTERACTIONS *
965 **************************/
970 /* REACTION-FIELD ELECTROSTATICS */
971 felec = qq13*(rinv13*rinvsq13-krf2);
975 /* Calculate temporary vectorial force */
980 /* Update vectorial force */
984 f[j_coord_offset+DIM*3+XX] -= tx;
985 f[j_coord_offset+DIM*3+YY] -= ty;
986 f[j_coord_offset+DIM*3+ZZ] -= tz;
990 /**************************
991 * CALCULATE INTERACTIONS *
992 **************************/
997 /* REACTION-FIELD ELECTROSTATICS */
998 felec = qq21*(rinv21*rinvsq21-krf2);
1002 /* Calculate temporary vectorial force */
1007 /* Update vectorial force */
1011 f[j_coord_offset+DIM*1+XX] -= tx;
1012 f[j_coord_offset+DIM*1+YY] -= ty;
1013 f[j_coord_offset+DIM*1+ZZ] -= tz;
1017 /**************************
1018 * CALCULATE INTERACTIONS *
1019 **************************/
1024 /* REACTION-FIELD ELECTROSTATICS */
1025 felec = qq22*(rinv22*rinvsq22-krf2);
1029 /* Calculate temporary vectorial force */
1034 /* Update vectorial force */
1038 f[j_coord_offset+DIM*2+XX] -= tx;
1039 f[j_coord_offset+DIM*2+YY] -= ty;
1040 f[j_coord_offset+DIM*2+ZZ] -= tz;
1044 /**************************
1045 * CALCULATE INTERACTIONS *
1046 **************************/
1051 /* REACTION-FIELD ELECTROSTATICS */
1052 felec = qq23*(rinv23*rinvsq23-krf2);
1056 /* Calculate temporary vectorial force */
1061 /* Update vectorial force */
1065 f[j_coord_offset+DIM*3+XX] -= tx;
1066 f[j_coord_offset+DIM*3+YY] -= ty;
1067 f[j_coord_offset+DIM*3+ZZ] -= tz;
1071 /**************************
1072 * CALCULATE INTERACTIONS *
1073 **************************/
1078 /* REACTION-FIELD ELECTROSTATICS */
1079 felec = qq31*(rinv31*rinvsq31-krf2);
1083 /* Calculate temporary vectorial force */
1088 /* Update vectorial force */
1092 f[j_coord_offset+DIM*1+XX] -= tx;
1093 f[j_coord_offset+DIM*1+YY] -= ty;
1094 f[j_coord_offset+DIM*1+ZZ] -= tz;
1098 /**************************
1099 * CALCULATE INTERACTIONS *
1100 **************************/
1105 /* REACTION-FIELD ELECTROSTATICS */
1106 felec = qq32*(rinv32*rinvsq32-krf2);
1110 /* Calculate temporary vectorial force */
1115 /* Update vectorial force */
1119 f[j_coord_offset+DIM*2+XX] -= tx;
1120 f[j_coord_offset+DIM*2+YY] -= ty;
1121 f[j_coord_offset+DIM*2+ZZ] -= tz;
1125 /**************************
1126 * CALCULATE INTERACTIONS *
1127 **************************/
1132 /* REACTION-FIELD ELECTROSTATICS */
1133 felec = qq33*(rinv33*rinvsq33-krf2);
1137 /* Calculate temporary vectorial force */
1142 /* Update vectorial force */
1146 f[j_coord_offset+DIM*3+XX] -= tx;
1147 f[j_coord_offset+DIM*3+YY] -= ty;
1148 f[j_coord_offset+DIM*3+ZZ] -= tz;
1152 /* Inner loop uses 261 flops */
1154 /* End of innermost loop */
1157 f[i_coord_offset+DIM*0+XX] += fix0;
1158 f[i_coord_offset+DIM*0+YY] += fiy0;
1159 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1163 f[i_coord_offset+DIM*1+XX] += fix1;
1164 f[i_coord_offset+DIM*1+YY] += fiy1;
1165 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1169 f[i_coord_offset+DIM*2+XX] += fix2;
1170 f[i_coord_offset+DIM*2+YY] += fiy2;
1171 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1175 f[i_coord_offset+DIM*3+XX] += fix3;
1176 f[i_coord_offset+DIM*3+YY] += fiy3;
1177 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1181 fshift[i_shift_offset+XX] += tx;
1182 fshift[i_shift_offset+YY] += ty;
1183 fshift[i_shift_offset+ZZ] += tz;
1185 /* Increment number of inner iterations */
1186 inneriter += j_index_end - j_index_start;
1188 /* Outer loop uses 39 flops */
1191 /* Increment number of outer iterations */
1194 /* Update outer/inner flops */
1196 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*261);