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_ElecRF_VdwBham_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwBham_GeomW4W4_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
67 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
69 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
71 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
72 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
73 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
74 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
75 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
76 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
77 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
78 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
79 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
80 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
81 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
82 real velec,felec,velecsum,facel,crf,krf,krf2;
85 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
94 jindex = nlist->jindex;
96 shiftidx = nlist->shift;
98 shiftvec = fr->shift_vec[0];
99 fshift = fr->fshift[0];
101 charge = mdatoms->chargeA;
105 nvdwtype = fr->ntype;
107 vdwtype = mdatoms->typeA;
109 /* Setup water-specific parameters */
110 inr = nlist->iinr[0];
111 iq1 = facel*charge[inr+1];
112 iq2 = facel*charge[inr+2];
113 iq3 = facel*charge[inr+3];
114 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
119 vdwjidx0 = 3*vdwtype[inr+0];
120 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
121 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
122 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
136 /* Start outer loop over neighborlists */
137 for(iidx=0; iidx<nri; iidx++)
139 /* Load shift vector for this list */
140 i_shift_offset = DIM*shiftidx[iidx];
141 shX = shiftvec[i_shift_offset+XX];
142 shY = shiftvec[i_shift_offset+YY];
143 shZ = shiftvec[i_shift_offset+ZZ];
145 /* Load limits for loop over neighbors */
146 j_index_start = jindex[iidx];
147 j_index_end = jindex[iidx+1];
149 /* Get outer coordinate index */
151 i_coord_offset = DIM*inr;
153 /* Load i particle coords and add shift vector */
154 ix0 = shX + x[i_coord_offset+DIM*0+XX];
155 iy0 = shY + x[i_coord_offset+DIM*0+YY];
156 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
157 ix1 = shX + x[i_coord_offset+DIM*1+XX];
158 iy1 = shY + x[i_coord_offset+DIM*1+YY];
159 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
160 ix2 = shX + x[i_coord_offset+DIM*2+XX];
161 iy2 = shY + x[i_coord_offset+DIM*2+YY];
162 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
163 ix3 = shX + x[i_coord_offset+DIM*3+XX];
164 iy3 = shY + x[i_coord_offset+DIM*3+YY];
165 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
180 /* Reset potential sums */
184 /* Start inner kernel loop */
185 for(jidx=j_index_start; jidx<j_index_end; jidx++)
187 /* Get j neighbor index, and coordinate index */
189 j_coord_offset = DIM*jnr;
191 /* load j atom coordinates */
192 jx0 = x[j_coord_offset+DIM*0+XX];
193 jy0 = x[j_coord_offset+DIM*0+YY];
194 jz0 = x[j_coord_offset+DIM*0+ZZ];
195 jx1 = x[j_coord_offset+DIM*1+XX];
196 jy1 = x[j_coord_offset+DIM*1+YY];
197 jz1 = x[j_coord_offset+DIM*1+ZZ];
198 jx2 = x[j_coord_offset+DIM*2+XX];
199 jy2 = x[j_coord_offset+DIM*2+YY];
200 jz2 = x[j_coord_offset+DIM*2+ZZ];
201 jx3 = x[j_coord_offset+DIM*3+XX];
202 jy3 = x[j_coord_offset+DIM*3+YY];
203 jz3 = x[j_coord_offset+DIM*3+ZZ];
205 /* Calculate displacement vector */
237 /* Calculate squared distance and things based on it */
238 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
239 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
240 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
241 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
242 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
243 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
244 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
245 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
246 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
247 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
249 rinv00 = gmx_invsqrt(rsq00);
250 rinv11 = gmx_invsqrt(rsq11);
251 rinv12 = gmx_invsqrt(rsq12);
252 rinv13 = gmx_invsqrt(rsq13);
253 rinv21 = gmx_invsqrt(rsq21);
254 rinv22 = gmx_invsqrt(rsq22);
255 rinv23 = gmx_invsqrt(rsq23);
256 rinv31 = gmx_invsqrt(rsq31);
257 rinv32 = gmx_invsqrt(rsq32);
258 rinv33 = gmx_invsqrt(rsq33);
260 rinvsq00 = rinv00*rinv00;
261 rinvsq11 = rinv11*rinv11;
262 rinvsq12 = rinv12*rinv12;
263 rinvsq13 = rinv13*rinv13;
264 rinvsq21 = rinv21*rinv21;
265 rinvsq22 = rinv22*rinv22;
266 rinvsq23 = rinv23*rinv23;
267 rinvsq31 = rinv31*rinv31;
268 rinvsq32 = rinv32*rinv32;
269 rinvsq33 = rinv33*rinv33;
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
277 /* BUCKINGHAM DISPERSION/REPULSION */
278 rinvsix = rinvsq00*rinvsq00*rinvsq00;
279 vvdw6 = c6_00*rinvsix;
281 vvdwexp = cexp1_00*exp(-br);
282 vvdw = vvdwexp - vvdw6*(1.0/6.0);
283 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
285 /* Update potential sums from outer loop */
290 /* Calculate temporary vectorial force */
295 /* Update vectorial force */
299 f[j_coord_offset+DIM*0+XX] -= tx;
300 f[j_coord_offset+DIM*0+YY] -= ty;
301 f[j_coord_offset+DIM*0+ZZ] -= tz;
303 /**************************
304 * CALCULATE INTERACTIONS *
305 **************************/
307 /* REACTION-FIELD ELECTROSTATICS */
308 velec = qq11*(rinv11+krf*rsq11-crf);
309 felec = qq11*(rinv11*rinvsq11-krf2);
311 /* Update potential sums from outer loop */
316 /* Calculate temporary vectorial force */
321 /* Update vectorial force */
325 f[j_coord_offset+DIM*1+XX] -= tx;
326 f[j_coord_offset+DIM*1+YY] -= ty;
327 f[j_coord_offset+DIM*1+ZZ] -= tz;
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
333 /* REACTION-FIELD ELECTROSTATICS */
334 velec = qq12*(rinv12+krf*rsq12-crf);
335 felec = qq12*(rinv12*rinvsq12-krf2);
337 /* Update potential sums from outer loop */
342 /* Calculate temporary vectorial force */
347 /* Update vectorial force */
351 f[j_coord_offset+DIM*2+XX] -= tx;
352 f[j_coord_offset+DIM*2+YY] -= ty;
353 f[j_coord_offset+DIM*2+ZZ] -= tz;
355 /**************************
356 * CALCULATE INTERACTIONS *
357 **************************/
359 /* REACTION-FIELD ELECTROSTATICS */
360 velec = qq13*(rinv13+krf*rsq13-crf);
361 felec = qq13*(rinv13*rinvsq13-krf2);
363 /* Update potential sums from outer loop */
368 /* Calculate temporary vectorial force */
373 /* Update vectorial force */
377 f[j_coord_offset+DIM*3+XX] -= tx;
378 f[j_coord_offset+DIM*3+YY] -= ty;
379 f[j_coord_offset+DIM*3+ZZ] -= tz;
381 /**************************
382 * CALCULATE INTERACTIONS *
383 **************************/
385 /* REACTION-FIELD ELECTROSTATICS */
386 velec = qq21*(rinv21+krf*rsq21-crf);
387 felec = qq21*(rinv21*rinvsq21-krf2);
389 /* Update potential sums from outer loop */
394 /* Calculate temporary vectorial force */
399 /* Update vectorial force */
403 f[j_coord_offset+DIM*1+XX] -= tx;
404 f[j_coord_offset+DIM*1+YY] -= ty;
405 f[j_coord_offset+DIM*1+ZZ] -= tz;
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
411 /* REACTION-FIELD ELECTROSTATICS */
412 velec = qq22*(rinv22+krf*rsq22-crf);
413 felec = qq22*(rinv22*rinvsq22-krf2);
415 /* Update potential sums from outer loop */
420 /* Calculate temporary vectorial force */
425 /* Update vectorial force */
429 f[j_coord_offset+DIM*2+XX] -= tx;
430 f[j_coord_offset+DIM*2+YY] -= ty;
431 f[j_coord_offset+DIM*2+ZZ] -= tz;
433 /**************************
434 * CALCULATE INTERACTIONS *
435 **************************/
437 /* REACTION-FIELD ELECTROSTATICS */
438 velec = qq23*(rinv23+krf*rsq23-crf);
439 felec = qq23*(rinv23*rinvsq23-krf2);
441 /* Update potential sums from outer loop */
446 /* Calculate temporary vectorial force */
451 /* Update vectorial force */
455 f[j_coord_offset+DIM*3+XX] -= tx;
456 f[j_coord_offset+DIM*3+YY] -= ty;
457 f[j_coord_offset+DIM*3+ZZ] -= tz;
459 /**************************
460 * CALCULATE INTERACTIONS *
461 **************************/
463 /* REACTION-FIELD ELECTROSTATICS */
464 velec = qq31*(rinv31+krf*rsq31-crf);
465 felec = qq31*(rinv31*rinvsq31-krf2);
467 /* Update potential sums from outer loop */
472 /* Calculate temporary vectorial force */
477 /* Update vectorial force */
481 f[j_coord_offset+DIM*1+XX] -= tx;
482 f[j_coord_offset+DIM*1+YY] -= ty;
483 f[j_coord_offset+DIM*1+ZZ] -= tz;
485 /**************************
486 * CALCULATE INTERACTIONS *
487 **************************/
489 /* REACTION-FIELD ELECTROSTATICS */
490 velec = qq32*(rinv32+krf*rsq32-crf);
491 felec = qq32*(rinv32*rinvsq32-krf2);
493 /* Update potential sums from outer loop */
498 /* Calculate temporary vectorial force */
503 /* Update vectorial force */
507 f[j_coord_offset+DIM*2+XX] -= tx;
508 f[j_coord_offset+DIM*2+YY] -= ty;
509 f[j_coord_offset+DIM*2+ZZ] -= tz;
511 /**************************
512 * CALCULATE INTERACTIONS *
513 **************************/
515 /* REACTION-FIELD ELECTROSTATICS */
516 velec = qq33*(rinv33+krf*rsq33-crf);
517 felec = qq33*(rinv33*rinvsq33-krf2);
519 /* Update potential sums from outer loop */
524 /* Calculate temporary vectorial force */
529 /* Update vectorial force */
533 f[j_coord_offset+DIM*3+XX] -= tx;
534 f[j_coord_offset+DIM*3+YY] -= ty;
535 f[j_coord_offset+DIM*3+ZZ] -= tz;
537 /* Inner loop uses 340 flops */
539 /* End of innermost loop */
542 f[i_coord_offset+DIM*0+XX] += fix0;
543 f[i_coord_offset+DIM*0+YY] += fiy0;
544 f[i_coord_offset+DIM*0+ZZ] += fiz0;
548 f[i_coord_offset+DIM*1+XX] += fix1;
549 f[i_coord_offset+DIM*1+YY] += fiy1;
550 f[i_coord_offset+DIM*1+ZZ] += fiz1;
554 f[i_coord_offset+DIM*2+XX] += fix2;
555 f[i_coord_offset+DIM*2+YY] += fiy2;
556 f[i_coord_offset+DIM*2+ZZ] += fiz2;
560 f[i_coord_offset+DIM*3+XX] += fix3;
561 f[i_coord_offset+DIM*3+YY] += fiy3;
562 f[i_coord_offset+DIM*3+ZZ] += fiz3;
566 fshift[i_shift_offset+XX] += tx;
567 fshift[i_shift_offset+YY] += ty;
568 fshift[i_shift_offset+ZZ] += tz;
571 /* Update potential energies */
572 kernel_data->energygrp_elec[ggid] += velecsum;
573 kernel_data->energygrp_vdw[ggid] += vvdwsum;
575 /* Increment number of inner iterations */
576 inneriter += j_index_end - j_index_start;
578 /* Outer loop uses 41 flops */
581 /* Increment number of outer iterations */
584 /* Update outer/inner flops */
586 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*340);
589 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW4W4_F_c
590 * Electrostatics interaction: ReactionField
591 * VdW interaction: Buckingham
592 * Geometry: Water4-Water4
593 * Calculate force/pot: Force
596 nb_kernel_ElecRF_VdwBham_GeomW4W4_F_c
597 (t_nblist * gmx_restrict nlist,
598 rvec * gmx_restrict xx,
599 rvec * gmx_restrict ff,
600 t_forcerec * gmx_restrict fr,
601 t_mdatoms * gmx_restrict mdatoms,
602 nb_kernel_data_t * gmx_restrict kernel_data,
603 t_nrnb * gmx_restrict nrnb)
605 int i_shift_offset,i_coord_offset,j_coord_offset;
606 int j_index_start,j_index_end;
607 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
608 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
609 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
610 real *shiftvec,*fshift,*x,*f;
612 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
614 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
616 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
618 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
620 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
622 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
624 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
626 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
627 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
628 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
629 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
630 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
631 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
632 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
633 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
634 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
635 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
636 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
637 real velec,felec,velecsum,facel,crf,krf,krf2;
640 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
649 jindex = nlist->jindex;
651 shiftidx = nlist->shift;
653 shiftvec = fr->shift_vec[0];
654 fshift = fr->fshift[0];
656 charge = mdatoms->chargeA;
660 nvdwtype = fr->ntype;
662 vdwtype = mdatoms->typeA;
664 /* Setup water-specific parameters */
665 inr = nlist->iinr[0];
666 iq1 = facel*charge[inr+1];
667 iq2 = facel*charge[inr+2];
668 iq3 = facel*charge[inr+3];
669 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
674 vdwjidx0 = 3*vdwtype[inr+0];
675 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
676 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
677 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
691 /* Start outer loop over neighborlists */
692 for(iidx=0; iidx<nri; iidx++)
694 /* Load shift vector for this list */
695 i_shift_offset = DIM*shiftidx[iidx];
696 shX = shiftvec[i_shift_offset+XX];
697 shY = shiftvec[i_shift_offset+YY];
698 shZ = shiftvec[i_shift_offset+ZZ];
700 /* Load limits for loop over neighbors */
701 j_index_start = jindex[iidx];
702 j_index_end = jindex[iidx+1];
704 /* Get outer coordinate index */
706 i_coord_offset = DIM*inr;
708 /* Load i particle coords and add shift vector */
709 ix0 = shX + x[i_coord_offset+DIM*0+XX];
710 iy0 = shY + x[i_coord_offset+DIM*0+YY];
711 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
712 ix1 = shX + x[i_coord_offset+DIM*1+XX];
713 iy1 = shY + x[i_coord_offset+DIM*1+YY];
714 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
715 ix2 = shX + x[i_coord_offset+DIM*2+XX];
716 iy2 = shY + x[i_coord_offset+DIM*2+YY];
717 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
718 ix3 = shX + x[i_coord_offset+DIM*3+XX];
719 iy3 = shY + x[i_coord_offset+DIM*3+YY];
720 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
735 /* Start inner kernel loop */
736 for(jidx=j_index_start; jidx<j_index_end; jidx++)
738 /* Get j neighbor index, and coordinate index */
740 j_coord_offset = DIM*jnr;
742 /* load j atom coordinates */
743 jx0 = x[j_coord_offset+DIM*0+XX];
744 jy0 = x[j_coord_offset+DIM*0+YY];
745 jz0 = x[j_coord_offset+DIM*0+ZZ];
746 jx1 = x[j_coord_offset+DIM*1+XX];
747 jy1 = x[j_coord_offset+DIM*1+YY];
748 jz1 = x[j_coord_offset+DIM*1+ZZ];
749 jx2 = x[j_coord_offset+DIM*2+XX];
750 jy2 = x[j_coord_offset+DIM*2+YY];
751 jz2 = x[j_coord_offset+DIM*2+ZZ];
752 jx3 = x[j_coord_offset+DIM*3+XX];
753 jy3 = x[j_coord_offset+DIM*3+YY];
754 jz3 = x[j_coord_offset+DIM*3+ZZ];
756 /* Calculate displacement vector */
788 /* Calculate squared distance and things based on it */
789 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
790 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
791 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
792 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
793 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
794 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
795 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
796 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
797 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
798 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
800 rinv00 = gmx_invsqrt(rsq00);
801 rinv11 = gmx_invsqrt(rsq11);
802 rinv12 = gmx_invsqrt(rsq12);
803 rinv13 = gmx_invsqrt(rsq13);
804 rinv21 = gmx_invsqrt(rsq21);
805 rinv22 = gmx_invsqrt(rsq22);
806 rinv23 = gmx_invsqrt(rsq23);
807 rinv31 = gmx_invsqrt(rsq31);
808 rinv32 = gmx_invsqrt(rsq32);
809 rinv33 = gmx_invsqrt(rsq33);
811 rinvsq00 = rinv00*rinv00;
812 rinvsq11 = rinv11*rinv11;
813 rinvsq12 = rinv12*rinv12;
814 rinvsq13 = rinv13*rinv13;
815 rinvsq21 = rinv21*rinv21;
816 rinvsq22 = rinv22*rinv22;
817 rinvsq23 = rinv23*rinv23;
818 rinvsq31 = rinv31*rinv31;
819 rinvsq32 = rinv32*rinv32;
820 rinvsq33 = rinv33*rinv33;
822 /**************************
823 * CALCULATE INTERACTIONS *
824 **************************/
828 /* BUCKINGHAM DISPERSION/REPULSION */
829 rinvsix = rinvsq00*rinvsq00*rinvsq00;
830 vvdw6 = c6_00*rinvsix;
832 vvdwexp = cexp1_00*exp(-br);
833 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
837 /* Calculate temporary vectorial force */
842 /* Update vectorial force */
846 f[j_coord_offset+DIM*0+XX] -= tx;
847 f[j_coord_offset+DIM*0+YY] -= ty;
848 f[j_coord_offset+DIM*0+ZZ] -= tz;
850 /**************************
851 * CALCULATE INTERACTIONS *
852 **************************/
854 /* REACTION-FIELD ELECTROSTATICS */
855 felec = qq11*(rinv11*rinvsq11-krf2);
859 /* Calculate temporary vectorial force */
864 /* Update vectorial force */
868 f[j_coord_offset+DIM*1+XX] -= tx;
869 f[j_coord_offset+DIM*1+YY] -= ty;
870 f[j_coord_offset+DIM*1+ZZ] -= tz;
872 /**************************
873 * CALCULATE INTERACTIONS *
874 **************************/
876 /* REACTION-FIELD ELECTROSTATICS */
877 felec = qq12*(rinv12*rinvsq12-krf2);
881 /* Calculate temporary vectorial force */
886 /* Update vectorial force */
890 f[j_coord_offset+DIM*2+XX] -= tx;
891 f[j_coord_offset+DIM*2+YY] -= ty;
892 f[j_coord_offset+DIM*2+ZZ] -= tz;
894 /**************************
895 * CALCULATE INTERACTIONS *
896 **************************/
898 /* REACTION-FIELD ELECTROSTATICS */
899 felec = qq13*(rinv13*rinvsq13-krf2);
903 /* Calculate temporary vectorial force */
908 /* Update vectorial force */
912 f[j_coord_offset+DIM*3+XX] -= tx;
913 f[j_coord_offset+DIM*3+YY] -= ty;
914 f[j_coord_offset+DIM*3+ZZ] -= tz;
916 /**************************
917 * CALCULATE INTERACTIONS *
918 **************************/
920 /* REACTION-FIELD ELECTROSTATICS */
921 felec = qq21*(rinv21*rinvsq21-krf2);
925 /* Calculate temporary vectorial force */
930 /* Update vectorial force */
934 f[j_coord_offset+DIM*1+XX] -= tx;
935 f[j_coord_offset+DIM*1+YY] -= ty;
936 f[j_coord_offset+DIM*1+ZZ] -= tz;
938 /**************************
939 * CALCULATE INTERACTIONS *
940 **************************/
942 /* REACTION-FIELD ELECTROSTATICS */
943 felec = qq22*(rinv22*rinvsq22-krf2);
947 /* Calculate temporary vectorial force */
952 /* Update vectorial force */
956 f[j_coord_offset+DIM*2+XX] -= tx;
957 f[j_coord_offset+DIM*2+YY] -= ty;
958 f[j_coord_offset+DIM*2+ZZ] -= tz;
960 /**************************
961 * CALCULATE INTERACTIONS *
962 **************************/
964 /* REACTION-FIELD ELECTROSTATICS */
965 felec = qq23*(rinv23*rinvsq23-krf2);
969 /* Calculate temporary vectorial force */
974 /* Update vectorial force */
978 f[j_coord_offset+DIM*3+XX] -= tx;
979 f[j_coord_offset+DIM*3+YY] -= ty;
980 f[j_coord_offset+DIM*3+ZZ] -= tz;
982 /**************************
983 * CALCULATE INTERACTIONS *
984 **************************/
986 /* REACTION-FIELD ELECTROSTATICS */
987 felec = qq31*(rinv31*rinvsq31-krf2);
991 /* Calculate temporary vectorial force */
996 /* Update vectorial force */
1000 f[j_coord_offset+DIM*1+XX] -= tx;
1001 f[j_coord_offset+DIM*1+YY] -= ty;
1002 f[j_coord_offset+DIM*1+ZZ] -= tz;
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1008 /* REACTION-FIELD ELECTROSTATICS */
1009 felec = qq32*(rinv32*rinvsq32-krf2);
1013 /* Calculate temporary vectorial force */
1018 /* Update vectorial force */
1022 f[j_coord_offset+DIM*2+XX] -= tx;
1023 f[j_coord_offset+DIM*2+YY] -= ty;
1024 f[j_coord_offset+DIM*2+ZZ] -= tz;
1026 /**************************
1027 * CALCULATE INTERACTIONS *
1028 **************************/
1030 /* REACTION-FIELD ELECTROSTATICS */
1031 felec = qq33*(rinv33*rinvsq33-krf2);
1035 /* Calculate temporary vectorial force */
1040 /* Update vectorial force */
1044 f[j_coord_offset+DIM*3+XX] -= tx;
1045 f[j_coord_offset+DIM*3+YY] -= ty;
1046 f[j_coord_offset+DIM*3+ZZ] -= tz;
1048 /* Inner loop uses 292 flops */
1050 /* End of innermost loop */
1053 f[i_coord_offset+DIM*0+XX] += fix0;
1054 f[i_coord_offset+DIM*0+YY] += fiy0;
1055 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1059 f[i_coord_offset+DIM*1+XX] += fix1;
1060 f[i_coord_offset+DIM*1+YY] += fiy1;
1061 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1065 f[i_coord_offset+DIM*2+XX] += fix2;
1066 f[i_coord_offset+DIM*2+YY] += fiy2;
1067 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1071 f[i_coord_offset+DIM*3+XX] += fix3;
1072 f[i_coord_offset+DIM*3+YY] += fiy3;
1073 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1077 fshift[i_shift_offset+XX] += tx;
1078 fshift[i_shift_offset+YY] += ty;
1079 fshift[i_shift_offset+ZZ] += tz;
1081 /* Increment number of inner iterations */
1082 inneriter += j_index_end - j_index_start;
1084 /* Outer loop uses 39 flops */
1087 /* Increment number of outer iterations */
1090 /* Update outer/inner flops */
1092 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*292);