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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
85 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
87 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
88 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
89 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
90 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
91 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
92 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
93 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
94 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
95 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
96 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
97 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
98 real velec,felec,velecsum,facel,crf,krf,krf2;
101 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
104 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
118 charge = mdatoms->chargeA;
122 nvdwtype = fr->ntype;
124 vdwtype = mdatoms->typeA;
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq1 = facel*charge[inr+1];
129 iq2 = facel*charge[inr+2];
130 iq3 = facel*charge[inr+3];
131 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
136 vdwjidx0 = 3*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
139 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
150 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
151 rcutoff = fr->rcoulomb;
152 rcutoff2 = rcutoff*rcutoff;
154 rswitch = fr->rvdw_switch;
155 /* Setup switch parameters */
157 swV3 = -10.0/(d*d*d);
158 swV4 = 15.0/(d*d*d*d);
159 swV5 = -6.0/(d*d*d*d*d);
160 swF2 = -30.0/(d*d*d);
161 swF3 = 60.0/(d*d*d*d);
162 swF4 = -30.0/(d*d*d*d*d);
167 /* Start outer loop over neighborlists */
168 for(iidx=0; iidx<nri; iidx++)
170 /* Load shift vector for this list */
171 i_shift_offset = DIM*shiftidx[iidx];
172 shX = shiftvec[i_shift_offset+XX];
173 shY = shiftvec[i_shift_offset+YY];
174 shZ = shiftvec[i_shift_offset+ZZ];
176 /* Load limits for loop over neighbors */
177 j_index_start = jindex[iidx];
178 j_index_end = jindex[iidx+1];
180 /* Get outer coordinate index */
182 i_coord_offset = DIM*inr;
184 /* Load i particle coords and add shift vector */
185 ix0 = shX + x[i_coord_offset+DIM*0+XX];
186 iy0 = shY + x[i_coord_offset+DIM*0+YY];
187 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
188 ix1 = shX + x[i_coord_offset+DIM*1+XX];
189 iy1 = shY + x[i_coord_offset+DIM*1+YY];
190 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
191 ix2 = shX + x[i_coord_offset+DIM*2+XX];
192 iy2 = shY + x[i_coord_offset+DIM*2+YY];
193 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
194 ix3 = shX + x[i_coord_offset+DIM*3+XX];
195 iy3 = shY + x[i_coord_offset+DIM*3+YY];
196 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
211 /* Reset potential sums */
215 /* Start inner kernel loop */
216 for(jidx=j_index_start; jidx<j_index_end; jidx++)
218 /* Get j neighbor index, and coordinate index */
220 j_coord_offset = DIM*jnr;
222 /* load j atom coordinates */
223 jx0 = x[j_coord_offset+DIM*0+XX];
224 jy0 = x[j_coord_offset+DIM*0+YY];
225 jz0 = x[j_coord_offset+DIM*0+ZZ];
226 jx1 = x[j_coord_offset+DIM*1+XX];
227 jy1 = x[j_coord_offset+DIM*1+YY];
228 jz1 = x[j_coord_offset+DIM*1+ZZ];
229 jx2 = x[j_coord_offset+DIM*2+XX];
230 jy2 = x[j_coord_offset+DIM*2+YY];
231 jz2 = x[j_coord_offset+DIM*2+ZZ];
232 jx3 = x[j_coord_offset+DIM*3+XX];
233 jy3 = x[j_coord_offset+DIM*3+YY];
234 jz3 = x[j_coord_offset+DIM*3+ZZ];
236 /* Calculate displacement vector */
268 /* Calculate squared distance and things based on it */
269 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
270 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
271 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
272 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
273 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
274 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
275 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
276 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
277 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
278 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
280 rinv00 = gmx_invsqrt(rsq00);
281 rinv11 = gmx_invsqrt(rsq11);
282 rinv12 = gmx_invsqrt(rsq12);
283 rinv13 = gmx_invsqrt(rsq13);
284 rinv21 = gmx_invsqrt(rsq21);
285 rinv22 = gmx_invsqrt(rsq22);
286 rinv23 = gmx_invsqrt(rsq23);
287 rinv31 = gmx_invsqrt(rsq31);
288 rinv32 = gmx_invsqrt(rsq32);
289 rinv33 = gmx_invsqrt(rsq33);
291 rinvsq00 = rinv00*rinv00;
292 rinvsq11 = rinv11*rinv11;
293 rinvsq12 = rinv12*rinv12;
294 rinvsq13 = rinv13*rinv13;
295 rinvsq21 = rinv21*rinv21;
296 rinvsq22 = rinv22*rinv22;
297 rinvsq23 = rinv23*rinv23;
298 rinvsq31 = rinv31*rinv31;
299 rinvsq32 = rinv32*rinv32;
300 rinvsq33 = rinv33*rinv33;
302 /**************************
303 * CALCULATE INTERACTIONS *
304 **************************/
311 /* BUCKINGHAM DISPERSION/REPULSION */
312 rinvsix = rinvsq00*rinvsq00*rinvsq00;
313 vvdw6 = c6_00*rinvsix;
315 vvdwexp = cexp1_00*exp(-br);
316 vvdw = vvdwexp - vvdw6*(1.0/6.0);
317 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
320 d = (d>0.0) ? d : 0.0;
322 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
324 dsw = d2*(swF2+d*(swF3+d*swF4));
326 /* Evaluate switch function */
327 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
328 fvdw = fvdw*sw - rinv00*vvdw*dsw;
331 /* Update potential sums from outer loop */
336 /* Calculate temporary vectorial force */
341 /* Update vectorial force */
345 f[j_coord_offset+DIM*0+XX] -= tx;
346 f[j_coord_offset+DIM*0+YY] -= ty;
347 f[j_coord_offset+DIM*0+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
358 /* REACTION-FIELD ELECTROSTATICS */
359 velec = qq11*(rinv11+krf*rsq11-crf);
360 felec = qq11*(rinv11*rinvsq11-krf2);
362 /* Update potential sums from outer loop */
367 /* Calculate temporary vectorial force */
372 /* Update vectorial force */
376 f[j_coord_offset+DIM*1+XX] -= tx;
377 f[j_coord_offset+DIM*1+YY] -= ty;
378 f[j_coord_offset+DIM*1+ZZ] -= tz;
382 /**************************
383 * CALCULATE INTERACTIONS *
384 **************************/
389 /* REACTION-FIELD ELECTROSTATICS */
390 velec = qq12*(rinv12+krf*rsq12-crf);
391 felec = qq12*(rinv12*rinvsq12-krf2);
393 /* Update potential sums from outer loop */
398 /* Calculate temporary vectorial force */
403 /* Update vectorial force */
407 f[j_coord_offset+DIM*2+XX] -= tx;
408 f[j_coord_offset+DIM*2+YY] -= ty;
409 f[j_coord_offset+DIM*2+ZZ] -= tz;
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
420 /* REACTION-FIELD ELECTROSTATICS */
421 velec = qq13*(rinv13+krf*rsq13-crf);
422 felec = qq13*(rinv13*rinvsq13-krf2);
424 /* Update potential sums from outer loop */
429 /* Calculate temporary vectorial force */
434 /* Update vectorial force */
438 f[j_coord_offset+DIM*3+XX] -= tx;
439 f[j_coord_offset+DIM*3+YY] -= ty;
440 f[j_coord_offset+DIM*3+ZZ] -= tz;
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
451 /* REACTION-FIELD ELECTROSTATICS */
452 velec = qq21*(rinv21+krf*rsq21-crf);
453 felec = qq21*(rinv21*rinvsq21-krf2);
455 /* Update potential sums from outer loop */
460 /* Calculate temporary vectorial force */
465 /* Update vectorial force */
469 f[j_coord_offset+DIM*1+XX] -= tx;
470 f[j_coord_offset+DIM*1+YY] -= ty;
471 f[j_coord_offset+DIM*1+ZZ] -= tz;
475 /**************************
476 * CALCULATE INTERACTIONS *
477 **************************/
482 /* REACTION-FIELD ELECTROSTATICS */
483 velec = qq22*(rinv22+krf*rsq22-crf);
484 felec = qq22*(rinv22*rinvsq22-krf2);
486 /* Update potential sums from outer loop */
491 /* Calculate temporary vectorial force */
496 /* Update vectorial force */
500 f[j_coord_offset+DIM*2+XX] -= tx;
501 f[j_coord_offset+DIM*2+YY] -= ty;
502 f[j_coord_offset+DIM*2+ZZ] -= tz;
506 /**************************
507 * CALCULATE INTERACTIONS *
508 **************************/
513 /* REACTION-FIELD ELECTROSTATICS */
514 velec = qq23*(rinv23+krf*rsq23-crf);
515 felec = qq23*(rinv23*rinvsq23-krf2);
517 /* Update potential sums from outer loop */
522 /* Calculate temporary vectorial force */
527 /* Update vectorial force */
531 f[j_coord_offset+DIM*3+XX] -= tx;
532 f[j_coord_offset+DIM*3+YY] -= ty;
533 f[j_coord_offset+DIM*3+ZZ] -= tz;
537 /**************************
538 * CALCULATE INTERACTIONS *
539 **************************/
544 /* REACTION-FIELD ELECTROSTATICS */
545 velec = qq31*(rinv31+krf*rsq31-crf);
546 felec = qq31*(rinv31*rinvsq31-krf2);
548 /* Update potential sums from outer loop */
553 /* Calculate temporary vectorial force */
558 /* Update vectorial force */
562 f[j_coord_offset+DIM*1+XX] -= tx;
563 f[j_coord_offset+DIM*1+YY] -= ty;
564 f[j_coord_offset+DIM*1+ZZ] -= tz;
568 /**************************
569 * CALCULATE INTERACTIONS *
570 **************************/
575 /* REACTION-FIELD ELECTROSTATICS */
576 velec = qq32*(rinv32+krf*rsq32-crf);
577 felec = qq32*(rinv32*rinvsq32-krf2);
579 /* Update potential sums from outer loop */
584 /* Calculate temporary vectorial force */
589 /* Update vectorial force */
593 f[j_coord_offset+DIM*2+XX] -= tx;
594 f[j_coord_offset+DIM*2+YY] -= ty;
595 f[j_coord_offset+DIM*2+ZZ] -= tz;
599 /**************************
600 * CALCULATE INTERACTIONS *
601 **************************/
606 /* REACTION-FIELD ELECTROSTATICS */
607 velec = qq33*(rinv33+krf*rsq33-crf);
608 felec = qq33*(rinv33*rinvsq33-krf2);
610 /* Update potential sums from outer loop */
615 /* Calculate temporary vectorial force */
620 /* Update vectorial force */
624 f[j_coord_offset+DIM*3+XX] -= tx;
625 f[j_coord_offset+DIM*3+YY] -= ty;
626 f[j_coord_offset+DIM*3+ZZ] -= tz;
630 /* Inner loop uses 358 flops */
632 /* End of innermost loop */
635 f[i_coord_offset+DIM*0+XX] += fix0;
636 f[i_coord_offset+DIM*0+YY] += fiy0;
637 f[i_coord_offset+DIM*0+ZZ] += fiz0;
641 f[i_coord_offset+DIM*1+XX] += fix1;
642 f[i_coord_offset+DIM*1+YY] += fiy1;
643 f[i_coord_offset+DIM*1+ZZ] += fiz1;
647 f[i_coord_offset+DIM*2+XX] += fix2;
648 f[i_coord_offset+DIM*2+YY] += fiy2;
649 f[i_coord_offset+DIM*2+ZZ] += fiz2;
653 f[i_coord_offset+DIM*3+XX] += fix3;
654 f[i_coord_offset+DIM*3+YY] += fiy3;
655 f[i_coord_offset+DIM*3+ZZ] += fiz3;
659 fshift[i_shift_offset+XX] += tx;
660 fshift[i_shift_offset+YY] += ty;
661 fshift[i_shift_offset+ZZ] += tz;
664 /* Update potential energies */
665 kernel_data->energygrp_elec[ggid] += velecsum;
666 kernel_data->energygrp_vdw[ggid] += vvdwsum;
668 /* Increment number of inner iterations */
669 inneriter += j_index_end - j_index_start;
671 /* Outer loop uses 41 flops */
674 /* Increment number of outer iterations */
677 /* Update outer/inner flops */
679 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*358);
682 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
683 * Electrostatics interaction: ReactionField
684 * VdW interaction: Buckingham
685 * Geometry: Water4-Water4
686 * Calculate force/pot: Force
689 nb_kernel_ElecRFCut_VdwBhamSw_GeomW4W4_F_c
690 (t_nblist * gmx_restrict nlist,
691 rvec * gmx_restrict xx,
692 rvec * gmx_restrict ff,
693 t_forcerec * gmx_restrict fr,
694 t_mdatoms * gmx_restrict mdatoms,
695 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
696 t_nrnb * gmx_restrict nrnb)
698 int i_shift_offset,i_coord_offset,j_coord_offset;
699 int j_index_start,j_index_end;
700 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
701 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
702 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
703 real *shiftvec,*fshift,*x,*f;
705 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
707 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
709 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
711 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
713 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
715 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
717 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
719 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
720 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
721 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
722 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
723 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
724 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
725 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
726 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
727 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
728 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
729 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
730 real velec,felec,velecsum,facel,crf,krf,krf2;
733 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
736 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
743 jindex = nlist->jindex;
745 shiftidx = nlist->shift;
747 shiftvec = fr->shift_vec[0];
748 fshift = fr->fshift[0];
750 charge = mdatoms->chargeA;
754 nvdwtype = fr->ntype;
756 vdwtype = mdatoms->typeA;
758 /* Setup water-specific parameters */
759 inr = nlist->iinr[0];
760 iq1 = facel*charge[inr+1];
761 iq2 = facel*charge[inr+2];
762 iq3 = facel*charge[inr+3];
763 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
768 vdwjidx0 = 3*vdwtype[inr+0];
769 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
770 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
771 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
782 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
783 rcutoff = fr->rcoulomb;
784 rcutoff2 = rcutoff*rcutoff;
786 rswitch = fr->rvdw_switch;
787 /* Setup switch parameters */
789 swV3 = -10.0/(d*d*d);
790 swV4 = 15.0/(d*d*d*d);
791 swV5 = -6.0/(d*d*d*d*d);
792 swF2 = -30.0/(d*d*d);
793 swF3 = 60.0/(d*d*d*d);
794 swF4 = -30.0/(d*d*d*d*d);
799 /* Start outer loop over neighborlists */
800 for(iidx=0; iidx<nri; iidx++)
802 /* Load shift vector for this list */
803 i_shift_offset = DIM*shiftidx[iidx];
804 shX = shiftvec[i_shift_offset+XX];
805 shY = shiftvec[i_shift_offset+YY];
806 shZ = shiftvec[i_shift_offset+ZZ];
808 /* Load limits for loop over neighbors */
809 j_index_start = jindex[iidx];
810 j_index_end = jindex[iidx+1];
812 /* Get outer coordinate index */
814 i_coord_offset = DIM*inr;
816 /* Load i particle coords and add shift vector */
817 ix0 = shX + x[i_coord_offset+DIM*0+XX];
818 iy0 = shY + x[i_coord_offset+DIM*0+YY];
819 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
820 ix1 = shX + x[i_coord_offset+DIM*1+XX];
821 iy1 = shY + x[i_coord_offset+DIM*1+YY];
822 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
823 ix2 = shX + x[i_coord_offset+DIM*2+XX];
824 iy2 = shY + x[i_coord_offset+DIM*2+YY];
825 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
826 ix3 = shX + x[i_coord_offset+DIM*3+XX];
827 iy3 = shY + x[i_coord_offset+DIM*3+YY];
828 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
843 /* Start inner kernel loop */
844 for(jidx=j_index_start; jidx<j_index_end; jidx++)
846 /* Get j neighbor index, and coordinate index */
848 j_coord_offset = DIM*jnr;
850 /* load j atom coordinates */
851 jx0 = x[j_coord_offset+DIM*0+XX];
852 jy0 = x[j_coord_offset+DIM*0+YY];
853 jz0 = x[j_coord_offset+DIM*0+ZZ];
854 jx1 = x[j_coord_offset+DIM*1+XX];
855 jy1 = x[j_coord_offset+DIM*1+YY];
856 jz1 = x[j_coord_offset+DIM*1+ZZ];
857 jx2 = x[j_coord_offset+DIM*2+XX];
858 jy2 = x[j_coord_offset+DIM*2+YY];
859 jz2 = x[j_coord_offset+DIM*2+ZZ];
860 jx3 = x[j_coord_offset+DIM*3+XX];
861 jy3 = x[j_coord_offset+DIM*3+YY];
862 jz3 = x[j_coord_offset+DIM*3+ZZ];
864 /* Calculate displacement vector */
896 /* Calculate squared distance and things based on it */
897 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
898 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
899 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
900 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
901 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
902 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
903 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
904 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
905 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
906 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
908 rinv00 = gmx_invsqrt(rsq00);
909 rinv11 = gmx_invsqrt(rsq11);
910 rinv12 = gmx_invsqrt(rsq12);
911 rinv13 = gmx_invsqrt(rsq13);
912 rinv21 = gmx_invsqrt(rsq21);
913 rinv22 = gmx_invsqrt(rsq22);
914 rinv23 = gmx_invsqrt(rsq23);
915 rinv31 = gmx_invsqrt(rsq31);
916 rinv32 = gmx_invsqrt(rsq32);
917 rinv33 = gmx_invsqrt(rsq33);
919 rinvsq00 = rinv00*rinv00;
920 rinvsq11 = rinv11*rinv11;
921 rinvsq12 = rinv12*rinv12;
922 rinvsq13 = rinv13*rinv13;
923 rinvsq21 = rinv21*rinv21;
924 rinvsq22 = rinv22*rinv22;
925 rinvsq23 = rinv23*rinv23;
926 rinvsq31 = rinv31*rinv31;
927 rinvsq32 = rinv32*rinv32;
928 rinvsq33 = rinv33*rinv33;
930 /**************************
931 * CALCULATE INTERACTIONS *
932 **************************/
939 /* BUCKINGHAM DISPERSION/REPULSION */
940 rinvsix = rinvsq00*rinvsq00*rinvsq00;
941 vvdw6 = c6_00*rinvsix;
943 vvdwexp = cexp1_00*exp(-br);
944 vvdw = vvdwexp - vvdw6*(1.0/6.0);
945 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
948 d = (d>0.0) ? d : 0.0;
950 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
952 dsw = d2*(swF2+d*(swF3+d*swF4));
954 /* Evaluate switch function */
955 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
956 fvdw = fvdw*sw - rinv00*vvdw*dsw;
960 /* Calculate temporary vectorial force */
965 /* Update vectorial force */
969 f[j_coord_offset+DIM*0+XX] -= tx;
970 f[j_coord_offset+DIM*0+YY] -= ty;
971 f[j_coord_offset+DIM*0+ZZ] -= tz;
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
982 /* REACTION-FIELD ELECTROSTATICS */
983 felec = qq11*(rinv11*rinvsq11-krf2);
987 /* Calculate temporary vectorial force */
992 /* Update vectorial force */
996 f[j_coord_offset+DIM*1+XX] -= tx;
997 f[j_coord_offset+DIM*1+YY] -= ty;
998 f[j_coord_offset+DIM*1+ZZ] -= tz;
1002 /**************************
1003 * CALCULATE INTERACTIONS *
1004 **************************/
1009 /* REACTION-FIELD ELECTROSTATICS */
1010 felec = qq12*(rinv12*rinvsq12-krf2);
1014 /* Calculate temporary vectorial force */
1019 /* Update vectorial force */
1023 f[j_coord_offset+DIM*2+XX] -= tx;
1024 f[j_coord_offset+DIM*2+YY] -= ty;
1025 f[j_coord_offset+DIM*2+ZZ] -= tz;
1029 /**************************
1030 * CALCULATE INTERACTIONS *
1031 **************************/
1036 /* REACTION-FIELD ELECTROSTATICS */
1037 felec = qq13*(rinv13*rinvsq13-krf2);
1041 /* Calculate temporary vectorial force */
1046 /* Update vectorial force */
1050 f[j_coord_offset+DIM*3+XX] -= tx;
1051 f[j_coord_offset+DIM*3+YY] -= ty;
1052 f[j_coord_offset+DIM*3+ZZ] -= tz;
1056 /**************************
1057 * CALCULATE INTERACTIONS *
1058 **************************/
1063 /* REACTION-FIELD ELECTROSTATICS */
1064 felec = qq21*(rinv21*rinvsq21-krf2);
1068 /* Calculate temporary vectorial force */
1073 /* Update vectorial force */
1077 f[j_coord_offset+DIM*1+XX] -= tx;
1078 f[j_coord_offset+DIM*1+YY] -= ty;
1079 f[j_coord_offset+DIM*1+ZZ] -= tz;
1083 /**************************
1084 * CALCULATE INTERACTIONS *
1085 **************************/
1090 /* REACTION-FIELD ELECTROSTATICS */
1091 felec = qq22*(rinv22*rinvsq22-krf2);
1095 /* Calculate temporary vectorial force */
1100 /* Update vectorial force */
1104 f[j_coord_offset+DIM*2+XX] -= tx;
1105 f[j_coord_offset+DIM*2+YY] -= ty;
1106 f[j_coord_offset+DIM*2+ZZ] -= tz;
1110 /**************************
1111 * CALCULATE INTERACTIONS *
1112 **************************/
1117 /* REACTION-FIELD ELECTROSTATICS */
1118 felec = qq23*(rinv23*rinvsq23-krf2);
1122 /* Calculate temporary vectorial force */
1127 /* Update vectorial force */
1131 f[j_coord_offset+DIM*3+XX] -= tx;
1132 f[j_coord_offset+DIM*3+YY] -= ty;
1133 f[j_coord_offset+DIM*3+ZZ] -= tz;
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1144 /* REACTION-FIELD ELECTROSTATICS */
1145 felec = qq31*(rinv31*rinvsq31-krf2);
1149 /* Calculate temporary vectorial force */
1154 /* Update vectorial force */
1158 f[j_coord_offset+DIM*1+XX] -= tx;
1159 f[j_coord_offset+DIM*1+YY] -= ty;
1160 f[j_coord_offset+DIM*1+ZZ] -= tz;
1164 /**************************
1165 * CALCULATE INTERACTIONS *
1166 **************************/
1171 /* REACTION-FIELD ELECTROSTATICS */
1172 felec = qq32*(rinv32*rinvsq32-krf2);
1176 /* Calculate temporary vectorial force */
1181 /* Update vectorial force */
1185 f[j_coord_offset+DIM*2+XX] -= tx;
1186 f[j_coord_offset+DIM*2+YY] -= ty;
1187 f[j_coord_offset+DIM*2+ZZ] -= tz;
1191 /**************************
1192 * CALCULATE INTERACTIONS *
1193 **************************/
1198 /* REACTION-FIELD ELECTROSTATICS */
1199 felec = qq33*(rinv33*rinvsq33-krf2);
1203 /* Calculate temporary vectorial force */
1208 /* Update vectorial force */
1212 f[j_coord_offset+DIM*3+XX] -= tx;
1213 f[j_coord_offset+DIM*3+YY] -= ty;
1214 f[j_coord_offset+DIM*3+ZZ] -= tz;
1218 /* Inner loop uses 311 flops */
1220 /* End of innermost loop */
1223 f[i_coord_offset+DIM*0+XX] += fix0;
1224 f[i_coord_offset+DIM*0+YY] += fiy0;
1225 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1229 f[i_coord_offset+DIM*1+XX] += fix1;
1230 f[i_coord_offset+DIM*1+YY] += fiy1;
1231 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1235 f[i_coord_offset+DIM*2+XX] += fix2;
1236 f[i_coord_offset+DIM*2+YY] += fiy2;
1237 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1241 f[i_coord_offset+DIM*3+XX] += fix3;
1242 f[i_coord_offset+DIM*3+YY] += fiy3;
1243 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1247 fshift[i_shift_offset+XX] += tx;
1248 fshift[i_shift_offset+YY] += ty;
1249 fshift[i_shift_offset+ZZ] += tz;
1251 /* Increment number of inner iterations */
1252 inneriter += j_index_end - j_index_start;
1254 /* Outer loop uses 39 flops */
1257 /* Increment number of outer iterations */
1260 /* Update outer/inner flops */
1262 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*311);