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_VdwLJSw_GeomW4W4_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSw_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 = 2*nvdwtype*vdwtype[inr+0];
136 vdwjidx0 = 2*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
149 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
150 rcutoff = fr->rcoulomb;
151 rcutoff2 = rcutoff*rcutoff;
153 rswitch = fr->rvdw_switch;
154 /* Setup switch parameters */
156 swV3 = -10.0/(d*d*d);
157 swV4 = 15.0/(d*d*d*d);
158 swV5 = -6.0/(d*d*d*d*d);
159 swF2 = -30.0/(d*d*d);
160 swF3 = 60.0/(d*d*d*d);
161 swF4 = -30.0/(d*d*d*d*d);
166 /* Start outer loop over neighborlists */
167 for(iidx=0; iidx<nri; iidx++)
169 /* Load shift vector for this list */
170 i_shift_offset = DIM*shiftidx[iidx];
171 shX = shiftvec[i_shift_offset+XX];
172 shY = shiftvec[i_shift_offset+YY];
173 shZ = shiftvec[i_shift_offset+ZZ];
175 /* Load limits for loop over neighbors */
176 j_index_start = jindex[iidx];
177 j_index_end = jindex[iidx+1];
179 /* Get outer coordinate index */
181 i_coord_offset = DIM*inr;
183 /* Load i particle coords and add shift vector */
184 ix0 = shX + x[i_coord_offset+DIM*0+XX];
185 iy0 = shY + x[i_coord_offset+DIM*0+YY];
186 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
187 ix1 = shX + x[i_coord_offset+DIM*1+XX];
188 iy1 = shY + x[i_coord_offset+DIM*1+YY];
189 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
190 ix2 = shX + x[i_coord_offset+DIM*2+XX];
191 iy2 = shY + x[i_coord_offset+DIM*2+YY];
192 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
193 ix3 = shX + x[i_coord_offset+DIM*3+XX];
194 iy3 = shY + x[i_coord_offset+DIM*3+YY];
195 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
210 /* Reset potential sums */
214 /* Start inner kernel loop */
215 for(jidx=j_index_start; jidx<j_index_end; jidx++)
217 /* Get j neighbor index, and coordinate index */
219 j_coord_offset = DIM*jnr;
221 /* load j atom coordinates */
222 jx0 = x[j_coord_offset+DIM*0+XX];
223 jy0 = x[j_coord_offset+DIM*0+YY];
224 jz0 = x[j_coord_offset+DIM*0+ZZ];
225 jx1 = x[j_coord_offset+DIM*1+XX];
226 jy1 = x[j_coord_offset+DIM*1+YY];
227 jz1 = x[j_coord_offset+DIM*1+ZZ];
228 jx2 = x[j_coord_offset+DIM*2+XX];
229 jy2 = x[j_coord_offset+DIM*2+YY];
230 jz2 = x[j_coord_offset+DIM*2+ZZ];
231 jx3 = x[j_coord_offset+DIM*3+XX];
232 jy3 = x[j_coord_offset+DIM*3+YY];
233 jz3 = x[j_coord_offset+DIM*3+ZZ];
235 /* Calculate displacement vector */
267 /* Calculate squared distance and things based on it */
268 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
269 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
270 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
271 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
272 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
273 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
274 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
275 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
276 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
277 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
279 rinv00 = gmx_invsqrt(rsq00);
280 rinv11 = gmx_invsqrt(rsq11);
281 rinv12 = gmx_invsqrt(rsq12);
282 rinv13 = gmx_invsqrt(rsq13);
283 rinv21 = gmx_invsqrt(rsq21);
284 rinv22 = gmx_invsqrt(rsq22);
285 rinv23 = gmx_invsqrt(rsq23);
286 rinv31 = gmx_invsqrt(rsq31);
287 rinv32 = gmx_invsqrt(rsq32);
288 rinv33 = gmx_invsqrt(rsq33);
290 rinvsq00 = rinv00*rinv00;
291 rinvsq11 = rinv11*rinv11;
292 rinvsq12 = rinv12*rinv12;
293 rinvsq13 = rinv13*rinv13;
294 rinvsq21 = rinv21*rinv21;
295 rinvsq22 = rinv22*rinv22;
296 rinvsq23 = rinv23*rinv23;
297 rinvsq31 = rinv31*rinv31;
298 rinvsq32 = rinv32*rinv32;
299 rinvsq33 = rinv33*rinv33;
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
310 /* LENNARD-JONES DISPERSION/REPULSION */
312 rinvsix = rinvsq00*rinvsq00*rinvsq00;
313 vvdw6 = c6_00*rinvsix;
314 vvdw12 = c12_00*rinvsix*rinvsix;
315 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
316 fvdw = (vvdw12-vvdw6)*rinvsq00;
319 d = (d>0.0) ? d : 0.0;
321 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
323 dsw = d2*(swF2+d*(swF3+d*swF4));
325 /* Evaluate switch function */
326 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
327 fvdw = fvdw*sw - rinv00*vvdw*dsw;
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*0+XX] -= tx;
345 f[j_coord_offset+DIM*0+YY] -= ty;
346 f[j_coord_offset+DIM*0+ZZ] -= tz;
350 /**************************
351 * CALCULATE INTERACTIONS *
352 **************************/
357 /* REACTION-FIELD ELECTROSTATICS */
358 velec = qq11*(rinv11+krf*rsq11-crf);
359 felec = qq11*(rinv11*rinvsq11-krf2);
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*1+XX] -= tx;
376 f[j_coord_offset+DIM*1+YY] -= ty;
377 f[j_coord_offset+DIM*1+ZZ] -= tz;
381 /**************************
382 * CALCULATE INTERACTIONS *
383 **************************/
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = qq12*(rinv12+krf*rsq12-crf);
390 felec = qq12*(rinv12*rinvsq12-krf2);
392 /* Update potential sums from outer loop */
397 /* Calculate temporary vectorial force */
402 /* Update vectorial force */
406 f[j_coord_offset+DIM*2+XX] -= tx;
407 f[j_coord_offset+DIM*2+YY] -= ty;
408 f[j_coord_offset+DIM*2+ZZ] -= tz;
412 /**************************
413 * CALCULATE INTERACTIONS *
414 **************************/
419 /* REACTION-FIELD ELECTROSTATICS */
420 velec = qq13*(rinv13+krf*rsq13-crf);
421 felec = qq13*(rinv13*rinvsq13-krf2);
423 /* Update potential sums from outer loop */
428 /* Calculate temporary vectorial force */
433 /* Update vectorial force */
437 f[j_coord_offset+DIM*3+XX] -= tx;
438 f[j_coord_offset+DIM*3+YY] -= ty;
439 f[j_coord_offset+DIM*3+ZZ] -= tz;
443 /**************************
444 * CALCULATE INTERACTIONS *
445 **************************/
450 /* REACTION-FIELD ELECTROSTATICS */
451 velec = qq21*(rinv21+krf*rsq21-crf);
452 felec = qq21*(rinv21*rinvsq21-krf2);
454 /* Update potential sums from outer loop */
459 /* Calculate temporary vectorial force */
464 /* Update vectorial force */
468 f[j_coord_offset+DIM*1+XX] -= tx;
469 f[j_coord_offset+DIM*1+YY] -= ty;
470 f[j_coord_offset+DIM*1+ZZ] -= tz;
474 /**************************
475 * CALCULATE INTERACTIONS *
476 **************************/
481 /* REACTION-FIELD ELECTROSTATICS */
482 velec = qq22*(rinv22+krf*rsq22-crf);
483 felec = qq22*(rinv22*rinvsq22-krf2);
485 /* Update potential sums from outer loop */
490 /* Calculate temporary vectorial force */
495 /* Update vectorial force */
499 f[j_coord_offset+DIM*2+XX] -= tx;
500 f[j_coord_offset+DIM*2+YY] -= ty;
501 f[j_coord_offset+DIM*2+ZZ] -= tz;
505 /**************************
506 * CALCULATE INTERACTIONS *
507 **************************/
512 /* REACTION-FIELD ELECTROSTATICS */
513 velec = qq23*(rinv23+krf*rsq23-crf);
514 felec = qq23*(rinv23*rinvsq23-krf2);
516 /* Update potential sums from outer loop */
521 /* Calculate temporary vectorial force */
526 /* Update vectorial force */
530 f[j_coord_offset+DIM*3+XX] -= tx;
531 f[j_coord_offset+DIM*3+YY] -= ty;
532 f[j_coord_offset+DIM*3+ZZ] -= tz;
536 /**************************
537 * CALCULATE INTERACTIONS *
538 **************************/
543 /* REACTION-FIELD ELECTROSTATICS */
544 velec = qq31*(rinv31+krf*rsq31-crf);
545 felec = qq31*(rinv31*rinvsq31-krf2);
547 /* Update potential sums from outer loop */
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*1+XX] -= tx;
562 f[j_coord_offset+DIM*1+YY] -= ty;
563 f[j_coord_offset+DIM*1+ZZ] -= tz;
567 /**************************
568 * CALCULATE INTERACTIONS *
569 **************************/
574 /* REACTION-FIELD ELECTROSTATICS */
575 velec = qq32*(rinv32+krf*rsq32-crf);
576 felec = qq32*(rinv32*rinvsq32-krf2);
578 /* Update potential sums from outer loop */
583 /* Calculate temporary vectorial force */
588 /* Update vectorial force */
592 f[j_coord_offset+DIM*2+XX] -= tx;
593 f[j_coord_offset+DIM*2+YY] -= ty;
594 f[j_coord_offset+DIM*2+ZZ] -= tz;
598 /**************************
599 * CALCULATE INTERACTIONS *
600 **************************/
605 /* REACTION-FIELD ELECTROSTATICS */
606 velec = qq33*(rinv33+krf*rsq33-crf);
607 felec = qq33*(rinv33*rinvsq33-krf2);
609 /* Update potential sums from outer loop */
614 /* Calculate temporary vectorial force */
619 /* Update vectorial force */
623 f[j_coord_offset+DIM*3+XX] -= tx;
624 f[j_coord_offset+DIM*3+YY] -= ty;
625 f[j_coord_offset+DIM*3+ZZ] -= tz;
629 /* Inner loop uses 332 flops */
631 /* End of innermost loop */
634 f[i_coord_offset+DIM*0+XX] += fix0;
635 f[i_coord_offset+DIM*0+YY] += fiy0;
636 f[i_coord_offset+DIM*0+ZZ] += fiz0;
640 f[i_coord_offset+DIM*1+XX] += fix1;
641 f[i_coord_offset+DIM*1+YY] += fiy1;
642 f[i_coord_offset+DIM*1+ZZ] += fiz1;
646 f[i_coord_offset+DIM*2+XX] += fix2;
647 f[i_coord_offset+DIM*2+YY] += fiy2;
648 f[i_coord_offset+DIM*2+ZZ] += fiz2;
652 f[i_coord_offset+DIM*3+XX] += fix3;
653 f[i_coord_offset+DIM*3+YY] += fiy3;
654 f[i_coord_offset+DIM*3+ZZ] += fiz3;
658 fshift[i_shift_offset+XX] += tx;
659 fshift[i_shift_offset+YY] += ty;
660 fshift[i_shift_offset+ZZ] += tz;
663 /* Update potential energies */
664 kernel_data->energygrp_elec[ggid] += velecsum;
665 kernel_data->energygrp_vdw[ggid] += vvdwsum;
667 /* Increment number of inner iterations */
668 inneriter += j_index_end - j_index_start;
670 /* Outer loop uses 41 flops */
673 /* Increment number of outer iterations */
676 /* Update outer/inner flops */
678 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*332);
681 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4W4_F_c
682 * Electrostatics interaction: ReactionField
683 * VdW interaction: LennardJones
684 * Geometry: Water4-Water4
685 * Calculate force/pot: Force
688 nb_kernel_ElecRFCut_VdwLJSw_GeomW4W4_F_c
689 (t_nblist * gmx_restrict nlist,
690 rvec * gmx_restrict xx,
691 rvec * gmx_restrict ff,
692 t_forcerec * gmx_restrict fr,
693 t_mdatoms * gmx_restrict mdatoms,
694 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
695 t_nrnb * gmx_restrict nrnb)
697 int i_shift_offset,i_coord_offset,j_coord_offset;
698 int j_index_start,j_index_end;
699 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
700 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
701 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
702 real *shiftvec,*fshift,*x,*f;
704 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
706 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
708 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
710 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
712 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
714 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
716 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
718 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
719 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
720 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
721 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
722 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
723 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
724 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
725 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
726 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
727 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
728 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
729 real velec,felec,velecsum,facel,crf,krf,krf2;
732 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
735 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
742 jindex = nlist->jindex;
744 shiftidx = nlist->shift;
746 shiftvec = fr->shift_vec[0];
747 fshift = fr->fshift[0];
749 charge = mdatoms->chargeA;
753 nvdwtype = fr->ntype;
755 vdwtype = mdatoms->typeA;
757 /* Setup water-specific parameters */
758 inr = nlist->iinr[0];
759 iq1 = facel*charge[inr+1];
760 iq2 = facel*charge[inr+2];
761 iq3 = facel*charge[inr+3];
762 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
767 vdwjidx0 = 2*vdwtype[inr+0];
768 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
769 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
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 /* LENNARD-JONES DISPERSION/REPULSION */
939 rinvsix = rinvsq00*rinvsq00*rinvsq00;
940 vvdw6 = c6_00*rinvsix;
941 vvdw12 = c12_00*rinvsix*rinvsix;
942 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
943 fvdw = (vvdw12-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 285 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*285);