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_VdwBhamSw_GeomW3W3_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwBhamSw_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;
97 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
111 charge = mdatoms->chargeA;
115 nvdwtype = fr->ntype;
117 vdwtype = mdatoms->typeA;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq0 = facel*charge[inr+0];
122 iq1 = facel*charge[inr+1];
123 iq2 = facel*charge[inr+2];
124 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
129 vdwjidx0 = 3*vdwtype[inr+0];
131 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
132 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
133 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
143 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
144 rcutoff = fr->rcoulomb;
145 rcutoff2 = rcutoff*rcutoff;
147 rswitch = fr->rvdw_switch;
148 /* Setup switch parameters */
150 swV3 = -10.0/(d*d*d);
151 swV4 = 15.0/(d*d*d*d);
152 swV5 = -6.0/(d*d*d*d*d);
153 swF2 = -30.0/(d*d*d);
154 swF3 = 60.0/(d*d*d*d);
155 swF4 = -30.0/(d*d*d*d*d);
160 /* Start outer loop over neighborlists */
161 for(iidx=0; iidx<nri; iidx++)
163 /* Load shift vector for this list */
164 i_shift_offset = DIM*shiftidx[iidx];
165 shX = shiftvec[i_shift_offset+XX];
166 shY = shiftvec[i_shift_offset+YY];
167 shZ = shiftvec[i_shift_offset+ZZ];
169 /* Load limits for loop over neighbors */
170 j_index_start = jindex[iidx];
171 j_index_end = jindex[iidx+1];
173 /* Get outer coordinate index */
175 i_coord_offset = DIM*inr;
177 /* Load i particle coords and add shift vector */
178 ix0 = shX + x[i_coord_offset+DIM*0+XX];
179 iy0 = shY + x[i_coord_offset+DIM*0+YY];
180 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
181 ix1 = shX + x[i_coord_offset+DIM*1+XX];
182 iy1 = shY + x[i_coord_offset+DIM*1+YY];
183 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
184 ix2 = shX + x[i_coord_offset+DIM*2+XX];
185 iy2 = shY + x[i_coord_offset+DIM*2+YY];
186 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
198 /* Reset potential sums */
202 /* Start inner kernel loop */
203 for(jidx=j_index_start; jidx<j_index_end; jidx++)
205 /* Get j neighbor index, and coordinate index */
207 j_coord_offset = DIM*jnr;
209 /* load j atom coordinates */
210 jx0 = x[j_coord_offset+DIM*0+XX];
211 jy0 = x[j_coord_offset+DIM*0+YY];
212 jz0 = x[j_coord_offset+DIM*0+ZZ];
213 jx1 = x[j_coord_offset+DIM*1+XX];
214 jy1 = x[j_coord_offset+DIM*1+YY];
215 jz1 = x[j_coord_offset+DIM*1+ZZ];
216 jx2 = x[j_coord_offset+DIM*2+XX];
217 jy2 = x[j_coord_offset+DIM*2+YY];
218 jz2 = x[j_coord_offset+DIM*2+ZZ];
220 /* Calculate displacement vector */
249 /* Calculate squared distance and things based on it */
250 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
251 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
252 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
253 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
254 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
255 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
256 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
257 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
258 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
260 rinv00 = gmx_invsqrt(rsq00);
261 rinv01 = gmx_invsqrt(rsq01);
262 rinv02 = gmx_invsqrt(rsq02);
263 rinv10 = gmx_invsqrt(rsq10);
264 rinv11 = gmx_invsqrt(rsq11);
265 rinv12 = gmx_invsqrt(rsq12);
266 rinv20 = gmx_invsqrt(rsq20);
267 rinv21 = gmx_invsqrt(rsq21);
268 rinv22 = gmx_invsqrt(rsq22);
270 rinvsq00 = rinv00*rinv00;
271 rinvsq01 = rinv01*rinv01;
272 rinvsq02 = rinv02*rinv02;
273 rinvsq10 = rinv10*rinv10;
274 rinvsq11 = rinv11*rinv11;
275 rinvsq12 = rinv12*rinv12;
276 rinvsq20 = rinv20*rinv20;
277 rinvsq21 = rinv21*rinv21;
278 rinvsq22 = rinv22*rinv22;
280 /**************************
281 * CALCULATE INTERACTIONS *
282 **************************/
289 /* REACTION-FIELD ELECTROSTATICS */
290 velec = qq00*(rinv00+krf*rsq00-crf);
291 felec = qq00*(rinv00*rinvsq00-krf2);
293 /* BUCKINGHAM DISPERSION/REPULSION */
294 rinvsix = rinvsq00*rinvsq00*rinvsq00;
295 vvdw6 = c6_00*rinvsix;
297 vvdwexp = cexp1_00*exp(-br);
298 vvdw = vvdwexp - vvdw6*(1.0/6.0);
299 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
302 d = (d>0.0) ? d : 0.0;
304 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
306 dsw = d2*(swF2+d*(swF3+d*swF4));
308 /* Evaluate switch function */
309 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
310 fvdw = fvdw*sw - rinv00*vvdw*dsw;
313 /* Update potential sums from outer loop */
319 /* Calculate temporary vectorial force */
324 /* Update vectorial force */
328 f[j_coord_offset+DIM*0+XX] -= tx;
329 f[j_coord_offset+DIM*0+YY] -= ty;
330 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
341 /* REACTION-FIELD ELECTROSTATICS */
342 velec = qq01*(rinv01+krf*rsq01-crf);
343 felec = qq01*(rinv01*rinvsq01-krf2);
345 /* Update potential sums from outer loop */
350 /* Calculate temporary vectorial force */
355 /* Update vectorial force */
359 f[j_coord_offset+DIM*1+XX] -= tx;
360 f[j_coord_offset+DIM*1+YY] -= ty;
361 f[j_coord_offset+DIM*1+ZZ] -= tz;
365 /**************************
366 * CALCULATE INTERACTIONS *
367 **************************/
372 /* REACTION-FIELD ELECTROSTATICS */
373 velec = qq02*(rinv02+krf*rsq02-crf);
374 felec = qq02*(rinv02*rinvsq02-krf2);
376 /* Update potential sums from outer loop */
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*2+XX] -= tx;
391 f[j_coord_offset+DIM*2+YY] -= ty;
392 f[j_coord_offset+DIM*2+ZZ] -= tz;
396 /**************************
397 * CALCULATE INTERACTIONS *
398 **************************/
403 /* REACTION-FIELD ELECTROSTATICS */
404 velec = qq10*(rinv10+krf*rsq10-crf);
405 felec = qq10*(rinv10*rinvsq10-krf2);
407 /* Update potential sums from outer loop */
412 /* Calculate temporary vectorial force */
417 /* Update vectorial force */
421 f[j_coord_offset+DIM*0+XX] -= tx;
422 f[j_coord_offset+DIM*0+YY] -= ty;
423 f[j_coord_offset+DIM*0+ZZ] -= tz;
427 /**************************
428 * CALCULATE INTERACTIONS *
429 **************************/
434 /* REACTION-FIELD ELECTROSTATICS */
435 velec = qq11*(rinv11+krf*rsq11-crf);
436 felec = qq11*(rinv11*rinvsq11-krf2);
438 /* Update potential sums from outer loop */
443 /* Calculate temporary vectorial force */
448 /* Update vectorial force */
452 f[j_coord_offset+DIM*1+XX] -= tx;
453 f[j_coord_offset+DIM*1+YY] -= ty;
454 f[j_coord_offset+DIM*1+ZZ] -= tz;
458 /**************************
459 * CALCULATE INTERACTIONS *
460 **************************/
465 /* REACTION-FIELD ELECTROSTATICS */
466 velec = qq12*(rinv12+krf*rsq12-crf);
467 felec = qq12*(rinv12*rinvsq12-krf2);
469 /* Update potential sums from outer loop */
474 /* Calculate temporary vectorial force */
479 /* Update vectorial force */
483 f[j_coord_offset+DIM*2+XX] -= tx;
484 f[j_coord_offset+DIM*2+YY] -= ty;
485 f[j_coord_offset+DIM*2+ZZ] -= tz;
489 /**************************
490 * CALCULATE INTERACTIONS *
491 **************************/
496 /* REACTION-FIELD ELECTROSTATICS */
497 velec = qq20*(rinv20+krf*rsq20-crf);
498 felec = qq20*(rinv20*rinvsq20-krf2);
500 /* Update potential sums from outer loop */
505 /* Calculate temporary vectorial force */
510 /* Update vectorial force */
514 f[j_coord_offset+DIM*0+XX] -= tx;
515 f[j_coord_offset+DIM*0+YY] -= ty;
516 f[j_coord_offset+DIM*0+ZZ] -= tz;
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
527 /* REACTION-FIELD ELECTROSTATICS */
528 velec = qq21*(rinv21+krf*rsq21-crf);
529 felec = qq21*(rinv21*rinvsq21-krf2);
531 /* Update potential sums from outer loop */
536 /* Calculate temporary vectorial force */
541 /* Update vectorial force */
545 f[j_coord_offset+DIM*1+XX] -= tx;
546 f[j_coord_offset+DIM*1+YY] -= ty;
547 f[j_coord_offset+DIM*1+ZZ] -= tz;
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
558 /* REACTION-FIELD ELECTROSTATICS */
559 velec = qq22*(rinv22+krf*rsq22-crf);
560 felec = qq22*(rinv22*rinvsq22-krf2);
562 /* Update potential sums from outer loop */
567 /* Calculate temporary vectorial force */
572 /* Update vectorial force */
576 f[j_coord_offset+DIM*2+XX] -= tx;
577 f[j_coord_offset+DIM*2+YY] -= ty;
578 f[j_coord_offset+DIM*2+ZZ] -= tz;
582 /* Inner loop uses 336 flops */
584 /* End of innermost loop */
587 f[i_coord_offset+DIM*0+XX] += fix0;
588 f[i_coord_offset+DIM*0+YY] += fiy0;
589 f[i_coord_offset+DIM*0+ZZ] += fiz0;
593 f[i_coord_offset+DIM*1+XX] += fix1;
594 f[i_coord_offset+DIM*1+YY] += fiy1;
595 f[i_coord_offset+DIM*1+ZZ] += fiz1;
599 f[i_coord_offset+DIM*2+XX] += fix2;
600 f[i_coord_offset+DIM*2+YY] += fiy2;
601 f[i_coord_offset+DIM*2+ZZ] += fiz2;
605 fshift[i_shift_offset+XX] += tx;
606 fshift[i_shift_offset+YY] += ty;
607 fshift[i_shift_offset+ZZ] += tz;
610 /* Update potential energies */
611 kernel_data->energygrp_elec[ggid] += velecsum;
612 kernel_data->energygrp_vdw[ggid] += vvdwsum;
614 /* Increment number of inner iterations */
615 inneriter += j_index_end - j_index_start;
617 /* Outer loop uses 32 flops */
620 /* Increment number of outer iterations */
623 /* Update outer/inner flops */
625 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*336);
628 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_F_c
629 * Electrostatics interaction: ReactionField
630 * VdW interaction: Buckingham
631 * Geometry: Water3-Water3
632 * Calculate force/pot: Force
635 nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_F_c
636 (t_nblist * gmx_restrict nlist,
637 rvec * gmx_restrict xx,
638 rvec * gmx_restrict ff,
639 t_forcerec * gmx_restrict fr,
640 t_mdatoms * gmx_restrict mdatoms,
641 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
642 t_nrnb * gmx_restrict nrnb)
644 int i_shift_offset,i_coord_offset,j_coord_offset;
645 int j_index_start,j_index_end;
646 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
647 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
648 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
649 real *shiftvec,*fshift,*x,*f;
651 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
653 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
655 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
657 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
659 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
661 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
662 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
663 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
664 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
665 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
666 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
667 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
668 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
669 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
670 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
671 real velec,felec,velecsum,facel,crf,krf,krf2;
674 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
677 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
684 jindex = nlist->jindex;
686 shiftidx = nlist->shift;
688 shiftvec = fr->shift_vec[0];
689 fshift = fr->fshift[0];
691 charge = mdatoms->chargeA;
695 nvdwtype = fr->ntype;
697 vdwtype = mdatoms->typeA;
699 /* Setup water-specific parameters */
700 inr = nlist->iinr[0];
701 iq0 = facel*charge[inr+0];
702 iq1 = facel*charge[inr+1];
703 iq2 = facel*charge[inr+2];
704 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
709 vdwjidx0 = 3*vdwtype[inr+0];
711 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
712 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
713 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
723 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
724 rcutoff = fr->rcoulomb;
725 rcutoff2 = rcutoff*rcutoff;
727 rswitch = fr->rvdw_switch;
728 /* Setup switch parameters */
730 swV3 = -10.0/(d*d*d);
731 swV4 = 15.0/(d*d*d*d);
732 swV5 = -6.0/(d*d*d*d*d);
733 swF2 = -30.0/(d*d*d);
734 swF3 = 60.0/(d*d*d*d);
735 swF4 = -30.0/(d*d*d*d*d);
740 /* Start outer loop over neighborlists */
741 for(iidx=0; iidx<nri; iidx++)
743 /* Load shift vector for this list */
744 i_shift_offset = DIM*shiftidx[iidx];
745 shX = shiftvec[i_shift_offset+XX];
746 shY = shiftvec[i_shift_offset+YY];
747 shZ = shiftvec[i_shift_offset+ZZ];
749 /* Load limits for loop over neighbors */
750 j_index_start = jindex[iidx];
751 j_index_end = jindex[iidx+1];
753 /* Get outer coordinate index */
755 i_coord_offset = DIM*inr;
757 /* Load i particle coords and add shift vector */
758 ix0 = shX + x[i_coord_offset+DIM*0+XX];
759 iy0 = shY + x[i_coord_offset+DIM*0+YY];
760 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
761 ix1 = shX + x[i_coord_offset+DIM*1+XX];
762 iy1 = shY + x[i_coord_offset+DIM*1+YY];
763 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
764 ix2 = shX + x[i_coord_offset+DIM*2+XX];
765 iy2 = shY + x[i_coord_offset+DIM*2+YY];
766 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
778 /* Start inner kernel loop */
779 for(jidx=j_index_start; jidx<j_index_end; jidx++)
781 /* Get j neighbor index, and coordinate index */
783 j_coord_offset = DIM*jnr;
785 /* load j atom coordinates */
786 jx0 = x[j_coord_offset+DIM*0+XX];
787 jy0 = x[j_coord_offset+DIM*0+YY];
788 jz0 = x[j_coord_offset+DIM*0+ZZ];
789 jx1 = x[j_coord_offset+DIM*1+XX];
790 jy1 = x[j_coord_offset+DIM*1+YY];
791 jz1 = x[j_coord_offset+DIM*1+ZZ];
792 jx2 = x[j_coord_offset+DIM*2+XX];
793 jy2 = x[j_coord_offset+DIM*2+YY];
794 jz2 = x[j_coord_offset+DIM*2+ZZ];
796 /* Calculate displacement vector */
825 /* Calculate squared distance and things based on it */
826 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
827 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
828 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
829 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
830 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
831 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
832 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
833 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
834 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
836 rinv00 = gmx_invsqrt(rsq00);
837 rinv01 = gmx_invsqrt(rsq01);
838 rinv02 = gmx_invsqrt(rsq02);
839 rinv10 = gmx_invsqrt(rsq10);
840 rinv11 = gmx_invsqrt(rsq11);
841 rinv12 = gmx_invsqrt(rsq12);
842 rinv20 = gmx_invsqrt(rsq20);
843 rinv21 = gmx_invsqrt(rsq21);
844 rinv22 = gmx_invsqrt(rsq22);
846 rinvsq00 = rinv00*rinv00;
847 rinvsq01 = rinv01*rinv01;
848 rinvsq02 = rinv02*rinv02;
849 rinvsq10 = rinv10*rinv10;
850 rinvsq11 = rinv11*rinv11;
851 rinvsq12 = rinv12*rinv12;
852 rinvsq20 = rinv20*rinv20;
853 rinvsq21 = rinv21*rinv21;
854 rinvsq22 = rinv22*rinv22;
856 /**************************
857 * CALCULATE INTERACTIONS *
858 **************************/
865 /* REACTION-FIELD ELECTROSTATICS */
866 felec = qq00*(rinv00*rinvsq00-krf2);
868 /* BUCKINGHAM DISPERSION/REPULSION */
869 rinvsix = rinvsq00*rinvsq00*rinvsq00;
870 vvdw6 = c6_00*rinvsix;
872 vvdwexp = cexp1_00*exp(-br);
873 vvdw = vvdwexp - vvdw6*(1.0/6.0);
874 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
877 d = (d>0.0) ? d : 0.0;
879 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
881 dsw = d2*(swF2+d*(swF3+d*swF4));
883 /* Evaluate switch function */
884 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
885 fvdw = fvdw*sw - rinv00*vvdw*dsw;
889 /* Calculate temporary vectorial force */
894 /* Update vectorial force */
898 f[j_coord_offset+DIM*0+XX] -= tx;
899 f[j_coord_offset+DIM*0+YY] -= ty;
900 f[j_coord_offset+DIM*0+ZZ] -= tz;
904 /**************************
905 * CALCULATE INTERACTIONS *
906 **************************/
911 /* REACTION-FIELD ELECTROSTATICS */
912 felec = qq01*(rinv01*rinvsq01-krf2);
916 /* Calculate temporary vectorial force */
921 /* Update vectorial force */
925 f[j_coord_offset+DIM*1+XX] -= tx;
926 f[j_coord_offset+DIM*1+YY] -= ty;
927 f[j_coord_offset+DIM*1+ZZ] -= tz;
931 /**************************
932 * CALCULATE INTERACTIONS *
933 **************************/
938 /* REACTION-FIELD ELECTROSTATICS */
939 felec = qq02*(rinv02*rinvsq02-krf2);
943 /* Calculate temporary vectorial force */
948 /* Update vectorial force */
952 f[j_coord_offset+DIM*2+XX] -= tx;
953 f[j_coord_offset+DIM*2+YY] -= ty;
954 f[j_coord_offset+DIM*2+ZZ] -= tz;
958 /**************************
959 * CALCULATE INTERACTIONS *
960 **************************/
965 /* REACTION-FIELD ELECTROSTATICS */
966 felec = qq10*(rinv10*rinvsq10-krf2);
970 /* Calculate temporary vectorial force */
975 /* Update vectorial force */
979 f[j_coord_offset+DIM*0+XX] -= tx;
980 f[j_coord_offset+DIM*0+YY] -= ty;
981 f[j_coord_offset+DIM*0+ZZ] -= tz;
985 /**************************
986 * CALCULATE INTERACTIONS *
987 **************************/
992 /* REACTION-FIELD ELECTROSTATICS */
993 felec = qq11*(rinv11*rinvsq11-krf2);
997 /* Calculate temporary vectorial force */
1002 /* Update vectorial force */
1006 f[j_coord_offset+DIM*1+XX] -= tx;
1007 f[j_coord_offset+DIM*1+YY] -= ty;
1008 f[j_coord_offset+DIM*1+ZZ] -= tz;
1012 /**************************
1013 * CALCULATE INTERACTIONS *
1014 **************************/
1019 /* REACTION-FIELD ELECTROSTATICS */
1020 felec = qq12*(rinv12*rinvsq12-krf2);
1024 /* Calculate temporary vectorial force */
1029 /* Update vectorial force */
1033 f[j_coord_offset+DIM*2+XX] -= tx;
1034 f[j_coord_offset+DIM*2+YY] -= ty;
1035 f[j_coord_offset+DIM*2+ZZ] -= tz;
1039 /**************************
1040 * CALCULATE INTERACTIONS *
1041 **************************/
1046 /* REACTION-FIELD ELECTROSTATICS */
1047 felec = qq20*(rinv20*rinvsq20-krf2);
1051 /* Calculate temporary vectorial force */
1056 /* Update vectorial force */
1060 f[j_coord_offset+DIM*0+XX] -= tx;
1061 f[j_coord_offset+DIM*0+YY] -= ty;
1062 f[j_coord_offset+DIM*0+ZZ] -= tz;
1066 /**************************
1067 * CALCULATE INTERACTIONS *
1068 **************************/
1073 /* REACTION-FIELD ELECTROSTATICS */
1074 felec = qq21*(rinv21*rinvsq21-krf2);
1078 /* Calculate temporary vectorial force */
1083 /* Update vectorial force */
1087 f[j_coord_offset+DIM*1+XX] -= tx;
1088 f[j_coord_offset+DIM*1+YY] -= ty;
1089 f[j_coord_offset+DIM*1+ZZ] -= tz;
1093 /**************************
1094 * CALCULATE INTERACTIONS *
1095 **************************/
1100 /* REACTION-FIELD ELECTROSTATICS */
1101 felec = qq22*(rinv22*rinvsq22-krf2);
1105 /* Calculate temporary vectorial force */
1110 /* Update vectorial force */
1114 f[j_coord_offset+DIM*2+XX] -= tx;
1115 f[j_coord_offset+DIM*2+YY] -= ty;
1116 f[j_coord_offset+DIM*2+ZZ] -= tz;
1120 /* Inner loop uses 289 flops */
1122 /* End of innermost loop */
1125 f[i_coord_offset+DIM*0+XX] += fix0;
1126 f[i_coord_offset+DIM*0+YY] += fiy0;
1127 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1131 f[i_coord_offset+DIM*1+XX] += fix1;
1132 f[i_coord_offset+DIM*1+YY] += fiy1;
1133 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1137 f[i_coord_offset+DIM*2+XX] += fix2;
1138 f[i_coord_offset+DIM*2+YY] += fiy2;
1139 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1143 fshift[i_shift_offset+XX] += tx;
1144 fshift[i_shift_offset+YY] += ty;
1145 fshift[i_shift_offset+ZZ] += tz;
1147 /* Increment number of inner iterations */
1148 inneriter += j_index_end - j_index_start;
1150 /* Outer loop uses 30 flops */
1153 /* Increment number of outer iterations */
1156 /* Update outer/inner flops */
1158 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*289);