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 "types/simple.h"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
93 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
95 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
109 charge = mdatoms->chargeA;
110 nvdwtype = fr->ntype;
112 vdwtype = mdatoms->typeA;
114 sh_ewald = fr->ic->sh_ewald;
115 ewtab = fr->ic->tabq_coul_FDV0;
116 ewtabscale = fr->ic->tabq_scale;
117 ewtabhalfspace = 0.5/ewtabscale;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq1 = facel*charge[inr+1];
122 iq2 = facel*charge[inr+2];
123 iq3 = facel*charge[inr+3];
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
126 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
127 rcutoff = fr->rcoulomb;
128 rcutoff2 = rcutoff*rcutoff;
130 rswitch = fr->rcoulomb_switch;
131 /* Setup switch parameters */
133 swV3 = -10.0/(d*d*d);
134 swV4 = 15.0/(d*d*d*d);
135 swV5 = -6.0/(d*d*d*d*d);
136 swF2 = -30.0/(d*d*d);
137 swF3 = 60.0/(d*d*d*d);
138 swF4 = -30.0/(d*d*d*d*d);
143 /* Start outer loop over neighborlists */
144 for(iidx=0; iidx<nri; iidx++)
146 /* Load shift vector for this list */
147 i_shift_offset = DIM*shiftidx[iidx];
148 shX = shiftvec[i_shift_offset+XX];
149 shY = shiftvec[i_shift_offset+YY];
150 shZ = shiftvec[i_shift_offset+ZZ];
152 /* Load limits for loop over neighbors */
153 j_index_start = jindex[iidx];
154 j_index_end = jindex[iidx+1];
156 /* Get outer coordinate index */
158 i_coord_offset = DIM*inr;
160 /* Load i particle coords and add shift vector */
161 ix0 = shX + x[i_coord_offset+DIM*0+XX];
162 iy0 = shY + x[i_coord_offset+DIM*0+YY];
163 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
164 ix1 = shX + x[i_coord_offset+DIM*1+XX];
165 iy1 = shY + x[i_coord_offset+DIM*1+YY];
166 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
167 ix2 = shX + x[i_coord_offset+DIM*2+XX];
168 iy2 = shY + x[i_coord_offset+DIM*2+YY];
169 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
170 ix3 = shX + x[i_coord_offset+DIM*3+XX];
171 iy3 = shY + x[i_coord_offset+DIM*3+YY];
172 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
187 /* Reset potential sums */
191 /* Start inner kernel loop */
192 for(jidx=j_index_start; jidx<j_index_end; jidx++)
194 /* Get j neighbor index, and coordinate index */
196 j_coord_offset = DIM*jnr;
198 /* load j atom coordinates */
199 jx0 = x[j_coord_offset+DIM*0+XX];
200 jy0 = x[j_coord_offset+DIM*0+YY];
201 jz0 = x[j_coord_offset+DIM*0+ZZ];
203 /* Calculate displacement vector */
217 /* Calculate squared distance and things based on it */
218 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
219 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
220 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
221 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
223 rinv00 = gmx_invsqrt(rsq00);
224 rinv10 = gmx_invsqrt(rsq10);
225 rinv20 = gmx_invsqrt(rsq20);
226 rinv30 = gmx_invsqrt(rsq30);
228 rinvsq00 = rinv00*rinv00;
229 rinvsq10 = rinv10*rinv10;
230 rinvsq20 = rinv20*rinv20;
231 rinvsq30 = rinv30*rinv30;
233 /* Load parameters for j particles */
235 vdwjidx0 = 2*vdwtype[jnr+0];
237 /**************************
238 * CALCULATE INTERACTIONS *
239 **************************/
246 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
247 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
249 /* LENNARD-JONES DISPERSION/REPULSION */
251 rinvsix = rinvsq00*rinvsq00*rinvsq00;
252 vvdw6 = c6_00*rinvsix;
253 vvdw12 = c12_00*rinvsix*rinvsix;
254 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
255 fvdw = (vvdw12-vvdw6)*rinvsq00;
258 d = (d>0.0) ? d : 0.0;
260 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
262 dsw = d2*(swF2+d*(swF3+d*swF4));
264 /* Evaluate switch function */
265 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
266 fvdw = fvdw*sw - rinv00*vvdw*dsw;
269 /* Update potential sums from outer loop */
274 /* Calculate temporary vectorial force */
279 /* Update vectorial force */
283 f[j_coord_offset+DIM*0+XX] -= tx;
284 f[j_coord_offset+DIM*0+YY] -= ty;
285 f[j_coord_offset+DIM*0+ZZ] -= tz;
289 /**************************
290 * CALCULATE INTERACTIONS *
291 **************************/
300 /* EWALD ELECTROSTATICS */
302 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
303 ewrt = r10*ewtabscale;
307 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
308 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
309 felec = qq10*rinv10*(rinvsq10-felec);
312 d = (d>0.0) ? d : 0.0;
314 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
316 dsw = d2*(swF2+d*(swF3+d*swF4));
318 /* Evaluate switch function */
319 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
320 felec = felec*sw - rinv10*velec*dsw;
323 /* Update potential sums from outer loop */
328 /* Calculate temporary vectorial force */
333 /* Update vectorial force */
337 f[j_coord_offset+DIM*0+XX] -= tx;
338 f[j_coord_offset+DIM*0+YY] -= ty;
339 f[j_coord_offset+DIM*0+ZZ] -= tz;
343 /**************************
344 * CALCULATE INTERACTIONS *
345 **************************/
354 /* EWALD ELECTROSTATICS */
356 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
357 ewrt = r20*ewtabscale;
361 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
362 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
363 felec = qq20*rinv20*(rinvsq20-felec);
366 d = (d>0.0) ? d : 0.0;
368 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
370 dsw = d2*(swF2+d*(swF3+d*swF4));
372 /* Evaluate switch function */
373 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
374 felec = felec*sw - rinv20*velec*dsw;
377 /* Update potential sums from outer loop */
382 /* Calculate temporary vectorial force */
387 /* Update vectorial force */
391 f[j_coord_offset+DIM*0+XX] -= tx;
392 f[j_coord_offset+DIM*0+YY] -= ty;
393 f[j_coord_offset+DIM*0+ZZ] -= tz;
397 /**************************
398 * CALCULATE INTERACTIONS *
399 **************************/
408 /* EWALD ELECTROSTATICS */
410 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
411 ewrt = r30*ewtabscale;
415 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
416 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
417 felec = qq30*rinv30*(rinvsq30-felec);
420 d = (d>0.0) ? d : 0.0;
422 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
424 dsw = d2*(swF2+d*(swF3+d*swF4));
426 /* Evaluate switch function */
427 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
428 felec = felec*sw - rinv30*velec*dsw;
431 /* Update potential sums from outer loop */
436 /* Calculate temporary vectorial force */
441 /* Update vectorial force */
445 f[j_coord_offset+DIM*0+XX] -= tx;
446 f[j_coord_offset+DIM*0+YY] -= ty;
447 f[j_coord_offset+DIM*0+ZZ] -= tz;
451 /* Inner loop uses 230 flops */
453 /* End of innermost loop */
456 f[i_coord_offset+DIM*0+XX] += fix0;
457 f[i_coord_offset+DIM*0+YY] += fiy0;
458 f[i_coord_offset+DIM*0+ZZ] += fiz0;
462 f[i_coord_offset+DIM*1+XX] += fix1;
463 f[i_coord_offset+DIM*1+YY] += fiy1;
464 f[i_coord_offset+DIM*1+ZZ] += fiz1;
468 f[i_coord_offset+DIM*2+XX] += fix2;
469 f[i_coord_offset+DIM*2+YY] += fiy2;
470 f[i_coord_offset+DIM*2+ZZ] += fiz2;
474 f[i_coord_offset+DIM*3+XX] += fix3;
475 f[i_coord_offset+DIM*3+YY] += fiy3;
476 f[i_coord_offset+DIM*3+ZZ] += fiz3;
480 fshift[i_shift_offset+XX] += tx;
481 fshift[i_shift_offset+YY] += ty;
482 fshift[i_shift_offset+ZZ] += tz;
485 /* Update potential energies */
486 kernel_data->energygrp_elec[ggid] += velecsum;
487 kernel_data->energygrp_vdw[ggid] += vvdwsum;
489 /* Increment number of inner iterations */
490 inneriter += j_index_end - j_index_start;
492 /* Outer loop uses 41 flops */
495 /* Increment number of outer iterations */
498 /* Update outer/inner flops */
500 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*230);
503 * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_F_c
504 * Electrostatics interaction: Ewald
505 * VdW interaction: LennardJones
506 * Geometry: Water4-Particle
507 * Calculate force/pot: Force
510 nb_kernel_ElecEwSw_VdwLJSw_GeomW4P1_F_c
511 (t_nblist * gmx_restrict nlist,
512 rvec * gmx_restrict xx,
513 rvec * gmx_restrict ff,
514 t_forcerec * gmx_restrict fr,
515 t_mdatoms * gmx_restrict mdatoms,
516 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
517 t_nrnb * gmx_restrict nrnb)
519 int i_shift_offset,i_coord_offset,j_coord_offset;
520 int j_index_start,j_index_end;
521 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
522 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
523 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
524 real *shiftvec,*fshift,*x,*f;
526 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
528 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
530 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
532 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
534 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
535 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
536 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
537 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
538 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
539 real velec,felec,velecsum,facel,crf,krf,krf2;
542 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
546 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
548 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
555 jindex = nlist->jindex;
557 shiftidx = nlist->shift;
559 shiftvec = fr->shift_vec[0];
560 fshift = fr->fshift[0];
562 charge = mdatoms->chargeA;
563 nvdwtype = fr->ntype;
565 vdwtype = mdatoms->typeA;
567 sh_ewald = fr->ic->sh_ewald;
568 ewtab = fr->ic->tabq_coul_FDV0;
569 ewtabscale = fr->ic->tabq_scale;
570 ewtabhalfspace = 0.5/ewtabscale;
572 /* Setup water-specific parameters */
573 inr = nlist->iinr[0];
574 iq1 = facel*charge[inr+1];
575 iq2 = facel*charge[inr+2];
576 iq3 = facel*charge[inr+3];
577 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
579 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
580 rcutoff = fr->rcoulomb;
581 rcutoff2 = rcutoff*rcutoff;
583 rswitch = fr->rcoulomb_switch;
584 /* Setup switch parameters */
586 swV3 = -10.0/(d*d*d);
587 swV4 = 15.0/(d*d*d*d);
588 swV5 = -6.0/(d*d*d*d*d);
589 swF2 = -30.0/(d*d*d);
590 swF3 = 60.0/(d*d*d*d);
591 swF4 = -30.0/(d*d*d*d*d);
596 /* Start outer loop over neighborlists */
597 for(iidx=0; iidx<nri; iidx++)
599 /* Load shift vector for this list */
600 i_shift_offset = DIM*shiftidx[iidx];
601 shX = shiftvec[i_shift_offset+XX];
602 shY = shiftvec[i_shift_offset+YY];
603 shZ = shiftvec[i_shift_offset+ZZ];
605 /* Load limits for loop over neighbors */
606 j_index_start = jindex[iidx];
607 j_index_end = jindex[iidx+1];
609 /* Get outer coordinate index */
611 i_coord_offset = DIM*inr;
613 /* Load i particle coords and add shift vector */
614 ix0 = shX + x[i_coord_offset+DIM*0+XX];
615 iy0 = shY + x[i_coord_offset+DIM*0+YY];
616 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
617 ix1 = shX + x[i_coord_offset+DIM*1+XX];
618 iy1 = shY + x[i_coord_offset+DIM*1+YY];
619 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
620 ix2 = shX + x[i_coord_offset+DIM*2+XX];
621 iy2 = shY + x[i_coord_offset+DIM*2+YY];
622 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
623 ix3 = shX + x[i_coord_offset+DIM*3+XX];
624 iy3 = shY + x[i_coord_offset+DIM*3+YY];
625 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
640 /* Start inner kernel loop */
641 for(jidx=j_index_start; jidx<j_index_end; jidx++)
643 /* Get j neighbor index, and coordinate index */
645 j_coord_offset = DIM*jnr;
647 /* load j atom coordinates */
648 jx0 = x[j_coord_offset+DIM*0+XX];
649 jy0 = x[j_coord_offset+DIM*0+YY];
650 jz0 = x[j_coord_offset+DIM*0+ZZ];
652 /* Calculate displacement vector */
666 /* Calculate squared distance and things based on it */
667 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
668 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
669 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
670 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
672 rinv00 = gmx_invsqrt(rsq00);
673 rinv10 = gmx_invsqrt(rsq10);
674 rinv20 = gmx_invsqrt(rsq20);
675 rinv30 = gmx_invsqrt(rsq30);
677 rinvsq00 = rinv00*rinv00;
678 rinvsq10 = rinv10*rinv10;
679 rinvsq20 = rinv20*rinv20;
680 rinvsq30 = rinv30*rinv30;
682 /* Load parameters for j particles */
684 vdwjidx0 = 2*vdwtype[jnr+0];
686 /**************************
687 * CALCULATE INTERACTIONS *
688 **************************/
695 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
696 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
698 /* LENNARD-JONES DISPERSION/REPULSION */
700 rinvsix = rinvsq00*rinvsq00*rinvsq00;
701 vvdw6 = c6_00*rinvsix;
702 vvdw12 = c12_00*rinvsix*rinvsix;
703 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
704 fvdw = (vvdw12-vvdw6)*rinvsq00;
707 d = (d>0.0) ? d : 0.0;
709 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
711 dsw = d2*(swF2+d*(swF3+d*swF4));
713 /* Evaluate switch function */
714 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
715 fvdw = fvdw*sw - rinv00*vvdw*dsw;
719 /* Calculate temporary vectorial force */
724 /* Update vectorial force */
728 f[j_coord_offset+DIM*0+XX] -= tx;
729 f[j_coord_offset+DIM*0+YY] -= ty;
730 f[j_coord_offset+DIM*0+ZZ] -= tz;
734 /**************************
735 * CALCULATE INTERACTIONS *
736 **************************/
745 /* EWALD ELECTROSTATICS */
747 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
748 ewrt = r10*ewtabscale;
752 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
753 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
754 felec = qq10*rinv10*(rinvsq10-felec);
757 d = (d>0.0) ? d : 0.0;
759 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
761 dsw = d2*(swF2+d*(swF3+d*swF4));
763 /* Evaluate switch function */
764 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
765 felec = felec*sw - rinv10*velec*dsw;
769 /* Calculate temporary vectorial force */
774 /* Update vectorial force */
778 f[j_coord_offset+DIM*0+XX] -= tx;
779 f[j_coord_offset+DIM*0+YY] -= ty;
780 f[j_coord_offset+DIM*0+ZZ] -= tz;
784 /**************************
785 * CALCULATE INTERACTIONS *
786 **************************/
795 /* EWALD ELECTROSTATICS */
797 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
798 ewrt = r20*ewtabscale;
802 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
803 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
804 felec = qq20*rinv20*(rinvsq20-felec);
807 d = (d>0.0) ? d : 0.0;
809 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
811 dsw = d2*(swF2+d*(swF3+d*swF4));
813 /* Evaluate switch function */
814 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
815 felec = felec*sw - rinv20*velec*dsw;
819 /* Calculate temporary vectorial force */
824 /* Update vectorial force */
828 f[j_coord_offset+DIM*0+XX] -= tx;
829 f[j_coord_offset+DIM*0+YY] -= ty;
830 f[j_coord_offset+DIM*0+ZZ] -= tz;
834 /**************************
835 * CALCULATE INTERACTIONS *
836 **************************/
845 /* EWALD ELECTROSTATICS */
847 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
848 ewrt = r30*ewtabscale;
852 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
853 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
854 felec = qq30*rinv30*(rinvsq30-felec);
857 d = (d>0.0) ? d : 0.0;
859 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
861 dsw = d2*(swF2+d*(swF3+d*swF4));
863 /* Evaluate switch function */
864 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
865 felec = felec*sw - rinv30*velec*dsw;
869 /* Calculate temporary vectorial force */
874 /* Update vectorial force */
878 f[j_coord_offset+DIM*0+XX] -= tx;
879 f[j_coord_offset+DIM*0+YY] -= ty;
880 f[j_coord_offset+DIM*0+ZZ] -= tz;
884 /* Inner loop uses 222 flops */
886 /* End of innermost loop */
889 f[i_coord_offset+DIM*0+XX] += fix0;
890 f[i_coord_offset+DIM*0+YY] += fiy0;
891 f[i_coord_offset+DIM*0+ZZ] += fiz0;
895 f[i_coord_offset+DIM*1+XX] += fix1;
896 f[i_coord_offset+DIM*1+YY] += fiy1;
897 f[i_coord_offset+DIM*1+ZZ] += fiz1;
901 f[i_coord_offset+DIM*2+XX] += fix2;
902 f[i_coord_offset+DIM*2+YY] += fiy2;
903 f[i_coord_offset+DIM*2+ZZ] += fiz2;
907 f[i_coord_offset+DIM*3+XX] += fix3;
908 f[i_coord_offset+DIM*3+YY] += fiy3;
909 f[i_coord_offset+DIM*3+ZZ] += fiz3;
913 fshift[i_shift_offset+XX] += tx;
914 fshift[i_shift_offset+YY] += ty;
915 fshift[i_shift_offset+ZZ] += tz;
917 /* Increment number of inner iterations */
918 inneriter += j_index_end - j_index_start;
920 /* Outer loop uses 39 flops */
923 /* Increment number of outer iterations */
926 /* Update outer/inner flops */
928 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*222);