2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * 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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
99 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
113 charge = mdatoms->chargeA;
117 nvdwtype = fr->ntype;
119 vdwtype = mdatoms->typeA;
121 /* Setup water-specific parameters */
122 inr = nlist->iinr[0];
123 iq0 = facel*charge[inr+0];
124 iq1 = facel*charge[inr+1];
125 iq2 = facel*charge[inr+2];
126 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
131 vdwjidx0 = 2*vdwtype[inr+0];
133 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
134 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
144 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
145 rcutoff = fr->rcoulomb;
146 rcutoff2 = rcutoff*rcutoff;
148 rswitch = fr->rvdw_switch;
149 /* Setup switch parameters */
151 swV3 = -10.0/(d*d*d);
152 swV4 = 15.0/(d*d*d*d);
153 swV5 = -6.0/(d*d*d*d*d);
154 swF2 = -30.0/(d*d*d);
155 swF3 = 60.0/(d*d*d*d);
156 swF4 = -30.0/(d*d*d*d*d);
161 /* Start outer loop over neighborlists */
162 for(iidx=0; iidx<nri; iidx++)
164 /* Load shift vector for this list */
165 i_shift_offset = DIM*shiftidx[iidx];
166 shX = shiftvec[i_shift_offset+XX];
167 shY = shiftvec[i_shift_offset+YY];
168 shZ = shiftvec[i_shift_offset+ZZ];
170 /* Load limits for loop over neighbors */
171 j_index_start = jindex[iidx];
172 j_index_end = jindex[iidx+1];
174 /* Get outer coordinate index */
176 i_coord_offset = DIM*inr;
178 /* Load i particle coords and add shift vector */
179 ix0 = shX + x[i_coord_offset+DIM*0+XX];
180 iy0 = shY + x[i_coord_offset+DIM*0+YY];
181 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
182 ix1 = shX + x[i_coord_offset+DIM*1+XX];
183 iy1 = shY + x[i_coord_offset+DIM*1+YY];
184 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
185 ix2 = shX + x[i_coord_offset+DIM*2+XX];
186 iy2 = shY + x[i_coord_offset+DIM*2+YY];
187 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
199 /* Reset potential sums */
203 /* Start inner kernel loop */
204 for(jidx=j_index_start; jidx<j_index_end; jidx++)
206 /* Get j neighbor index, and coordinate index */
208 j_coord_offset = DIM*jnr;
210 /* load j atom coordinates */
211 jx0 = x[j_coord_offset+DIM*0+XX];
212 jy0 = x[j_coord_offset+DIM*0+YY];
213 jz0 = x[j_coord_offset+DIM*0+ZZ];
214 jx1 = x[j_coord_offset+DIM*1+XX];
215 jy1 = x[j_coord_offset+DIM*1+YY];
216 jz1 = x[j_coord_offset+DIM*1+ZZ];
217 jx2 = x[j_coord_offset+DIM*2+XX];
218 jy2 = x[j_coord_offset+DIM*2+YY];
219 jz2 = x[j_coord_offset+DIM*2+ZZ];
221 /* Calculate displacement vector */
250 /* Calculate squared distance and things based on it */
251 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
252 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
253 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
254 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
255 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
256 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
257 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
258 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
259 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
261 rinv00 = gmx_invsqrt(rsq00);
262 rinv01 = gmx_invsqrt(rsq01);
263 rinv02 = gmx_invsqrt(rsq02);
264 rinv10 = gmx_invsqrt(rsq10);
265 rinv11 = gmx_invsqrt(rsq11);
266 rinv12 = gmx_invsqrt(rsq12);
267 rinv20 = gmx_invsqrt(rsq20);
268 rinv21 = gmx_invsqrt(rsq21);
269 rinv22 = gmx_invsqrt(rsq22);
271 rinvsq00 = rinv00*rinv00;
272 rinvsq01 = rinv01*rinv01;
273 rinvsq02 = rinv02*rinv02;
274 rinvsq10 = rinv10*rinv10;
275 rinvsq11 = rinv11*rinv11;
276 rinvsq12 = rinv12*rinv12;
277 rinvsq20 = rinv20*rinv20;
278 rinvsq21 = rinv21*rinv21;
279 rinvsq22 = rinv22*rinv22;
281 /**************************
282 * CALCULATE INTERACTIONS *
283 **************************/
290 /* REACTION-FIELD ELECTROSTATICS */
291 velec = qq00*(rinv00+krf*rsq00-crf);
292 felec = qq00*(rinv00*rinvsq00-krf2);
294 /* LENNARD-JONES DISPERSION/REPULSION */
296 rinvsix = rinvsq00*rinvsq00*rinvsq00;
297 vvdw6 = c6_00*rinvsix;
298 vvdw12 = c12_00*rinvsix*rinvsix;
299 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
300 fvdw = (vvdw12-vvdw6)*rinvsq00;
303 d = (d>0.0) ? d : 0.0;
305 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
307 dsw = d2*(swF2+d*(swF3+d*swF4));
309 /* Evaluate switch function */
310 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
311 fvdw = fvdw*sw - rinv00*vvdw*dsw;
314 /* Update potential sums from outer loop */
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 = qq01*(rinv01+krf*rsq01-crf);
344 felec = qq01*(rinv01*rinvsq01-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 = qq02*(rinv02+krf*rsq02-crf);
375 felec = qq02*(rinv02*rinvsq02-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 = qq10*(rinv10+krf*rsq10-crf);
406 felec = qq10*(rinv10*rinvsq10-krf2);
408 /* Update potential sums from outer loop */
413 /* Calculate temporary vectorial force */
418 /* Update vectorial force */
422 f[j_coord_offset+DIM*0+XX] -= tx;
423 f[j_coord_offset+DIM*0+YY] -= ty;
424 f[j_coord_offset+DIM*0+ZZ] -= tz;
428 /**************************
429 * CALCULATE INTERACTIONS *
430 **************************/
435 /* REACTION-FIELD ELECTROSTATICS */
436 velec = qq11*(rinv11+krf*rsq11-crf);
437 felec = qq11*(rinv11*rinvsq11-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 = qq12*(rinv12+krf*rsq12-crf);
468 felec = qq12*(rinv12*rinvsq12-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 = qq20*(rinv20+krf*rsq20-crf);
499 felec = qq20*(rinv20*rinvsq20-krf2);
501 /* Update potential sums from outer loop */
506 /* Calculate temporary vectorial force */
511 /* Update vectorial force */
515 f[j_coord_offset+DIM*0+XX] -= tx;
516 f[j_coord_offset+DIM*0+YY] -= ty;
517 f[j_coord_offset+DIM*0+ZZ] -= tz;
521 /**************************
522 * CALCULATE INTERACTIONS *
523 **************************/
528 /* REACTION-FIELD ELECTROSTATICS */
529 velec = qq21*(rinv21+krf*rsq21-crf);
530 felec = qq21*(rinv21*rinvsq21-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 = qq22*(rinv22+krf*rsq22-crf);
561 felec = qq22*(rinv22*rinvsq22-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 /* Inner loop uses 310 flops */
585 /* End of innermost loop */
588 f[i_coord_offset+DIM*0+XX] += fix0;
589 f[i_coord_offset+DIM*0+YY] += fiy0;
590 f[i_coord_offset+DIM*0+ZZ] += fiz0;
594 f[i_coord_offset+DIM*1+XX] += fix1;
595 f[i_coord_offset+DIM*1+YY] += fiy1;
596 f[i_coord_offset+DIM*1+ZZ] += fiz1;
600 f[i_coord_offset+DIM*2+XX] += fix2;
601 f[i_coord_offset+DIM*2+YY] += fiy2;
602 f[i_coord_offset+DIM*2+ZZ] += fiz2;
606 fshift[i_shift_offset+XX] += tx;
607 fshift[i_shift_offset+YY] += ty;
608 fshift[i_shift_offset+ZZ] += tz;
611 /* Update potential energies */
612 kernel_data->energygrp_elec[ggid] += velecsum;
613 kernel_data->energygrp_vdw[ggid] += vvdwsum;
615 /* Increment number of inner iterations */
616 inneriter += j_index_end - j_index_start;
618 /* Outer loop uses 32 flops */
621 /* Increment number of outer iterations */
624 /* Update outer/inner flops */
626 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*310);
629 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_F_c
630 * Electrostatics interaction: ReactionField
631 * VdW interaction: LennardJones
632 * Geometry: Water3-Water3
633 * Calculate force/pot: Force
636 nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_F_c
637 (t_nblist * gmx_restrict nlist,
638 rvec * gmx_restrict xx,
639 rvec * gmx_restrict ff,
640 t_forcerec * gmx_restrict fr,
641 t_mdatoms * gmx_restrict mdatoms,
642 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
643 t_nrnb * gmx_restrict nrnb)
645 int i_shift_offset,i_coord_offset,j_coord_offset;
646 int j_index_start,j_index_end;
647 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
648 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
649 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
650 real *shiftvec,*fshift,*x,*f;
652 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
654 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
656 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
658 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
660 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
662 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
663 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
664 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
665 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
666 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
667 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
668 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
669 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
670 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
671 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
672 real velec,felec,velecsum,facel,crf,krf,krf2;
675 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
678 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
685 jindex = nlist->jindex;
687 shiftidx = nlist->shift;
689 shiftvec = fr->shift_vec[0];
690 fshift = fr->fshift[0];
692 charge = mdatoms->chargeA;
696 nvdwtype = fr->ntype;
698 vdwtype = mdatoms->typeA;
700 /* Setup water-specific parameters */
701 inr = nlist->iinr[0];
702 iq0 = facel*charge[inr+0];
703 iq1 = facel*charge[inr+1];
704 iq2 = facel*charge[inr+2];
705 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
710 vdwjidx0 = 2*vdwtype[inr+0];
712 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
713 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
723 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
724 rcutoff = fr->rcoulomb;
725 rcutoff2 = rcutoff*rcutoff;
727 rswitch = fr->rvdw_switch;
728 /* Setup switch parameters */
730 swV3 = -10.0/(d*d*d);
731 swV4 = 15.0/(d*d*d*d);
732 swV5 = -6.0/(d*d*d*d*d);
733 swF2 = -30.0/(d*d*d);
734 swF3 = 60.0/(d*d*d*d);
735 swF4 = -30.0/(d*d*d*d*d);
740 /* Start outer loop over neighborlists */
741 for(iidx=0; iidx<nri; iidx++)
743 /* Load shift vector for this list */
744 i_shift_offset = DIM*shiftidx[iidx];
745 shX = shiftvec[i_shift_offset+XX];
746 shY = shiftvec[i_shift_offset+YY];
747 shZ = shiftvec[i_shift_offset+ZZ];
749 /* Load limits for loop over neighbors */
750 j_index_start = jindex[iidx];
751 j_index_end = jindex[iidx+1];
753 /* Get outer coordinate index */
755 i_coord_offset = DIM*inr;
757 /* Load i particle coords and add shift vector */
758 ix0 = shX + x[i_coord_offset+DIM*0+XX];
759 iy0 = shY + x[i_coord_offset+DIM*0+YY];
760 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
761 ix1 = shX + x[i_coord_offset+DIM*1+XX];
762 iy1 = shY + x[i_coord_offset+DIM*1+YY];
763 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
764 ix2 = shX + x[i_coord_offset+DIM*2+XX];
765 iy2 = shY + x[i_coord_offset+DIM*2+YY];
766 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
778 /* Start inner kernel loop */
779 for(jidx=j_index_start; jidx<j_index_end; jidx++)
781 /* Get j neighbor index, and coordinate index */
783 j_coord_offset = DIM*jnr;
785 /* load j atom coordinates */
786 jx0 = x[j_coord_offset+DIM*0+XX];
787 jy0 = x[j_coord_offset+DIM*0+YY];
788 jz0 = x[j_coord_offset+DIM*0+ZZ];
789 jx1 = x[j_coord_offset+DIM*1+XX];
790 jy1 = x[j_coord_offset+DIM*1+YY];
791 jz1 = x[j_coord_offset+DIM*1+ZZ];
792 jx2 = x[j_coord_offset+DIM*2+XX];
793 jy2 = x[j_coord_offset+DIM*2+YY];
794 jz2 = x[j_coord_offset+DIM*2+ZZ];
796 /* Calculate displacement vector */
825 /* Calculate squared distance and things based on it */
826 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
827 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
828 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
829 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
830 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
831 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
832 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
833 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
834 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
836 rinv00 = gmx_invsqrt(rsq00);
837 rinv01 = gmx_invsqrt(rsq01);
838 rinv02 = gmx_invsqrt(rsq02);
839 rinv10 = gmx_invsqrt(rsq10);
840 rinv11 = gmx_invsqrt(rsq11);
841 rinv12 = gmx_invsqrt(rsq12);
842 rinv20 = gmx_invsqrt(rsq20);
843 rinv21 = gmx_invsqrt(rsq21);
844 rinv22 = gmx_invsqrt(rsq22);
846 rinvsq00 = rinv00*rinv00;
847 rinvsq01 = rinv01*rinv01;
848 rinvsq02 = rinv02*rinv02;
849 rinvsq10 = rinv10*rinv10;
850 rinvsq11 = rinv11*rinv11;
851 rinvsq12 = rinv12*rinv12;
852 rinvsq20 = rinv20*rinv20;
853 rinvsq21 = rinv21*rinv21;
854 rinvsq22 = rinv22*rinv22;
856 /**************************
857 * CALCULATE INTERACTIONS *
858 **************************/
865 /* REACTION-FIELD ELECTROSTATICS */
866 felec = qq00*(rinv00*rinvsq00-krf2);
868 /* LENNARD-JONES DISPERSION/REPULSION */
870 rinvsix = rinvsq00*rinvsq00*rinvsq00;
871 vvdw6 = c6_00*rinvsix;
872 vvdw12 = c12_00*rinvsix*rinvsix;
873 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
874 fvdw = (vvdw12-vvdw6)*rinvsq00;
877 d = (d>0.0) ? d : 0.0;
879 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
881 dsw = d2*(swF2+d*(swF3+d*swF4));
883 /* Evaluate switch function */
884 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
885 fvdw = fvdw*sw - rinv00*vvdw*dsw;
889 /* Calculate temporary vectorial force */
894 /* Update vectorial force */
898 f[j_coord_offset+DIM*0+XX] -= tx;
899 f[j_coord_offset+DIM*0+YY] -= ty;
900 f[j_coord_offset+DIM*0+ZZ] -= tz;
904 /**************************
905 * CALCULATE INTERACTIONS *
906 **************************/
911 /* REACTION-FIELD ELECTROSTATICS */
912 felec = qq01*(rinv01*rinvsq01-krf2);
916 /* Calculate temporary vectorial force */
921 /* Update vectorial force */
925 f[j_coord_offset+DIM*1+XX] -= tx;
926 f[j_coord_offset+DIM*1+YY] -= ty;
927 f[j_coord_offset+DIM*1+ZZ] -= tz;
931 /**************************
932 * CALCULATE INTERACTIONS *
933 **************************/
938 /* REACTION-FIELD ELECTROSTATICS */
939 felec = qq02*(rinv02*rinvsq02-krf2);
943 /* Calculate temporary vectorial force */
948 /* Update vectorial force */
952 f[j_coord_offset+DIM*2+XX] -= tx;
953 f[j_coord_offset+DIM*2+YY] -= ty;
954 f[j_coord_offset+DIM*2+ZZ] -= tz;
958 /**************************
959 * CALCULATE INTERACTIONS *
960 **************************/
965 /* REACTION-FIELD ELECTROSTATICS */
966 felec = qq10*(rinv10*rinvsq10-krf2);
970 /* Calculate temporary vectorial force */
975 /* Update vectorial force */
979 f[j_coord_offset+DIM*0+XX] -= tx;
980 f[j_coord_offset+DIM*0+YY] -= ty;
981 f[j_coord_offset+DIM*0+ZZ] -= tz;
985 /**************************
986 * CALCULATE INTERACTIONS *
987 **************************/
992 /* REACTION-FIELD ELECTROSTATICS */
993 felec = qq11*(rinv11*rinvsq11-krf2);
997 /* Calculate temporary vectorial force */
1002 /* Update vectorial force */
1006 f[j_coord_offset+DIM*1+XX] -= tx;
1007 f[j_coord_offset+DIM*1+YY] -= ty;
1008 f[j_coord_offset+DIM*1+ZZ] -= tz;
1012 /**************************
1013 * CALCULATE INTERACTIONS *
1014 **************************/
1019 /* REACTION-FIELD ELECTROSTATICS */
1020 felec = qq12*(rinv12*rinvsq12-krf2);
1024 /* Calculate temporary vectorial force */
1029 /* Update vectorial force */
1033 f[j_coord_offset+DIM*2+XX] -= tx;
1034 f[j_coord_offset+DIM*2+YY] -= ty;
1035 f[j_coord_offset+DIM*2+ZZ] -= tz;
1039 /**************************
1040 * CALCULATE INTERACTIONS *
1041 **************************/
1046 /* REACTION-FIELD ELECTROSTATICS */
1047 felec = qq20*(rinv20*rinvsq20-krf2);
1051 /* Calculate temporary vectorial force */
1056 /* Update vectorial force */
1060 f[j_coord_offset+DIM*0+XX] -= tx;
1061 f[j_coord_offset+DIM*0+YY] -= ty;
1062 f[j_coord_offset+DIM*0+ZZ] -= tz;
1066 /**************************
1067 * CALCULATE INTERACTIONS *
1068 **************************/
1073 /* REACTION-FIELD ELECTROSTATICS */
1074 felec = qq21*(rinv21*rinvsq21-krf2);
1078 /* Calculate temporary vectorial force */
1083 /* Update vectorial force */
1087 f[j_coord_offset+DIM*1+XX] -= tx;
1088 f[j_coord_offset+DIM*1+YY] -= ty;
1089 f[j_coord_offset+DIM*1+ZZ] -= tz;
1093 /**************************
1094 * CALCULATE INTERACTIONS *
1095 **************************/
1100 /* REACTION-FIELD ELECTROSTATICS */
1101 felec = qq22*(rinv22*rinvsq22-krf2);
1105 /* Calculate temporary vectorial force */
1110 /* Update vectorial force */
1114 f[j_coord_offset+DIM*2+XX] -= tx;
1115 f[j_coord_offset+DIM*2+YY] -= ty;
1116 f[j_coord_offset+DIM*2+ZZ] -= tz;
1120 /* Inner loop uses 263 flops */
1122 /* End of innermost loop */
1125 f[i_coord_offset+DIM*0+XX] += fix0;
1126 f[i_coord_offset+DIM*0+YY] += fiy0;
1127 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1131 f[i_coord_offset+DIM*1+XX] += fix1;
1132 f[i_coord_offset+DIM*1+YY] += fiy1;
1133 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1137 f[i_coord_offset+DIM*2+XX] += fix2;
1138 f[i_coord_offset+DIM*2+YY] += fiy2;
1139 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1143 fshift[i_shift_offset+XX] += tx;
1144 fshift[i_shift_offset+YY] += ty;
1145 fshift[i_shift_offset+ZZ] += tz;
1147 /* Increment number of inner iterations */
1148 inneriter += j_index_end - j_index_start;
1150 /* Outer loop uses 30 flops */
1153 /* Increment number of outer iterations */
1156 /* Update outer/inner flops */
1158 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*263);