2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
65 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
67 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
68 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
69 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
70 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
71 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
72 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
73 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
74 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
75 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
76 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
83 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
90 jindex = nlist->jindex;
92 shiftidx = nlist->shift;
94 shiftvec = fr->shift_vec[0];
95 fshift = fr->fshift[0];
97 charge = mdatoms->chargeA;
101 nvdwtype = fr->ntype;
103 vdwtype = mdatoms->typeA;
105 /* Setup water-specific parameters */
106 inr = nlist->iinr[0];
107 iq0 = facel*charge[inr+0];
108 iq1 = facel*charge[inr+1];
109 iq2 = facel*charge[inr+2];
110 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
115 vdwjidx0 = 3*vdwtype[inr+0];
117 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
118 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
119 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
129 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
130 rcutoff = fr->rcoulomb;
131 rcutoff2 = rcutoff*rcutoff;
133 rswitch = fr->rvdw_switch;
134 /* Setup switch parameters */
136 swV3 = -10.0/(d*d*d);
137 swV4 = 15.0/(d*d*d*d);
138 swV5 = -6.0/(d*d*d*d*d);
139 swF2 = -30.0/(d*d*d);
140 swF3 = 60.0/(d*d*d*d);
141 swF4 = -30.0/(d*d*d*d*d);
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];
184 /* Reset potential sums */
188 /* Start inner kernel loop */
189 for(jidx=j_index_start; jidx<j_index_end; jidx++)
191 /* Get j neighbor index, and coordinate index */
193 j_coord_offset = DIM*jnr;
195 /* load j atom coordinates */
196 jx0 = x[j_coord_offset+DIM*0+XX];
197 jy0 = x[j_coord_offset+DIM*0+YY];
198 jz0 = x[j_coord_offset+DIM*0+ZZ];
199 jx1 = x[j_coord_offset+DIM*1+XX];
200 jy1 = x[j_coord_offset+DIM*1+YY];
201 jz1 = x[j_coord_offset+DIM*1+ZZ];
202 jx2 = x[j_coord_offset+DIM*2+XX];
203 jy2 = x[j_coord_offset+DIM*2+YY];
204 jz2 = x[j_coord_offset+DIM*2+ZZ];
206 /* Calculate displacement vector */
235 /* Calculate squared distance and things based on it */
236 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
237 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
238 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
239 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
240 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
241 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
242 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
243 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
244 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
246 rinv00 = gmx_invsqrt(rsq00);
247 rinv01 = gmx_invsqrt(rsq01);
248 rinv02 = gmx_invsqrt(rsq02);
249 rinv10 = gmx_invsqrt(rsq10);
250 rinv11 = gmx_invsqrt(rsq11);
251 rinv12 = gmx_invsqrt(rsq12);
252 rinv20 = gmx_invsqrt(rsq20);
253 rinv21 = gmx_invsqrt(rsq21);
254 rinv22 = gmx_invsqrt(rsq22);
256 rinvsq00 = rinv00*rinv00;
257 rinvsq01 = rinv01*rinv01;
258 rinvsq02 = rinv02*rinv02;
259 rinvsq10 = rinv10*rinv10;
260 rinvsq11 = rinv11*rinv11;
261 rinvsq12 = rinv12*rinv12;
262 rinvsq20 = rinv20*rinv20;
263 rinvsq21 = rinv21*rinv21;
264 rinvsq22 = rinv22*rinv22;
266 /**************************
267 * CALCULATE INTERACTIONS *
268 **************************/
275 /* REACTION-FIELD ELECTROSTATICS */
276 velec = qq00*(rinv00+krf*rsq00-crf);
277 felec = qq00*(rinv00*rinvsq00-krf2);
279 /* BUCKINGHAM DISPERSION/REPULSION */
280 rinvsix = rinvsq00*rinvsq00*rinvsq00;
281 vvdw6 = c6_00*rinvsix;
283 vvdwexp = cexp1_00*exp(-br);
284 vvdw = vvdwexp - vvdw6*(1.0/6.0);
285 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
288 d = (d>0.0) ? d : 0.0;
290 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
292 dsw = d2*(swF2+d*(swF3+d*swF4));
294 /* Evaluate switch function */
295 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
296 fvdw = fvdw*sw - rinv00*vvdw*dsw;
299 /* Update potential sums from outer loop */
305 /* Calculate temporary vectorial force */
310 /* Update vectorial force */
314 f[j_coord_offset+DIM*0+XX] -= tx;
315 f[j_coord_offset+DIM*0+YY] -= ty;
316 f[j_coord_offset+DIM*0+ZZ] -= tz;
320 /**************************
321 * CALCULATE INTERACTIONS *
322 **************************/
327 /* REACTION-FIELD ELECTROSTATICS */
328 velec = qq01*(rinv01+krf*rsq01-crf);
329 felec = qq01*(rinv01*rinvsq01-krf2);
331 /* Update potential sums from outer loop */
336 /* Calculate temporary vectorial force */
341 /* Update vectorial force */
345 f[j_coord_offset+DIM*1+XX] -= tx;
346 f[j_coord_offset+DIM*1+YY] -= ty;
347 f[j_coord_offset+DIM*1+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
358 /* REACTION-FIELD ELECTROSTATICS */
359 velec = qq02*(rinv02+krf*rsq02-crf);
360 felec = qq02*(rinv02*rinvsq02-krf2);
362 /* Update potential sums from outer loop */
367 /* Calculate temporary vectorial force */
372 /* Update vectorial force */
376 f[j_coord_offset+DIM*2+XX] -= tx;
377 f[j_coord_offset+DIM*2+YY] -= ty;
378 f[j_coord_offset+DIM*2+ZZ] -= tz;
382 /**************************
383 * CALCULATE INTERACTIONS *
384 **************************/
389 /* REACTION-FIELD ELECTROSTATICS */
390 velec = qq10*(rinv10+krf*rsq10-crf);
391 felec = qq10*(rinv10*rinvsq10-krf2);
393 /* Update potential sums from outer loop */
398 /* Calculate temporary vectorial force */
403 /* Update vectorial force */
407 f[j_coord_offset+DIM*0+XX] -= tx;
408 f[j_coord_offset+DIM*0+YY] -= ty;
409 f[j_coord_offset+DIM*0+ZZ] -= tz;
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
420 /* REACTION-FIELD ELECTROSTATICS */
421 velec = qq11*(rinv11+krf*rsq11-crf);
422 felec = qq11*(rinv11*rinvsq11-krf2);
424 /* Update potential sums from outer loop */
429 /* Calculate temporary vectorial force */
434 /* Update vectorial force */
438 f[j_coord_offset+DIM*1+XX] -= tx;
439 f[j_coord_offset+DIM*1+YY] -= ty;
440 f[j_coord_offset+DIM*1+ZZ] -= tz;
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
451 /* REACTION-FIELD ELECTROSTATICS */
452 velec = qq12*(rinv12+krf*rsq12-crf);
453 felec = qq12*(rinv12*rinvsq12-krf2);
455 /* Update potential sums from outer loop */
460 /* Calculate temporary vectorial force */
465 /* Update vectorial force */
469 f[j_coord_offset+DIM*2+XX] -= tx;
470 f[j_coord_offset+DIM*2+YY] -= ty;
471 f[j_coord_offset+DIM*2+ZZ] -= tz;
475 /**************************
476 * CALCULATE INTERACTIONS *
477 **************************/
482 /* REACTION-FIELD ELECTROSTATICS */
483 velec = qq20*(rinv20+krf*rsq20-crf);
484 felec = qq20*(rinv20*rinvsq20-krf2);
486 /* Update potential sums from outer loop */
491 /* Calculate temporary vectorial force */
496 /* Update vectorial force */
500 f[j_coord_offset+DIM*0+XX] -= tx;
501 f[j_coord_offset+DIM*0+YY] -= ty;
502 f[j_coord_offset+DIM*0+ZZ] -= tz;
506 /**************************
507 * CALCULATE INTERACTIONS *
508 **************************/
513 /* REACTION-FIELD ELECTROSTATICS */
514 velec = qq21*(rinv21+krf*rsq21-crf);
515 felec = qq21*(rinv21*rinvsq21-krf2);
517 /* Update potential sums from outer loop */
522 /* Calculate temporary vectorial force */
527 /* Update vectorial force */
531 f[j_coord_offset+DIM*1+XX] -= tx;
532 f[j_coord_offset+DIM*1+YY] -= ty;
533 f[j_coord_offset+DIM*1+ZZ] -= tz;
537 /**************************
538 * CALCULATE INTERACTIONS *
539 **************************/
544 /* REACTION-FIELD ELECTROSTATICS */
545 velec = qq22*(rinv22+krf*rsq22-crf);
546 felec = qq22*(rinv22*rinvsq22-krf2);
548 /* Update potential sums from outer loop */
553 /* Calculate temporary vectorial force */
558 /* Update vectorial force */
562 f[j_coord_offset+DIM*2+XX] -= tx;
563 f[j_coord_offset+DIM*2+YY] -= ty;
564 f[j_coord_offset+DIM*2+ZZ] -= tz;
568 /* Inner loop uses 336 flops */
570 /* End of innermost loop */
573 f[i_coord_offset+DIM*0+XX] += fix0;
574 f[i_coord_offset+DIM*0+YY] += fiy0;
575 f[i_coord_offset+DIM*0+ZZ] += fiz0;
579 f[i_coord_offset+DIM*1+XX] += fix1;
580 f[i_coord_offset+DIM*1+YY] += fiy1;
581 f[i_coord_offset+DIM*1+ZZ] += fiz1;
585 f[i_coord_offset+DIM*2+XX] += fix2;
586 f[i_coord_offset+DIM*2+YY] += fiy2;
587 f[i_coord_offset+DIM*2+ZZ] += fiz2;
591 fshift[i_shift_offset+XX] += tx;
592 fshift[i_shift_offset+YY] += ty;
593 fshift[i_shift_offset+ZZ] += tz;
596 /* Update potential energies */
597 kernel_data->energygrp_elec[ggid] += velecsum;
598 kernel_data->energygrp_vdw[ggid] += vvdwsum;
600 /* Increment number of inner iterations */
601 inneriter += j_index_end - j_index_start;
603 /* Outer loop uses 32 flops */
606 /* Increment number of outer iterations */
609 /* Update outer/inner flops */
611 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*336);
614 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_F_c
615 * Electrostatics interaction: ReactionField
616 * VdW interaction: Buckingham
617 * Geometry: Water3-Water3
618 * Calculate force/pot: Force
621 nb_kernel_ElecRFCut_VdwBhamSw_GeomW3W3_F_c
622 (t_nblist * gmx_restrict nlist,
623 rvec * gmx_restrict xx,
624 rvec * gmx_restrict ff,
625 t_forcerec * gmx_restrict fr,
626 t_mdatoms * gmx_restrict mdatoms,
627 nb_kernel_data_t * gmx_restrict kernel_data,
628 t_nrnb * gmx_restrict nrnb)
630 int i_shift_offset,i_coord_offset,j_coord_offset;
631 int j_index_start,j_index_end;
632 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
633 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
634 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
635 real *shiftvec,*fshift,*x,*f;
637 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
639 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
641 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
643 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
645 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
647 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
648 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
649 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
650 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
651 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
652 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
653 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
654 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
655 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
656 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
657 real velec,felec,velecsum,facel,crf,krf,krf2;
660 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
663 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
670 jindex = nlist->jindex;
672 shiftidx = nlist->shift;
674 shiftvec = fr->shift_vec[0];
675 fshift = fr->fshift[0];
677 charge = mdatoms->chargeA;
681 nvdwtype = fr->ntype;
683 vdwtype = mdatoms->typeA;
685 /* Setup water-specific parameters */
686 inr = nlist->iinr[0];
687 iq0 = facel*charge[inr+0];
688 iq1 = facel*charge[inr+1];
689 iq2 = facel*charge[inr+2];
690 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
695 vdwjidx0 = 3*vdwtype[inr+0];
697 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
698 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
699 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
709 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
710 rcutoff = fr->rcoulomb;
711 rcutoff2 = rcutoff*rcutoff;
713 rswitch = fr->rvdw_switch;
714 /* Setup switch parameters */
716 swV3 = -10.0/(d*d*d);
717 swV4 = 15.0/(d*d*d*d);
718 swV5 = -6.0/(d*d*d*d*d);
719 swF2 = -30.0/(d*d*d);
720 swF3 = 60.0/(d*d*d*d);
721 swF4 = -30.0/(d*d*d*d*d);
726 /* Start outer loop over neighborlists */
727 for(iidx=0; iidx<nri; iidx++)
729 /* Load shift vector for this list */
730 i_shift_offset = DIM*shiftidx[iidx];
731 shX = shiftvec[i_shift_offset+XX];
732 shY = shiftvec[i_shift_offset+YY];
733 shZ = shiftvec[i_shift_offset+ZZ];
735 /* Load limits for loop over neighbors */
736 j_index_start = jindex[iidx];
737 j_index_end = jindex[iidx+1];
739 /* Get outer coordinate index */
741 i_coord_offset = DIM*inr;
743 /* Load i particle coords and add shift vector */
744 ix0 = shX + x[i_coord_offset+DIM*0+XX];
745 iy0 = shY + x[i_coord_offset+DIM*0+YY];
746 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
747 ix1 = shX + x[i_coord_offset+DIM*1+XX];
748 iy1 = shY + x[i_coord_offset+DIM*1+YY];
749 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
750 ix2 = shX + x[i_coord_offset+DIM*2+XX];
751 iy2 = shY + x[i_coord_offset+DIM*2+YY];
752 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
764 /* Start inner kernel loop */
765 for(jidx=j_index_start; jidx<j_index_end; jidx++)
767 /* Get j neighbor index, and coordinate index */
769 j_coord_offset = DIM*jnr;
771 /* load j atom coordinates */
772 jx0 = x[j_coord_offset+DIM*0+XX];
773 jy0 = x[j_coord_offset+DIM*0+YY];
774 jz0 = x[j_coord_offset+DIM*0+ZZ];
775 jx1 = x[j_coord_offset+DIM*1+XX];
776 jy1 = x[j_coord_offset+DIM*1+YY];
777 jz1 = x[j_coord_offset+DIM*1+ZZ];
778 jx2 = x[j_coord_offset+DIM*2+XX];
779 jy2 = x[j_coord_offset+DIM*2+YY];
780 jz2 = x[j_coord_offset+DIM*2+ZZ];
782 /* Calculate displacement vector */
811 /* Calculate squared distance and things based on it */
812 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
813 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
814 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
815 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
816 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
817 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
818 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
819 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
820 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
822 rinv00 = gmx_invsqrt(rsq00);
823 rinv01 = gmx_invsqrt(rsq01);
824 rinv02 = gmx_invsqrt(rsq02);
825 rinv10 = gmx_invsqrt(rsq10);
826 rinv11 = gmx_invsqrt(rsq11);
827 rinv12 = gmx_invsqrt(rsq12);
828 rinv20 = gmx_invsqrt(rsq20);
829 rinv21 = gmx_invsqrt(rsq21);
830 rinv22 = gmx_invsqrt(rsq22);
832 rinvsq00 = rinv00*rinv00;
833 rinvsq01 = rinv01*rinv01;
834 rinvsq02 = rinv02*rinv02;
835 rinvsq10 = rinv10*rinv10;
836 rinvsq11 = rinv11*rinv11;
837 rinvsq12 = rinv12*rinv12;
838 rinvsq20 = rinv20*rinv20;
839 rinvsq21 = rinv21*rinv21;
840 rinvsq22 = rinv22*rinv22;
842 /**************************
843 * CALCULATE INTERACTIONS *
844 **************************/
851 /* REACTION-FIELD ELECTROSTATICS */
852 felec = qq00*(rinv00*rinvsq00-krf2);
854 /* BUCKINGHAM DISPERSION/REPULSION */
855 rinvsix = rinvsq00*rinvsq00*rinvsq00;
856 vvdw6 = c6_00*rinvsix;
858 vvdwexp = cexp1_00*exp(-br);
859 vvdw = vvdwexp - vvdw6*(1.0/6.0);
860 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
863 d = (d>0.0) ? d : 0.0;
865 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
867 dsw = d2*(swF2+d*(swF3+d*swF4));
869 /* Evaluate switch function */
870 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
871 fvdw = fvdw*sw - rinv00*vvdw*dsw;
875 /* Calculate temporary vectorial force */
880 /* Update vectorial force */
884 f[j_coord_offset+DIM*0+XX] -= tx;
885 f[j_coord_offset+DIM*0+YY] -= ty;
886 f[j_coord_offset+DIM*0+ZZ] -= tz;
890 /**************************
891 * CALCULATE INTERACTIONS *
892 **************************/
897 /* REACTION-FIELD ELECTROSTATICS */
898 felec = qq01*(rinv01*rinvsq01-krf2);
902 /* Calculate temporary vectorial force */
907 /* Update vectorial force */
911 f[j_coord_offset+DIM*1+XX] -= tx;
912 f[j_coord_offset+DIM*1+YY] -= ty;
913 f[j_coord_offset+DIM*1+ZZ] -= tz;
917 /**************************
918 * CALCULATE INTERACTIONS *
919 **************************/
924 /* REACTION-FIELD ELECTROSTATICS */
925 felec = qq02*(rinv02*rinvsq02-krf2);
929 /* Calculate temporary vectorial force */
934 /* Update vectorial force */
938 f[j_coord_offset+DIM*2+XX] -= tx;
939 f[j_coord_offset+DIM*2+YY] -= ty;
940 f[j_coord_offset+DIM*2+ZZ] -= tz;
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
951 /* REACTION-FIELD ELECTROSTATICS */
952 felec = qq10*(rinv10*rinvsq10-krf2);
956 /* Calculate temporary vectorial force */
961 /* Update vectorial force */
965 f[j_coord_offset+DIM*0+XX] -= tx;
966 f[j_coord_offset+DIM*0+YY] -= ty;
967 f[j_coord_offset+DIM*0+ZZ] -= tz;
971 /**************************
972 * CALCULATE INTERACTIONS *
973 **************************/
978 /* REACTION-FIELD ELECTROSTATICS */
979 felec = qq11*(rinv11*rinvsq11-krf2);
983 /* Calculate temporary vectorial force */
988 /* Update vectorial force */
992 f[j_coord_offset+DIM*1+XX] -= tx;
993 f[j_coord_offset+DIM*1+YY] -= ty;
994 f[j_coord_offset+DIM*1+ZZ] -= tz;
998 /**************************
999 * CALCULATE INTERACTIONS *
1000 **************************/
1005 /* REACTION-FIELD ELECTROSTATICS */
1006 felec = qq12*(rinv12*rinvsq12-krf2);
1010 /* Calculate temporary vectorial force */
1015 /* Update vectorial force */
1019 f[j_coord_offset+DIM*2+XX] -= tx;
1020 f[j_coord_offset+DIM*2+YY] -= ty;
1021 f[j_coord_offset+DIM*2+ZZ] -= tz;
1025 /**************************
1026 * CALCULATE INTERACTIONS *
1027 **************************/
1032 /* REACTION-FIELD ELECTROSTATICS */
1033 felec = qq20*(rinv20*rinvsq20-krf2);
1037 /* Calculate temporary vectorial force */
1042 /* Update vectorial force */
1046 f[j_coord_offset+DIM*0+XX] -= tx;
1047 f[j_coord_offset+DIM*0+YY] -= ty;
1048 f[j_coord_offset+DIM*0+ZZ] -= tz;
1052 /**************************
1053 * CALCULATE INTERACTIONS *
1054 **************************/
1059 /* REACTION-FIELD ELECTROSTATICS */
1060 felec = qq21*(rinv21*rinvsq21-krf2);
1064 /* Calculate temporary vectorial force */
1069 /* Update vectorial force */
1073 f[j_coord_offset+DIM*1+XX] -= tx;
1074 f[j_coord_offset+DIM*1+YY] -= ty;
1075 f[j_coord_offset+DIM*1+ZZ] -= tz;
1079 /**************************
1080 * CALCULATE INTERACTIONS *
1081 **************************/
1086 /* REACTION-FIELD ELECTROSTATICS */
1087 felec = qq22*(rinv22*rinvsq22-krf2);
1091 /* Calculate temporary vectorial force */
1096 /* Update vectorial force */
1100 f[j_coord_offset+DIM*2+XX] -= tx;
1101 f[j_coord_offset+DIM*2+YY] -= ty;
1102 f[j_coord_offset+DIM*2+ZZ] -= tz;
1106 /* Inner loop uses 289 flops */
1108 /* End of innermost loop */
1111 f[i_coord_offset+DIM*0+XX] += fix0;
1112 f[i_coord_offset+DIM*0+YY] += fiy0;
1113 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1117 f[i_coord_offset+DIM*1+XX] += fix1;
1118 f[i_coord_offset+DIM*1+YY] += fiy1;
1119 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1123 f[i_coord_offset+DIM*2+XX] += fix2;
1124 f[i_coord_offset+DIM*2+YY] += fiy2;
1125 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1129 fshift[i_shift_offset+XX] += tx;
1130 fshift[i_shift_offset+YY] += ty;
1131 fshift[i_shift_offset+ZZ] += tz;
1133 /* Increment number of inner iterations */
1134 inneriter += j_index_end - j_index_start;
1136 /* Outer loop uses 30 flops */
1139 /* Increment number of outer iterations */
1142 /* Update outer/inner flops */
1144 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*289);