2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwLJ_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;
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
115 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 /* Setup water-specific parameters */
121 inr = nlist->iinr[0];
122 iq1 = facel*charge[inr+1];
123 iq2 = facel*charge[inr+2];
124 iq3 = facel*charge[inr+3];
125 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
130 vdwjidx0 = 2*vdwtype[inr+0];
131 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
132 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
146 /* Start outer loop over neighborlists */
147 for(iidx=0; iidx<nri; iidx++)
149 /* Load shift vector for this list */
150 i_shift_offset = DIM*shiftidx[iidx];
151 shX = shiftvec[i_shift_offset+XX];
152 shY = shiftvec[i_shift_offset+YY];
153 shZ = shiftvec[i_shift_offset+ZZ];
155 /* Load limits for loop over neighbors */
156 j_index_start = jindex[iidx];
157 j_index_end = jindex[iidx+1];
159 /* Get outer coordinate index */
161 i_coord_offset = DIM*inr;
163 /* Load i particle coords and add shift vector */
164 ix0 = shX + x[i_coord_offset+DIM*0+XX];
165 iy0 = shY + x[i_coord_offset+DIM*0+YY];
166 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
167 ix1 = shX + x[i_coord_offset+DIM*1+XX];
168 iy1 = shY + x[i_coord_offset+DIM*1+YY];
169 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
170 ix2 = shX + x[i_coord_offset+DIM*2+XX];
171 iy2 = shY + x[i_coord_offset+DIM*2+YY];
172 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
173 ix3 = shX + x[i_coord_offset+DIM*3+XX];
174 iy3 = shY + x[i_coord_offset+DIM*3+YY];
175 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
190 /* Reset potential sums */
194 /* Start inner kernel loop */
195 for(jidx=j_index_start; jidx<j_index_end; jidx++)
197 /* Get j neighbor index, and coordinate index */
199 j_coord_offset = DIM*jnr;
201 /* load j atom coordinates */
202 jx0 = x[j_coord_offset+DIM*0+XX];
203 jy0 = x[j_coord_offset+DIM*0+YY];
204 jz0 = x[j_coord_offset+DIM*0+ZZ];
205 jx1 = x[j_coord_offset+DIM*1+XX];
206 jy1 = x[j_coord_offset+DIM*1+YY];
207 jz1 = x[j_coord_offset+DIM*1+ZZ];
208 jx2 = x[j_coord_offset+DIM*2+XX];
209 jy2 = x[j_coord_offset+DIM*2+YY];
210 jz2 = x[j_coord_offset+DIM*2+ZZ];
211 jx3 = x[j_coord_offset+DIM*3+XX];
212 jy3 = x[j_coord_offset+DIM*3+YY];
213 jz3 = x[j_coord_offset+DIM*3+ZZ];
215 /* Calculate displacement vector */
247 /* Calculate squared distance and things based on it */
248 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
249 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
250 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
251 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
252 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
253 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
254 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
255 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
256 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
257 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
259 rinv11 = gmx_invsqrt(rsq11);
260 rinv12 = gmx_invsqrt(rsq12);
261 rinv13 = gmx_invsqrt(rsq13);
262 rinv21 = gmx_invsqrt(rsq21);
263 rinv22 = gmx_invsqrt(rsq22);
264 rinv23 = gmx_invsqrt(rsq23);
265 rinv31 = gmx_invsqrt(rsq31);
266 rinv32 = gmx_invsqrt(rsq32);
267 rinv33 = gmx_invsqrt(rsq33);
269 rinvsq00 = 1.0/rsq00;
270 rinvsq11 = rinv11*rinv11;
271 rinvsq12 = rinv12*rinv12;
272 rinvsq13 = rinv13*rinv13;
273 rinvsq21 = rinv21*rinv21;
274 rinvsq22 = rinv22*rinv22;
275 rinvsq23 = rinv23*rinv23;
276 rinvsq31 = rinv31*rinv31;
277 rinvsq32 = rinv32*rinv32;
278 rinvsq33 = rinv33*rinv33;
280 /**************************
281 * CALCULATE INTERACTIONS *
282 **************************/
284 /* LENNARD-JONES DISPERSION/REPULSION */
286 rinvsix = rinvsq00*rinvsq00*rinvsq00;
287 vvdw6 = c6_00*rinvsix;
288 vvdw12 = c12_00*rinvsix*rinvsix;
289 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
290 fvdw = (vvdw12-vvdw6)*rinvsq00;
292 /* Update potential sums from outer loop */
297 /* Calculate temporary vectorial force */
302 /* Update vectorial force */
306 f[j_coord_offset+DIM*0+XX] -= tx;
307 f[j_coord_offset+DIM*0+YY] -= ty;
308 f[j_coord_offset+DIM*0+ZZ] -= tz;
310 /**************************
311 * CALCULATE INTERACTIONS *
312 **************************/
314 /* COULOMB ELECTROSTATICS */
316 felec = velec*rinvsq11;
318 /* Update potential sums from outer loop */
323 /* Calculate temporary vectorial force */
328 /* Update vectorial force */
332 f[j_coord_offset+DIM*1+XX] -= tx;
333 f[j_coord_offset+DIM*1+YY] -= ty;
334 f[j_coord_offset+DIM*1+ZZ] -= tz;
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
340 /* COULOMB ELECTROSTATICS */
342 felec = velec*rinvsq12;
344 /* Update potential sums from outer loop */
349 /* Calculate temporary vectorial force */
354 /* Update vectorial force */
358 f[j_coord_offset+DIM*2+XX] -= tx;
359 f[j_coord_offset+DIM*2+YY] -= ty;
360 f[j_coord_offset+DIM*2+ZZ] -= tz;
362 /**************************
363 * CALCULATE INTERACTIONS *
364 **************************/
366 /* COULOMB ELECTROSTATICS */
368 felec = velec*rinvsq13;
370 /* Update potential sums from outer loop */
375 /* Calculate temporary vectorial force */
380 /* Update vectorial force */
384 f[j_coord_offset+DIM*3+XX] -= tx;
385 f[j_coord_offset+DIM*3+YY] -= ty;
386 f[j_coord_offset+DIM*3+ZZ] -= tz;
388 /**************************
389 * CALCULATE INTERACTIONS *
390 **************************/
392 /* COULOMB ELECTROSTATICS */
394 felec = velec*rinvsq21;
396 /* Update potential sums from outer loop */
401 /* Calculate temporary vectorial force */
406 /* Update vectorial force */
410 f[j_coord_offset+DIM*1+XX] -= tx;
411 f[j_coord_offset+DIM*1+YY] -= ty;
412 f[j_coord_offset+DIM*1+ZZ] -= tz;
414 /**************************
415 * CALCULATE INTERACTIONS *
416 **************************/
418 /* COULOMB ELECTROSTATICS */
420 felec = velec*rinvsq22;
422 /* Update potential sums from outer loop */
427 /* Calculate temporary vectorial force */
432 /* Update vectorial force */
436 f[j_coord_offset+DIM*2+XX] -= tx;
437 f[j_coord_offset+DIM*2+YY] -= ty;
438 f[j_coord_offset+DIM*2+ZZ] -= tz;
440 /**************************
441 * CALCULATE INTERACTIONS *
442 **************************/
444 /* COULOMB ELECTROSTATICS */
446 felec = velec*rinvsq23;
448 /* Update potential sums from outer loop */
453 /* Calculate temporary vectorial force */
458 /* Update vectorial force */
462 f[j_coord_offset+DIM*3+XX] -= tx;
463 f[j_coord_offset+DIM*3+YY] -= ty;
464 f[j_coord_offset+DIM*3+ZZ] -= tz;
466 /**************************
467 * CALCULATE INTERACTIONS *
468 **************************/
470 /* COULOMB ELECTROSTATICS */
472 felec = velec*rinvsq31;
474 /* Update potential sums from outer loop */
479 /* Calculate temporary vectorial force */
484 /* Update vectorial force */
488 f[j_coord_offset+DIM*1+XX] -= tx;
489 f[j_coord_offset+DIM*1+YY] -= ty;
490 f[j_coord_offset+DIM*1+ZZ] -= tz;
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
496 /* COULOMB ELECTROSTATICS */
498 felec = velec*rinvsq32;
500 /* Update potential sums from outer loop */
505 /* Calculate temporary vectorial force */
510 /* Update vectorial force */
514 f[j_coord_offset+DIM*2+XX] -= tx;
515 f[j_coord_offset+DIM*2+YY] -= ty;
516 f[j_coord_offset+DIM*2+ZZ] -= tz;
518 /**************************
519 * CALCULATE INTERACTIONS *
520 **************************/
522 /* COULOMB ELECTROSTATICS */
524 felec = velec*rinvsq33;
526 /* Update potential sums from outer loop */
531 /* Calculate temporary vectorial force */
536 /* Update vectorial force */
540 f[j_coord_offset+DIM*3+XX] -= tx;
541 f[j_coord_offset+DIM*3+YY] -= ty;
542 f[j_coord_offset+DIM*3+ZZ] -= tz;
544 /* Inner loop uses 275 flops */
546 /* End of innermost loop */
549 f[i_coord_offset+DIM*0+XX] += fix0;
550 f[i_coord_offset+DIM*0+YY] += fiy0;
551 f[i_coord_offset+DIM*0+ZZ] += fiz0;
555 f[i_coord_offset+DIM*1+XX] += fix1;
556 f[i_coord_offset+DIM*1+YY] += fiy1;
557 f[i_coord_offset+DIM*1+ZZ] += fiz1;
561 f[i_coord_offset+DIM*2+XX] += fix2;
562 f[i_coord_offset+DIM*2+YY] += fiy2;
563 f[i_coord_offset+DIM*2+ZZ] += fiz2;
567 f[i_coord_offset+DIM*3+XX] += fix3;
568 f[i_coord_offset+DIM*3+YY] += fiy3;
569 f[i_coord_offset+DIM*3+ZZ] += fiz3;
573 fshift[i_shift_offset+XX] += tx;
574 fshift[i_shift_offset+YY] += ty;
575 fshift[i_shift_offset+ZZ] += tz;
578 /* Update potential energies */
579 kernel_data->energygrp_elec[ggid] += velecsum;
580 kernel_data->energygrp_vdw[ggid] += vvdwsum;
582 /* Increment number of inner iterations */
583 inneriter += j_index_end - j_index_start;
585 /* Outer loop uses 41 flops */
588 /* Increment number of outer iterations */
591 /* Update outer/inner flops */
593 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*275);
596 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_c
597 * Electrostatics interaction: Coulomb
598 * VdW interaction: LennardJones
599 * Geometry: Water4-Water4
600 * Calculate force/pot: Force
603 nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_c
604 (t_nblist * gmx_restrict nlist,
605 rvec * gmx_restrict xx,
606 rvec * gmx_restrict ff,
607 t_forcerec * gmx_restrict fr,
608 t_mdatoms * gmx_restrict mdatoms,
609 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
610 t_nrnb * gmx_restrict nrnb)
612 int i_shift_offset,i_coord_offset,j_coord_offset;
613 int j_index_start,j_index_end;
614 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
615 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
616 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
617 real *shiftvec,*fshift,*x,*f;
619 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
621 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
623 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
625 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
627 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
629 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
631 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
633 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
634 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
635 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
636 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
637 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
638 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
639 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
640 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
641 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
642 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
643 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
644 real velec,felec,velecsum,facel,crf,krf,krf2;
647 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
656 jindex = nlist->jindex;
658 shiftidx = nlist->shift;
660 shiftvec = fr->shift_vec[0];
661 fshift = fr->fshift[0];
663 charge = mdatoms->chargeA;
664 nvdwtype = fr->ntype;
666 vdwtype = mdatoms->typeA;
668 /* Setup water-specific parameters */
669 inr = nlist->iinr[0];
670 iq1 = facel*charge[inr+1];
671 iq2 = facel*charge[inr+2];
672 iq3 = facel*charge[inr+3];
673 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
678 vdwjidx0 = 2*vdwtype[inr+0];
679 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
680 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
694 /* Start outer loop over neighborlists */
695 for(iidx=0; iidx<nri; iidx++)
697 /* Load shift vector for this list */
698 i_shift_offset = DIM*shiftidx[iidx];
699 shX = shiftvec[i_shift_offset+XX];
700 shY = shiftvec[i_shift_offset+YY];
701 shZ = shiftvec[i_shift_offset+ZZ];
703 /* Load limits for loop over neighbors */
704 j_index_start = jindex[iidx];
705 j_index_end = jindex[iidx+1];
707 /* Get outer coordinate index */
709 i_coord_offset = DIM*inr;
711 /* Load i particle coords and add shift vector */
712 ix0 = shX + x[i_coord_offset+DIM*0+XX];
713 iy0 = shY + x[i_coord_offset+DIM*0+YY];
714 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
715 ix1 = shX + x[i_coord_offset+DIM*1+XX];
716 iy1 = shY + x[i_coord_offset+DIM*1+YY];
717 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
718 ix2 = shX + x[i_coord_offset+DIM*2+XX];
719 iy2 = shY + x[i_coord_offset+DIM*2+YY];
720 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
721 ix3 = shX + x[i_coord_offset+DIM*3+XX];
722 iy3 = shY + x[i_coord_offset+DIM*3+YY];
723 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
738 /* Start inner kernel loop */
739 for(jidx=j_index_start; jidx<j_index_end; jidx++)
741 /* Get j neighbor index, and coordinate index */
743 j_coord_offset = DIM*jnr;
745 /* load j atom coordinates */
746 jx0 = x[j_coord_offset+DIM*0+XX];
747 jy0 = x[j_coord_offset+DIM*0+YY];
748 jz0 = x[j_coord_offset+DIM*0+ZZ];
749 jx1 = x[j_coord_offset+DIM*1+XX];
750 jy1 = x[j_coord_offset+DIM*1+YY];
751 jz1 = x[j_coord_offset+DIM*1+ZZ];
752 jx2 = x[j_coord_offset+DIM*2+XX];
753 jy2 = x[j_coord_offset+DIM*2+YY];
754 jz2 = x[j_coord_offset+DIM*2+ZZ];
755 jx3 = x[j_coord_offset+DIM*3+XX];
756 jy3 = x[j_coord_offset+DIM*3+YY];
757 jz3 = x[j_coord_offset+DIM*3+ZZ];
759 /* Calculate displacement vector */
791 /* Calculate squared distance and things based on it */
792 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
793 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
794 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
795 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
796 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
797 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
798 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
799 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
800 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
801 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
803 rinv11 = gmx_invsqrt(rsq11);
804 rinv12 = gmx_invsqrt(rsq12);
805 rinv13 = gmx_invsqrt(rsq13);
806 rinv21 = gmx_invsqrt(rsq21);
807 rinv22 = gmx_invsqrt(rsq22);
808 rinv23 = gmx_invsqrt(rsq23);
809 rinv31 = gmx_invsqrt(rsq31);
810 rinv32 = gmx_invsqrt(rsq32);
811 rinv33 = gmx_invsqrt(rsq33);
813 rinvsq00 = 1.0/rsq00;
814 rinvsq11 = rinv11*rinv11;
815 rinvsq12 = rinv12*rinv12;
816 rinvsq13 = rinv13*rinv13;
817 rinvsq21 = rinv21*rinv21;
818 rinvsq22 = rinv22*rinv22;
819 rinvsq23 = rinv23*rinv23;
820 rinvsq31 = rinv31*rinv31;
821 rinvsq32 = rinv32*rinv32;
822 rinvsq33 = rinv33*rinv33;
824 /**************************
825 * CALCULATE INTERACTIONS *
826 **************************/
828 /* LENNARD-JONES DISPERSION/REPULSION */
830 rinvsix = rinvsq00*rinvsq00*rinvsq00;
831 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
835 /* Calculate temporary vectorial force */
840 /* Update vectorial force */
844 f[j_coord_offset+DIM*0+XX] -= tx;
845 f[j_coord_offset+DIM*0+YY] -= ty;
846 f[j_coord_offset+DIM*0+ZZ] -= tz;
848 /**************************
849 * CALCULATE INTERACTIONS *
850 **************************/
852 /* COULOMB ELECTROSTATICS */
854 felec = velec*rinvsq11;
858 /* Calculate temporary vectorial force */
863 /* Update vectorial force */
867 f[j_coord_offset+DIM*1+XX] -= tx;
868 f[j_coord_offset+DIM*1+YY] -= ty;
869 f[j_coord_offset+DIM*1+ZZ] -= tz;
871 /**************************
872 * CALCULATE INTERACTIONS *
873 **************************/
875 /* COULOMB ELECTROSTATICS */
877 felec = velec*rinvsq12;
881 /* Calculate temporary vectorial force */
886 /* Update vectorial force */
890 f[j_coord_offset+DIM*2+XX] -= tx;
891 f[j_coord_offset+DIM*2+YY] -= ty;
892 f[j_coord_offset+DIM*2+ZZ] -= tz;
894 /**************************
895 * CALCULATE INTERACTIONS *
896 **************************/
898 /* COULOMB ELECTROSTATICS */
900 felec = velec*rinvsq13;
904 /* Calculate temporary vectorial force */
909 /* Update vectorial force */
913 f[j_coord_offset+DIM*3+XX] -= tx;
914 f[j_coord_offset+DIM*3+YY] -= ty;
915 f[j_coord_offset+DIM*3+ZZ] -= tz;
917 /**************************
918 * CALCULATE INTERACTIONS *
919 **************************/
921 /* COULOMB ELECTROSTATICS */
923 felec = velec*rinvsq21;
927 /* Calculate temporary vectorial force */
932 /* Update vectorial force */
936 f[j_coord_offset+DIM*1+XX] -= tx;
937 f[j_coord_offset+DIM*1+YY] -= ty;
938 f[j_coord_offset+DIM*1+ZZ] -= tz;
940 /**************************
941 * CALCULATE INTERACTIONS *
942 **************************/
944 /* COULOMB ELECTROSTATICS */
946 felec = velec*rinvsq22;
950 /* Calculate temporary vectorial force */
955 /* Update vectorial force */
959 f[j_coord_offset+DIM*2+XX] -= tx;
960 f[j_coord_offset+DIM*2+YY] -= ty;
961 f[j_coord_offset+DIM*2+ZZ] -= tz;
963 /**************************
964 * CALCULATE INTERACTIONS *
965 **************************/
967 /* COULOMB ELECTROSTATICS */
969 felec = velec*rinvsq23;
973 /* Calculate temporary vectorial force */
978 /* Update vectorial force */
982 f[j_coord_offset+DIM*3+XX] -= tx;
983 f[j_coord_offset+DIM*3+YY] -= ty;
984 f[j_coord_offset+DIM*3+ZZ] -= tz;
986 /**************************
987 * CALCULATE INTERACTIONS *
988 **************************/
990 /* COULOMB ELECTROSTATICS */
992 felec = velec*rinvsq31;
996 /* Calculate temporary vectorial force */
1001 /* Update vectorial force */
1005 f[j_coord_offset+DIM*1+XX] -= tx;
1006 f[j_coord_offset+DIM*1+YY] -= ty;
1007 f[j_coord_offset+DIM*1+ZZ] -= tz;
1009 /**************************
1010 * CALCULATE INTERACTIONS *
1011 **************************/
1013 /* COULOMB ELECTROSTATICS */
1014 velec = qq32*rinv32;
1015 felec = velec*rinvsq32;
1019 /* Calculate temporary vectorial force */
1024 /* Update vectorial force */
1028 f[j_coord_offset+DIM*2+XX] -= tx;
1029 f[j_coord_offset+DIM*2+YY] -= ty;
1030 f[j_coord_offset+DIM*2+ZZ] -= tz;
1032 /**************************
1033 * CALCULATE INTERACTIONS *
1034 **************************/
1036 /* COULOMB ELECTROSTATICS */
1037 velec = qq33*rinv33;
1038 felec = velec*rinvsq33;
1042 /* Calculate temporary vectorial force */
1047 /* Update vectorial force */
1051 f[j_coord_offset+DIM*3+XX] -= tx;
1052 f[j_coord_offset+DIM*3+YY] -= ty;
1053 f[j_coord_offset+DIM*3+ZZ] -= tz;
1055 /* Inner loop uses 261 flops */
1057 /* End of innermost loop */
1060 f[i_coord_offset+DIM*0+XX] += fix0;
1061 f[i_coord_offset+DIM*0+YY] += fiy0;
1062 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1066 f[i_coord_offset+DIM*1+XX] += fix1;
1067 f[i_coord_offset+DIM*1+YY] += fiy1;
1068 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1072 f[i_coord_offset+DIM*2+XX] += fix2;
1073 f[i_coord_offset+DIM*2+YY] += fiy2;
1074 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1078 f[i_coord_offset+DIM*3+XX] += fix3;
1079 f[i_coord_offset+DIM*3+YY] += fiy3;
1080 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1084 fshift[i_shift_offset+XX] += tx;
1085 fshift[i_shift_offset+YY] += ty;
1086 fshift[i_shift_offset+ZZ] += tz;
1088 /* Increment number of inner iterations */
1089 inneriter += j_index_end - j_index_start;
1091 /* Outer loop uses 39 flops */
1094 /* Increment number of outer iterations */
1097 /* Update outer/inner flops */
1099 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*261);