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_ElecRFCut_VdwBhamSh_GeomW3W3_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
103 jindex = nlist->jindex;
105 shiftidx = nlist->shift;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
110 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 /* Setup water-specific parameters */
119 inr = nlist->iinr[0];
120 iq0 = facel*charge[inr+0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
123 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
128 vdwjidx0 = 3*vdwtype[inr+0];
130 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
131 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
132 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
142 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
143 rcutoff = fr->rcoulomb;
144 rcutoff2 = rcutoff*rcutoff;
146 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
152 /* Start outer loop over neighborlists */
153 for(iidx=0; iidx<nri; iidx++)
155 /* Load shift vector for this list */
156 i_shift_offset = DIM*shiftidx[iidx];
157 shX = shiftvec[i_shift_offset+XX];
158 shY = shiftvec[i_shift_offset+YY];
159 shZ = shiftvec[i_shift_offset+ZZ];
161 /* Load limits for loop over neighbors */
162 j_index_start = jindex[iidx];
163 j_index_end = jindex[iidx+1];
165 /* Get outer coordinate index */
167 i_coord_offset = DIM*inr;
169 /* Load i particle coords and add shift vector */
170 ix0 = shX + x[i_coord_offset+DIM*0+XX];
171 iy0 = shY + x[i_coord_offset+DIM*0+YY];
172 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
173 ix1 = shX + x[i_coord_offset+DIM*1+XX];
174 iy1 = shY + x[i_coord_offset+DIM*1+YY];
175 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
176 ix2 = shX + x[i_coord_offset+DIM*2+XX];
177 iy2 = shY + x[i_coord_offset+DIM*2+YY];
178 iz2 = shZ + x[i_coord_offset+DIM*2+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];
212 /* Calculate displacement vector */
241 /* Calculate squared distance and things based on it */
242 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
243 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
244 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
245 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
246 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
247 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
248 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
249 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
250 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
252 rinv00 = gmx_invsqrt(rsq00);
253 rinv01 = gmx_invsqrt(rsq01);
254 rinv02 = gmx_invsqrt(rsq02);
255 rinv10 = gmx_invsqrt(rsq10);
256 rinv11 = gmx_invsqrt(rsq11);
257 rinv12 = gmx_invsqrt(rsq12);
258 rinv20 = gmx_invsqrt(rsq20);
259 rinv21 = gmx_invsqrt(rsq21);
260 rinv22 = gmx_invsqrt(rsq22);
262 rinvsq00 = rinv00*rinv00;
263 rinvsq01 = rinv01*rinv01;
264 rinvsq02 = rinv02*rinv02;
265 rinvsq10 = rinv10*rinv10;
266 rinvsq11 = rinv11*rinv11;
267 rinvsq12 = rinv12*rinv12;
268 rinvsq20 = rinv20*rinv20;
269 rinvsq21 = rinv21*rinv21;
270 rinvsq22 = rinv22*rinv22;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
281 /* REACTION-FIELD ELECTROSTATICS */
282 velec = qq00*(rinv00+krf*rsq00-crf);
283 felec = qq00*(rinv00*rinvsq00-krf2);
285 /* BUCKINGHAM DISPERSION/REPULSION */
286 rinvsix = rinvsq00*rinvsq00*rinvsq00;
287 vvdw6 = c6_00*rinvsix;
289 vvdwexp = cexp1_00*exp(-br);
290 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
291 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
293 /* Update potential sums from outer loop */
299 /* Calculate temporary vectorial force */
304 /* Update vectorial force */
308 f[j_coord_offset+DIM*0+XX] -= tx;
309 f[j_coord_offset+DIM*0+YY] -= ty;
310 f[j_coord_offset+DIM*0+ZZ] -= tz;
314 /**************************
315 * CALCULATE INTERACTIONS *
316 **************************/
321 /* REACTION-FIELD ELECTROSTATICS */
322 velec = qq01*(rinv01+krf*rsq01-crf);
323 felec = qq01*(rinv01*rinvsq01-krf2);
325 /* Update potential sums from outer loop */
330 /* Calculate temporary vectorial force */
335 /* Update vectorial force */
339 f[j_coord_offset+DIM*1+XX] -= tx;
340 f[j_coord_offset+DIM*1+YY] -= ty;
341 f[j_coord_offset+DIM*1+ZZ] -= tz;
345 /**************************
346 * CALCULATE INTERACTIONS *
347 **************************/
352 /* REACTION-FIELD ELECTROSTATICS */
353 velec = qq02*(rinv02+krf*rsq02-crf);
354 felec = qq02*(rinv02*rinvsq02-krf2);
356 /* Update potential sums from outer loop */
361 /* Calculate temporary vectorial force */
366 /* Update vectorial force */
370 f[j_coord_offset+DIM*2+XX] -= tx;
371 f[j_coord_offset+DIM*2+YY] -= ty;
372 f[j_coord_offset+DIM*2+ZZ] -= tz;
376 /**************************
377 * CALCULATE INTERACTIONS *
378 **************************/
383 /* REACTION-FIELD ELECTROSTATICS */
384 velec = qq10*(rinv10+krf*rsq10-crf);
385 felec = qq10*(rinv10*rinvsq10-krf2);
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*0+XX] -= tx;
402 f[j_coord_offset+DIM*0+YY] -= ty;
403 f[j_coord_offset+DIM*0+ZZ] -= tz;
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
414 /* REACTION-FIELD ELECTROSTATICS */
415 velec = qq11*(rinv11+krf*rsq11-crf);
416 felec = qq11*(rinv11*rinvsq11-krf2);
418 /* Update potential sums from outer loop */
423 /* Calculate temporary vectorial force */
428 /* Update vectorial force */
432 f[j_coord_offset+DIM*1+XX] -= tx;
433 f[j_coord_offset+DIM*1+YY] -= ty;
434 f[j_coord_offset+DIM*1+ZZ] -= tz;
438 /**************************
439 * CALCULATE INTERACTIONS *
440 **************************/
445 /* REACTION-FIELD ELECTROSTATICS */
446 velec = qq12*(rinv12+krf*rsq12-crf);
447 felec = qq12*(rinv12*rinvsq12-krf2);
449 /* Update potential sums from outer loop */
454 /* Calculate temporary vectorial force */
459 /* Update vectorial force */
463 f[j_coord_offset+DIM*2+XX] -= tx;
464 f[j_coord_offset+DIM*2+YY] -= ty;
465 f[j_coord_offset+DIM*2+ZZ] -= tz;
469 /**************************
470 * CALCULATE INTERACTIONS *
471 **************************/
476 /* REACTION-FIELD ELECTROSTATICS */
477 velec = qq20*(rinv20+krf*rsq20-crf);
478 felec = qq20*(rinv20*rinvsq20-krf2);
480 /* Update potential sums from outer loop */
485 /* Calculate temporary vectorial force */
490 /* Update vectorial force */
494 f[j_coord_offset+DIM*0+XX] -= tx;
495 f[j_coord_offset+DIM*0+YY] -= ty;
496 f[j_coord_offset+DIM*0+ZZ] -= tz;
500 /**************************
501 * CALCULATE INTERACTIONS *
502 **************************/
507 /* REACTION-FIELD ELECTROSTATICS */
508 velec = qq21*(rinv21+krf*rsq21-crf);
509 felec = qq21*(rinv21*rinvsq21-krf2);
511 /* Update potential sums from outer loop */
516 /* Calculate temporary vectorial force */
521 /* Update vectorial force */
525 f[j_coord_offset+DIM*1+XX] -= tx;
526 f[j_coord_offset+DIM*1+YY] -= ty;
527 f[j_coord_offset+DIM*1+ZZ] -= tz;
531 /**************************
532 * CALCULATE INTERACTIONS *
533 **************************/
538 /* REACTION-FIELD ELECTROSTATICS */
539 velec = qq22*(rinv22+krf*rsq22-crf);
540 felec = qq22*(rinv22*rinvsq22-krf2);
542 /* Update potential sums from outer loop */
547 /* Calculate temporary vectorial force */
552 /* Update vectorial force */
556 f[j_coord_offset+DIM*2+XX] -= tx;
557 f[j_coord_offset+DIM*2+YY] -= ty;
558 f[j_coord_offset+DIM*2+ZZ] -= tz;
562 /* Inner loop uses 349 flops */
564 /* End of innermost loop */
567 f[i_coord_offset+DIM*0+XX] += fix0;
568 f[i_coord_offset+DIM*0+YY] += fiy0;
569 f[i_coord_offset+DIM*0+ZZ] += fiz0;
573 f[i_coord_offset+DIM*1+XX] += fix1;
574 f[i_coord_offset+DIM*1+YY] += fiy1;
575 f[i_coord_offset+DIM*1+ZZ] += fiz1;
579 f[i_coord_offset+DIM*2+XX] += fix2;
580 f[i_coord_offset+DIM*2+YY] += fiy2;
581 f[i_coord_offset+DIM*2+ZZ] += fiz2;
585 fshift[i_shift_offset+XX] += tx;
586 fshift[i_shift_offset+YY] += ty;
587 fshift[i_shift_offset+ZZ] += tz;
590 /* Update potential energies */
591 kernel_data->energygrp_elec[ggid] += velecsum;
592 kernel_data->energygrp_vdw[ggid] += vvdwsum;
594 /* Increment number of inner iterations */
595 inneriter += j_index_end - j_index_start;
597 /* Outer loop uses 32 flops */
600 /* Increment number of outer iterations */
603 /* Update outer/inner flops */
605 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*349);
608 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_F_c
609 * Electrostatics interaction: ReactionField
610 * VdW interaction: Buckingham
611 * Geometry: Water3-Water3
612 * Calculate force/pot: Force
615 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3W3_F_c
616 (t_nblist * gmx_restrict nlist,
617 rvec * gmx_restrict xx,
618 rvec * gmx_restrict ff,
619 t_forcerec * gmx_restrict fr,
620 t_mdatoms * gmx_restrict mdatoms,
621 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
622 t_nrnb * gmx_restrict nrnb)
624 int i_shift_offset,i_coord_offset,j_coord_offset;
625 int j_index_start,j_index_end;
626 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
627 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
628 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
629 real *shiftvec,*fshift,*x,*f;
631 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
633 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
635 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
637 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
639 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
641 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
642 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
643 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
644 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
645 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
646 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
647 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
648 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
649 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
650 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
651 real velec,felec,velecsum,facel,crf,krf,krf2;
654 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
663 jindex = nlist->jindex;
665 shiftidx = nlist->shift;
667 shiftvec = fr->shift_vec[0];
668 fshift = fr->fshift[0];
670 charge = mdatoms->chargeA;
674 nvdwtype = fr->ntype;
676 vdwtype = mdatoms->typeA;
678 /* Setup water-specific parameters */
679 inr = nlist->iinr[0];
680 iq0 = facel*charge[inr+0];
681 iq1 = facel*charge[inr+1];
682 iq2 = facel*charge[inr+2];
683 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
688 vdwjidx0 = 3*vdwtype[inr+0];
690 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
691 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
692 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
702 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
703 rcutoff = fr->rcoulomb;
704 rcutoff2 = rcutoff*rcutoff;
706 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
712 /* Start outer loop over neighborlists */
713 for(iidx=0; iidx<nri; iidx++)
715 /* Load shift vector for this list */
716 i_shift_offset = DIM*shiftidx[iidx];
717 shX = shiftvec[i_shift_offset+XX];
718 shY = shiftvec[i_shift_offset+YY];
719 shZ = shiftvec[i_shift_offset+ZZ];
721 /* Load limits for loop over neighbors */
722 j_index_start = jindex[iidx];
723 j_index_end = jindex[iidx+1];
725 /* Get outer coordinate index */
727 i_coord_offset = DIM*inr;
729 /* Load i particle coords and add shift vector */
730 ix0 = shX + x[i_coord_offset+DIM*0+XX];
731 iy0 = shY + x[i_coord_offset+DIM*0+YY];
732 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
733 ix1 = shX + x[i_coord_offset+DIM*1+XX];
734 iy1 = shY + x[i_coord_offset+DIM*1+YY];
735 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
736 ix2 = shX + x[i_coord_offset+DIM*2+XX];
737 iy2 = shY + x[i_coord_offset+DIM*2+YY];
738 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
750 /* Start inner kernel loop */
751 for(jidx=j_index_start; jidx<j_index_end; jidx++)
753 /* Get j neighbor index, and coordinate index */
755 j_coord_offset = DIM*jnr;
757 /* load j atom coordinates */
758 jx0 = x[j_coord_offset+DIM*0+XX];
759 jy0 = x[j_coord_offset+DIM*0+YY];
760 jz0 = x[j_coord_offset+DIM*0+ZZ];
761 jx1 = x[j_coord_offset+DIM*1+XX];
762 jy1 = x[j_coord_offset+DIM*1+YY];
763 jz1 = x[j_coord_offset+DIM*1+ZZ];
764 jx2 = x[j_coord_offset+DIM*2+XX];
765 jy2 = x[j_coord_offset+DIM*2+YY];
766 jz2 = x[j_coord_offset+DIM*2+ZZ];
768 /* Calculate displacement vector */
797 /* Calculate squared distance and things based on it */
798 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
799 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
800 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
801 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
802 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
803 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
804 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
805 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
806 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
808 rinv00 = gmx_invsqrt(rsq00);
809 rinv01 = gmx_invsqrt(rsq01);
810 rinv02 = gmx_invsqrt(rsq02);
811 rinv10 = gmx_invsqrt(rsq10);
812 rinv11 = gmx_invsqrt(rsq11);
813 rinv12 = gmx_invsqrt(rsq12);
814 rinv20 = gmx_invsqrt(rsq20);
815 rinv21 = gmx_invsqrt(rsq21);
816 rinv22 = gmx_invsqrt(rsq22);
818 rinvsq00 = rinv00*rinv00;
819 rinvsq01 = rinv01*rinv01;
820 rinvsq02 = rinv02*rinv02;
821 rinvsq10 = rinv10*rinv10;
822 rinvsq11 = rinv11*rinv11;
823 rinvsq12 = rinv12*rinv12;
824 rinvsq20 = rinv20*rinv20;
825 rinvsq21 = rinv21*rinv21;
826 rinvsq22 = rinv22*rinv22;
828 /**************************
829 * CALCULATE INTERACTIONS *
830 **************************/
837 /* REACTION-FIELD ELECTROSTATICS */
838 felec = qq00*(rinv00*rinvsq00-krf2);
840 /* BUCKINGHAM DISPERSION/REPULSION */
841 rinvsix = rinvsq00*rinvsq00*rinvsq00;
842 vvdw6 = c6_00*rinvsix;
844 vvdwexp = cexp1_00*exp(-br);
845 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
849 /* Calculate temporary vectorial force */
854 /* Update vectorial force */
858 f[j_coord_offset+DIM*0+XX] -= tx;
859 f[j_coord_offset+DIM*0+YY] -= ty;
860 f[j_coord_offset+DIM*0+ZZ] -= tz;
864 /**************************
865 * CALCULATE INTERACTIONS *
866 **************************/
871 /* REACTION-FIELD ELECTROSTATICS */
872 felec = qq01*(rinv01*rinvsq01-krf2);
876 /* Calculate temporary vectorial force */
881 /* Update vectorial force */
885 f[j_coord_offset+DIM*1+XX] -= tx;
886 f[j_coord_offset+DIM*1+YY] -= ty;
887 f[j_coord_offset+DIM*1+ZZ] -= tz;
891 /**************************
892 * CALCULATE INTERACTIONS *
893 **************************/
898 /* REACTION-FIELD ELECTROSTATICS */
899 felec = qq02*(rinv02*rinvsq02-krf2);
903 /* Calculate temporary vectorial force */
908 /* Update vectorial force */
912 f[j_coord_offset+DIM*2+XX] -= tx;
913 f[j_coord_offset+DIM*2+YY] -= ty;
914 f[j_coord_offset+DIM*2+ZZ] -= tz;
918 /**************************
919 * CALCULATE INTERACTIONS *
920 **************************/
925 /* REACTION-FIELD ELECTROSTATICS */
926 felec = qq10*(rinv10*rinvsq10-krf2);
930 /* Calculate temporary vectorial force */
935 /* Update vectorial force */
939 f[j_coord_offset+DIM*0+XX] -= tx;
940 f[j_coord_offset+DIM*0+YY] -= ty;
941 f[j_coord_offset+DIM*0+ZZ] -= tz;
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
952 /* REACTION-FIELD ELECTROSTATICS */
953 felec = qq11*(rinv11*rinvsq11-krf2);
957 /* Calculate temporary vectorial force */
962 /* Update vectorial force */
966 f[j_coord_offset+DIM*1+XX] -= tx;
967 f[j_coord_offset+DIM*1+YY] -= ty;
968 f[j_coord_offset+DIM*1+ZZ] -= tz;
972 /**************************
973 * CALCULATE INTERACTIONS *
974 **************************/
979 /* REACTION-FIELD ELECTROSTATICS */
980 felec = qq12*(rinv12*rinvsq12-krf2);
984 /* Calculate temporary vectorial force */
989 /* Update vectorial force */
993 f[j_coord_offset+DIM*2+XX] -= tx;
994 f[j_coord_offset+DIM*2+YY] -= ty;
995 f[j_coord_offset+DIM*2+ZZ] -= tz;
999 /**************************
1000 * CALCULATE INTERACTIONS *
1001 **************************/
1006 /* REACTION-FIELD ELECTROSTATICS */
1007 felec = qq20*(rinv20*rinvsq20-krf2);
1011 /* Calculate temporary vectorial force */
1016 /* Update vectorial force */
1020 f[j_coord_offset+DIM*0+XX] -= tx;
1021 f[j_coord_offset+DIM*0+YY] -= ty;
1022 f[j_coord_offset+DIM*0+ZZ] -= tz;
1026 /**************************
1027 * CALCULATE INTERACTIONS *
1028 **************************/
1033 /* REACTION-FIELD ELECTROSTATICS */
1034 felec = qq21*(rinv21*rinvsq21-krf2);
1038 /* Calculate temporary vectorial force */
1043 /* Update vectorial force */
1047 f[j_coord_offset+DIM*1+XX] -= tx;
1048 f[j_coord_offset+DIM*1+YY] -= ty;
1049 f[j_coord_offset+DIM*1+ZZ] -= tz;
1053 /**************************
1054 * CALCULATE INTERACTIONS *
1055 **************************/
1060 /* REACTION-FIELD ELECTROSTATICS */
1061 felec = qq22*(rinv22*rinvsq22-krf2);
1065 /* Calculate temporary vectorial force */
1070 /* Update vectorial force */
1074 f[j_coord_offset+DIM*2+XX] -= tx;
1075 f[j_coord_offset+DIM*2+YY] -= ty;
1076 f[j_coord_offset+DIM*2+ZZ] -= tz;
1080 /* Inner loop uses 270 flops */
1082 /* End of innermost loop */
1085 f[i_coord_offset+DIM*0+XX] += fix0;
1086 f[i_coord_offset+DIM*0+YY] += fiy0;
1087 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1091 f[i_coord_offset+DIM*1+XX] += fix1;
1092 f[i_coord_offset+DIM*1+YY] += fiy1;
1093 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1097 f[i_coord_offset+DIM*2+XX] += fix2;
1098 f[i_coord_offset+DIM*2+YY] += fiy2;
1099 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1103 fshift[i_shift_offset+XX] += tx;
1104 fshift[i_shift_offset+YY] += ty;
1105 fshift[i_shift_offset+ZZ] += tz;
1107 /* Increment number of inner iterations */
1108 inneriter += j_index_end - j_index_start;
1110 /* Outer loop uses 30 flops */
1113 /* Increment number of outer iterations */
1116 /* Update outer/inner flops */
1118 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*270);