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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3W3_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRF_VdwLJ_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
103 jindex = nlist->jindex;
105 shiftidx = nlist->shift;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
110 charge = mdatoms->chargeA;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 /* Setup water-specific parameters */
119 inr = nlist->iinr[0];
120 iq0 = facel*charge[inr+0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
123 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
128 vdwjidx0 = 2*vdwtype[inr+0];
130 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
131 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
144 /* Start outer loop over neighborlists */
145 for(iidx=0; iidx<nri; iidx++)
147 /* Load shift vector for this list */
148 i_shift_offset = DIM*shiftidx[iidx];
149 shX = shiftvec[i_shift_offset+XX];
150 shY = shiftvec[i_shift_offset+YY];
151 shZ = shiftvec[i_shift_offset+ZZ];
153 /* Load limits for loop over neighbors */
154 j_index_start = jindex[iidx];
155 j_index_end = jindex[iidx+1];
157 /* Get outer coordinate index */
159 i_coord_offset = DIM*inr;
161 /* Load i particle coords and add shift vector */
162 ix0 = shX + x[i_coord_offset+DIM*0+XX];
163 iy0 = shY + x[i_coord_offset+DIM*0+YY];
164 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
165 ix1 = shX + x[i_coord_offset+DIM*1+XX];
166 iy1 = shY + x[i_coord_offset+DIM*1+YY];
167 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
168 ix2 = shX + x[i_coord_offset+DIM*2+XX];
169 iy2 = shY + x[i_coord_offset+DIM*2+YY];
170 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
182 /* Reset potential sums */
186 /* Start inner kernel loop */
187 for(jidx=j_index_start; jidx<j_index_end; jidx++)
189 /* Get j neighbor index, and coordinate index */
191 j_coord_offset = DIM*jnr;
193 /* load j atom coordinates */
194 jx0 = x[j_coord_offset+DIM*0+XX];
195 jy0 = x[j_coord_offset+DIM*0+YY];
196 jz0 = x[j_coord_offset+DIM*0+ZZ];
197 jx1 = x[j_coord_offset+DIM*1+XX];
198 jy1 = x[j_coord_offset+DIM*1+YY];
199 jz1 = x[j_coord_offset+DIM*1+ZZ];
200 jx2 = x[j_coord_offset+DIM*2+XX];
201 jy2 = x[j_coord_offset+DIM*2+YY];
202 jz2 = x[j_coord_offset+DIM*2+ZZ];
204 /* Calculate displacement vector */
233 /* Calculate squared distance and things based on it */
234 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
235 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
236 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
237 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
238 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
239 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
240 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
241 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
242 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
244 rinv00 = gmx_invsqrt(rsq00);
245 rinv01 = gmx_invsqrt(rsq01);
246 rinv02 = gmx_invsqrt(rsq02);
247 rinv10 = gmx_invsqrt(rsq10);
248 rinv11 = gmx_invsqrt(rsq11);
249 rinv12 = gmx_invsqrt(rsq12);
250 rinv20 = gmx_invsqrt(rsq20);
251 rinv21 = gmx_invsqrt(rsq21);
252 rinv22 = gmx_invsqrt(rsq22);
254 rinvsq00 = rinv00*rinv00;
255 rinvsq01 = rinv01*rinv01;
256 rinvsq02 = rinv02*rinv02;
257 rinvsq10 = rinv10*rinv10;
258 rinvsq11 = rinv11*rinv11;
259 rinvsq12 = rinv12*rinv12;
260 rinvsq20 = rinv20*rinv20;
261 rinvsq21 = rinv21*rinv21;
262 rinvsq22 = rinv22*rinv22;
264 /**************************
265 * CALCULATE INTERACTIONS *
266 **************************/
268 /* REACTION-FIELD ELECTROSTATICS */
269 velec = qq00*(rinv00+krf*rsq00-crf);
270 felec = qq00*(rinv00*rinvsq00-krf2);
272 /* LENNARD-JONES DISPERSION/REPULSION */
274 rinvsix = rinvsq00*rinvsq00*rinvsq00;
275 vvdw6 = c6_00*rinvsix;
276 vvdw12 = c12_00*rinvsix*rinvsix;
277 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
278 fvdw = (vvdw12-vvdw6)*rinvsq00;
280 /* 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 = qq01*(rinv01+krf*rsq01-crf);
305 felec = qq01*(rinv01*rinvsq01-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 = qq02*(rinv02+krf*rsq02-crf);
331 felec = qq02*(rinv02*rinvsq02-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 = qq10*(rinv10+krf*rsq10-crf);
357 felec = qq10*(rinv10*rinvsq10-krf2);
359 /* Update potential sums from outer loop */
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f[j_coord_offset+DIM*0+XX] -= tx;
374 f[j_coord_offset+DIM*0+YY] -= ty;
375 f[j_coord_offset+DIM*0+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
381 /* REACTION-FIELD ELECTROSTATICS */
382 velec = qq11*(rinv11+krf*rsq11-crf);
383 felec = qq11*(rinv11*rinvsq11-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 = qq12*(rinv12+krf*rsq12-crf);
409 felec = qq12*(rinv12*rinvsq12-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 = qq20*(rinv20+krf*rsq20-crf);
435 felec = qq20*(rinv20*rinvsq20-krf2);
437 /* Update potential sums from outer loop */
442 /* Calculate temporary vectorial force */
447 /* Update vectorial force */
451 f[j_coord_offset+DIM*0+XX] -= tx;
452 f[j_coord_offset+DIM*0+YY] -= ty;
453 f[j_coord_offset+DIM*0+ZZ] -= tz;
455 /**************************
456 * CALCULATE INTERACTIONS *
457 **************************/
459 /* REACTION-FIELD ELECTROSTATICS */
460 velec = qq21*(rinv21+krf*rsq21-crf);
461 felec = qq21*(rinv21*rinvsq21-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 = qq22*(rinv22+krf*rsq22-crf);
487 felec = qq22*(rinv22*rinvsq22-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 /* Inner loop uses 291 flops */
509 /* End of innermost loop */
512 f[i_coord_offset+DIM*0+XX] += fix0;
513 f[i_coord_offset+DIM*0+YY] += fiy0;
514 f[i_coord_offset+DIM*0+ZZ] += fiz0;
518 f[i_coord_offset+DIM*1+XX] += fix1;
519 f[i_coord_offset+DIM*1+YY] += fiy1;
520 f[i_coord_offset+DIM*1+ZZ] += fiz1;
524 f[i_coord_offset+DIM*2+XX] += fix2;
525 f[i_coord_offset+DIM*2+YY] += fiy2;
526 f[i_coord_offset+DIM*2+ZZ] += fiz2;
530 fshift[i_shift_offset+XX] += tx;
531 fshift[i_shift_offset+YY] += ty;
532 fshift[i_shift_offset+ZZ] += tz;
535 /* Update potential energies */
536 kernel_data->energygrp_elec[ggid] += velecsum;
537 kernel_data->energygrp_vdw[ggid] += vvdwsum;
539 /* Increment number of inner iterations */
540 inneriter += j_index_end - j_index_start;
542 /* Outer loop uses 32 flops */
545 /* Increment number of outer iterations */
548 /* Update outer/inner flops */
550 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*291);
553 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3W3_F_c
554 * Electrostatics interaction: ReactionField
555 * VdW interaction: LennardJones
556 * Geometry: Water3-Water3
557 * Calculate force/pot: Force
560 nb_kernel_ElecRF_VdwLJ_GeomW3W3_F_c
561 (t_nblist * gmx_restrict nlist,
562 rvec * gmx_restrict xx,
563 rvec * gmx_restrict ff,
564 t_forcerec * gmx_restrict fr,
565 t_mdatoms * gmx_restrict mdatoms,
566 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
567 t_nrnb * gmx_restrict nrnb)
569 int i_shift_offset,i_coord_offset,j_coord_offset;
570 int j_index_start,j_index_end;
571 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
572 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
573 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
574 real *shiftvec,*fshift,*x,*f;
576 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
578 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
580 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
582 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
584 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
586 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
587 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
588 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
589 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
590 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
591 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
592 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
593 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
594 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
595 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
596 real velec,felec,velecsum,facel,crf,krf,krf2;
599 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
608 jindex = nlist->jindex;
610 shiftidx = nlist->shift;
612 shiftvec = fr->shift_vec[0];
613 fshift = fr->fshift[0];
615 charge = mdatoms->chargeA;
619 nvdwtype = fr->ntype;
621 vdwtype = mdatoms->typeA;
623 /* Setup water-specific parameters */
624 inr = nlist->iinr[0];
625 iq0 = facel*charge[inr+0];
626 iq1 = facel*charge[inr+1];
627 iq2 = facel*charge[inr+2];
628 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
633 vdwjidx0 = 2*vdwtype[inr+0];
635 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
636 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
649 /* Start outer loop over neighborlists */
650 for(iidx=0; iidx<nri; iidx++)
652 /* Load shift vector for this list */
653 i_shift_offset = DIM*shiftidx[iidx];
654 shX = shiftvec[i_shift_offset+XX];
655 shY = shiftvec[i_shift_offset+YY];
656 shZ = shiftvec[i_shift_offset+ZZ];
658 /* Load limits for loop over neighbors */
659 j_index_start = jindex[iidx];
660 j_index_end = jindex[iidx+1];
662 /* Get outer coordinate index */
664 i_coord_offset = DIM*inr;
666 /* Load i particle coords and add shift vector */
667 ix0 = shX + x[i_coord_offset+DIM*0+XX];
668 iy0 = shY + x[i_coord_offset+DIM*0+YY];
669 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
670 ix1 = shX + x[i_coord_offset+DIM*1+XX];
671 iy1 = shY + x[i_coord_offset+DIM*1+YY];
672 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
673 ix2 = shX + x[i_coord_offset+DIM*2+XX];
674 iy2 = shY + x[i_coord_offset+DIM*2+YY];
675 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
687 /* Start inner kernel loop */
688 for(jidx=j_index_start; jidx<j_index_end; jidx++)
690 /* Get j neighbor index, and coordinate index */
692 j_coord_offset = DIM*jnr;
694 /* load j atom coordinates */
695 jx0 = x[j_coord_offset+DIM*0+XX];
696 jy0 = x[j_coord_offset+DIM*0+YY];
697 jz0 = x[j_coord_offset+DIM*0+ZZ];
698 jx1 = x[j_coord_offset+DIM*1+XX];
699 jy1 = x[j_coord_offset+DIM*1+YY];
700 jz1 = x[j_coord_offset+DIM*1+ZZ];
701 jx2 = x[j_coord_offset+DIM*2+XX];
702 jy2 = x[j_coord_offset+DIM*2+YY];
703 jz2 = x[j_coord_offset+DIM*2+ZZ];
705 /* Calculate displacement vector */
734 /* Calculate squared distance and things based on it */
735 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
736 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
737 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
738 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
739 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
740 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
741 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
742 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
743 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
745 rinv00 = gmx_invsqrt(rsq00);
746 rinv01 = gmx_invsqrt(rsq01);
747 rinv02 = gmx_invsqrt(rsq02);
748 rinv10 = gmx_invsqrt(rsq10);
749 rinv11 = gmx_invsqrt(rsq11);
750 rinv12 = gmx_invsqrt(rsq12);
751 rinv20 = gmx_invsqrt(rsq20);
752 rinv21 = gmx_invsqrt(rsq21);
753 rinv22 = gmx_invsqrt(rsq22);
755 rinvsq00 = rinv00*rinv00;
756 rinvsq01 = rinv01*rinv01;
757 rinvsq02 = rinv02*rinv02;
758 rinvsq10 = rinv10*rinv10;
759 rinvsq11 = rinv11*rinv11;
760 rinvsq12 = rinv12*rinv12;
761 rinvsq20 = rinv20*rinv20;
762 rinvsq21 = rinv21*rinv21;
763 rinvsq22 = rinv22*rinv22;
765 /**************************
766 * CALCULATE INTERACTIONS *
767 **************************/
769 /* REACTION-FIELD ELECTROSTATICS */
770 felec = qq00*(rinv00*rinvsq00-krf2);
772 /* LENNARD-JONES DISPERSION/REPULSION */
774 rinvsix = rinvsq00*rinvsq00*rinvsq00;
775 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
779 /* Calculate temporary vectorial force */
784 /* Update vectorial force */
788 f[j_coord_offset+DIM*0+XX] -= tx;
789 f[j_coord_offset+DIM*0+YY] -= ty;
790 f[j_coord_offset+DIM*0+ZZ] -= tz;
792 /**************************
793 * CALCULATE INTERACTIONS *
794 **************************/
796 /* REACTION-FIELD ELECTROSTATICS */
797 felec = qq01*(rinv01*rinvsq01-krf2);
801 /* Calculate temporary vectorial force */
806 /* Update vectorial force */
810 f[j_coord_offset+DIM*1+XX] -= tx;
811 f[j_coord_offset+DIM*1+YY] -= ty;
812 f[j_coord_offset+DIM*1+ZZ] -= tz;
814 /**************************
815 * CALCULATE INTERACTIONS *
816 **************************/
818 /* REACTION-FIELD ELECTROSTATICS */
819 felec = qq02*(rinv02*rinvsq02-krf2);
823 /* Calculate temporary vectorial force */
828 /* Update vectorial force */
832 f[j_coord_offset+DIM*2+XX] -= tx;
833 f[j_coord_offset+DIM*2+YY] -= ty;
834 f[j_coord_offset+DIM*2+ZZ] -= tz;
836 /**************************
837 * CALCULATE INTERACTIONS *
838 **************************/
840 /* REACTION-FIELD ELECTROSTATICS */
841 felec = qq10*(rinv10*rinvsq10-krf2);
845 /* Calculate temporary vectorial force */
850 /* Update vectorial force */
854 f[j_coord_offset+DIM*0+XX] -= tx;
855 f[j_coord_offset+DIM*0+YY] -= ty;
856 f[j_coord_offset+DIM*0+ZZ] -= tz;
858 /**************************
859 * CALCULATE INTERACTIONS *
860 **************************/
862 /* REACTION-FIELD ELECTROSTATICS */
863 felec = qq11*(rinv11*rinvsq11-krf2);
867 /* Calculate temporary vectorial force */
872 /* Update vectorial force */
876 f[j_coord_offset+DIM*1+XX] -= tx;
877 f[j_coord_offset+DIM*1+YY] -= ty;
878 f[j_coord_offset+DIM*1+ZZ] -= tz;
880 /**************************
881 * CALCULATE INTERACTIONS *
882 **************************/
884 /* REACTION-FIELD ELECTROSTATICS */
885 felec = qq12*(rinv12*rinvsq12-krf2);
889 /* Calculate temporary vectorial force */
894 /* Update vectorial force */
898 f[j_coord_offset+DIM*2+XX] -= tx;
899 f[j_coord_offset+DIM*2+YY] -= ty;
900 f[j_coord_offset+DIM*2+ZZ] -= tz;
902 /**************************
903 * CALCULATE INTERACTIONS *
904 **************************/
906 /* REACTION-FIELD ELECTROSTATICS */
907 felec = qq20*(rinv20*rinvsq20-krf2);
911 /* Calculate temporary vectorial force */
916 /* Update vectorial force */
920 f[j_coord_offset+DIM*0+XX] -= tx;
921 f[j_coord_offset+DIM*0+YY] -= ty;
922 f[j_coord_offset+DIM*0+ZZ] -= tz;
924 /**************************
925 * CALCULATE INTERACTIONS *
926 **************************/
928 /* REACTION-FIELD ELECTROSTATICS */
929 felec = qq21*(rinv21*rinvsq21-krf2);
933 /* Calculate temporary vectorial force */
938 /* Update vectorial force */
942 f[j_coord_offset+DIM*1+XX] -= tx;
943 f[j_coord_offset+DIM*1+YY] -= ty;
944 f[j_coord_offset+DIM*1+ZZ] -= tz;
946 /**************************
947 * CALCULATE INTERACTIONS *
948 **************************/
950 /* REACTION-FIELD ELECTROSTATICS */
951 felec = qq22*(rinv22*rinvsq22-krf2);
955 /* Calculate temporary vectorial force */
960 /* Update vectorial force */
964 f[j_coord_offset+DIM*2+XX] -= tx;
965 f[j_coord_offset+DIM*2+YY] -= ty;
966 f[j_coord_offset+DIM*2+ZZ] -= tz;
968 /* Inner loop uses 241 flops */
970 /* End of innermost loop */
973 f[i_coord_offset+DIM*0+XX] += fix0;
974 f[i_coord_offset+DIM*0+YY] += fiy0;
975 f[i_coord_offset+DIM*0+ZZ] += fiz0;
979 f[i_coord_offset+DIM*1+XX] += fix1;
980 f[i_coord_offset+DIM*1+YY] += fiy1;
981 f[i_coord_offset+DIM*1+ZZ] += fiz1;
985 f[i_coord_offset+DIM*2+XX] += fix2;
986 f[i_coord_offset+DIM*2+YY] += fiy2;
987 f[i_coord_offset+DIM*2+ZZ] += fiz2;
991 fshift[i_shift_offset+XX] += tx;
992 fshift[i_shift_offset+YY] += ty;
993 fshift[i_shift_offset+ZZ] += tz;
995 /* Increment number of inner iterations */
996 inneriter += j_index_end - j_index_start;
998 /* Outer loop uses 30 flops */
1001 /* Increment number of outer iterations */
1004 /* Update outer/inner flops */
1006 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*241);