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_VdwLJSw_GeomW3W3_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Water3
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwLJSw_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 = 2*nvdwtype*vdwtype[inr+0];
115 vdwjidx0 = 2*vdwtype[inr+0];
117 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
118 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
128 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
129 rcutoff = fr->rcoulomb;
130 rcutoff2 = rcutoff*rcutoff;
132 rswitch = fr->rvdw_switch;
133 /* Setup switch parameters */
135 swV3 = -10.0/(d*d*d);
136 swV4 = 15.0/(d*d*d*d);
137 swV5 = -6.0/(d*d*d*d*d);
138 swF2 = -30.0/(d*d*d);
139 swF3 = 60.0/(d*d*d*d);
140 swF4 = -30.0/(d*d*d*d*d);
145 /* Start outer loop over neighborlists */
146 for(iidx=0; iidx<nri; iidx++)
148 /* Load shift vector for this list */
149 i_shift_offset = DIM*shiftidx[iidx];
150 shX = shiftvec[i_shift_offset+XX];
151 shY = shiftvec[i_shift_offset+YY];
152 shZ = shiftvec[i_shift_offset+ZZ];
154 /* Load limits for loop over neighbors */
155 j_index_start = jindex[iidx];
156 j_index_end = jindex[iidx+1];
158 /* Get outer coordinate index */
160 i_coord_offset = DIM*inr;
162 /* Load i particle coords and add shift vector */
163 ix0 = shX + x[i_coord_offset+DIM*0+XX];
164 iy0 = shY + x[i_coord_offset+DIM*0+YY];
165 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
166 ix1 = shX + x[i_coord_offset+DIM*1+XX];
167 iy1 = shY + x[i_coord_offset+DIM*1+YY];
168 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
169 ix2 = shX + x[i_coord_offset+DIM*2+XX];
170 iy2 = shY + x[i_coord_offset+DIM*2+YY];
171 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
183 /* Reset potential sums */
187 /* Start inner kernel loop */
188 for(jidx=j_index_start; jidx<j_index_end; jidx++)
190 /* Get j neighbor index, and coordinate index */
192 j_coord_offset = DIM*jnr;
194 /* load j atom coordinates */
195 jx0 = x[j_coord_offset+DIM*0+XX];
196 jy0 = x[j_coord_offset+DIM*0+YY];
197 jz0 = x[j_coord_offset+DIM*0+ZZ];
198 jx1 = x[j_coord_offset+DIM*1+XX];
199 jy1 = x[j_coord_offset+DIM*1+YY];
200 jz1 = x[j_coord_offset+DIM*1+ZZ];
201 jx2 = x[j_coord_offset+DIM*2+XX];
202 jy2 = x[j_coord_offset+DIM*2+YY];
203 jz2 = x[j_coord_offset+DIM*2+ZZ];
205 /* Calculate displacement vector */
234 /* Calculate squared distance and things based on it */
235 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
236 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
237 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
238 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
239 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
240 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
241 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
242 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
243 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
245 rinv00 = gmx_invsqrt(rsq00);
246 rinv01 = gmx_invsqrt(rsq01);
247 rinv02 = gmx_invsqrt(rsq02);
248 rinv10 = gmx_invsqrt(rsq10);
249 rinv11 = gmx_invsqrt(rsq11);
250 rinv12 = gmx_invsqrt(rsq12);
251 rinv20 = gmx_invsqrt(rsq20);
252 rinv21 = gmx_invsqrt(rsq21);
253 rinv22 = gmx_invsqrt(rsq22);
255 rinvsq00 = rinv00*rinv00;
256 rinvsq01 = rinv01*rinv01;
257 rinvsq02 = rinv02*rinv02;
258 rinvsq10 = rinv10*rinv10;
259 rinvsq11 = rinv11*rinv11;
260 rinvsq12 = rinv12*rinv12;
261 rinvsq20 = rinv20*rinv20;
262 rinvsq21 = rinv21*rinv21;
263 rinvsq22 = rinv22*rinv22;
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
274 /* REACTION-FIELD ELECTROSTATICS */
275 velec = qq00*(rinv00+krf*rsq00-crf);
276 felec = qq00*(rinv00*rinvsq00-krf2);
278 /* LENNARD-JONES DISPERSION/REPULSION */
280 rinvsix = rinvsq00*rinvsq00*rinvsq00;
281 vvdw6 = c6_00*rinvsix;
282 vvdw12 = c12_00*rinvsix*rinvsix;
283 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
284 fvdw = (vvdw12-vvdw6)*rinvsq00;
287 d = (d>0.0) ? d : 0.0;
289 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
291 dsw = d2*(swF2+d*(swF3+d*swF4));
293 /* Evaluate switch function */
294 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
295 fvdw = fvdw*sw - rinv00*vvdw*dsw;
298 /* Update potential sums from outer loop */
304 /* Calculate temporary vectorial force */
309 /* Update vectorial force */
313 f[j_coord_offset+DIM*0+XX] -= tx;
314 f[j_coord_offset+DIM*0+YY] -= ty;
315 f[j_coord_offset+DIM*0+ZZ] -= tz;
319 /**************************
320 * CALCULATE INTERACTIONS *
321 **************************/
326 /* REACTION-FIELD ELECTROSTATICS */
327 velec = qq01*(rinv01+krf*rsq01-crf);
328 felec = qq01*(rinv01*rinvsq01-krf2);
330 /* Update potential sums from outer loop */
335 /* Calculate temporary vectorial force */
340 /* Update vectorial force */
344 f[j_coord_offset+DIM*1+XX] -= tx;
345 f[j_coord_offset+DIM*1+YY] -= ty;
346 f[j_coord_offset+DIM*1+ZZ] -= tz;
350 /**************************
351 * CALCULATE INTERACTIONS *
352 **************************/
357 /* REACTION-FIELD ELECTROSTATICS */
358 velec = qq02*(rinv02+krf*rsq02-crf);
359 felec = qq02*(rinv02*rinvsq02-krf2);
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*2+XX] -= tx;
376 f[j_coord_offset+DIM*2+YY] -= ty;
377 f[j_coord_offset+DIM*2+ZZ] -= tz;
381 /**************************
382 * CALCULATE INTERACTIONS *
383 **************************/
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = qq10*(rinv10+krf*rsq10-crf);
390 felec = qq10*(rinv10*rinvsq10-krf2);
392 /* Update potential sums from outer loop */
397 /* Calculate temporary vectorial force */
402 /* Update vectorial force */
406 f[j_coord_offset+DIM*0+XX] -= tx;
407 f[j_coord_offset+DIM*0+YY] -= ty;
408 f[j_coord_offset+DIM*0+ZZ] -= tz;
412 /**************************
413 * CALCULATE INTERACTIONS *
414 **************************/
419 /* REACTION-FIELD ELECTROSTATICS */
420 velec = qq11*(rinv11+krf*rsq11-crf);
421 felec = qq11*(rinv11*rinvsq11-krf2);
423 /* Update potential sums from outer loop */
428 /* Calculate temporary vectorial force */
433 /* Update vectorial force */
437 f[j_coord_offset+DIM*1+XX] -= tx;
438 f[j_coord_offset+DIM*1+YY] -= ty;
439 f[j_coord_offset+DIM*1+ZZ] -= tz;
443 /**************************
444 * CALCULATE INTERACTIONS *
445 **************************/
450 /* REACTION-FIELD ELECTROSTATICS */
451 velec = qq12*(rinv12+krf*rsq12-crf);
452 felec = qq12*(rinv12*rinvsq12-krf2);
454 /* Update potential sums from outer loop */
459 /* Calculate temporary vectorial force */
464 /* Update vectorial force */
468 f[j_coord_offset+DIM*2+XX] -= tx;
469 f[j_coord_offset+DIM*2+YY] -= ty;
470 f[j_coord_offset+DIM*2+ZZ] -= tz;
474 /**************************
475 * CALCULATE INTERACTIONS *
476 **************************/
481 /* REACTION-FIELD ELECTROSTATICS */
482 velec = qq20*(rinv20+krf*rsq20-crf);
483 felec = qq20*(rinv20*rinvsq20-krf2);
485 /* Update potential sums from outer loop */
490 /* Calculate temporary vectorial force */
495 /* Update vectorial force */
499 f[j_coord_offset+DIM*0+XX] -= tx;
500 f[j_coord_offset+DIM*0+YY] -= ty;
501 f[j_coord_offset+DIM*0+ZZ] -= tz;
505 /**************************
506 * CALCULATE INTERACTIONS *
507 **************************/
512 /* REACTION-FIELD ELECTROSTATICS */
513 velec = qq21*(rinv21+krf*rsq21-crf);
514 felec = qq21*(rinv21*rinvsq21-krf2);
516 /* Update potential sums from outer loop */
521 /* Calculate temporary vectorial force */
526 /* Update vectorial force */
530 f[j_coord_offset+DIM*1+XX] -= tx;
531 f[j_coord_offset+DIM*1+YY] -= ty;
532 f[j_coord_offset+DIM*1+ZZ] -= tz;
536 /**************************
537 * CALCULATE INTERACTIONS *
538 **************************/
543 /* REACTION-FIELD ELECTROSTATICS */
544 velec = qq22*(rinv22+krf*rsq22-crf);
545 felec = qq22*(rinv22*rinvsq22-krf2);
547 /* Update potential sums from outer loop */
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*2+XX] -= tx;
562 f[j_coord_offset+DIM*2+YY] -= ty;
563 f[j_coord_offset+DIM*2+ZZ] -= tz;
567 /* Inner loop uses 310 flops */
569 /* End of innermost loop */
572 f[i_coord_offset+DIM*0+XX] += fix0;
573 f[i_coord_offset+DIM*0+YY] += fiy0;
574 f[i_coord_offset+DIM*0+ZZ] += fiz0;
578 f[i_coord_offset+DIM*1+XX] += fix1;
579 f[i_coord_offset+DIM*1+YY] += fiy1;
580 f[i_coord_offset+DIM*1+ZZ] += fiz1;
584 f[i_coord_offset+DIM*2+XX] += fix2;
585 f[i_coord_offset+DIM*2+YY] += fiy2;
586 f[i_coord_offset+DIM*2+ZZ] += fiz2;
590 fshift[i_shift_offset+XX] += tx;
591 fshift[i_shift_offset+YY] += ty;
592 fshift[i_shift_offset+ZZ] += tz;
595 /* Update potential energies */
596 kernel_data->energygrp_elec[ggid] += velecsum;
597 kernel_data->energygrp_vdw[ggid] += vvdwsum;
599 /* Increment number of inner iterations */
600 inneriter += j_index_end - j_index_start;
602 /* Outer loop uses 32 flops */
605 /* Increment number of outer iterations */
608 /* Update outer/inner flops */
610 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*310);
613 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_F_c
614 * Electrostatics interaction: ReactionField
615 * VdW interaction: LennardJones
616 * Geometry: Water3-Water3
617 * Calculate force/pot: Force
620 nb_kernel_ElecRFCut_VdwLJSw_GeomW3W3_F_c
621 (t_nblist * gmx_restrict nlist,
622 rvec * gmx_restrict xx,
623 rvec * gmx_restrict ff,
624 t_forcerec * gmx_restrict fr,
625 t_mdatoms * gmx_restrict mdatoms,
626 nb_kernel_data_t * gmx_restrict kernel_data,
627 t_nrnb * gmx_restrict nrnb)
629 int i_shift_offset,i_coord_offset,j_coord_offset;
630 int j_index_start,j_index_end;
631 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
632 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
633 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
634 real *shiftvec,*fshift,*x,*f;
636 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
638 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
640 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
642 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
644 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
646 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
647 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
648 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
649 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
650 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
651 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
652 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
653 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
654 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
655 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
656 real velec,felec,velecsum,facel,crf,krf,krf2;
659 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
662 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
669 jindex = nlist->jindex;
671 shiftidx = nlist->shift;
673 shiftvec = fr->shift_vec[0];
674 fshift = fr->fshift[0];
676 charge = mdatoms->chargeA;
680 nvdwtype = fr->ntype;
682 vdwtype = mdatoms->typeA;
684 /* Setup water-specific parameters */
685 inr = nlist->iinr[0];
686 iq0 = facel*charge[inr+0];
687 iq1 = facel*charge[inr+1];
688 iq2 = facel*charge[inr+2];
689 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
694 vdwjidx0 = 2*vdwtype[inr+0];
696 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
697 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
707 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
708 rcutoff = fr->rcoulomb;
709 rcutoff2 = rcutoff*rcutoff;
711 rswitch = fr->rvdw_switch;
712 /* Setup switch parameters */
714 swV3 = -10.0/(d*d*d);
715 swV4 = 15.0/(d*d*d*d);
716 swV5 = -6.0/(d*d*d*d*d);
717 swF2 = -30.0/(d*d*d);
718 swF3 = 60.0/(d*d*d*d);
719 swF4 = -30.0/(d*d*d*d*d);
724 /* Start outer loop over neighborlists */
725 for(iidx=0; iidx<nri; iidx++)
727 /* Load shift vector for this list */
728 i_shift_offset = DIM*shiftidx[iidx];
729 shX = shiftvec[i_shift_offset+XX];
730 shY = shiftvec[i_shift_offset+YY];
731 shZ = shiftvec[i_shift_offset+ZZ];
733 /* Load limits for loop over neighbors */
734 j_index_start = jindex[iidx];
735 j_index_end = jindex[iidx+1];
737 /* Get outer coordinate index */
739 i_coord_offset = DIM*inr;
741 /* Load i particle coords and add shift vector */
742 ix0 = shX + x[i_coord_offset+DIM*0+XX];
743 iy0 = shY + x[i_coord_offset+DIM*0+YY];
744 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
745 ix1 = shX + x[i_coord_offset+DIM*1+XX];
746 iy1 = shY + x[i_coord_offset+DIM*1+YY];
747 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
748 ix2 = shX + x[i_coord_offset+DIM*2+XX];
749 iy2 = shY + x[i_coord_offset+DIM*2+YY];
750 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
762 /* Start inner kernel loop */
763 for(jidx=j_index_start; jidx<j_index_end; jidx++)
765 /* Get j neighbor index, and coordinate index */
767 j_coord_offset = DIM*jnr;
769 /* load j atom coordinates */
770 jx0 = x[j_coord_offset+DIM*0+XX];
771 jy0 = x[j_coord_offset+DIM*0+YY];
772 jz0 = x[j_coord_offset+DIM*0+ZZ];
773 jx1 = x[j_coord_offset+DIM*1+XX];
774 jy1 = x[j_coord_offset+DIM*1+YY];
775 jz1 = x[j_coord_offset+DIM*1+ZZ];
776 jx2 = x[j_coord_offset+DIM*2+XX];
777 jy2 = x[j_coord_offset+DIM*2+YY];
778 jz2 = x[j_coord_offset+DIM*2+ZZ];
780 /* Calculate displacement vector */
809 /* Calculate squared distance and things based on it */
810 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
811 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
812 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
813 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
814 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
815 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
816 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
817 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
818 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
820 rinv00 = gmx_invsqrt(rsq00);
821 rinv01 = gmx_invsqrt(rsq01);
822 rinv02 = gmx_invsqrt(rsq02);
823 rinv10 = gmx_invsqrt(rsq10);
824 rinv11 = gmx_invsqrt(rsq11);
825 rinv12 = gmx_invsqrt(rsq12);
826 rinv20 = gmx_invsqrt(rsq20);
827 rinv21 = gmx_invsqrt(rsq21);
828 rinv22 = gmx_invsqrt(rsq22);
830 rinvsq00 = rinv00*rinv00;
831 rinvsq01 = rinv01*rinv01;
832 rinvsq02 = rinv02*rinv02;
833 rinvsq10 = rinv10*rinv10;
834 rinvsq11 = rinv11*rinv11;
835 rinvsq12 = rinv12*rinv12;
836 rinvsq20 = rinv20*rinv20;
837 rinvsq21 = rinv21*rinv21;
838 rinvsq22 = rinv22*rinv22;
840 /**************************
841 * CALCULATE INTERACTIONS *
842 **************************/
849 /* REACTION-FIELD ELECTROSTATICS */
850 felec = qq00*(rinv00*rinvsq00-krf2);
852 /* LENNARD-JONES DISPERSION/REPULSION */
854 rinvsix = rinvsq00*rinvsq00*rinvsq00;
855 vvdw6 = c6_00*rinvsix;
856 vvdw12 = c12_00*rinvsix*rinvsix;
857 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
858 fvdw = (vvdw12-vvdw6)*rinvsq00;
861 d = (d>0.0) ? d : 0.0;
863 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
865 dsw = d2*(swF2+d*(swF3+d*swF4));
867 /* Evaluate switch function */
868 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
869 fvdw = fvdw*sw - rinv00*vvdw*dsw;
873 /* Calculate temporary vectorial force */
878 /* Update vectorial force */
882 f[j_coord_offset+DIM*0+XX] -= tx;
883 f[j_coord_offset+DIM*0+YY] -= ty;
884 f[j_coord_offset+DIM*0+ZZ] -= tz;
888 /**************************
889 * CALCULATE INTERACTIONS *
890 **************************/
895 /* REACTION-FIELD ELECTROSTATICS */
896 felec = qq01*(rinv01*rinvsq01-krf2);
900 /* Calculate temporary vectorial force */
905 /* Update vectorial force */
909 f[j_coord_offset+DIM*1+XX] -= tx;
910 f[j_coord_offset+DIM*1+YY] -= ty;
911 f[j_coord_offset+DIM*1+ZZ] -= tz;
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
922 /* REACTION-FIELD ELECTROSTATICS */
923 felec = qq02*(rinv02*rinvsq02-krf2);
927 /* Calculate temporary vectorial force */
932 /* Update vectorial force */
936 f[j_coord_offset+DIM*2+XX] -= tx;
937 f[j_coord_offset+DIM*2+YY] -= ty;
938 f[j_coord_offset+DIM*2+ZZ] -= tz;
942 /**************************
943 * CALCULATE INTERACTIONS *
944 **************************/
949 /* REACTION-FIELD ELECTROSTATICS */
950 felec = qq10*(rinv10*rinvsq10-krf2);
954 /* Calculate temporary vectorial force */
959 /* Update vectorial force */
963 f[j_coord_offset+DIM*0+XX] -= tx;
964 f[j_coord_offset+DIM*0+YY] -= ty;
965 f[j_coord_offset+DIM*0+ZZ] -= tz;
969 /**************************
970 * CALCULATE INTERACTIONS *
971 **************************/
976 /* REACTION-FIELD ELECTROSTATICS */
977 felec = qq11*(rinv11*rinvsq11-krf2);
981 /* Calculate temporary vectorial force */
986 /* Update vectorial force */
990 f[j_coord_offset+DIM*1+XX] -= tx;
991 f[j_coord_offset+DIM*1+YY] -= ty;
992 f[j_coord_offset+DIM*1+ZZ] -= tz;
996 /**************************
997 * CALCULATE INTERACTIONS *
998 **************************/
1003 /* REACTION-FIELD ELECTROSTATICS */
1004 felec = qq12*(rinv12*rinvsq12-krf2);
1008 /* Calculate temporary vectorial force */
1013 /* Update vectorial force */
1017 f[j_coord_offset+DIM*2+XX] -= tx;
1018 f[j_coord_offset+DIM*2+YY] -= ty;
1019 f[j_coord_offset+DIM*2+ZZ] -= tz;
1023 /**************************
1024 * CALCULATE INTERACTIONS *
1025 **************************/
1030 /* REACTION-FIELD ELECTROSTATICS */
1031 felec = qq20*(rinv20*rinvsq20-krf2);
1035 /* Calculate temporary vectorial force */
1040 /* Update vectorial force */
1044 f[j_coord_offset+DIM*0+XX] -= tx;
1045 f[j_coord_offset+DIM*0+YY] -= ty;
1046 f[j_coord_offset+DIM*0+ZZ] -= tz;
1050 /**************************
1051 * CALCULATE INTERACTIONS *
1052 **************************/
1057 /* REACTION-FIELD ELECTROSTATICS */
1058 felec = qq21*(rinv21*rinvsq21-krf2);
1062 /* Calculate temporary vectorial force */
1067 /* Update vectorial force */
1071 f[j_coord_offset+DIM*1+XX] -= tx;
1072 f[j_coord_offset+DIM*1+YY] -= ty;
1073 f[j_coord_offset+DIM*1+ZZ] -= tz;
1077 /**************************
1078 * CALCULATE INTERACTIONS *
1079 **************************/
1084 /* REACTION-FIELD ELECTROSTATICS */
1085 felec = qq22*(rinv22*rinvsq22-krf2);
1089 /* Calculate temporary vectorial force */
1094 /* Update vectorial force */
1098 f[j_coord_offset+DIM*2+XX] -= tx;
1099 f[j_coord_offset+DIM*2+YY] -= ty;
1100 f[j_coord_offset+DIM*2+ZZ] -= tz;
1104 /* Inner loop uses 263 flops */
1106 /* End of innermost loop */
1109 f[i_coord_offset+DIM*0+XX] += fix0;
1110 f[i_coord_offset+DIM*0+YY] += fiy0;
1111 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1115 f[i_coord_offset+DIM*1+XX] += fix1;
1116 f[i_coord_offset+DIM*1+YY] += fiy1;
1117 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1121 f[i_coord_offset+DIM*2+XX] += fix2;
1122 f[i_coord_offset+DIM*2+YY] += fiy2;
1123 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1127 fshift[i_shift_offset+XX] += tx;
1128 fshift[i_shift_offset+YY] += ty;
1129 fshift[i_shift_offset+ZZ] += tz;
1131 /* Increment number of inner iterations */
1132 inneriter += j_index_end - j_index_start;
1134 /* Outer loop uses 30 flops */
1137 /* Increment number of outer iterations */
1140 /* Update outer/inner flops */
1142 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*263);