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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3W3_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwLJ_GeomW3W3_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
85 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
86 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
87 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
88 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
89 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
90 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
91 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
92 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
93 real velec,felec,velecsum,facel,crf,krf,krf2;
96 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
112 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 /* Setup water-specific parameters */
121 inr = nlist->iinr[0];
122 iq0 = facel*charge[inr+0];
123 iq1 = facel*charge[inr+1];
124 iq2 = facel*charge[inr+2];
125 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
130 vdwjidx0 = 2*vdwtype[inr+0];
132 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
133 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
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 **************************/
270 /* REACTION-FIELD ELECTROSTATICS */
271 velec = qq00*(rinv00+krf*rsq00-crf);
272 felec = qq00*(rinv00*rinvsq00-krf2);
274 /* LENNARD-JONES DISPERSION/REPULSION */
276 rinvsix = rinvsq00*rinvsq00*rinvsq00;
277 vvdw6 = c6_00*rinvsix;
278 vvdw12 = c12_00*rinvsix*rinvsix;
279 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
280 fvdw = (vvdw12-vvdw6)*rinvsq00;
282 /* Update potential sums from outer loop */
288 /* Calculate temporary vectorial force */
293 /* Update vectorial force */
297 f[j_coord_offset+DIM*0+XX] -= tx;
298 f[j_coord_offset+DIM*0+YY] -= ty;
299 f[j_coord_offset+DIM*0+ZZ] -= tz;
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
305 /* REACTION-FIELD ELECTROSTATICS */
306 velec = qq01*(rinv01+krf*rsq01-crf);
307 felec = qq01*(rinv01*rinvsq01-krf2);
309 /* Update potential sums from outer loop */
314 /* Calculate temporary vectorial force */
319 /* Update vectorial force */
323 f[j_coord_offset+DIM*1+XX] -= tx;
324 f[j_coord_offset+DIM*1+YY] -= ty;
325 f[j_coord_offset+DIM*1+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
331 /* REACTION-FIELD ELECTROSTATICS */
332 velec = qq02*(rinv02+krf*rsq02-crf);
333 felec = qq02*(rinv02*rinvsq02-krf2);
335 /* Update potential sums from outer loop */
340 /* Calculate temporary vectorial force */
345 /* Update vectorial force */
349 f[j_coord_offset+DIM*2+XX] -= tx;
350 f[j_coord_offset+DIM*2+YY] -= ty;
351 f[j_coord_offset+DIM*2+ZZ] -= tz;
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
357 /* REACTION-FIELD ELECTROSTATICS */
358 velec = qq10*(rinv10+krf*rsq10-crf);
359 felec = qq10*(rinv10*rinvsq10-krf2);
361 /* Update potential sums from outer loop */
366 /* Calculate temporary vectorial force */
371 /* Update vectorial force */
375 f[j_coord_offset+DIM*0+XX] -= tx;
376 f[j_coord_offset+DIM*0+YY] -= ty;
377 f[j_coord_offset+DIM*0+ZZ] -= tz;
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
383 /* REACTION-FIELD ELECTROSTATICS */
384 velec = qq11*(rinv11+krf*rsq11-crf);
385 felec = qq11*(rinv11*rinvsq11-krf2);
387 /* Update potential sums from outer loop */
392 /* Calculate temporary vectorial force */
397 /* Update vectorial force */
401 f[j_coord_offset+DIM*1+XX] -= tx;
402 f[j_coord_offset+DIM*1+YY] -= ty;
403 f[j_coord_offset+DIM*1+ZZ] -= tz;
405 /**************************
406 * CALCULATE INTERACTIONS *
407 **************************/
409 /* REACTION-FIELD ELECTROSTATICS */
410 velec = qq12*(rinv12+krf*rsq12-crf);
411 felec = qq12*(rinv12*rinvsq12-krf2);
413 /* Update potential sums from outer loop */
418 /* Calculate temporary vectorial force */
423 /* Update vectorial force */
427 f[j_coord_offset+DIM*2+XX] -= tx;
428 f[j_coord_offset+DIM*2+YY] -= ty;
429 f[j_coord_offset+DIM*2+ZZ] -= tz;
431 /**************************
432 * CALCULATE INTERACTIONS *
433 **************************/
435 /* REACTION-FIELD ELECTROSTATICS */
436 velec = qq20*(rinv20+krf*rsq20-crf);
437 felec = qq20*(rinv20*rinvsq20-krf2);
439 /* Update potential sums from outer loop */
444 /* Calculate temporary vectorial force */
449 /* Update vectorial force */
453 f[j_coord_offset+DIM*0+XX] -= tx;
454 f[j_coord_offset+DIM*0+YY] -= ty;
455 f[j_coord_offset+DIM*0+ZZ] -= tz;
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
461 /* REACTION-FIELD ELECTROSTATICS */
462 velec = qq21*(rinv21+krf*rsq21-crf);
463 felec = qq21*(rinv21*rinvsq21-krf2);
465 /* Update potential sums from outer loop */
470 /* Calculate temporary vectorial force */
475 /* Update vectorial force */
479 f[j_coord_offset+DIM*1+XX] -= tx;
480 f[j_coord_offset+DIM*1+YY] -= ty;
481 f[j_coord_offset+DIM*1+ZZ] -= tz;
483 /**************************
484 * CALCULATE INTERACTIONS *
485 **************************/
487 /* REACTION-FIELD ELECTROSTATICS */
488 velec = qq22*(rinv22+krf*rsq22-crf);
489 felec = qq22*(rinv22*rinvsq22-krf2);
491 /* Update potential sums from outer loop */
496 /* Calculate temporary vectorial force */
501 /* Update vectorial force */
505 f[j_coord_offset+DIM*2+XX] -= tx;
506 f[j_coord_offset+DIM*2+YY] -= ty;
507 f[j_coord_offset+DIM*2+ZZ] -= tz;
509 /* Inner loop uses 291 flops */
511 /* End of innermost loop */
514 f[i_coord_offset+DIM*0+XX] += fix0;
515 f[i_coord_offset+DIM*0+YY] += fiy0;
516 f[i_coord_offset+DIM*0+ZZ] += fiz0;
520 f[i_coord_offset+DIM*1+XX] += fix1;
521 f[i_coord_offset+DIM*1+YY] += fiy1;
522 f[i_coord_offset+DIM*1+ZZ] += fiz1;
526 f[i_coord_offset+DIM*2+XX] += fix2;
527 f[i_coord_offset+DIM*2+YY] += fiy2;
528 f[i_coord_offset+DIM*2+ZZ] += fiz2;
532 fshift[i_shift_offset+XX] += tx;
533 fshift[i_shift_offset+YY] += ty;
534 fshift[i_shift_offset+ZZ] += tz;
537 /* Update potential energies */
538 kernel_data->energygrp_elec[ggid] += velecsum;
539 kernel_data->energygrp_vdw[ggid] += vvdwsum;
541 /* Increment number of inner iterations */
542 inneriter += j_index_end - j_index_start;
544 /* Outer loop uses 32 flops */
547 /* Increment number of outer iterations */
550 /* Update outer/inner flops */
552 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*291);
555 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3W3_F_c
556 * Electrostatics interaction: ReactionField
557 * VdW interaction: LennardJones
558 * Geometry: Water3-Water3
559 * Calculate force/pot: Force
562 nb_kernel_ElecRF_VdwLJ_GeomW3W3_F_c
563 (t_nblist * gmx_restrict nlist,
564 rvec * gmx_restrict xx,
565 rvec * gmx_restrict ff,
566 t_forcerec * gmx_restrict fr,
567 t_mdatoms * gmx_restrict mdatoms,
568 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
569 t_nrnb * gmx_restrict nrnb)
571 int i_shift_offset,i_coord_offset,j_coord_offset;
572 int j_index_start,j_index_end;
573 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
574 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
575 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
576 real *shiftvec,*fshift,*x,*f;
578 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
580 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
582 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
584 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
586 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
588 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
589 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
590 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
591 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
592 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
593 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
594 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
595 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
596 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
597 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
598 real velec,felec,velecsum,facel,crf,krf,krf2;
601 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
610 jindex = nlist->jindex;
612 shiftidx = nlist->shift;
614 shiftvec = fr->shift_vec[0];
615 fshift = fr->fshift[0];
617 charge = mdatoms->chargeA;
621 nvdwtype = fr->ntype;
623 vdwtype = mdatoms->typeA;
625 /* Setup water-specific parameters */
626 inr = nlist->iinr[0];
627 iq0 = facel*charge[inr+0];
628 iq1 = facel*charge[inr+1];
629 iq2 = facel*charge[inr+2];
630 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
635 vdwjidx0 = 2*vdwtype[inr+0];
637 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
638 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
651 /* Start outer loop over neighborlists */
652 for(iidx=0; iidx<nri; iidx++)
654 /* Load shift vector for this list */
655 i_shift_offset = DIM*shiftidx[iidx];
656 shX = shiftvec[i_shift_offset+XX];
657 shY = shiftvec[i_shift_offset+YY];
658 shZ = shiftvec[i_shift_offset+ZZ];
660 /* Load limits for loop over neighbors */
661 j_index_start = jindex[iidx];
662 j_index_end = jindex[iidx+1];
664 /* Get outer coordinate index */
666 i_coord_offset = DIM*inr;
668 /* Load i particle coords and add shift vector */
669 ix0 = shX + x[i_coord_offset+DIM*0+XX];
670 iy0 = shY + x[i_coord_offset+DIM*0+YY];
671 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
672 ix1 = shX + x[i_coord_offset+DIM*1+XX];
673 iy1 = shY + x[i_coord_offset+DIM*1+YY];
674 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
675 ix2 = shX + x[i_coord_offset+DIM*2+XX];
676 iy2 = shY + x[i_coord_offset+DIM*2+YY];
677 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
689 /* Start inner kernel loop */
690 for(jidx=j_index_start; jidx<j_index_end; jidx++)
692 /* Get j neighbor index, and coordinate index */
694 j_coord_offset = DIM*jnr;
696 /* load j atom coordinates */
697 jx0 = x[j_coord_offset+DIM*0+XX];
698 jy0 = x[j_coord_offset+DIM*0+YY];
699 jz0 = x[j_coord_offset+DIM*0+ZZ];
700 jx1 = x[j_coord_offset+DIM*1+XX];
701 jy1 = x[j_coord_offset+DIM*1+YY];
702 jz1 = x[j_coord_offset+DIM*1+ZZ];
703 jx2 = x[j_coord_offset+DIM*2+XX];
704 jy2 = x[j_coord_offset+DIM*2+YY];
705 jz2 = x[j_coord_offset+DIM*2+ZZ];
707 /* Calculate displacement vector */
736 /* Calculate squared distance and things based on it */
737 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
738 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
739 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
740 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
741 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
742 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
743 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
744 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
745 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
747 rinv00 = gmx_invsqrt(rsq00);
748 rinv01 = gmx_invsqrt(rsq01);
749 rinv02 = gmx_invsqrt(rsq02);
750 rinv10 = gmx_invsqrt(rsq10);
751 rinv11 = gmx_invsqrt(rsq11);
752 rinv12 = gmx_invsqrt(rsq12);
753 rinv20 = gmx_invsqrt(rsq20);
754 rinv21 = gmx_invsqrt(rsq21);
755 rinv22 = gmx_invsqrt(rsq22);
757 rinvsq00 = rinv00*rinv00;
758 rinvsq01 = rinv01*rinv01;
759 rinvsq02 = rinv02*rinv02;
760 rinvsq10 = rinv10*rinv10;
761 rinvsq11 = rinv11*rinv11;
762 rinvsq12 = rinv12*rinv12;
763 rinvsq20 = rinv20*rinv20;
764 rinvsq21 = rinv21*rinv21;
765 rinvsq22 = rinv22*rinv22;
767 /**************************
768 * CALCULATE INTERACTIONS *
769 **************************/
771 /* REACTION-FIELD ELECTROSTATICS */
772 felec = qq00*(rinv00*rinvsq00-krf2);
774 /* LENNARD-JONES DISPERSION/REPULSION */
776 rinvsix = rinvsq00*rinvsq00*rinvsq00;
777 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
781 /* Calculate temporary vectorial force */
786 /* Update vectorial force */
790 f[j_coord_offset+DIM*0+XX] -= tx;
791 f[j_coord_offset+DIM*0+YY] -= ty;
792 f[j_coord_offset+DIM*0+ZZ] -= tz;
794 /**************************
795 * CALCULATE INTERACTIONS *
796 **************************/
798 /* REACTION-FIELD ELECTROSTATICS */
799 felec = qq01*(rinv01*rinvsq01-krf2);
803 /* Calculate temporary vectorial force */
808 /* Update vectorial force */
812 f[j_coord_offset+DIM*1+XX] -= tx;
813 f[j_coord_offset+DIM*1+YY] -= ty;
814 f[j_coord_offset+DIM*1+ZZ] -= tz;
816 /**************************
817 * CALCULATE INTERACTIONS *
818 **************************/
820 /* REACTION-FIELD ELECTROSTATICS */
821 felec = qq02*(rinv02*rinvsq02-krf2);
825 /* Calculate temporary vectorial force */
830 /* Update vectorial force */
834 f[j_coord_offset+DIM*2+XX] -= tx;
835 f[j_coord_offset+DIM*2+YY] -= ty;
836 f[j_coord_offset+DIM*2+ZZ] -= tz;
838 /**************************
839 * CALCULATE INTERACTIONS *
840 **************************/
842 /* REACTION-FIELD ELECTROSTATICS */
843 felec = qq10*(rinv10*rinvsq10-krf2);
847 /* Calculate temporary vectorial force */
852 /* Update vectorial force */
856 f[j_coord_offset+DIM*0+XX] -= tx;
857 f[j_coord_offset+DIM*0+YY] -= ty;
858 f[j_coord_offset+DIM*0+ZZ] -= tz;
860 /**************************
861 * CALCULATE INTERACTIONS *
862 **************************/
864 /* REACTION-FIELD ELECTROSTATICS */
865 felec = qq11*(rinv11*rinvsq11-krf2);
869 /* Calculate temporary vectorial force */
874 /* Update vectorial force */
878 f[j_coord_offset+DIM*1+XX] -= tx;
879 f[j_coord_offset+DIM*1+YY] -= ty;
880 f[j_coord_offset+DIM*1+ZZ] -= tz;
882 /**************************
883 * CALCULATE INTERACTIONS *
884 **************************/
886 /* REACTION-FIELD ELECTROSTATICS */
887 felec = qq12*(rinv12*rinvsq12-krf2);
891 /* Calculate temporary vectorial force */
896 /* Update vectorial force */
900 f[j_coord_offset+DIM*2+XX] -= tx;
901 f[j_coord_offset+DIM*2+YY] -= ty;
902 f[j_coord_offset+DIM*2+ZZ] -= tz;
904 /**************************
905 * CALCULATE INTERACTIONS *
906 **************************/
908 /* REACTION-FIELD ELECTROSTATICS */
909 felec = qq20*(rinv20*rinvsq20-krf2);
913 /* Calculate temporary vectorial force */
918 /* Update vectorial force */
922 f[j_coord_offset+DIM*0+XX] -= tx;
923 f[j_coord_offset+DIM*0+YY] -= ty;
924 f[j_coord_offset+DIM*0+ZZ] -= tz;
926 /**************************
927 * CALCULATE INTERACTIONS *
928 **************************/
930 /* REACTION-FIELD ELECTROSTATICS */
931 felec = qq21*(rinv21*rinvsq21-krf2);
935 /* Calculate temporary vectorial force */
940 /* Update vectorial force */
944 f[j_coord_offset+DIM*1+XX] -= tx;
945 f[j_coord_offset+DIM*1+YY] -= ty;
946 f[j_coord_offset+DIM*1+ZZ] -= tz;
948 /**************************
949 * CALCULATE INTERACTIONS *
950 **************************/
952 /* REACTION-FIELD ELECTROSTATICS */
953 felec = qq22*(rinv22*rinvsq22-krf2);
957 /* Calculate temporary vectorial force */
962 /* Update vectorial force */
966 f[j_coord_offset+DIM*2+XX] -= tx;
967 f[j_coord_offset+DIM*2+YY] -= ty;
968 f[j_coord_offset+DIM*2+ZZ] -= tz;
970 /* Inner loop uses 241 flops */
972 /* End of innermost loop */
975 f[i_coord_offset+DIM*0+XX] += fix0;
976 f[i_coord_offset+DIM*0+YY] += fiy0;
977 f[i_coord_offset+DIM*0+ZZ] += fiz0;
981 f[i_coord_offset+DIM*1+XX] += fix1;
982 f[i_coord_offset+DIM*1+YY] += fiy1;
983 f[i_coord_offset+DIM*1+ZZ] += fiz1;
987 f[i_coord_offset+DIM*2+XX] += fix2;
988 f[i_coord_offset+DIM*2+YY] += fiy2;
989 f[i_coord_offset+DIM*2+ZZ] += fiz2;
993 fshift[i_shift_offset+XX] += tx;
994 fshift[i_shift_offset+YY] += ty;
995 fshift[i_shift_offset+ZZ] += tz;
997 /* Increment number of inner iterations */
998 inneriter += j_index_end - j_index_start;
1000 /* Outer loop uses 30 flops */
1003 /* Increment number of outer iterations */
1006 /* Update outer/inner flops */
1008 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*241);