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_VdwLJ_GeomW4W4_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Water4
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwLJ_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 = 2*nvdwtype*vdwtype[inr+0];
119 vdwjidx0 = 2*vdwtype[inr+0];
120 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
121 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
140 shX = shiftvec[i_shift_offset+XX];
141 shY = shiftvec[i_shift_offset+YY];
142 shZ = shiftvec[i_shift_offset+ZZ];
144 /* Load limits for loop over neighbors */
145 j_index_start = jindex[iidx];
146 j_index_end = jindex[iidx+1];
148 /* Get outer coordinate index */
150 i_coord_offset = DIM*inr;
152 /* Load i particle coords and add shift vector */
153 ix0 = shX + x[i_coord_offset+DIM*0+XX];
154 iy0 = shY + x[i_coord_offset+DIM*0+YY];
155 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
156 ix1 = shX + x[i_coord_offset+DIM*1+XX];
157 iy1 = shY + x[i_coord_offset+DIM*1+YY];
158 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
159 ix2 = shX + x[i_coord_offset+DIM*2+XX];
160 iy2 = shY + x[i_coord_offset+DIM*2+YY];
161 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
162 ix3 = shX + x[i_coord_offset+DIM*3+XX];
163 iy3 = shY + x[i_coord_offset+DIM*3+YY];
164 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
179 /* Reset potential sums */
183 /* Start inner kernel loop */
184 for(jidx=j_index_start; jidx<j_index_end; jidx++)
186 /* Get j neighbor index, and coordinate index */
188 j_coord_offset = DIM*jnr;
190 /* load j atom coordinates */
191 jx0 = x[j_coord_offset+DIM*0+XX];
192 jy0 = x[j_coord_offset+DIM*0+YY];
193 jz0 = x[j_coord_offset+DIM*0+ZZ];
194 jx1 = x[j_coord_offset+DIM*1+XX];
195 jy1 = x[j_coord_offset+DIM*1+YY];
196 jz1 = x[j_coord_offset+DIM*1+ZZ];
197 jx2 = x[j_coord_offset+DIM*2+XX];
198 jy2 = x[j_coord_offset+DIM*2+YY];
199 jz2 = x[j_coord_offset+DIM*2+ZZ];
200 jx3 = x[j_coord_offset+DIM*3+XX];
201 jy3 = x[j_coord_offset+DIM*3+YY];
202 jz3 = x[j_coord_offset+DIM*3+ZZ];
204 /* Calculate displacement vector */
236 /* Calculate squared distance and things based on it */
237 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
238 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
239 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
240 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
241 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
242 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
243 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
244 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
245 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
246 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
248 rinv11 = gmx_invsqrt(rsq11);
249 rinv12 = gmx_invsqrt(rsq12);
250 rinv13 = gmx_invsqrt(rsq13);
251 rinv21 = gmx_invsqrt(rsq21);
252 rinv22 = gmx_invsqrt(rsq22);
253 rinv23 = gmx_invsqrt(rsq23);
254 rinv31 = gmx_invsqrt(rsq31);
255 rinv32 = gmx_invsqrt(rsq32);
256 rinv33 = gmx_invsqrt(rsq33);
258 rinvsq00 = 1.0/rsq00;
259 rinvsq11 = rinv11*rinv11;
260 rinvsq12 = rinv12*rinv12;
261 rinvsq13 = rinv13*rinv13;
262 rinvsq21 = rinv21*rinv21;
263 rinvsq22 = rinv22*rinv22;
264 rinvsq23 = rinv23*rinv23;
265 rinvsq31 = rinv31*rinv31;
266 rinvsq32 = rinv32*rinv32;
267 rinvsq33 = rinv33*rinv33;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
273 /* LENNARD-JONES DISPERSION/REPULSION */
275 rinvsix = rinvsq00*rinvsq00*rinvsq00;
276 vvdw6 = c6_00*rinvsix;
277 vvdw12 = c12_00*rinvsix*rinvsix;
278 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
279 fvdw = (vvdw12-vvdw6)*rinvsq00;
281 /* Update potential sums from outer loop */
286 /* Calculate temporary vectorial force */
291 /* Update vectorial force */
295 f[j_coord_offset+DIM*0+XX] -= tx;
296 f[j_coord_offset+DIM*0+YY] -= ty;
297 f[j_coord_offset+DIM*0+ZZ] -= tz;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
303 /* REACTION-FIELD ELECTROSTATICS */
304 velec = qq11*(rinv11+krf*rsq11-crf);
305 felec = qq11*(rinv11*rinvsq11-krf2);
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*1+XX] -= tx;
322 f[j_coord_offset+DIM*1+YY] -= ty;
323 f[j_coord_offset+DIM*1+ZZ] -= tz;
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
329 /* REACTION-FIELD ELECTROSTATICS */
330 velec = qq12*(rinv12+krf*rsq12-crf);
331 felec = qq12*(rinv12*rinvsq12-krf2);
333 /* Update potential sums from outer loop */
338 /* Calculate temporary vectorial force */
343 /* Update vectorial force */
347 f[j_coord_offset+DIM*2+XX] -= tx;
348 f[j_coord_offset+DIM*2+YY] -= ty;
349 f[j_coord_offset+DIM*2+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
355 /* REACTION-FIELD ELECTROSTATICS */
356 velec = qq13*(rinv13+krf*rsq13-crf);
357 felec = qq13*(rinv13*rinvsq13-krf2);
359 /* Update potential sums from outer loop */
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f[j_coord_offset+DIM*3+XX] -= tx;
374 f[j_coord_offset+DIM*3+YY] -= ty;
375 f[j_coord_offset+DIM*3+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
381 /* REACTION-FIELD ELECTROSTATICS */
382 velec = qq21*(rinv21+krf*rsq21-crf);
383 felec = qq21*(rinv21*rinvsq21-krf2);
385 /* Update potential sums from outer loop */
390 /* Calculate temporary vectorial force */
395 /* Update vectorial force */
399 f[j_coord_offset+DIM*1+XX] -= tx;
400 f[j_coord_offset+DIM*1+YY] -= ty;
401 f[j_coord_offset+DIM*1+ZZ] -= tz;
403 /**************************
404 * CALCULATE INTERACTIONS *
405 **************************/
407 /* REACTION-FIELD ELECTROSTATICS */
408 velec = qq22*(rinv22+krf*rsq22-crf);
409 felec = qq22*(rinv22*rinvsq22-krf2);
411 /* Update potential sums from outer loop */
416 /* Calculate temporary vectorial force */
421 /* Update vectorial force */
425 f[j_coord_offset+DIM*2+XX] -= tx;
426 f[j_coord_offset+DIM*2+YY] -= ty;
427 f[j_coord_offset+DIM*2+ZZ] -= tz;
429 /**************************
430 * CALCULATE INTERACTIONS *
431 **************************/
433 /* REACTION-FIELD ELECTROSTATICS */
434 velec = qq23*(rinv23+krf*rsq23-crf);
435 felec = qq23*(rinv23*rinvsq23-krf2);
437 /* Update potential sums from outer loop */
442 /* Calculate temporary vectorial force */
447 /* Update vectorial force */
451 f[j_coord_offset+DIM*3+XX] -= tx;
452 f[j_coord_offset+DIM*3+YY] -= ty;
453 f[j_coord_offset+DIM*3+ZZ] -= tz;
455 /**************************
456 * CALCULATE INTERACTIONS *
457 **************************/
459 /* REACTION-FIELD ELECTROSTATICS */
460 velec = qq31*(rinv31+krf*rsq31-crf);
461 felec = qq31*(rinv31*rinvsq31-krf2);
463 /* Update potential sums from outer loop */
468 /* Calculate temporary vectorial force */
473 /* Update vectorial force */
477 f[j_coord_offset+DIM*1+XX] -= tx;
478 f[j_coord_offset+DIM*1+YY] -= ty;
479 f[j_coord_offset+DIM*1+ZZ] -= tz;
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
485 /* REACTION-FIELD ELECTROSTATICS */
486 velec = qq32*(rinv32+krf*rsq32-crf);
487 felec = qq32*(rinv32*rinvsq32-krf2);
489 /* Update potential sums from outer loop */
494 /* Calculate temporary vectorial force */
499 /* Update vectorial force */
503 f[j_coord_offset+DIM*2+XX] -= tx;
504 f[j_coord_offset+DIM*2+YY] -= ty;
505 f[j_coord_offset+DIM*2+ZZ] -= tz;
507 /**************************
508 * CALCULATE INTERACTIONS *
509 **************************/
511 /* REACTION-FIELD ELECTROSTATICS */
512 velec = qq33*(rinv33+krf*rsq33-crf);
513 felec = qq33*(rinv33*rinvsq33-krf2);
515 /* Update potential sums from outer loop */
520 /* Calculate temporary vectorial force */
525 /* Update vectorial force */
529 f[j_coord_offset+DIM*3+XX] -= tx;
530 f[j_coord_offset+DIM*3+YY] -= ty;
531 f[j_coord_offset+DIM*3+ZZ] -= tz;
533 /* Inner loop uses 311 flops */
535 /* End of innermost loop */
538 f[i_coord_offset+DIM*0+XX] += fix0;
539 f[i_coord_offset+DIM*0+YY] += fiy0;
540 f[i_coord_offset+DIM*0+ZZ] += fiz0;
544 f[i_coord_offset+DIM*1+XX] += fix1;
545 f[i_coord_offset+DIM*1+YY] += fiy1;
546 f[i_coord_offset+DIM*1+ZZ] += fiz1;
550 f[i_coord_offset+DIM*2+XX] += fix2;
551 f[i_coord_offset+DIM*2+YY] += fiy2;
552 f[i_coord_offset+DIM*2+ZZ] += fiz2;
556 f[i_coord_offset+DIM*3+XX] += fix3;
557 f[i_coord_offset+DIM*3+YY] += fiy3;
558 f[i_coord_offset+DIM*3+ZZ] += fiz3;
562 fshift[i_shift_offset+XX] += tx;
563 fshift[i_shift_offset+YY] += ty;
564 fshift[i_shift_offset+ZZ] += tz;
567 /* Update potential energies */
568 kernel_data->energygrp_elec[ggid] += velecsum;
569 kernel_data->energygrp_vdw[ggid] += vvdwsum;
571 /* Increment number of inner iterations */
572 inneriter += j_index_end - j_index_start;
574 /* Outer loop uses 41 flops */
577 /* Increment number of outer iterations */
580 /* Update outer/inner flops */
582 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*311);
585 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_c
586 * Electrostatics interaction: ReactionField
587 * VdW interaction: LennardJones
588 * Geometry: Water4-Water4
589 * Calculate force/pot: Force
592 nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_c
593 (t_nblist * gmx_restrict nlist,
594 rvec * gmx_restrict xx,
595 rvec * gmx_restrict ff,
596 t_forcerec * gmx_restrict fr,
597 t_mdatoms * gmx_restrict mdatoms,
598 nb_kernel_data_t * gmx_restrict kernel_data,
599 t_nrnb * gmx_restrict nrnb)
601 int i_shift_offset,i_coord_offset,j_coord_offset;
602 int j_index_start,j_index_end;
603 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
604 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
605 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
606 real *shiftvec,*fshift,*x,*f;
608 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
610 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
612 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
614 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
616 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
618 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
620 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
622 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
623 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
624 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
625 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
626 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
627 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
628 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
629 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
630 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
631 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
632 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
633 real velec,felec,velecsum,facel,crf,krf,krf2;
636 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
645 jindex = nlist->jindex;
647 shiftidx = nlist->shift;
649 shiftvec = fr->shift_vec[0];
650 fshift = fr->fshift[0];
652 charge = mdatoms->chargeA;
656 nvdwtype = fr->ntype;
658 vdwtype = mdatoms->typeA;
660 /* Setup water-specific parameters */
661 inr = nlist->iinr[0];
662 iq1 = facel*charge[inr+1];
663 iq2 = facel*charge[inr+2];
664 iq3 = facel*charge[inr+3];
665 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
670 vdwjidx0 = 2*vdwtype[inr+0];
671 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
672 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
686 /* Start outer loop over neighborlists */
687 for(iidx=0; iidx<nri; iidx++)
689 /* Load shift vector for this list */
690 i_shift_offset = DIM*shiftidx[iidx];
691 shX = shiftvec[i_shift_offset+XX];
692 shY = shiftvec[i_shift_offset+YY];
693 shZ = shiftvec[i_shift_offset+ZZ];
695 /* Load limits for loop over neighbors */
696 j_index_start = jindex[iidx];
697 j_index_end = jindex[iidx+1];
699 /* Get outer coordinate index */
701 i_coord_offset = DIM*inr;
703 /* Load i particle coords and add shift vector */
704 ix0 = shX + x[i_coord_offset+DIM*0+XX];
705 iy0 = shY + x[i_coord_offset+DIM*0+YY];
706 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
707 ix1 = shX + x[i_coord_offset+DIM*1+XX];
708 iy1 = shY + x[i_coord_offset+DIM*1+YY];
709 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
710 ix2 = shX + x[i_coord_offset+DIM*2+XX];
711 iy2 = shY + x[i_coord_offset+DIM*2+YY];
712 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
713 ix3 = shX + x[i_coord_offset+DIM*3+XX];
714 iy3 = shY + x[i_coord_offset+DIM*3+YY];
715 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
730 /* Start inner kernel loop */
731 for(jidx=j_index_start; jidx<j_index_end; jidx++)
733 /* Get j neighbor index, and coordinate index */
735 j_coord_offset = DIM*jnr;
737 /* load j atom coordinates */
738 jx0 = x[j_coord_offset+DIM*0+XX];
739 jy0 = x[j_coord_offset+DIM*0+YY];
740 jz0 = x[j_coord_offset+DIM*0+ZZ];
741 jx1 = x[j_coord_offset+DIM*1+XX];
742 jy1 = x[j_coord_offset+DIM*1+YY];
743 jz1 = x[j_coord_offset+DIM*1+ZZ];
744 jx2 = x[j_coord_offset+DIM*2+XX];
745 jy2 = x[j_coord_offset+DIM*2+YY];
746 jz2 = x[j_coord_offset+DIM*2+ZZ];
747 jx3 = x[j_coord_offset+DIM*3+XX];
748 jy3 = x[j_coord_offset+DIM*3+YY];
749 jz3 = x[j_coord_offset+DIM*3+ZZ];
751 /* Calculate displacement vector */
783 /* Calculate squared distance and things based on it */
784 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
785 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
786 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
787 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
788 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
789 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
790 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
791 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
792 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
793 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
795 rinv11 = gmx_invsqrt(rsq11);
796 rinv12 = gmx_invsqrt(rsq12);
797 rinv13 = gmx_invsqrt(rsq13);
798 rinv21 = gmx_invsqrt(rsq21);
799 rinv22 = gmx_invsqrt(rsq22);
800 rinv23 = gmx_invsqrt(rsq23);
801 rinv31 = gmx_invsqrt(rsq31);
802 rinv32 = gmx_invsqrt(rsq32);
803 rinv33 = gmx_invsqrt(rsq33);
805 rinvsq00 = 1.0/rsq00;
806 rinvsq11 = rinv11*rinv11;
807 rinvsq12 = rinv12*rinv12;
808 rinvsq13 = rinv13*rinv13;
809 rinvsq21 = rinv21*rinv21;
810 rinvsq22 = rinv22*rinv22;
811 rinvsq23 = rinv23*rinv23;
812 rinvsq31 = rinv31*rinv31;
813 rinvsq32 = rinv32*rinv32;
814 rinvsq33 = rinv33*rinv33;
816 /**************************
817 * CALCULATE INTERACTIONS *
818 **************************/
820 /* LENNARD-JONES DISPERSION/REPULSION */
822 rinvsix = rinvsq00*rinvsq00*rinvsq00;
823 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
827 /* Calculate temporary vectorial force */
832 /* Update vectorial force */
836 f[j_coord_offset+DIM*0+XX] -= tx;
837 f[j_coord_offset+DIM*0+YY] -= ty;
838 f[j_coord_offset+DIM*0+ZZ] -= tz;
840 /**************************
841 * CALCULATE INTERACTIONS *
842 **************************/
844 /* REACTION-FIELD ELECTROSTATICS */
845 felec = qq11*(rinv11*rinvsq11-krf2);
849 /* Calculate temporary vectorial force */
854 /* Update vectorial force */
858 f[j_coord_offset+DIM*1+XX] -= tx;
859 f[j_coord_offset+DIM*1+YY] -= ty;
860 f[j_coord_offset+DIM*1+ZZ] -= tz;
862 /**************************
863 * CALCULATE INTERACTIONS *
864 **************************/
866 /* REACTION-FIELD ELECTROSTATICS */
867 felec = qq12*(rinv12*rinvsq12-krf2);
871 /* Calculate temporary vectorial force */
876 /* Update vectorial force */
880 f[j_coord_offset+DIM*2+XX] -= tx;
881 f[j_coord_offset+DIM*2+YY] -= ty;
882 f[j_coord_offset+DIM*2+ZZ] -= tz;
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 /* REACTION-FIELD ELECTROSTATICS */
889 felec = qq13*(rinv13*rinvsq13-krf2);
893 /* Calculate temporary vectorial force */
898 /* Update vectorial force */
902 f[j_coord_offset+DIM*3+XX] -= tx;
903 f[j_coord_offset+DIM*3+YY] -= ty;
904 f[j_coord_offset+DIM*3+ZZ] -= tz;
906 /**************************
907 * CALCULATE INTERACTIONS *
908 **************************/
910 /* REACTION-FIELD ELECTROSTATICS */
911 felec = qq21*(rinv21*rinvsq21-krf2);
915 /* Calculate temporary vectorial force */
920 /* Update vectorial force */
924 f[j_coord_offset+DIM*1+XX] -= tx;
925 f[j_coord_offset+DIM*1+YY] -= ty;
926 f[j_coord_offset+DIM*1+ZZ] -= tz;
928 /**************************
929 * CALCULATE INTERACTIONS *
930 **************************/
932 /* REACTION-FIELD ELECTROSTATICS */
933 felec = qq22*(rinv22*rinvsq22-krf2);
937 /* Calculate temporary vectorial force */
942 /* Update vectorial force */
946 f[j_coord_offset+DIM*2+XX] -= tx;
947 f[j_coord_offset+DIM*2+YY] -= ty;
948 f[j_coord_offset+DIM*2+ZZ] -= tz;
950 /**************************
951 * CALCULATE INTERACTIONS *
952 **************************/
954 /* REACTION-FIELD ELECTROSTATICS */
955 felec = qq23*(rinv23*rinvsq23-krf2);
959 /* Calculate temporary vectorial force */
964 /* Update vectorial force */
968 f[j_coord_offset+DIM*3+XX] -= tx;
969 f[j_coord_offset+DIM*3+YY] -= ty;
970 f[j_coord_offset+DIM*3+ZZ] -= tz;
972 /**************************
973 * CALCULATE INTERACTIONS *
974 **************************/
976 /* REACTION-FIELD ELECTROSTATICS */
977 felec = qq31*(rinv31*rinvsq31-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;
994 /**************************
995 * CALCULATE INTERACTIONS *
996 **************************/
998 /* REACTION-FIELD ELECTROSTATICS */
999 felec = qq32*(rinv32*rinvsq32-krf2);
1003 /* Calculate temporary vectorial force */
1008 /* Update vectorial force */
1012 f[j_coord_offset+DIM*2+XX] -= tx;
1013 f[j_coord_offset+DIM*2+YY] -= ty;
1014 f[j_coord_offset+DIM*2+ZZ] -= tz;
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
1020 /* REACTION-FIELD ELECTROSTATICS */
1021 felec = qq33*(rinv33*rinvsq33-krf2);
1025 /* Calculate temporary vectorial force */
1030 /* Update vectorial force */
1034 f[j_coord_offset+DIM*3+XX] -= tx;
1035 f[j_coord_offset+DIM*3+YY] -= ty;
1036 f[j_coord_offset+DIM*3+ZZ] -= tz;
1038 /* Inner loop uses 261 flops */
1040 /* End of innermost loop */
1043 f[i_coord_offset+DIM*0+XX] += fix0;
1044 f[i_coord_offset+DIM*0+YY] += fiy0;
1045 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1049 f[i_coord_offset+DIM*1+XX] += fix1;
1050 f[i_coord_offset+DIM*1+YY] += fiy1;
1051 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1055 f[i_coord_offset+DIM*2+XX] += fix2;
1056 f[i_coord_offset+DIM*2+YY] += fiy2;
1057 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1061 f[i_coord_offset+DIM*3+XX] += fix3;
1062 f[i_coord_offset+DIM*3+YY] += fiy3;
1063 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1067 fshift[i_shift_offset+XX] += tx;
1068 fshift[i_shift_offset+YY] += ty;
1069 fshift[i_shift_offset+ZZ] += tz;
1071 /* Increment number of inner iterations */
1072 inneriter += j_index_end - j_index_start;
1074 /* Outer loop uses 39 flops */
1077 /* Increment number of outer iterations */
1080 /* Update outer/inner flops */
1082 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*261);