2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
97 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
111 charge = mdatoms->chargeA;
115 nvdwtype = fr->ntype;
117 vdwtype = mdatoms->typeA;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq0 = facel*charge[inr+0];
122 iq1 = facel*charge[inr+1];
123 iq2 = facel*charge[inr+2];
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
129 vdwjidx0 = 2*vdwtype[inr+0];
131 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
132 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
142 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
143 rcutoff = fr->rcoulomb;
144 rcutoff2 = rcutoff*rcutoff;
146 rswitch = fr->rvdw_switch;
147 /* Setup switch parameters */
149 swV3 = -10.0/(d*d*d);
150 swV4 = 15.0/(d*d*d*d);
151 swV5 = -6.0/(d*d*d*d*d);
152 swF2 = -30.0/(d*d*d);
153 swF3 = 60.0/(d*d*d*d);
154 swF4 = -30.0/(d*d*d*d*d);
159 /* Start outer loop over neighborlists */
160 for(iidx=0; iidx<nri; iidx++)
162 /* Load shift vector for this list */
163 i_shift_offset = DIM*shiftidx[iidx];
164 shX = shiftvec[i_shift_offset+XX];
165 shY = shiftvec[i_shift_offset+YY];
166 shZ = shiftvec[i_shift_offset+ZZ];
168 /* Load limits for loop over neighbors */
169 j_index_start = jindex[iidx];
170 j_index_end = jindex[iidx+1];
172 /* Get outer coordinate index */
174 i_coord_offset = DIM*inr;
176 /* Load i particle coords and add shift vector */
177 ix0 = shX + x[i_coord_offset+DIM*0+XX];
178 iy0 = shY + x[i_coord_offset+DIM*0+YY];
179 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
180 ix1 = shX + x[i_coord_offset+DIM*1+XX];
181 iy1 = shY + x[i_coord_offset+DIM*1+YY];
182 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
183 ix2 = shX + x[i_coord_offset+DIM*2+XX];
184 iy2 = shY + x[i_coord_offset+DIM*2+YY];
185 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
197 /* Reset potential sums */
201 /* Start inner kernel loop */
202 for(jidx=j_index_start; jidx<j_index_end; jidx++)
204 /* Get j neighbor index, and coordinate index */
206 j_coord_offset = DIM*jnr;
208 /* load j atom coordinates */
209 jx0 = x[j_coord_offset+DIM*0+XX];
210 jy0 = x[j_coord_offset+DIM*0+YY];
211 jz0 = x[j_coord_offset+DIM*0+ZZ];
212 jx1 = x[j_coord_offset+DIM*1+XX];
213 jy1 = x[j_coord_offset+DIM*1+YY];
214 jz1 = x[j_coord_offset+DIM*1+ZZ];
215 jx2 = x[j_coord_offset+DIM*2+XX];
216 jy2 = x[j_coord_offset+DIM*2+YY];
217 jz2 = x[j_coord_offset+DIM*2+ZZ];
219 /* Calculate displacement vector */
248 /* Calculate squared distance and things based on it */
249 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
250 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
251 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
252 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
253 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
254 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
255 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
256 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
257 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
259 rinv00 = gmx_invsqrt(rsq00);
260 rinv01 = gmx_invsqrt(rsq01);
261 rinv02 = gmx_invsqrt(rsq02);
262 rinv10 = gmx_invsqrt(rsq10);
263 rinv11 = gmx_invsqrt(rsq11);
264 rinv12 = gmx_invsqrt(rsq12);
265 rinv20 = gmx_invsqrt(rsq20);
266 rinv21 = gmx_invsqrt(rsq21);
267 rinv22 = gmx_invsqrt(rsq22);
269 rinvsq00 = rinv00*rinv00;
270 rinvsq01 = rinv01*rinv01;
271 rinvsq02 = rinv02*rinv02;
272 rinvsq10 = rinv10*rinv10;
273 rinvsq11 = rinv11*rinv11;
274 rinvsq12 = rinv12*rinv12;
275 rinvsq20 = rinv20*rinv20;
276 rinvsq21 = rinv21*rinv21;
277 rinvsq22 = rinv22*rinv22;
279 /**************************
280 * CALCULATE INTERACTIONS *
281 **************************/
288 /* REACTION-FIELD ELECTROSTATICS */
289 velec = qq00*(rinv00+krf*rsq00-crf);
290 felec = qq00*(rinv00*rinvsq00-krf2);
292 /* LENNARD-JONES DISPERSION/REPULSION */
294 rinvsix = rinvsq00*rinvsq00*rinvsq00;
295 vvdw6 = c6_00*rinvsix;
296 vvdw12 = c12_00*rinvsix*rinvsix;
297 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
298 fvdw = (vvdw12-vvdw6)*rinvsq00;
301 d = (d>0.0) ? d : 0.0;
303 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
305 dsw = d2*(swF2+d*(swF3+d*swF4));
307 /* Evaluate switch function */
308 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
309 fvdw = fvdw*sw - rinv00*vvdw*dsw;
312 /* Update potential sums from outer loop */
318 /* Calculate temporary vectorial force */
323 /* Update vectorial force */
327 f[j_coord_offset+DIM*0+XX] -= tx;
328 f[j_coord_offset+DIM*0+YY] -= ty;
329 f[j_coord_offset+DIM*0+ZZ] -= tz;
333 /**************************
334 * CALCULATE INTERACTIONS *
335 **************************/
340 /* REACTION-FIELD ELECTROSTATICS */
341 velec = qq01*(rinv01+krf*rsq01-crf);
342 felec = qq01*(rinv01*rinvsq01-krf2);
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*1+XX] -= tx;
359 f[j_coord_offset+DIM*1+YY] -= ty;
360 f[j_coord_offset+DIM*1+ZZ] -= tz;
364 /**************************
365 * CALCULATE INTERACTIONS *
366 **************************/
371 /* REACTION-FIELD ELECTROSTATICS */
372 velec = qq02*(rinv02+krf*rsq02-crf);
373 felec = qq02*(rinv02*rinvsq02-krf2);
375 /* Update potential sums from outer loop */
380 /* Calculate temporary vectorial force */
385 /* Update vectorial force */
389 f[j_coord_offset+DIM*2+XX] -= tx;
390 f[j_coord_offset+DIM*2+YY] -= ty;
391 f[j_coord_offset+DIM*2+ZZ] -= tz;
395 /**************************
396 * CALCULATE INTERACTIONS *
397 **************************/
402 /* REACTION-FIELD ELECTROSTATICS */
403 velec = qq10*(rinv10+krf*rsq10-crf);
404 felec = qq10*(rinv10*rinvsq10-krf2);
406 /* Update potential sums from outer loop */
411 /* Calculate temporary vectorial force */
416 /* Update vectorial force */
420 f[j_coord_offset+DIM*0+XX] -= tx;
421 f[j_coord_offset+DIM*0+YY] -= ty;
422 f[j_coord_offset+DIM*0+ZZ] -= tz;
426 /**************************
427 * CALCULATE INTERACTIONS *
428 **************************/
433 /* REACTION-FIELD ELECTROSTATICS */
434 velec = qq11*(rinv11+krf*rsq11-crf);
435 felec = qq11*(rinv11*rinvsq11-krf2);
437 /* Update potential sums from outer loop */
442 /* Calculate temporary vectorial force */
447 /* Update vectorial force */
451 f[j_coord_offset+DIM*1+XX] -= tx;
452 f[j_coord_offset+DIM*1+YY] -= ty;
453 f[j_coord_offset+DIM*1+ZZ] -= tz;
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
464 /* REACTION-FIELD ELECTROSTATICS */
465 velec = qq12*(rinv12+krf*rsq12-crf);
466 felec = qq12*(rinv12*rinvsq12-krf2);
468 /* Update potential sums from outer loop */
473 /* Calculate temporary vectorial force */
478 /* Update vectorial force */
482 f[j_coord_offset+DIM*2+XX] -= tx;
483 f[j_coord_offset+DIM*2+YY] -= ty;
484 f[j_coord_offset+DIM*2+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
495 /* REACTION-FIELD ELECTROSTATICS */
496 velec = qq20*(rinv20+krf*rsq20-crf);
497 felec = qq20*(rinv20*rinvsq20-krf2);
499 /* Update potential sums from outer loop */
504 /* Calculate temporary vectorial force */
509 /* Update vectorial force */
513 f[j_coord_offset+DIM*0+XX] -= tx;
514 f[j_coord_offset+DIM*0+YY] -= ty;
515 f[j_coord_offset+DIM*0+ZZ] -= tz;
519 /**************************
520 * CALCULATE INTERACTIONS *
521 **************************/
526 /* REACTION-FIELD ELECTROSTATICS */
527 velec = qq21*(rinv21+krf*rsq21-crf);
528 felec = qq21*(rinv21*rinvsq21-krf2);
530 /* Update potential sums from outer loop */
535 /* Calculate temporary vectorial force */
540 /* Update vectorial force */
544 f[j_coord_offset+DIM*1+XX] -= tx;
545 f[j_coord_offset+DIM*1+YY] -= ty;
546 f[j_coord_offset+DIM*1+ZZ] -= tz;
550 /**************************
551 * CALCULATE INTERACTIONS *
552 **************************/
557 /* REACTION-FIELD ELECTROSTATICS */
558 velec = qq22*(rinv22+krf*rsq22-crf);
559 felec = qq22*(rinv22*rinvsq22-krf2);
561 /* Update potential sums from outer loop */
566 /* Calculate temporary vectorial force */
571 /* Update vectorial force */
575 f[j_coord_offset+DIM*2+XX] -= tx;
576 f[j_coord_offset+DIM*2+YY] -= ty;
577 f[j_coord_offset+DIM*2+ZZ] -= tz;
581 /* Inner loop uses 310 flops */
583 /* End of innermost loop */
586 f[i_coord_offset+DIM*0+XX] += fix0;
587 f[i_coord_offset+DIM*0+YY] += fiy0;
588 f[i_coord_offset+DIM*0+ZZ] += fiz0;
592 f[i_coord_offset+DIM*1+XX] += fix1;
593 f[i_coord_offset+DIM*1+YY] += fiy1;
594 f[i_coord_offset+DIM*1+ZZ] += fiz1;
598 f[i_coord_offset+DIM*2+XX] += fix2;
599 f[i_coord_offset+DIM*2+YY] += fiy2;
600 f[i_coord_offset+DIM*2+ZZ] += fiz2;
604 fshift[i_shift_offset+XX] += tx;
605 fshift[i_shift_offset+YY] += ty;
606 fshift[i_shift_offset+ZZ] += tz;
609 /* Update potential energies */
610 kernel_data->energygrp_elec[ggid] += velecsum;
611 kernel_data->energygrp_vdw[ggid] += vvdwsum;
613 /* Increment number of inner iterations */
614 inneriter += j_index_end - j_index_start;
616 /* Outer loop uses 32 flops */
619 /* Increment number of outer iterations */
622 /* Update outer/inner flops */
624 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*310);
627 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_F_c
628 * Electrostatics interaction: ReactionField
629 * VdW interaction: LennardJones
630 * Geometry: Water3-Water3
631 * Calculate force/pot: Force
634 nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_F_c
635 (t_nblist * gmx_restrict nlist,
636 rvec * gmx_restrict xx,
637 rvec * gmx_restrict ff,
638 t_forcerec * gmx_restrict fr,
639 t_mdatoms * gmx_restrict mdatoms,
640 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
641 t_nrnb * gmx_restrict nrnb)
643 int i_shift_offset,i_coord_offset,j_coord_offset;
644 int j_index_start,j_index_end;
645 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
646 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
647 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
648 real *shiftvec,*fshift,*x,*f;
650 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
652 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
654 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
656 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
658 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
660 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
661 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
662 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
663 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
664 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
665 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
666 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
667 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
668 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
669 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
670 real velec,felec,velecsum,facel,crf,krf,krf2;
673 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
676 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
683 jindex = nlist->jindex;
685 shiftidx = nlist->shift;
687 shiftvec = fr->shift_vec[0];
688 fshift = fr->fshift[0];
690 charge = mdatoms->chargeA;
694 nvdwtype = fr->ntype;
696 vdwtype = mdatoms->typeA;
698 /* Setup water-specific parameters */
699 inr = nlist->iinr[0];
700 iq0 = facel*charge[inr+0];
701 iq1 = facel*charge[inr+1];
702 iq2 = facel*charge[inr+2];
703 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
708 vdwjidx0 = 2*vdwtype[inr+0];
710 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
711 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
721 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
722 rcutoff = fr->rcoulomb;
723 rcutoff2 = rcutoff*rcutoff;
725 rswitch = fr->rvdw_switch;
726 /* Setup switch parameters */
728 swV3 = -10.0/(d*d*d);
729 swV4 = 15.0/(d*d*d*d);
730 swV5 = -6.0/(d*d*d*d*d);
731 swF2 = -30.0/(d*d*d);
732 swF3 = 60.0/(d*d*d*d);
733 swF4 = -30.0/(d*d*d*d*d);
738 /* Start outer loop over neighborlists */
739 for(iidx=0; iidx<nri; iidx++)
741 /* Load shift vector for this list */
742 i_shift_offset = DIM*shiftidx[iidx];
743 shX = shiftvec[i_shift_offset+XX];
744 shY = shiftvec[i_shift_offset+YY];
745 shZ = shiftvec[i_shift_offset+ZZ];
747 /* Load limits for loop over neighbors */
748 j_index_start = jindex[iidx];
749 j_index_end = jindex[iidx+1];
751 /* Get outer coordinate index */
753 i_coord_offset = DIM*inr;
755 /* Load i particle coords and add shift vector */
756 ix0 = shX + x[i_coord_offset+DIM*0+XX];
757 iy0 = shY + x[i_coord_offset+DIM*0+YY];
758 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
759 ix1 = shX + x[i_coord_offset+DIM*1+XX];
760 iy1 = shY + x[i_coord_offset+DIM*1+YY];
761 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
762 ix2 = shX + x[i_coord_offset+DIM*2+XX];
763 iy2 = shY + x[i_coord_offset+DIM*2+YY];
764 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
776 /* Start inner kernel loop */
777 for(jidx=j_index_start; jidx<j_index_end; jidx++)
779 /* Get j neighbor index, and coordinate index */
781 j_coord_offset = DIM*jnr;
783 /* load j atom coordinates */
784 jx0 = x[j_coord_offset+DIM*0+XX];
785 jy0 = x[j_coord_offset+DIM*0+YY];
786 jz0 = x[j_coord_offset+DIM*0+ZZ];
787 jx1 = x[j_coord_offset+DIM*1+XX];
788 jy1 = x[j_coord_offset+DIM*1+YY];
789 jz1 = x[j_coord_offset+DIM*1+ZZ];
790 jx2 = x[j_coord_offset+DIM*2+XX];
791 jy2 = x[j_coord_offset+DIM*2+YY];
792 jz2 = x[j_coord_offset+DIM*2+ZZ];
794 /* Calculate displacement vector */
823 /* Calculate squared distance and things based on it */
824 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
825 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
826 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
827 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
828 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
829 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
830 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
831 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
832 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
834 rinv00 = gmx_invsqrt(rsq00);
835 rinv01 = gmx_invsqrt(rsq01);
836 rinv02 = gmx_invsqrt(rsq02);
837 rinv10 = gmx_invsqrt(rsq10);
838 rinv11 = gmx_invsqrt(rsq11);
839 rinv12 = gmx_invsqrt(rsq12);
840 rinv20 = gmx_invsqrt(rsq20);
841 rinv21 = gmx_invsqrt(rsq21);
842 rinv22 = gmx_invsqrt(rsq22);
844 rinvsq00 = rinv00*rinv00;
845 rinvsq01 = rinv01*rinv01;
846 rinvsq02 = rinv02*rinv02;
847 rinvsq10 = rinv10*rinv10;
848 rinvsq11 = rinv11*rinv11;
849 rinvsq12 = rinv12*rinv12;
850 rinvsq20 = rinv20*rinv20;
851 rinvsq21 = rinv21*rinv21;
852 rinvsq22 = rinv22*rinv22;
854 /**************************
855 * CALCULATE INTERACTIONS *
856 **************************/
863 /* REACTION-FIELD ELECTROSTATICS */
864 felec = qq00*(rinv00*rinvsq00-krf2);
866 /* LENNARD-JONES DISPERSION/REPULSION */
868 rinvsix = rinvsq00*rinvsq00*rinvsq00;
869 vvdw6 = c6_00*rinvsix;
870 vvdw12 = c12_00*rinvsix*rinvsix;
871 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
872 fvdw = (vvdw12-vvdw6)*rinvsq00;
875 d = (d>0.0) ? d : 0.0;
877 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
879 dsw = d2*(swF2+d*(swF3+d*swF4));
881 /* Evaluate switch function */
882 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
883 fvdw = fvdw*sw - rinv00*vvdw*dsw;
887 /* Calculate temporary vectorial force */
892 /* Update vectorial force */
896 f[j_coord_offset+DIM*0+XX] -= tx;
897 f[j_coord_offset+DIM*0+YY] -= ty;
898 f[j_coord_offset+DIM*0+ZZ] -= tz;
902 /**************************
903 * CALCULATE INTERACTIONS *
904 **************************/
909 /* REACTION-FIELD ELECTROSTATICS */
910 felec = qq01*(rinv01*rinvsq01-krf2);
914 /* Calculate temporary vectorial force */
919 /* Update vectorial force */
923 f[j_coord_offset+DIM*1+XX] -= tx;
924 f[j_coord_offset+DIM*1+YY] -= ty;
925 f[j_coord_offset+DIM*1+ZZ] -= tz;
929 /**************************
930 * CALCULATE INTERACTIONS *
931 **************************/
936 /* REACTION-FIELD ELECTROSTATICS */
937 felec = qq02*(rinv02*rinvsq02-krf2);
941 /* Calculate temporary vectorial force */
946 /* Update vectorial force */
950 f[j_coord_offset+DIM*2+XX] -= tx;
951 f[j_coord_offset+DIM*2+YY] -= ty;
952 f[j_coord_offset+DIM*2+ZZ] -= tz;
956 /**************************
957 * CALCULATE INTERACTIONS *
958 **************************/
963 /* REACTION-FIELD ELECTROSTATICS */
964 felec = qq10*(rinv10*rinvsq10-krf2);
968 /* Calculate temporary vectorial force */
973 /* Update vectorial force */
977 f[j_coord_offset+DIM*0+XX] -= tx;
978 f[j_coord_offset+DIM*0+YY] -= ty;
979 f[j_coord_offset+DIM*0+ZZ] -= tz;
983 /**************************
984 * CALCULATE INTERACTIONS *
985 **************************/
990 /* REACTION-FIELD ELECTROSTATICS */
991 felec = qq11*(rinv11*rinvsq11-krf2);
995 /* Calculate temporary vectorial force */
1000 /* Update vectorial force */
1004 f[j_coord_offset+DIM*1+XX] -= tx;
1005 f[j_coord_offset+DIM*1+YY] -= ty;
1006 f[j_coord_offset+DIM*1+ZZ] -= tz;
1010 /**************************
1011 * CALCULATE INTERACTIONS *
1012 **************************/
1017 /* REACTION-FIELD ELECTROSTATICS */
1018 felec = qq12*(rinv12*rinvsq12-krf2);
1022 /* Calculate temporary vectorial force */
1027 /* Update vectorial force */
1031 f[j_coord_offset+DIM*2+XX] -= tx;
1032 f[j_coord_offset+DIM*2+YY] -= ty;
1033 f[j_coord_offset+DIM*2+ZZ] -= tz;
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1044 /* REACTION-FIELD ELECTROSTATICS */
1045 felec = qq20*(rinv20*rinvsq20-krf2);
1049 /* Calculate temporary vectorial force */
1054 /* Update vectorial force */
1058 f[j_coord_offset+DIM*0+XX] -= tx;
1059 f[j_coord_offset+DIM*0+YY] -= ty;
1060 f[j_coord_offset+DIM*0+ZZ] -= tz;
1064 /**************************
1065 * CALCULATE INTERACTIONS *
1066 **************************/
1071 /* REACTION-FIELD ELECTROSTATICS */
1072 felec = qq21*(rinv21*rinvsq21-krf2);
1076 /* Calculate temporary vectorial force */
1081 /* Update vectorial force */
1085 f[j_coord_offset+DIM*1+XX] -= tx;
1086 f[j_coord_offset+DIM*1+YY] -= ty;
1087 f[j_coord_offset+DIM*1+ZZ] -= tz;
1091 /**************************
1092 * CALCULATE INTERACTIONS *
1093 **************************/
1098 /* REACTION-FIELD ELECTROSTATICS */
1099 felec = qq22*(rinv22*rinvsq22-krf2);
1103 /* Calculate temporary vectorial force */
1108 /* Update vectorial force */
1112 f[j_coord_offset+DIM*2+XX] -= tx;
1113 f[j_coord_offset+DIM*2+YY] -= ty;
1114 f[j_coord_offset+DIM*2+ZZ] -= tz;
1118 /* Inner loop uses 263 flops */
1120 /* End of innermost loop */
1123 f[i_coord_offset+DIM*0+XX] += fix0;
1124 f[i_coord_offset+DIM*0+YY] += fiy0;
1125 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1129 f[i_coord_offset+DIM*1+XX] += fix1;
1130 f[i_coord_offset+DIM*1+YY] += fiy1;
1131 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1135 f[i_coord_offset+DIM*2+XX] += fix2;
1136 f[i_coord_offset+DIM*2+YY] += fiy2;
1137 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1141 fshift[i_shift_offset+XX] += tx;
1142 fshift[i_shift_offset+YY] += ty;
1143 fshift[i_shift_offset+ZZ] += tz;
1145 /* Increment number of inner iterations */
1146 inneriter += j_index_end - j_index_start;
1148 /* Outer loop uses 30 flops */
1151 /* Increment number of outer iterations */
1154 /* Update outer/inner flops */
1156 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*263);