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_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_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 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;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
99 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
113 charge = mdatoms->chargeA;
117 nvdwtype = fr->ntype;
119 vdwtype = mdatoms->typeA;
121 /* Setup water-specific parameters */
122 inr = nlist->iinr[0];
123 iq0 = facel*charge[inr+0];
124 iq1 = facel*charge[inr+1];
125 iq2 = facel*charge[inr+2];
126 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
131 vdwjidx0 = 3*vdwtype[inr+0];
133 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
134 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
135 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
145 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
146 rcutoff = fr->rcoulomb;
147 rcutoff2 = rcutoff*rcutoff;
149 rswitch = fr->rvdw_switch;
150 /* Setup switch parameters */
152 swV3 = -10.0/(d*d*d);
153 swV4 = 15.0/(d*d*d*d);
154 swV5 = -6.0/(d*d*d*d*d);
155 swF2 = -30.0/(d*d*d);
156 swF3 = 60.0/(d*d*d*d);
157 swF4 = -30.0/(d*d*d*d*d);
162 /* Start outer loop over neighborlists */
163 for(iidx=0; iidx<nri; iidx++)
165 /* Load shift vector for this list */
166 i_shift_offset = DIM*shiftidx[iidx];
167 shX = shiftvec[i_shift_offset+XX];
168 shY = shiftvec[i_shift_offset+YY];
169 shZ = shiftvec[i_shift_offset+ZZ];
171 /* Load limits for loop over neighbors */
172 j_index_start = jindex[iidx];
173 j_index_end = jindex[iidx+1];
175 /* Get outer coordinate index */
177 i_coord_offset = DIM*inr;
179 /* Load i particle coords and add shift vector */
180 ix0 = shX + x[i_coord_offset+DIM*0+XX];
181 iy0 = shY + x[i_coord_offset+DIM*0+YY];
182 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
183 ix1 = shX + x[i_coord_offset+DIM*1+XX];
184 iy1 = shY + x[i_coord_offset+DIM*1+YY];
185 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
186 ix2 = shX + x[i_coord_offset+DIM*2+XX];
187 iy2 = shY + x[i_coord_offset+DIM*2+YY];
188 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
200 /* Reset potential sums */
204 /* Start inner kernel loop */
205 for(jidx=j_index_start; jidx<j_index_end; jidx++)
207 /* Get j neighbor index, and coordinate index */
209 j_coord_offset = DIM*jnr;
211 /* load j atom coordinates */
212 jx0 = x[j_coord_offset+DIM*0+XX];
213 jy0 = x[j_coord_offset+DIM*0+YY];
214 jz0 = x[j_coord_offset+DIM*0+ZZ];
215 jx1 = x[j_coord_offset+DIM*1+XX];
216 jy1 = x[j_coord_offset+DIM*1+YY];
217 jz1 = x[j_coord_offset+DIM*1+ZZ];
218 jx2 = x[j_coord_offset+DIM*2+XX];
219 jy2 = x[j_coord_offset+DIM*2+YY];
220 jz2 = x[j_coord_offset+DIM*2+ZZ];
222 /* Calculate displacement vector */
251 /* Calculate squared distance and things based on it */
252 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
253 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
254 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
255 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
256 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
257 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
258 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
259 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
260 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
262 rinv00 = gmx_invsqrt(rsq00);
263 rinv01 = gmx_invsqrt(rsq01);
264 rinv02 = gmx_invsqrt(rsq02);
265 rinv10 = gmx_invsqrt(rsq10);
266 rinv11 = gmx_invsqrt(rsq11);
267 rinv12 = gmx_invsqrt(rsq12);
268 rinv20 = gmx_invsqrt(rsq20);
269 rinv21 = gmx_invsqrt(rsq21);
270 rinv22 = gmx_invsqrt(rsq22);
272 rinvsq00 = rinv00*rinv00;
273 rinvsq01 = rinv01*rinv01;
274 rinvsq02 = rinv02*rinv02;
275 rinvsq10 = rinv10*rinv10;
276 rinvsq11 = rinv11*rinv11;
277 rinvsq12 = rinv12*rinv12;
278 rinvsq20 = rinv20*rinv20;
279 rinvsq21 = rinv21*rinv21;
280 rinvsq22 = rinv22*rinv22;
282 /**************************
283 * CALCULATE INTERACTIONS *
284 **************************/
291 /* REACTION-FIELD ELECTROSTATICS */
292 velec = qq00*(rinv00+krf*rsq00-crf);
293 felec = qq00*(rinv00*rinvsq00-krf2);
295 /* BUCKINGHAM DISPERSION/REPULSION */
296 rinvsix = rinvsq00*rinvsq00*rinvsq00;
297 vvdw6 = c6_00*rinvsix;
299 vvdwexp = cexp1_00*exp(-br);
300 vvdw = vvdwexp - vvdw6*(1.0/6.0);
301 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
304 d = (d>0.0) ? d : 0.0;
306 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
308 dsw = d2*(swF2+d*(swF3+d*swF4));
310 /* Evaluate switch function */
311 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
312 fvdw = fvdw*sw - rinv00*vvdw*dsw;
315 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
343 /* REACTION-FIELD ELECTROSTATICS */
344 velec = qq01*(rinv01+krf*rsq01-crf);
345 felec = qq01*(rinv01*rinvsq01-krf2);
347 /* Update potential sums from outer loop */
352 /* Calculate temporary vectorial force */
357 /* Update vectorial force */
361 f[j_coord_offset+DIM*1+XX] -= tx;
362 f[j_coord_offset+DIM*1+YY] -= ty;
363 f[j_coord_offset+DIM*1+ZZ] -= tz;
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
374 /* REACTION-FIELD ELECTROSTATICS */
375 velec = qq02*(rinv02+krf*rsq02-crf);
376 felec = qq02*(rinv02*rinvsq02-krf2);
378 /* Update potential sums from outer loop */
383 /* Calculate temporary vectorial force */
388 /* Update vectorial force */
392 f[j_coord_offset+DIM*2+XX] -= tx;
393 f[j_coord_offset+DIM*2+YY] -= ty;
394 f[j_coord_offset+DIM*2+ZZ] -= tz;
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
405 /* REACTION-FIELD ELECTROSTATICS */
406 velec = qq10*(rinv10+krf*rsq10-crf);
407 felec = qq10*(rinv10*rinvsq10-krf2);
409 /* Update potential sums from outer loop */
414 /* Calculate temporary vectorial force */
419 /* Update vectorial force */
423 f[j_coord_offset+DIM*0+XX] -= tx;
424 f[j_coord_offset+DIM*0+YY] -= ty;
425 f[j_coord_offset+DIM*0+ZZ] -= tz;
429 /**************************
430 * CALCULATE INTERACTIONS *
431 **************************/
436 /* REACTION-FIELD ELECTROSTATICS */
437 velec = qq11*(rinv11+krf*rsq11-crf);
438 felec = qq11*(rinv11*rinvsq11-krf2);
440 /* Update potential sums from outer loop */
445 /* Calculate temporary vectorial force */
450 /* Update vectorial force */
454 f[j_coord_offset+DIM*1+XX] -= tx;
455 f[j_coord_offset+DIM*1+YY] -= ty;
456 f[j_coord_offset+DIM*1+ZZ] -= tz;
460 /**************************
461 * CALCULATE INTERACTIONS *
462 **************************/
467 /* REACTION-FIELD ELECTROSTATICS */
468 velec = qq12*(rinv12+krf*rsq12-crf);
469 felec = qq12*(rinv12*rinvsq12-krf2);
471 /* Update potential sums from outer loop */
476 /* Calculate temporary vectorial force */
481 /* Update vectorial force */
485 f[j_coord_offset+DIM*2+XX] -= tx;
486 f[j_coord_offset+DIM*2+YY] -= ty;
487 f[j_coord_offset+DIM*2+ZZ] -= tz;
491 /**************************
492 * CALCULATE INTERACTIONS *
493 **************************/
498 /* REACTION-FIELD ELECTROSTATICS */
499 velec = qq20*(rinv20+krf*rsq20-crf);
500 felec = qq20*(rinv20*rinvsq20-krf2);
502 /* Update potential sums from outer loop */
507 /* Calculate temporary vectorial force */
512 /* Update vectorial force */
516 f[j_coord_offset+DIM*0+XX] -= tx;
517 f[j_coord_offset+DIM*0+YY] -= ty;
518 f[j_coord_offset+DIM*0+ZZ] -= tz;
522 /**************************
523 * CALCULATE INTERACTIONS *
524 **************************/
529 /* REACTION-FIELD ELECTROSTATICS */
530 velec = qq21*(rinv21+krf*rsq21-crf);
531 felec = qq21*(rinv21*rinvsq21-krf2);
533 /* Update potential sums from outer loop */
538 /* Calculate temporary vectorial force */
543 /* Update vectorial force */
547 f[j_coord_offset+DIM*1+XX] -= tx;
548 f[j_coord_offset+DIM*1+YY] -= ty;
549 f[j_coord_offset+DIM*1+ZZ] -= tz;
553 /**************************
554 * CALCULATE INTERACTIONS *
555 **************************/
560 /* REACTION-FIELD ELECTROSTATICS */
561 velec = qq22*(rinv22+krf*rsq22-crf);
562 felec = qq22*(rinv22*rinvsq22-krf2);
564 /* Update potential sums from outer loop */
569 /* Calculate temporary vectorial force */
574 /* Update vectorial force */
578 f[j_coord_offset+DIM*2+XX] -= tx;
579 f[j_coord_offset+DIM*2+YY] -= ty;
580 f[j_coord_offset+DIM*2+ZZ] -= tz;
584 /* Inner loop uses 336 flops */
586 /* End of innermost loop */
589 f[i_coord_offset+DIM*0+XX] += fix0;
590 f[i_coord_offset+DIM*0+YY] += fiy0;
591 f[i_coord_offset+DIM*0+ZZ] += fiz0;
595 f[i_coord_offset+DIM*1+XX] += fix1;
596 f[i_coord_offset+DIM*1+YY] += fiy1;
597 f[i_coord_offset+DIM*1+ZZ] += fiz1;
601 f[i_coord_offset+DIM*2+XX] += fix2;
602 f[i_coord_offset+DIM*2+YY] += fiy2;
603 f[i_coord_offset+DIM*2+ZZ] += fiz2;
607 fshift[i_shift_offset+XX] += tx;
608 fshift[i_shift_offset+YY] += ty;
609 fshift[i_shift_offset+ZZ] += tz;
612 /* Update potential energies */
613 kernel_data->energygrp_elec[ggid] += velecsum;
614 kernel_data->energygrp_vdw[ggid] += vvdwsum;
616 /* Increment number of inner iterations */
617 inneriter += j_index_end - j_index_start;
619 /* Outer loop uses 32 flops */
622 /* Increment number of outer iterations */
625 /* Update outer/inner flops */
627 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*336);
630 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_F_c
631 * Electrostatics interaction: ReactionField
632 * VdW interaction: Buckingham
633 * Geometry: Water3-Water3
634 * Calculate force/pot: Force
637 nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_F_c
638 (t_nblist * gmx_restrict nlist,
639 rvec * gmx_restrict xx,
640 rvec * gmx_restrict ff,
641 t_forcerec * gmx_restrict fr,
642 t_mdatoms * gmx_restrict mdatoms,
643 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
644 t_nrnb * gmx_restrict nrnb)
646 int i_shift_offset,i_coord_offset,j_coord_offset;
647 int j_index_start,j_index_end;
648 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
649 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
650 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
651 real *shiftvec,*fshift,*x,*f;
653 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
655 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
657 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
659 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
661 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
663 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
664 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
665 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
666 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
667 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
668 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
669 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
670 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
671 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
672 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
673 real velec,felec,velecsum,facel,crf,krf,krf2;
676 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
679 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
686 jindex = nlist->jindex;
688 shiftidx = nlist->shift;
690 shiftvec = fr->shift_vec[0];
691 fshift = fr->fshift[0];
693 charge = mdatoms->chargeA;
697 nvdwtype = fr->ntype;
699 vdwtype = mdatoms->typeA;
701 /* Setup water-specific parameters */
702 inr = nlist->iinr[0];
703 iq0 = facel*charge[inr+0];
704 iq1 = facel*charge[inr+1];
705 iq2 = facel*charge[inr+2];
706 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
711 vdwjidx0 = 3*vdwtype[inr+0];
713 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
714 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
715 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
725 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
726 rcutoff = fr->rcoulomb;
727 rcutoff2 = rcutoff*rcutoff;
729 rswitch = fr->rvdw_switch;
730 /* Setup switch parameters */
732 swV3 = -10.0/(d*d*d);
733 swV4 = 15.0/(d*d*d*d);
734 swV5 = -6.0/(d*d*d*d*d);
735 swF2 = -30.0/(d*d*d);
736 swF3 = 60.0/(d*d*d*d);
737 swF4 = -30.0/(d*d*d*d*d);
742 /* Start outer loop over neighborlists */
743 for(iidx=0; iidx<nri; iidx++)
745 /* Load shift vector for this list */
746 i_shift_offset = DIM*shiftidx[iidx];
747 shX = shiftvec[i_shift_offset+XX];
748 shY = shiftvec[i_shift_offset+YY];
749 shZ = shiftvec[i_shift_offset+ZZ];
751 /* Load limits for loop over neighbors */
752 j_index_start = jindex[iidx];
753 j_index_end = jindex[iidx+1];
755 /* Get outer coordinate index */
757 i_coord_offset = DIM*inr;
759 /* Load i particle coords and add shift vector */
760 ix0 = shX + x[i_coord_offset+DIM*0+XX];
761 iy0 = shY + x[i_coord_offset+DIM*0+YY];
762 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
763 ix1 = shX + x[i_coord_offset+DIM*1+XX];
764 iy1 = shY + x[i_coord_offset+DIM*1+YY];
765 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
766 ix2 = shX + x[i_coord_offset+DIM*2+XX];
767 iy2 = shY + x[i_coord_offset+DIM*2+YY];
768 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
780 /* Start inner kernel loop */
781 for(jidx=j_index_start; jidx<j_index_end; jidx++)
783 /* Get j neighbor index, and coordinate index */
785 j_coord_offset = DIM*jnr;
787 /* load j atom coordinates */
788 jx0 = x[j_coord_offset+DIM*0+XX];
789 jy0 = x[j_coord_offset+DIM*0+YY];
790 jz0 = x[j_coord_offset+DIM*0+ZZ];
791 jx1 = x[j_coord_offset+DIM*1+XX];
792 jy1 = x[j_coord_offset+DIM*1+YY];
793 jz1 = x[j_coord_offset+DIM*1+ZZ];
794 jx2 = x[j_coord_offset+DIM*2+XX];
795 jy2 = x[j_coord_offset+DIM*2+YY];
796 jz2 = x[j_coord_offset+DIM*2+ZZ];
798 /* Calculate displacement vector */
827 /* Calculate squared distance and things based on it */
828 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
829 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
830 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
831 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
832 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
833 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
834 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
835 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
836 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
838 rinv00 = gmx_invsqrt(rsq00);
839 rinv01 = gmx_invsqrt(rsq01);
840 rinv02 = gmx_invsqrt(rsq02);
841 rinv10 = gmx_invsqrt(rsq10);
842 rinv11 = gmx_invsqrt(rsq11);
843 rinv12 = gmx_invsqrt(rsq12);
844 rinv20 = gmx_invsqrt(rsq20);
845 rinv21 = gmx_invsqrt(rsq21);
846 rinv22 = gmx_invsqrt(rsq22);
848 rinvsq00 = rinv00*rinv00;
849 rinvsq01 = rinv01*rinv01;
850 rinvsq02 = rinv02*rinv02;
851 rinvsq10 = rinv10*rinv10;
852 rinvsq11 = rinv11*rinv11;
853 rinvsq12 = rinv12*rinv12;
854 rinvsq20 = rinv20*rinv20;
855 rinvsq21 = rinv21*rinv21;
856 rinvsq22 = rinv22*rinv22;
858 /**************************
859 * CALCULATE INTERACTIONS *
860 **************************/
867 /* REACTION-FIELD ELECTROSTATICS */
868 felec = qq00*(rinv00*rinvsq00-krf2);
870 /* BUCKINGHAM DISPERSION/REPULSION */
871 rinvsix = rinvsq00*rinvsq00*rinvsq00;
872 vvdw6 = c6_00*rinvsix;
874 vvdwexp = cexp1_00*exp(-br);
875 vvdw = vvdwexp - vvdw6*(1.0/6.0);
876 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
879 d = (d>0.0) ? d : 0.0;
881 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
883 dsw = d2*(swF2+d*(swF3+d*swF4));
885 /* Evaluate switch function */
886 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
887 fvdw = fvdw*sw - rinv00*vvdw*dsw;
891 /* Calculate temporary vectorial force */
896 /* Update vectorial force */
900 f[j_coord_offset+DIM*0+XX] -= tx;
901 f[j_coord_offset+DIM*0+YY] -= ty;
902 f[j_coord_offset+DIM*0+ZZ] -= tz;
906 /**************************
907 * CALCULATE INTERACTIONS *
908 **************************/
913 /* REACTION-FIELD ELECTROSTATICS */
914 felec = qq01*(rinv01*rinvsq01-krf2);
918 /* Calculate temporary vectorial force */
923 /* Update vectorial force */
927 f[j_coord_offset+DIM*1+XX] -= tx;
928 f[j_coord_offset+DIM*1+YY] -= ty;
929 f[j_coord_offset+DIM*1+ZZ] -= tz;
933 /**************************
934 * CALCULATE INTERACTIONS *
935 **************************/
940 /* REACTION-FIELD ELECTROSTATICS */
941 felec = qq02*(rinv02*rinvsq02-krf2);
945 /* Calculate temporary vectorial force */
950 /* Update vectorial force */
954 f[j_coord_offset+DIM*2+XX] -= tx;
955 f[j_coord_offset+DIM*2+YY] -= ty;
956 f[j_coord_offset+DIM*2+ZZ] -= tz;
960 /**************************
961 * CALCULATE INTERACTIONS *
962 **************************/
967 /* REACTION-FIELD ELECTROSTATICS */
968 felec = qq10*(rinv10*rinvsq10-krf2);
972 /* Calculate temporary vectorial force */
977 /* Update vectorial force */
981 f[j_coord_offset+DIM*0+XX] -= tx;
982 f[j_coord_offset+DIM*0+YY] -= ty;
983 f[j_coord_offset+DIM*0+ZZ] -= tz;
987 /**************************
988 * CALCULATE INTERACTIONS *
989 **************************/
994 /* REACTION-FIELD ELECTROSTATICS */
995 felec = qq11*(rinv11*rinvsq11-krf2);
999 /* Calculate temporary vectorial force */
1004 /* Update vectorial force */
1008 f[j_coord_offset+DIM*1+XX] -= tx;
1009 f[j_coord_offset+DIM*1+YY] -= ty;
1010 f[j_coord_offset+DIM*1+ZZ] -= tz;
1014 /**************************
1015 * CALCULATE INTERACTIONS *
1016 **************************/
1021 /* REACTION-FIELD ELECTROSTATICS */
1022 felec = qq12*(rinv12*rinvsq12-krf2);
1026 /* Calculate temporary vectorial force */
1031 /* Update vectorial force */
1035 f[j_coord_offset+DIM*2+XX] -= tx;
1036 f[j_coord_offset+DIM*2+YY] -= ty;
1037 f[j_coord_offset+DIM*2+ZZ] -= tz;
1041 /**************************
1042 * CALCULATE INTERACTIONS *
1043 **************************/
1048 /* REACTION-FIELD ELECTROSTATICS */
1049 felec = qq20*(rinv20*rinvsq20-krf2);
1053 /* Calculate temporary vectorial force */
1058 /* Update vectorial force */
1062 f[j_coord_offset+DIM*0+XX] -= tx;
1063 f[j_coord_offset+DIM*0+YY] -= ty;
1064 f[j_coord_offset+DIM*0+ZZ] -= tz;
1068 /**************************
1069 * CALCULATE INTERACTIONS *
1070 **************************/
1075 /* REACTION-FIELD ELECTROSTATICS */
1076 felec = qq21*(rinv21*rinvsq21-krf2);
1080 /* Calculate temporary vectorial force */
1085 /* Update vectorial force */
1089 f[j_coord_offset+DIM*1+XX] -= tx;
1090 f[j_coord_offset+DIM*1+YY] -= ty;
1091 f[j_coord_offset+DIM*1+ZZ] -= tz;
1095 /**************************
1096 * CALCULATE INTERACTIONS *
1097 **************************/
1102 /* REACTION-FIELD ELECTROSTATICS */
1103 felec = qq22*(rinv22*rinvsq22-krf2);
1107 /* Calculate temporary vectorial force */
1112 /* Update vectorial force */
1116 f[j_coord_offset+DIM*2+XX] -= tx;
1117 f[j_coord_offset+DIM*2+YY] -= ty;
1118 f[j_coord_offset+DIM*2+ZZ] -= tz;
1122 /* Inner loop uses 289 flops */
1124 /* End of innermost loop */
1127 f[i_coord_offset+DIM*0+XX] += fix0;
1128 f[i_coord_offset+DIM*0+YY] += fiy0;
1129 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1133 f[i_coord_offset+DIM*1+XX] += fix1;
1134 f[i_coord_offset+DIM*1+YY] += fiy1;
1135 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1139 f[i_coord_offset+DIM*2+XX] += fix2;
1140 f[i_coord_offset+DIM*2+YY] += fiy2;
1141 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1145 fshift[i_shift_offset+XX] += tx;
1146 fshift[i_shift_offset+YY] += ty;
1147 fshift[i_shift_offset+ZZ] += tz;
1149 /* Increment number of inner iterations */
1150 inneriter += j_index_end - j_index_start;
1152 /* Outer loop uses 30 flops */
1155 /* Increment number of outer iterations */
1158 /* Update outer/inner flops */
1160 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*289);