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_ElecEwSw_VdwLJSw_GeomW4P1_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
84 real velec,felec,velecsum,facel,crf,krf,krf2;
87 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
91 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
93 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
100 jindex = nlist->jindex;
102 shiftidx = nlist->shift;
104 shiftvec = fr->shift_vec[0];
105 fshift = fr->fshift[0];
107 charge = mdatoms->chargeA;
108 nvdwtype = fr->ntype;
110 vdwtype = mdatoms->typeA;
112 sh_ewald = fr->ic->sh_ewald;
113 ewtab = fr->ic->tabq_coul_FDV0;
114 ewtabscale = fr->ic->tabq_scale;
115 ewtabhalfspace = 0.5/ewtabscale;
117 /* Setup water-specific parameters */
118 inr = nlist->iinr[0];
119 iq1 = facel*charge[inr+1];
120 iq2 = facel*charge[inr+2];
121 iq3 = facel*charge[inr+3];
122 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
124 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
125 rcutoff = fr->rcoulomb;
126 rcutoff2 = rcutoff*rcutoff;
128 rswitch = fr->rcoulomb_switch;
129 /* Setup switch parameters */
131 swV3 = -10.0/(d*d*d);
132 swV4 = 15.0/(d*d*d*d);
133 swV5 = -6.0/(d*d*d*d*d);
134 swF2 = -30.0/(d*d*d);
135 swF3 = 60.0/(d*d*d*d);
136 swF4 = -30.0/(d*d*d*d*d);
141 /* Start outer loop over neighborlists */
142 for(iidx=0; iidx<nri; iidx++)
144 /* Load shift vector for this list */
145 i_shift_offset = DIM*shiftidx[iidx];
146 shX = shiftvec[i_shift_offset+XX];
147 shY = shiftvec[i_shift_offset+YY];
148 shZ = shiftvec[i_shift_offset+ZZ];
150 /* Load limits for loop over neighbors */
151 j_index_start = jindex[iidx];
152 j_index_end = jindex[iidx+1];
154 /* Get outer coordinate index */
156 i_coord_offset = DIM*inr;
158 /* Load i particle coords and add shift vector */
159 ix0 = shX + x[i_coord_offset+DIM*0+XX];
160 iy0 = shY + x[i_coord_offset+DIM*0+YY];
161 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
162 ix1 = shX + x[i_coord_offset+DIM*1+XX];
163 iy1 = shY + x[i_coord_offset+DIM*1+YY];
164 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
165 ix2 = shX + x[i_coord_offset+DIM*2+XX];
166 iy2 = shY + x[i_coord_offset+DIM*2+YY];
167 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
168 ix3 = shX + x[i_coord_offset+DIM*3+XX];
169 iy3 = shY + x[i_coord_offset+DIM*3+YY];
170 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
185 /* Reset potential sums */
189 /* Start inner kernel loop */
190 for(jidx=j_index_start; jidx<j_index_end; jidx++)
192 /* Get j neighbor index, and coordinate index */
194 j_coord_offset = DIM*jnr;
196 /* load j atom coordinates */
197 jx0 = x[j_coord_offset+DIM*0+XX];
198 jy0 = x[j_coord_offset+DIM*0+YY];
199 jz0 = x[j_coord_offset+DIM*0+ZZ];
201 /* Calculate displacement vector */
215 /* Calculate squared distance and things based on it */
216 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
217 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
218 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
219 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
221 rinv00 = gmx_invsqrt(rsq00);
222 rinv10 = gmx_invsqrt(rsq10);
223 rinv20 = gmx_invsqrt(rsq20);
224 rinv30 = gmx_invsqrt(rsq30);
226 rinvsq00 = rinv00*rinv00;
227 rinvsq10 = rinv10*rinv10;
228 rinvsq20 = rinv20*rinv20;
229 rinvsq30 = rinv30*rinv30;
231 /* Load parameters for j particles */
233 vdwjidx0 = 2*vdwtype[jnr+0];
235 /**************************
236 * CALCULATE INTERACTIONS *
237 **************************/
244 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
245 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
247 /* LENNARD-JONES DISPERSION/REPULSION */
249 rinvsix = rinvsq00*rinvsq00*rinvsq00;
250 vvdw6 = c6_00*rinvsix;
251 vvdw12 = c12_00*rinvsix*rinvsix;
252 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
253 fvdw = (vvdw12-vvdw6)*rinvsq00;
256 d = (d>0.0) ? d : 0.0;
258 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
260 dsw = d2*(swF2+d*(swF3+d*swF4));
262 /* Evaluate switch function */
263 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
264 fvdw = fvdw*sw - rinv00*vvdw*dsw;
267 /* Update potential sums from outer loop */
272 /* Calculate temporary vectorial force */
277 /* Update vectorial force */
281 f[j_coord_offset+DIM*0+XX] -= tx;
282 f[j_coord_offset+DIM*0+YY] -= ty;
283 f[j_coord_offset+DIM*0+ZZ] -= tz;
287 /**************************
288 * CALCULATE INTERACTIONS *
289 **************************/
298 /* EWALD ELECTROSTATICS */
300 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
301 ewrt = r10*ewtabscale;
305 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
306 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
307 felec = qq10*rinv10*(rinvsq10-felec);
310 d = (d>0.0) ? d : 0.0;
312 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
314 dsw = d2*(swF2+d*(swF3+d*swF4));
316 /* Evaluate switch function */
317 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
318 felec = felec*sw - rinv10*velec*dsw;
321 /* Update potential sums from outer loop */
326 /* Calculate temporary vectorial force */
331 /* Update vectorial force */
335 f[j_coord_offset+DIM*0+XX] -= tx;
336 f[j_coord_offset+DIM*0+YY] -= ty;
337 f[j_coord_offset+DIM*0+ZZ] -= tz;
341 /**************************
342 * CALCULATE INTERACTIONS *
343 **************************/
352 /* EWALD ELECTROSTATICS */
354 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
355 ewrt = r20*ewtabscale;
359 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
360 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
361 felec = qq20*rinv20*(rinvsq20-felec);
364 d = (d>0.0) ? d : 0.0;
366 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
368 dsw = d2*(swF2+d*(swF3+d*swF4));
370 /* Evaluate switch function */
371 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
372 felec = felec*sw - rinv20*velec*dsw;
375 /* Update potential sums from outer loop */
380 /* Calculate temporary vectorial force */
385 /* Update vectorial force */
389 f[j_coord_offset+DIM*0+XX] -= tx;
390 f[j_coord_offset+DIM*0+YY] -= ty;
391 f[j_coord_offset+DIM*0+ZZ] -= tz;
395 /**************************
396 * CALCULATE INTERACTIONS *
397 **************************/
406 /* EWALD ELECTROSTATICS */
408 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
409 ewrt = r30*ewtabscale;
413 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
414 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
415 felec = qq30*rinv30*(rinvsq30-felec);
418 d = (d>0.0) ? d : 0.0;
420 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
422 dsw = d2*(swF2+d*(swF3+d*swF4));
424 /* Evaluate switch function */
425 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
426 felec = felec*sw - rinv30*velec*dsw;
429 /* Update potential sums from outer loop */
434 /* Calculate temporary vectorial force */
439 /* Update vectorial force */
443 f[j_coord_offset+DIM*0+XX] -= tx;
444 f[j_coord_offset+DIM*0+YY] -= ty;
445 f[j_coord_offset+DIM*0+ZZ] -= tz;
449 /* Inner loop uses 230 flops */
451 /* End of innermost loop */
454 f[i_coord_offset+DIM*0+XX] += fix0;
455 f[i_coord_offset+DIM*0+YY] += fiy0;
456 f[i_coord_offset+DIM*0+ZZ] += fiz0;
460 f[i_coord_offset+DIM*1+XX] += fix1;
461 f[i_coord_offset+DIM*1+YY] += fiy1;
462 f[i_coord_offset+DIM*1+ZZ] += fiz1;
466 f[i_coord_offset+DIM*2+XX] += fix2;
467 f[i_coord_offset+DIM*2+YY] += fiy2;
468 f[i_coord_offset+DIM*2+ZZ] += fiz2;
472 f[i_coord_offset+DIM*3+XX] += fix3;
473 f[i_coord_offset+DIM*3+YY] += fiy3;
474 f[i_coord_offset+DIM*3+ZZ] += fiz3;
478 fshift[i_shift_offset+XX] += tx;
479 fshift[i_shift_offset+YY] += ty;
480 fshift[i_shift_offset+ZZ] += tz;
483 /* Update potential energies */
484 kernel_data->energygrp_elec[ggid] += velecsum;
485 kernel_data->energygrp_vdw[ggid] += vvdwsum;
487 /* Increment number of inner iterations */
488 inneriter += j_index_end - j_index_start;
490 /* Outer loop uses 41 flops */
493 /* Increment number of outer iterations */
496 /* Update outer/inner flops */
498 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*230);
501 * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_F_c
502 * Electrostatics interaction: Ewald
503 * VdW interaction: LennardJones
504 * Geometry: Water4-Particle
505 * Calculate force/pot: Force
508 nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_F_c
509 (t_nblist * gmx_restrict nlist,
510 rvec * gmx_restrict xx,
511 rvec * gmx_restrict ff,
512 t_forcerec * gmx_restrict fr,
513 t_mdatoms * gmx_restrict mdatoms,
514 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
515 t_nrnb * gmx_restrict nrnb)
517 int i_shift_offset,i_coord_offset,j_coord_offset;
518 int j_index_start,j_index_end;
519 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
520 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
521 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
522 real *shiftvec,*fshift,*x,*f;
524 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
526 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
528 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
530 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
532 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
533 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
534 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
535 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
536 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
537 real velec,felec,velecsum,facel,crf,krf,krf2;
540 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
544 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
546 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
553 jindex = nlist->jindex;
555 shiftidx = nlist->shift;
557 shiftvec = fr->shift_vec[0];
558 fshift = fr->fshift[0];
560 charge = mdatoms->chargeA;
561 nvdwtype = fr->ntype;
563 vdwtype = mdatoms->typeA;
565 sh_ewald = fr->ic->sh_ewald;
566 ewtab = fr->ic->tabq_coul_FDV0;
567 ewtabscale = fr->ic->tabq_scale;
568 ewtabhalfspace = 0.5/ewtabscale;
570 /* Setup water-specific parameters */
571 inr = nlist->iinr[0];
572 iq1 = facel*charge[inr+1];
573 iq2 = facel*charge[inr+2];
574 iq3 = facel*charge[inr+3];
575 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
577 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
578 rcutoff = fr->rcoulomb;
579 rcutoff2 = rcutoff*rcutoff;
581 rswitch = fr->rcoulomb_switch;
582 /* Setup switch parameters */
584 swV3 = -10.0/(d*d*d);
585 swV4 = 15.0/(d*d*d*d);
586 swV5 = -6.0/(d*d*d*d*d);
587 swF2 = -30.0/(d*d*d);
588 swF3 = 60.0/(d*d*d*d);
589 swF4 = -30.0/(d*d*d*d*d);
594 /* Start outer loop over neighborlists */
595 for(iidx=0; iidx<nri; iidx++)
597 /* Load shift vector for this list */
598 i_shift_offset = DIM*shiftidx[iidx];
599 shX = shiftvec[i_shift_offset+XX];
600 shY = shiftvec[i_shift_offset+YY];
601 shZ = shiftvec[i_shift_offset+ZZ];
603 /* Load limits for loop over neighbors */
604 j_index_start = jindex[iidx];
605 j_index_end = jindex[iidx+1];
607 /* Get outer coordinate index */
609 i_coord_offset = DIM*inr;
611 /* Load i particle coords and add shift vector */
612 ix0 = shX + x[i_coord_offset+DIM*0+XX];
613 iy0 = shY + x[i_coord_offset+DIM*0+YY];
614 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
615 ix1 = shX + x[i_coord_offset+DIM*1+XX];
616 iy1 = shY + x[i_coord_offset+DIM*1+YY];
617 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
618 ix2 = shX + x[i_coord_offset+DIM*2+XX];
619 iy2 = shY + x[i_coord_offset+DIM*2+YY];
620 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
621 ix3 = shX + x[i_coord_offset+DIM*3+XX];
622 iy3 = shY + x[i_coord_offset+DIM*3+YY];
623 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
638 /* Start inner kernel loop */
639 for(jidx=j_index_start; jidx<j_index_end; jidx++)
641 /* Get j neighbor index, and coordinate index */
643 j_coord_offset = DIM*jnr;
645 /* load j atom coordinates */
646 jx0 = x[j_coord_offset+DIM*0+XX];
647 jy0 = x[j_coord_offset+DIM*0+YY];
648 jz0 = x[j_coord_offset+DIM*0+ZZ];
650 /* Calculate displacement vector */
664 /* Calculate squared distance and things based on it */
665 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
666 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
667 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
668 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
670 rinv00 = gmx_invsqrt(rsq00);
671 rinv10 = gmx_invsqrt(rsq10);
672 rinv20 = gmx_invsqrt(rsq20);
673 rinv30 = gmx_invsqrt(rsq30);
675 rinvsq00 = rinv00*rinv00;
676 rinvsq10 = rinv10*rinv10;
677 rinvsq20 = rinv20*rinv20;
678 rinvsq30 = rinv30*rinv30;
680 /* Load parameters for j particles */
682 vdwjidx0 = 2*vdwtype[jnr+0];
684 /**************************
685 * CALCULATE INTERACTIONS *
686 **************************/
693 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
694 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
696 /* LENNARD-JONES DISPERSION/REPULSION */
698 rinvsix = rinvsq00*rinvsq00*rinvsq00;
699 vvdw6 = c6_00*rinvsix;
700 vvdw12 = c12_00*rinvsix*rinvsix;
701 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
702 fvdw = (vvdw12-vvdw6)*rinvsq00;
705 d = (d>0.0) ? d : 0.0;
707 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
709 dsw = d2*(swF2+d*(swF3+d*swF4));
711 /* Evaluate switch function */
712 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
713 fvdw = fvdw*sw - rinv00*vvdw*dsw;
717 /* Calculate temporary vectorial force */
722 /* Update vectorial force */
726 f[j_coord_offset+DIM*0+XX] -= tx;
727 f[j_coord_offset+DIM*0+YY] -= ty;
728 f[j_coord_offset+DIM*0+ZZ] -= tz;
732 /**************************
733 * CALCULATE INTERACTIONS *
734 **************************/
743 /* EWALD ELECTROSTATICS */
745 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
746 ewrt = r10*ewtabscale;
750 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
751 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
752 felec = qq10*rinv10*(rinvsq10-felec);
755 d = (d>0.0) ? d : 0.0;
757 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
759 dsw = d2*(swF2+d*(swF3+d*swF4));
761 /* Evaluate switch function */
762 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
763 felec = felec*sw - rinv10*velec*dsw;
767 /* Calculate temporary vectorial force */
772 /* Update vectorial force */
776 f[j_coord_offset+DIM*0+XX] -= tx;
777 f[j_coord_offset+DIM*0+YY] -= ty;
778 f[j_coord_offset+DIM*0+ZZ] -= tz;
782 /**************************
783 * CALCULATE INTERACTIONS *
784 **************************/
793 /* EWALD ELECTROSTATICS */
795 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
796 ewrt = r20*ewtabscale;
800 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
801 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
802 felec = qq20*rinv20*(rinvsq20-felec);
805 d = (d>0.0) ? d : 0.0;
807 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
809 dsw = d2*(swF2+d*(swF3+d*swF4));
811 /* Evaluate switch function */
812 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
813 felec = felec*sw - rinv20*velec*dsw;
817 /* Calculate temporary vectorial force */
822 /* Update vectorial force */
826 f[j_coord_offset+DIM*0+XX] -= tx;
827 f[j_coord_offset+DIM*0+YY] -= ty;
828 f[j_coord_offset+DIM*0+ZZ] -= tz;
832 /**************************
833 * CALCULATE INTERACTIONS *
834 **************************/
843 /* EWALD ELECTROSTATICS */
845 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
846 ewrt = r30*ewtabscale;
850 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
851 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
852 felec = qq30*rinv30*(rinvsq30-felec);
855 d = (d>0.0) ? d : 0.0;
857 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
859 dsw = d2*(swF2+d*(swF3+d*swF4));
861 /* Evaluate switch function */
862 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
863 felec = felec*sw - rinv30*velec*dsw;
867 /* Calculate temporary vectorial force */
872 /* Update vectorial force */
876 f[j_coord_offset+DIM*0+XX] -= tx;
877 f[j_coord_offset+DIM*0+YY] -= ty;
878 f[j_coord_offset+DIM*0+ZZ] -= tz;
882 /* Inner loop uses 222 flops */
884 /* End of innermost loop */
887 f[i_coord_offset+DIM*0+XX] += fix0;
888 f[i_coord_offset+DIM*0+YY] += fiy0;
889 f[i_coord_offset+DIM*0+ZZ] += fiz0;
893 f[i_coord_offset+DIM*1+XX] += fix1;
894 f[i_coord_offset+DIM*1+YY] += fiy1;
895 f[i_coord_offset+DIM*1+ZZ] += fiz1;
899 f[i_coord_offset+DIM*2+XX] += fix2;
900 f[i_coord_offset+DIM*2+YY] += fiy2;
901 f[i_coord_offset+DIM*2+ZZ] += fiz2;
905 f[i_coord_offset+DIM*3+XX] += fix3;
906 f[i_coord_offset+DIM*3+YY] += fiy3;
907 f[i_coord_offset+DIM*3+ZZ] += fiz3;
911 fshift[i_shift_offset+XX] += tx;
912 fshift[i_shift_offset+YY] += ty;
913 fshift[i_shift_offset+ZZ] += tz;
915 /* Increment number of inner iterations */
916 inneriter += j_index_end - j_index_start;
918 /* Outer loop uses 39 flops */
921 /* Increment number of outer iterations */
924 /* Update outer/inner flops */
926 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*222);