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 "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: Buckingham
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
102 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
109 jindex = nlist->jindex;
111 shiftidx = nlist->shift;
113 shiftvec = fr->shift_vec[0];
114 fshift = fr->fshift[0];
116 charge = mdatoms->chargeA;
120 nvdwtype = fr->ntype;
122 vdwtype = mdatoms->typeA;
124 /* Setup water-specific parameters */
125 inr = nlist->iinr[0];
126 iq1 = facel*charge[inr+1];
127 iq2 = facel*charge[inr+2];
128 iq3 = facel*charge[inr+3];
129 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
134 vdwjidx0 = 3*vdwtype[inr+0];
135 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
136 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
137 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
148 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
149 rcutoff = fr->rcoulomb;
150 rcutoff2 = rcutoff*rcutoff;
152 rswitch = fr->rvdw_switch;
153 /* Setup switch parameters */
155 swV3 = -10.0/(d*d*d);
156 swV4 = 15.0/(d*d*d*d);
157 swV5 = -6.0/(d*d*d*d*d);
158 swF2 = -30.0/(d*d*d);
159 swF3 = 60.0/(d*d*d*d);
160 swF4 = -30.0/(d*d*d*d*d);
165 /* Start outer loop over neighborlists */
166 for(iidx=0; iidx<nri; iidx++)
168 /* Load shift vector for this list */
169 i_shift_offset = DIM*shiftidx[iidx];
170 shX = shiftvec[i_shift_offset+XX];
171 shY = shiftvec[i_shift_offset+YY];
172 shZ = shiftvec[i_shift_offset+ZZ];
174 /* Load limits for loop over neighbors */
175 j_index_start = jindex[iidx];
176 j_index_end = jindex[iidx+1];
178 /* Get outer coordinate index */
180 i_coord_offset = DIM*inr;
182 /* Load i particle coords and add shift vector */
183 ix0 = shX + x[i_coord_offset+DIM*0+XX];
184 iy0 = shY + x[i_coord_offset+DIM*0+YY];
185 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
186 ix1 = shX + x[i_coord_offset+DIM*1+XX];
187 iy1 = shY + x[i_coord_offset+DIM*1+YY];
188 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
189 ix2 = shX + x[i_coord_offset+DIM*2+XX];
190 iy2 = shY + x[i_coord_offset+DIM*2+YY];
191 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
192 ix3 = shX + x[i_coord_offset+DIM*3+XX];
193 iy3 = shY + x[i_coord_offset+DIM*3+YY];
194 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
209 /* Reset potential sums */
213 /* Start inner kernel loop */
214 for(jidx=j_index_start; jidx<j_index_end; jidx++)
216 /* Get j neighbor index, and coordinate index */
218 j_coord_offset = DIM*jnr;
220 /* load j atom coordinates */
221 jx0 = x[j_coord_offset+DIM*0+XX];
222 jy0 = x[j_coord_offset+DIM*0+YY];
223 jz0 = x[j_coord_offset+DIM*0+ZZ];
224 jx1 = x[j_coord_offset+DIM*1+XX];
225 jy1 = x[j_coord_offset+DIM*1+YY];
226 jz1 = x[j_coord_offset+DIM*1+ZZ];
227 jx2 = x[j_coord_offset+DIM*2+XX];
228 jy2 = x[j_coord_offset+DIM*2+YY];
229 jz2 = x[j_coord_offset+DIM*2+ZZ];
230 jx3 = x[j_coord_offset+DIM*3+XX];
231 jy3 = x[j_coord_offset+DIM*3+YY];
232 jz3 = x[j_coord_offset+DIM*3+ZZ];
234 /* Calculate displacement vector */
266 /* Calculate squared distance and things based on it */
267 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
268 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
269 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
270 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
271 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
272 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
273 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
274 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
275 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
276 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
278 rinv00 = gmx_invsqrt(rsq00);
279 rinv11 = gmx_invsqrt(rsq11);
280 rinv12 = gmx_invsqrt(rsq12);
281 rinv13 = gmx_invsqrt(rsq13);
282 rinv21 = gmx_invsqrt(rsq21);
283 rinv22 = gmx_invsqrt(rsq22);
284 rinv23 = gmx_invsqrt(rsq23);
285 rinv31 = gmx_invsqrt(rsq31);
286 rinv32 = gmx_invsqrt(rsq32);
287 rinv33 = gmx_invsqrt(rsq33);
289 rinvsq00 = rinv00*rinv00;
290 rinvsq11 = rinv11*rinv11;
291 rinvsq12 = rinv12*rinv12;
292 rinvsq13 = rinv13*rinv13;
293 rinvsq21 = rinv21*rinv21;
294 rinvsq22 = rinv22*rinv22;
295 rinvsq23 = rinv23*rinv23;
296 rinvsq31 = rinv31*rinv31;
297 rinvsq32 = rinv32*rinv32;
298 rinvsq33 = rinv33*rinv33;
300 /**************************
301 * CALCULATE INTERACTIONS *
302 **************************/
309 /* BUCKINGHAM DISPERSION/REPULSION */
310 rinvsix = rinvsq00*rinvsq00*rinvsq00;
311 vvdw6 = c6_00*rinvsix;
313 vvdwexp = cexp1_00*exp(-br);
314 vvdw = vvdwexp - vvdw6*(1.0/6.0);
315 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
318 d = (d>0.0) ? d : 0.0;
320 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
322 dsw = d2*(swF2+d*(swF3+d*swF4));
324 /* Evaluate switch function */
325 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
326 fvdw = fvdw*sw - rinv00*vvdw*dsw;
329 /* Update potential sums from outer loop */
334 /* Calculate temporary vectorial force */
339 /* Update vectorial force */
343 f[j_coord_offset+DIM*0+XX] -= tx;
344 f[j_coord_offset+DIM*0+YY] -= ty;
345 f[j_coord_offset+DIM*0+ZZ] -= tz;
349 /**************************
350 * CALCULATE INTERACTIONS *
351 **************************/
356 /* REACTION-FIELD ELECTROSTATICS */
357 velec = qq11*(rinv11+krf*rsq11-crf);
358 felec = qq11*(rinv11*rinvsq11-krf2);
360 /* Update potential sums from outer loop */
365 /* Calculate temporary vectorial force */
370 /* Update vectorial force */
374 f[j_coord_offset+DIM*1+XX] -= tx;
375 f[j_coord_offset+DIM*1+YY] -= ty;
376 f[j_coord_offset+DIM*1+ZZ] -= tz;
380 /**************************
381 * CALCULATE INTERACTIONS *
382 **************************/
387 /* REACTION-FIELD ELECTROSTATICS */
388 velec = qq12*(rinv12+krf*rsq12-crf);
389 felec = qq12*(rinv12*rinvsq12-krf2);
391 /* Update potential sums from outer loop */
396 /* Calculate temporary vectorial force */
401 /* Update vectorial force */
405 f[j_coord_offset+DIM*2+XX] -= tx;
406 f[j_coord_offset+DIM*2+YY] -= ty;
407 f[j_coord_offset+DIM*2+ZZ] -= tz;
411 /**************************
412 * CALCULATE INTERACTIONS *
413 **************************/
418 /* REACTION-FIELD ELECTROSTATICS */
419 velec = qq13*(rinv13+krf*rsq13-crf);
420 felec = qq13*(rinv13*rinvsq13-krf2);
422 /* Update potential sums from outer loop */
427 /* Calculate temporary vectorial force */
432 /* Update vectorial force */
436 f[j_coord_offset+DIM*3+XX] -= tx;
437 f[j_coord_offset+DIM*3+YY] -= ty;
438 f[j_coord_offset+DIM*3+ZZ] -= tz;
442 /**************************
443 * CALCULATE INTERACTIONS *
444 **************************/
449 /* REACTION-FIELD ELECTROSTATICS */
450 velec = qq21*(rinv21+krf*rsq21-crf);
451 felec = qq21*(rinv21*rinvsq21-krf2);
453 /* Update potential sums from outer loop */
458 /* Calculate temporary vectorial force */
463 /* Update vectorial force */
467 f[j_coord_offset+DIM*1+XX] -= tx;
468 f[j_coord_offset+DIM*1+YY] -= ty;
469 f[j_coord_offset+DIM*1+ZZ] -= tz;
473 /**************************
474 * CALCULATE INTERACTIONS *
475 **************************/
480 /* REACTION-FIELD ELECTROSTATICS */
481 velec = qq22*(rinv22+krf*rsq22-crf);
482 felec = qq22*(rinv22*rinvsq22-krf2);
484 /* Update potential sums from outer loop */
489 /* Calculate temporary vectorial force */
494 /* Update vectorial force */
498 f[j_coord_offset+DIM*2+XX] -= tx;
499 f[j_coord_offset+DIM*2+YY] -= ty;
500 f[j_coord_offset+DIM*2+ZZ] -= tz;
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
511 /* REACTION-FIELD ELECTROSTATICS */
512 velec = qq23*(rinv23+krf*rsq23-crf);
513 felec = qq23*(rinv23*rinvsq23-krf2);
515 /* Update potential sums from outer loop */
520 /* Calculate temporary vectorial force */
525 /* Update vectorial force */
529 f[j_coord_offset+DIM*3+XX] -= tx;
530 f[j_coord_offset+DIM*3+YY] -= ty;
531 f[j_coord_offset+DIM*3+ZZ] -= tz;
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
542 /* REACTION-FIELD ELECTROSTATICS */
543 velec = qq31*(rinv31+krf*rsq31-crf);
544 felec = qq31*(rinv31*rinvsq31-krf2);
546 /* Update potential sums from outer loop */
551 /* Calculate temporary vectorial force */
556 /* Update vectorial force */
560 f[j_coord_offset+DIM*1+XX] -= tx;
561 f[j_coord_offset+DIM*1+YY] -= ty;
562 f[j_coord_offset+DIM*1+ZZ] -= tz;
566 /**************************
567 * CALCULATE INTERACTIONS *
568 **************************/
573 /* REACTION-FIELD ELECTROSTATICS */
574 velec = qq32*(rinv32+krf*rsq32-crf);
575 felec = qq32*(rinv32*rinvsq32-krf2);
577 /* Update potential sums from outer loop */
582 /* Calculate temporary vectorial force */
587 /* Update vectorial force */
591 f[j_coord_offset+DIM*2+XX] -= tx;
592 f[j_coord_offset+DIM*2+YY] -= ty;
593 f[j_coord_offset+DIM*2+ZZ] -= tz;
597 /**************************
598 * CALCULATE INTERACTIONS *
599 **************************/
604 /* REACTION-FIELD ELECTROSTATICS */
605 velec = qq33*(rinv33+krf*rsq33-crf);
606 felec = qq33*(rinv33*rinvsq33-krf2);
608 /* Update potential sums from outer loop */
613 /* Calculate temporary vectorial force */
618 /* Update vectorial force */
622 f[j_coord_offset+DIM*3+XX] -= tx;
623 f[j_coord_offset+DIM*3+YY] -= ty;
624 f[j_coord_offset+DIM*3+ZZ] -= tz;
628 /* Inner loop uses 358 flops */
630 /* End of innermost loop */
633 f[i_coord_offset+DIM*0+XX] += fix0;
634 f[i_coord_offset+DIM*0+YY] += fiy0;
635 f[i_coord_offset+DIM*0+ZZ] += fiz0;
639 f[i_coord_offset+DIM*1+XX] += fix1;
640 f[i_coord_offset+DIM*1+YY] += fiy1;
641 f[i_coord_offset+DIM*1+ZZ] += fiz1;
645 f[i_coord_offset+DIM*2+XX] += fix2;
646 f[i_coord_offset+DIM*2+YY] += fiy2;
647 f[i_coord_offset+DIM*2+ZZ] += fiz2;
651 f[i_coord_offset+DIM*3+XX] += fix3;
652 f[i_coord_offset+DIM*3+YY] += fiy3;
653 f[i_coord_offset+DIM*3+ZZ] += fiz3;
657 fshift[i_shift_offset+XX] += tx;
658 fshift[i_shift_offset+YY] += ty;
659 fshift[i_shift_offset+ZZ] += tz;
662 /* Update potential energies */
663 kernel_data->energygrp_elec[ggid] += velecsum;
664 kernel_data->energygrp_vdw[ggid] += vvdwsum;
666 /* Increment number of inner iterations */
667 inneriter += j_index_end - j_index_start;
669 /* Outer loop uses 41 flops */
672 /* Increment number of outer iterations */
675 /* Update outer/inner flops */
677 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*358);
680 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
681 * Electrostatics interaction: ReactionField
682 * VdW interaction: Buckingham
683 * Geometry: Water4-Water4
684 * Calculate force/pot: Force
687 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
688 (t_nblist * gmx_restrict nlist,
689 rvec * gmx_restrict xx,
690 rvec * gmx_restrict ff,
691 t_forcerec * gmx_restrict fr,
692 t_mdatoms * gmx_restrict mdatoms,
693 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
694 t_nrnb * gmx_restrict nrnb)
696 int i_shift_offset,i_coord_offset,j_coord_offset;
697 int j_index_start,j_index_end;
698 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
699 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
700 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
701 real *shiftvec,*fshift,*x,*f;
703 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
705 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
707 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
709 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
711 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
713 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
715 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
717 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
718 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
719 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
720 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
721 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
722 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
723 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
724 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
725 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
726 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
727 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
728 real velec,felec,velecsum,facel,crf,krf,krf2;
731 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
734 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
741 jindex = nlist->jindex;
743 shiftidx = nlist->shift;
745 shiftvec = fr->shift_vec[0];
746 fshift = fr->fshift[0];
748 charge = mdatoms->chargeA;
752 nvdwtype = fr->ntype;
754 vdwtype = mdatoms->typeA;
756 /* Setup water-specific parameters */
757 inr = nlist->iinr[0];
758 iq1 = facel*charge[inr+1];
759 iq2 = facel*charge[inr+2];
760 iq3 = facel*charge[inr+3];
761 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
766 vdwjidx0 = 3*vdwtype[inr+0];
767 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
768 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
769 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
780 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
781 rcutoff = fr->rcoulomb;
782 rcutoff2 = rcutoff*rcutoff;
784 rswitch = fr->rvdw_switch;
785 /* Setup switch parameters */
787 swV3 = -10.0/(d*d*d);
788 swV4 = 15.0/(d*d*d*d);
789 swV5 = -6.0/(d*d*d*d*d);
790 swF2 = -30.0/(d*d*d);
791 swF3 = 60.0/(d*d*d*d);
792 swF4 = -30.0/(d*d*d*d*d);
797 /* Start outer loop over neighborlists */
798 for(iidx=0; iidx<nri; iidx++)
800 /* Load shift vector for this list */
801 i_shift_offset = DIM*shiftidx[iidx];
802 shX = shiftvec[i_shift_offset+XX];
803 shY = shiftvec[i_shift_offset+YY];
804 shZ = shiftvec[i_shift_offset+ZZ];
806 /* Load limits for loop over neighbors */
807 j_index_start = jindex[iidx];
808 j_index_end = jindex[iidx+1];
810 /* Get outer coordinate index */
812 i_coord_offset = DIM*inr;
814 /* Load i particle coords and add shift vector */
815 ix0 = shX + x[i_coord_offset+DIM*0+XX];
816 iy0 = shY + x[i_coord_offset+DIM*0+YY];
817 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
818 ix1 = shX + x[i_coord_offset+DIM*1+XX];
819 iy1 = shY + x[i_coord_offset+DIM*1+YY];
820 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
821 ix2 = shX + x[i_coord_offset+DIM*2+XX];
822 iy2 = shY + x[i_coord_offset+DIM*2+YY];
823 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
824 ix3 = shX + x[i_coord_offset+DIM*3+XX];
825 iy3 = shY + x[i_coord_offset+DIM*3+YY];
826 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
841 /* Start inner kernel loop */
842 for(jidx=j_index_start; jidx<j_index_end; jidx++)
844 /* Get j neighbor index, and coordinate index */
846 j_coord_offset = DIM*jnr;
848 /* load j atom coordinates */
849 jx0 = x[j_coord_offset+DIM*0+XX];
850 jy0 = x[j_coord_offset+DIM*0+YY];
851 jz0 = x[j_coord_offset+DIM*0+ZZ];
852 jx1 = x[j_coord_offset+DIM*1+XX];
853 jy1 = x[j_coord_offset+DIM*1+YY];
854 jz1 = x[j_coord_offset+DIM*1+ZZ];
855 jx2 = x[j_coord_offset+DIM*2+XX];
856 jy2 = x[j_coord_offset+DIM*2+YY];
857 jz2 = x[j_coord_offset+DIM*2+ZZ];
858 jx3 = x[j_coord_offset+DIM*3+XX];
859 jy3 = x[j_coord_offset+DIM*3+YY];
860 jz3 = x[j_coord_offset+DIM*3+ZZ];
862 /* Calculate displacement vector */
894 /* Calculate squared distance and things based on it */
895 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
896 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
897 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
898 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
899 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
900 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
901 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
902 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
903 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
904 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
906 rinv00 = gmx_invsqrt(rsq00);
907 rinv11 = gmx_invsqrt(rsq11);
908 rinv12 = gmx_invsqrt(rsq12);
909 rinv13 = gmx_invsqrt(rsq13);
910 rinv21 = gmx_invsqrt(rsq21);
911 rinv22 = gmx_invsqrt(rsq22);
912 rinv23 = gmx_invsqrt(rsq23);
913 rinv31 = gmx_invsqrt(rsq31);
914 rinv32 = gmx_invsqrt(rsq32);
915 rinv33 = gmx_invsqrt(rsq33);
917 rinvsq00 = rinv00*rinv00;
918 rinvsq11 = rinv11*rinv11;
919 rinvsq12 = rinv12*rinv12;
920 rinvsq13 = rinv13*rinv13;
921 rinvsq21 = rinv21*rinv21;
922 rinvsq22 = rinv22*rinv22;
923 rinvsq23 = rinv23*rinv23;
924 rinvsq31 = rinv31*rinv31;
925 rinvsq32 = rinv32*rinv32;
926 rinvsq33 = rinv33*rinv33;
928 /**************************
929 * CALCULATE INTERACTIONS *
930 **************************/
937 /* BUCKINGHAM DISPERSION/REPULSION */
938 rinvsix = rinvsq00*rinvsq00*rinvsq00;
939 vvdw6 = c6_00*rinvsix;
941 vvdwexp = cexp1_00*exp(-br);
942 vvdw = vvdwexp - vvdw6*(1.0/6.0);
943 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
946 d = (d>0.0) ? d : 0.0;
948 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
950 dsw = d2*(swF2+d*(swF3+d*swF4));
952 /* Evaluate switch function */
953 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
954 fvdw = fvdw*sw - rinv00*vvdw*dsw;
958 /* Calculate temporary vectorial force */
963 /* Update vectorial force */
967 f[j_coord_offset+DIM*0+XX] -= tx;
968 f[j_coord_offset+DIM*0+YY] -= ty;
969 f[j_coord_offset+DIM*0+ZZ] -= tz;
973 /**************************
974 * CALCULATE INTERACTIONS *
975 **************************/
980 /* REACTION-FIELD ELECTROSTATICS */
981 felec = qq11*(rinv11*rinvsq11-krf2);
985 /* Calculate temporary vectorial force */
990 /* Update vectorial force */
994 f[j_coord_offset+DIM*1+XX] -= tx;
995 f[j_coord_offset+DIM*1+YY] -= ty;
996 f[j_coord_offset+DIM*1+ZZ] -= tz;
1000 /**************************
1001 * CALCULATE INTERACTIONS *
1002 **************************/
1007 /* REACTION-FIELD ELECTROSTATICS */
1008 felec = qq12*(rinv12*rinvsq12-krf2);
1012 /* Calculate temporary vectorial force */
1017 /* Update vectorial force */
1021 f[j_coord_offset+DIM*2+XX] -= tx;
1022 f[j_coord_offset+DIM*2+YY] -= ty;
1023 f[j_coord_offset+DIM*2+ZZ] -= tz;
1027 /**************************
1028 * CALCULATE INTERACTIONS *
1029 **************************/
1034 /* REACTION-FIELD ELECTROSTATICS */
1035 felec = qq13*(rinv13*rinvsq13-krf2);
1039 /* Calculate temporary vectorial force */
1044 /* Update vectorial force */
1048 f[j_coord_offset+DIM*3+XX] -= tx;
1049 f[j_coord_offset+DIM*3+YY] -= ty;
1050 f[j_coord_offset+DIM*3+ZZ] -= tz;
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1061 /* REACTION-FIELD ELECTROSTATICS */
1062 felec = qq21*(rinv21*rinvsq21-krf2);
1066 /* Calculate temporary vectorial force */
1071 /* Update vectorial force */
1075 f[j_coord_offset+DIM*1+XX] -= tx;
1076 f[j_coord_offset+DIM*1+YY] -= ty;
1077 f[j_coord_offset+DIM*1+ZZ] -= tz;
1081 /**************************
1082 * CALCULATE INTERACTIONS *
1083 **************************/
1088 /* REACTION-FIELD ELECTROSTATICS */
1089 felec = qq22*(rinv22*rinvsq22-krf2);
1093 /* Calculate temporary vectorial force */
1098 /* Update vectorial force */
1102 f[j_coord_offset+DIM*2+XX] -= tx;
1103 f[j_coord_offset+DIM*2+YY] -= ty;
1104 f[j_coord_offset+DIM*2+ZZ] -= tz;
1108 /**************************
1109 * CALCULATE INTERACTIONS *
1110 **************************/
1115 /* REACTION-FIELD ELECTROSTATICS */
1116 felec = qq23*(rinv23*rinvsq23-krf2);
1120 /* Calculate temporary vectorial force */
1125 /* Update vectorial force */
1129 f[j_coord_offset+DIM*3+XX] -= tx;
1130 f[j_coord_offset+DIM*3+YY] -= ty;
1131 f[j_coord_offset+DIM*3+ZZ] -= tz;
1135 /**************************
1136 * CALCULATE INTERACTIONS *
1137 **************************/
1142 /* REACTION-FIELD ELECTROSTATICS */
1143 felec = qq31*(rinv31*rinvsq31-krf2);
1147 /* Calculate temporary vectorial force */
1152 /* Update vectorial force */
1156 f[j_coord_offset+DIM*1+XX] -= tx;
1157 f[j_coord_offset+DIM*1+YY] -= ty;
1158 f[j_coord_offset+DIM*1+ZZ] -= tz;
1162 /**************************
1163 * CALCULATE INTERACTIONS *
1164 **************************/
1169 /* REACTION-FIELD ELECTROSTATICS */
1170 felec = qq32*(rinv32*rinvsq32-krf2);
1174 /* Calculate temporary vectorial force */
1179 /* Update vectorial force */
1183 f[j_coord_offset+DIM*2+XX] -= tx;
1184 f[j_coord_offset+DIM*2+YY] -= ty;
1185 f[j_coord_offset+DIM*2+ZZ] -= tz;
1189 /**************************
1190 * CALCULATE INTERACTIONS *
1191 **************************/
1196 /* REACTION-FIELD ELECTROSTATICS */
1197 felec = qq33*(rinv33*rinvsq33-krf2);
1201 /* Calculate temporary vectorial force */
1206 /* Update vectorial force */
1210 f[j_coord_offset+DIM*3+XX] -= tx;
1211 f[j_coord_offset+DIM*3+YY] -= ty;
1212 f[j_coord_offset+DIM*3+ZZ] -= tz;
1216 /* Inner loop uses 311 flops */
1218 /* End of innermost loop */
1221 f[i_coord_offset+DIM*0+XX] += fix0;
1222 f[i_coord_offset+DIM*0+YY] += fiy0;
1223 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1227 f[i_coord_offset+DIM*1+XX] += fix1;
1228 f[i_coord_offset+DIM*1+YY] += fiy1;
1229 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1233 f[i_coord_offset+DIM*2+XX] += fix2;
1234 f[i_coord_offset+DIM*2+YY] += fiy2;
1235 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1239 f[i_coord_offset+DIM*3+XX] += fix3;
1240 f[i_coord_offset+DIM*3+YY] += fiy3;
1241 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1245 fshift[i_shift_offset+XX] += tx;
1246 fshift[i_shift_offset+YY] += ty;
1247 fshift[i_shift_offset+ZZ] += tz;
1249 /* Increment number of inner iterations */
1250 inneriter += j_index_end - j_index_start;
1252 /* Outer loop uses 39 flops */
1255 /* Increment number of outer iterations */
1258 /* Update outer/inner flops */
1260 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*311);