Remove all unnecessary HAVE_CONFIG_H
[gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_c.c
blobd4eceb666fd283a553a261d8447251cd7107da25
1 /*
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.
38 #include "config.h"
40 #include <math.h>
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
54 void
55 nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_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;
70 int vdwioffset0;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72 int vdwioffset1;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74 int vdwioffset2;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76 int vdwioffset3;
77 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
78 int vdwjidx0;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 int vdwjidx1;
81 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
82 int vdwjidx2;
83 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
84 int vdwjidx3;
85 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
86 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
87 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
88 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
89 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
90 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
91 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
92 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
93 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
94 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
95 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
96 real velec,felec,velecsum,facel,crf,krf,krf2;
97 real *charge;
98 int nvdwtype;
99 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
100 int *vdwtype;
101 real *vdwparam;
102 int vfitab;
103 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
104 real *vftab;
106 x = xx[0];
107 f = ff[0];
109 nri = nlist->nri;
110 iinr = nlist->iinr;
111 jindex = nlist->jindex;
112 jjnr = nlist->jjnr;
113 shiftidx = nlist->shift;
114 gid = nlist->gid;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
117 facel = fr->epsfac;
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
120 vdwparam = fr->nbfp;
121 vdwtype = mdatoms->typeA;
123 vftab = kernel_data->table_elec_vdw->data;
124 vftabscale = kernel_data->table_elec_vdw->scale;
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq1 = facel*charge[inr+1];
129 iq2 = facel*charge[inr+2];
130 iq3 = facel*charge[inr+3];
131 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
133 jq1 = charge[inr+1];
134 jq2 = charge[inr+2];
135 jq3 = charge[inr+3];
136 vdwjidx0 = 2*vdwtype[inr+0];
137 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
138 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
139 qq11 = iq1*jq1;
140 qq12 = iq1*jq2;
141 qq13 = iq1*jq3;
142 qq21 = iq2*jq1;
143 qq22 = iq2*jq2;
144 qq23 = iq2*jq3;
145 qq31 = iq3*jq1;
146 qq32 = iq3*jq2;
147 qq33 = iq3*jq3;
149 outeriter = 0;
150 inneriter = 0;
152 /* Start outer loop over neighborlists */
153 for(iidx=0; iidx<nri; iidx++)
155 /* Load shift vector for this list */
156 i_shift_offset = DIM*shiftidx[iidx];
157 shX = shiftvec[i_shift_offset+XX];
158 shY = shiftvec[i_shift_offset+YY];
159 shZ = shiftvec[i_shift_offset+ZZ];
161 /* Load limits for loop over neighbors */
162 j_index_start = jindex[iidx];
163 j_index_end = jindex[iidx+1];
165 /* Get outer coordinate index */
166 inr = iinr[iidx];
167 i_coord_offset = DIM*inr;
169 /* Load i particle coords and add shift vector */
170 ix0 = shX + x[i_coord_offset+DIM*0+XX];
171 iy0 = shY + x[i_coord_offset+DIM*0+YY];
172 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
173 ix1 = shX + x[i_coord_offset+DIM*1+XX];
174 iy1 = shY + x[i_coord_offset+DIM*1+YY];
175 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
176 ix2 = shX + x[i_coord_offset+DIM*2+XX];
177 iy2 = shY + x[i_coord_offset+DIM*2+YY];
178 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
179 ix3 = shX + x[i_coord_offset+DIM*3+XX];
180 iy3 = shY + x[i_coord_offset+DIM*3+YY];
181 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
183 fix0 = 0.0;
184 fiy0 = 0.0;
185 fiz0 = 0.0;
186 fix1 = 0.0;
187 fiy1 = 0.0;
188 fiz1 = 0.0;
189 fix2 = 0.0;
190 fiy2 = 0.0;
191 fiz2 = 0.0;
192 fix3 = 0.0;
193 fiy3 = 0.0;
194 fiz3 = 0.0;
196 /* Reset potential sums */
197 velecsum = 0.0;
198 vvdwsum = 0.0;
200 /* Start inner kernel loop */
201 for(jidx=j_index_start; jidx<j_index_end; jidx++)
203 /* Get j neighbor index, and coordinate index */
204 jnr = jjnr[jidx];
205 j_coord_offset = DIM*jnr;
207 /* load j atom coordinates */
208 jx0 = x[j_coord_offset+DIM*0+XX];
209 jy0 = x[j_coord_offset+DIM*0+YY];
210 jz0 = x[j_coord_offset+DIM*0+ZZ];
211 jx1 = x[j_coord_offset+DIM*1+XX];
212 jy1 = x[j_coord_offset+DIM*1+YY];
213 jz1 = x[j_coord_offset+DIM*1+ZZ];
214 jx2 = x[j_coord_offset+DIM*2+XX];
215 jy2 = x[j_coord_offset+DIM*2+YY];
216 jz2 = x[j_coord_offset+DIM*2+ZZ];
217 jx3 = x[j_coord_offset+DIM*3+XX];
218 jy3 = x[j_coord_offset+DIM*3+YY];
219 jz3 = x[j_coord_offset+DIM*3+ZZ];
221 /* Calculate displacement vector */
222 dx00 = ix0 - jx0;
223 dy00 = iy0 - jy0;
224 dz00 = iz0 - jz0;
225 dx11 = ix1 - jx1;
226 dy11 = iy1 - jy1;
227 dz11 = iz1 - jz1;
228 dx12 = ix1 - jx2;
229 dy12 = iy1 - jy2;
230 dz12 = iz1 - jz2;
231 dx13 = ix1 - jx3;
232 dy13 = iy1 - jy3;
233 dz13 = iz1 - jz3;
234 dx21 = ix2 - jx1;
235 dy21 = iy2 - jy1;
236 dz21 = iz2 - jz1;
237 dx22 = ix2 - jx2;
238 dy22 = iy2 - jy2;
239 dz22 = iz2 - jz2;
240 dx23 = ix2 - jx3;
241 dy23 = iy2 - jy3;
242 dz23 = iz2 - jz3;
243 dx31 = ix3 - jx1;
244 dy31 = iy3 - jy1;
245 dz31 = iz3 - jz1;
246 dx32 = ix3 - jx2;
247 dy32 = iy3 - jy2;
248 dz32 = iz3 - jz2;
249 dx33 = ix3 - jx3;
250 dy33 = iy3 - jy3;
251 dz33 = iz3 - jz3;
253 /* Calculate squared distance and things based on it */
254 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
255 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
256 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
257 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
258 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
259 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
260 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
261 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
262 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
263 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
265 rinv00 = gmx_invsqrt(rsq00);
266 rinv11 = gmx_invsqrt(rsq11);
267 rinv12 = gmx_invsqrt(rsq12);
268 rinv13 = gmx_invsqrt(rsq13);
269 rinv21 = gmx_invsqrt(rsq21);
270 rinv22 = gmx_invsqrt(rsq22);
271 rinv23 = gmx_invsqrt(rsq23);
272 rinv31 = gmx_invsqrt(rsq31);
273 rinv32 = gmx_invsqrt(rsq32);
274 rinv33 = gmx_invsqrt(rsq33);
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
280 r00 = rsq00*rinv00;
282 /* Calculate table index by multiplying r with table scale and truncate to integer */
283 rt = r00*vftabscale;
284 vfitab = rt;
285 vfeps = rt-vfitab;
286 vfitab = 3*4*vfitab;
288 /* CUBIC SPLINE TABLE DISPERSION */
289 vfitab += 4;
290 Y = vftab[vfitab];
291 F = vftab[vfitab+1];
292 Geps = vfeps*vftab[vfitab+2];
293 Heps2 = vfeps*vfeps*vftab[vfitab+3];
294 Fp = F+Geps+Heps2;
295 VV = Y+vfeps*Fp;
296 vvdw6 = c6_00*VV;
297 FF = Fp+Geps+2.0*Heps2;
298 fvdw6 = c6_00*FF;
300 /* CUBIC SPLINE TABLE REPULSION */
301 Y = vftab[vfitab+4];
302 F = vftab[vfitab+5];
303 Geps = vfeps*vftab[vfitab+6];
304 Heps2 = vfeps*vfeps*vftab[vfitab+7];
305 Fp = F+Geps+Heps2;
306 VV = Y+vfeps*Fp;
307 vvdw12 = c12_00*VV;
308 FF = Fp+Geps+2.0*Heps2;
309 fvdw12 = c12_00*FF;
310 vvdw = vvdw12+vvdw6;
311 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
313 /* Update potential sums from outer loop */
314 vvdwsum += vvdw;
316 fscal = fvdw;
318 /* Calculate temporary vectorial force */
319 tx = fscal*dx00;
320 ty = fscal*dy00;
321 tz = fscal*dz00;
323 /* Update vectorial force */
324 fix0 += tx;
325 fiy0 += ty;
326 fiz0 += tz;
327 f[j_coord_offset+DIM*0+XX] -= tx;
328 f[j_coord_offset+DIM*0+YY] -= ty;
329 f[j_coord_offset+DIM*0+ZZ] -= tz;
331 /**************************
332 * CALCULATE INTERACTIONS *
333 **************************/
335 r11 = rsq11*rinv11;
337 /* Calculate table index by multiplying r with table scale and truncate to integer */
338 rt = r11*vftabscale;
339 vfitab = rt;
340 vfeps = rt-vfitab;
341 vfitab = 3*4*vfitab;
343 /* CUBIC SPLINE TABLE ELECTROSTATICS */
344 Y = vftab[vfitab];
345 F = vftab[vfitab+1];
346 Geps = vfeps*vftab[vfitab+2];
347 Heps2 = vfeps*vfeps*vftab[vfitab+3];
348 Fp = F+Geps+Heps2;
349 VV = Y+vfeps*Fp;
350 velec = qq11*VV;
351 FF = Fp+Geps+2.0*Heps2;
352 felec = -qq11*FF*vftabscale*rinv11;
354 /* Update potential sums from outer loop */
355 velecsum += velec;
357 fscal = felec;
359 /* Calculate temporary vectorial force */
360 tx = fscal*dx11;
361 ty = fscal*dy11;
362 tz = fscal*dz11;
364 /* Update vectorial force */
365 fix1 += tx;
366 fiy1 += ty;
367 fiz1 += tz;
368 f[j_coord_offset+DIM*1+XX] -= tx;
369 f[j_coord_offset+DIM*1+YY] -= ty;
370 f[j_coord_offset+DIM*1+ZZ] -= tz;
372 /**************************
373 * CALCULATE INTERACTIONS *
374 **************************/
376 r12 = rsq12*rinv12;
378 /* Calculate table index by multiplying r with table scale and truncate to integer */
379 rt = r12*vftabscale;
380 vfitab = rt;
381 vfeps = rt-vfitab;
382 vfitab = 3*4*vfitab;
384 /* CUBIC SPLINE TABLE ELECTROSTATICS */
385 Y = vftab[vfitab];
386 F = vftab[vfitab+1];
387 Geps = vfeps*vftab[vfitab+2];
388 Heps2 = vfeps*vfeps*vftab[vfitab+3];
389 Fp = F+Geps+Heps2;
390 VV = Y+vfeps*Fp;
391 velec = qq12*VV;
392 FF = Fp+Geps+2.0*Heps2;
393 felec = -qq12*FF*vftabscale*rinv12;
395 /* Update potential sums from outer loop */
396 velecsum += velec;
398 fscal = felec;
400 /* Calculate temporary vectorial force */
401 tx = fscal*dx12;
402 ty = fscal*dy12;
403 tz = fscal*dz12;
405 /* Update vectorial force */
406 fix1 += tx;
407 fiy1 += ty;
408 fiz1 += tz;
409 f[j_coord_offset+DIM*2+XX] -= tx;
410 f[j_coord_offset+DIM*2+YY] -= ty;
411 f[j_coord_offset+DIM*2+ZZ] -= tz;
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
417 r13 = rsq13*rinv13;
419 /* Calculate table index by multiplying r with table scale and truncate to integer */
420 rt = r13*vftabscale;
421 vfitab = rt;
422 vfeps = rt-vfitab;
423 vfitab = 3*4*vfitab;
425 /* CUBIC SPLINE TABLE ELECTROSTATICS */
426 Y = vftab[vfitab];
427 F = vftab[vfitab+1];
428 Geps = vfeps*vftab[vfitab+2];
429 Heps2 = vfeps*vfeps*vftab[vfitab+3];
430 Fp = F+Geps+Heps2;
431 VV = Y+vfeps*Fp;
432 velec = qq13*VV;
433 FF = Fp+Geps+2.0*Heps2;
434 felec = -qq13*FF*vftabscale*rinv13;
436 /* Update potential sums from outer loop */
437 velecsum += velec;
439 fscal = felec;
441 /* Calculate temporary vectorial force */
442 tx = fscal*dx13;
443 ty = fscal*dy13;
444 tz = fscal*dz13;
446 /* Update vectorial force */
447 fix1 += tx;
448 fiy1 += ty;
449 fiz1 += tz;
450 f[j_coord_offset+DIM*3+XX] -= tx;
451 f[j_coord_offset+DIM*3+YY] -= ty;
452 f[j_coord_offset+DIM*3+ZZ] -= tz;
454 /**************************
455 * CALCULATE INTERACTIONS *
456 **************************/
458 r21 = rsq21*rinv21;
460 /* Calculate table index by multiplying r with table scale and truncate to integer */
461 rt = r21*vftabscale;
462 vfitab = rt;
463 vfeps = rt-vfitab;
464 vfitab = 3*4*vfitab;
466 /* CUBIC SPLINE TABLE ELECTROSTATICS */
467 Y = vftab[vfitab];
468 F = vftab[vfitab+1];
469 Geps = vfeps*vftab[vfitab+2];
470 Heps2 = vfeps*vfeps*vftab[vfitab+3];
471 Fp = F+Geps+Heps2;
472 VV = Y+vfeps*Fp;
473 velec = qq21*VV;
474 FF = Fp+Geps+2.0*Heps2;
475 felec = -qq21*FF*vftabscale*rinv21;
477 /* Update potential sums from outer loop */
478 velecsum += velec;
480 fscal = felec;
482 /* Calculate temporary vectorial force */
483 tx = fscal*dx21;
484 ty = fscal*dy21;
485 tz = fscal*dz21;
487 /* Update vectorial force */
488 fix2 += tx;
489 fiy2 += ty;
490 fiz2 += tz;
491 f[j_coord_offset+DIM*1+XX] -= tx;
492 f[j_coord_offset+DIM*1+YY] -= ty;
493 f[j_coord_offset+DIM*1+ZZ] -= tz;
495 /**************************
496 * CALCULATE INTERACTIONS *
497 **************************/
499 r22 = rsq22*rinv22;
501 /* Calculate table index by multiplying r with table scale and truncate to integer */
502 rt = r22*vftabscale;
503 vfitab = rt;
504 vfeps = rt-vfitab;
505 vfitab = 3*4*vfitab;
507 /* CUBIC SPLINE TABLE ELECTROSTATICS */
508 Y = vftab[vfitab];
509 F = vftab[vfitab+1];
510 Geps = vfeps*vftab[vfitab+2];
511 Heps2 = vfeps*vfeps*vftab[vfitab+3];
512 Fp = F+Geps+Heps2;
513 VV = Y+vfeps*Fp;
514 velec = qq22*VV;
515 FF = Fp+Geps+2.0*Heps2;
516 felec = -qq22*FF*vftabscale*rinv22;
518 /* Update potential sums from outer loop */
519 velecsum += velec;
521 fscal = felec;
523 /* Calculate temporary vectorial force */
524 tx = fscal*dx22;
525 ty = fscal*dy22;
526 tz = fscal*dz22;
528 /* Update vectorial force */
529 fix2 += tx;
530 fiy2 += ty;
531 fiz2 += tz;
532 f[j_coord_offset+DIM*2+XX] -= tx;
533 f[j_coord_offset+DIM*2+YY] -= ty;
534 f[j_coord_offset+DIM*2+ZZ] -= tz;
536 /**************************
537 * CALCULATE INTERACTIONS *
538 **************************/
540 r23 = rsq23*rinv23;
542 /* Calculate table index by multiplying r with table scale and truncate to integer */
543 rt = r23*vftabscale;
544 vfitab = rt;
545 vfeps = rt-vfitab;
546 vfitab = 3*4*vfitab;
548 /* CUBIC SPLINE TABLE ELECTROSTATICS */
549 Y = vftab[vfitab];
550 F = vftab[vfitab+1];
551 Geps = vfeps*vftab[vfitab+2];
552 Heps2 = vfeps*vfeps*vftab[vfitab+3];
553 Fp = F+Geps+Heps2;
554 VV = Y+vfeps*Fp;
555 velec = qq23*VV;
556 FF = Fp+Geps+2.0*Heps2;
557 felec = -qq23*FF*vftabscale*rinv23;
559 /* Update potential sums from outer loop */
560 velecsum += velec;
562 fscal = felec;
564 /* Calculate temporary vectorial force */
565 tx = fscal*dx23;
566 ty = fscal*dy23;
567 tz = fscal*dz23;
569 /* Update vectorial force */
570 fix2 += tx;
571 fiy2 += ty;
572 fiz2 += tz;
573 f[j_coord_offset+DIM*3+XX] -= tx;
574 f[j_coord_offset+DIM*3+YY] -= ty;
575 f[j_coord_offset+DIM*3+ZZ] -= tz;
577 /**************************
578 * CALCULATE INTERACTIONS *
579 **************************/
581 r31 = rsq31*rinv31;
583 /* Calculate table index by multiplying r with table scale and truncate to integer */
584 rt = r31*vftabscale;
585 vfitab = rt;
586 vfeps = rt-vfitab;
587 vfitab = 3*4*vfitab;
589 /* CUBIC SPLINE TABLE ELECTROSTATICS */
590 Y = vftab[vfitab];
591 F = vftab[vfitab+1];
592 Geps = vfeps*vftab[vfitab+2];
593 Heps2 = vfeps*vfeps*vftab[vfitab+3];
594 Fp = F+Geps+Heps2;
595 VV = Y+vfeps*Fp;
596 velec = qq31*VV;
597 FF = Fp+Geps+2.0*Heps2;
598 felec = -qq31*FF*vftabscale*rinv31;
600 /* Update potential sums from outer loop */
601 velecsum += velec;
603 fscal = felec;
605 /* Calculate temporary vectorial force */
606 tx = fscal*dx31;
607 ty = fscal*dy31;
608 tz = fscal*dz31;
610 /* Update vectorial force */
611 fix3 += tx;
612 fiy3 += ty;
613 fiz3 += tz;
614 f[j_coord_offset+DIM*1+XX] -= tx;
615 f[j_coord_offset+DIM*1+YY] -= ty;
616 f[j_coord_offset+DIM*1+ZZ] -= tz;
618 /**************************
619 * CALCULATE INTERACTIONS *
620 **************************/
622 r32 = rsq32*rinv32;
624 /* Calculate table index by multiplying r with table scale and truncate to integer */
625 rt = r32*vftabscale;
626 vfitab = rt;
627 vfeps = rt-vfitab;
628 vfitab = 3*4*vfitab;
630 /* CUBIC SPLINE TABLE ELECTROSTATICS */
631 Y = vftab[vfitab];
632 F = vftab[vfitab+1];
633 Geps = vfeps*vftab[vfitab+2];
634 Heps2 = vfeps*vfeps*vftab[vfitab+3];
635 Fp = F+Geps+Heps2;
636 VV = Y+vfeps*Fp;
637 velec = qq32*VV;
638 FF = Fp+Geps+2.0*Heps2;
639 felec = -qq32*FF*vftabscale*rinv32;
641 /* Update potential sums from outer loop */
642 velecsum += velec;
644 fscal = felec;
646 /* Calculate temporary vectorial force */
647 tx = fscal*dx32;
648 ty = fscal*dy32;
649 tz = fscal*dz32;
651 /* Update vectorial force */
652 fix3 += tx;
653 fiy3 += ty;
654 fiz3 += tz;
655 f[j_coord_offset+DIM*2+XX] -= tx;
656 f[j_coord_offset+DIM*2+YY] -= ty;
657 f[j_coord_offset+DIM*2+ZZ] -= tz;
659 /**************************
660 * CALCULATE INTERACTIONS *
661 **************************/
663 r33 = rsq33*rinv33;
665 /* Calculate table index by multiplying r with table scale and truncate to integer */
666 rt = r33*vftabscale;
667 vfitab = rt;
668 vfeps = rt-vfitab;
669 vfitab = 3*4*vfitab;
671 /* CUBIC SPLINE TABLE ELECTROSTATICS */
672 Y = vftab[vfitab];
673 F = vftab[vfitab+1];
674 Geps = vfeps*vftab[vfitab+2];
675 Heps2 = vfeps*vfeps*vftab[vfitab+3];
676 Fp = F+Geps+Heps2;
677 VV = Y+vfeps*Fp;
678 velec = qq33*VV;
679 FF = Fp+Geps+2.0*Heps2;
680 felec = -qq33*FF*vftabscale*rinv33;
682 /* Update potential sums from outer loop */
683 velecsum += velec;
685 fscal = felec;
687 /* Calculate temporary vectorial force */
688 tx = fscal*dx33;
689 ty = fscal*dy33;
690 tz = fscal*dz33;
692 /* Update vectorial force */
693 fix3 += tx;
694 fiy3 += ty;
695 fiz3 += tz;
696 f[j_coord_offset+DIM*3+XX] -= tx;
697 f[j_coord_offset+DIM*3+YY] -= ty;
698 f[j_coord_offset+DIM*3+ZZ] -= tz;
700 /* Inner loop uses 424 flops */
702 /* End of innermost loop */
704 tx = ty = tz = 0;
705 f[i_coord_offset+DIM*0+XX] += fix0;
706 f[i_coord_offset+DIM*0+YY] += fiy0;
707 f[i_coord_offset+DIM*0+ZZ] += fiz0;
708 tx += fix0;
709 ty += fiy0;
710 tz += fiz0;
711 f[i_coord_offset+DIM*1+XX] += fix1;
712 f[i_coord_offset+DIM*1+YY] += fiy1;
713 f[i_coord_offset+DIM*1+ZZ] += fiz1;
714 tx += fix1;
715 ty += fiy1;
716 tz += fiz1;
717 f[i_coord_offset+DIM*2+XX] += fix2;
718 f[i_coord_offset+DIM*2+YY] += fiy2;
719 f[i_coord_offset+DIM*2+ZZ] += fiz2;
720 tx += fix2;
721 ty += fiy2;
722 tz += fiz2;
723 f[i_coord_offset+DIM*3+XX] += fix3;
724 f[i_coord_offset+DIM*3+YY] += fiy3;
725 f[i_coord_offset+DIM*3+ZZ] += fiz3;
726 tx += fix3;
727 ty += fiy3;
728 tz += fiz3;
729 fshift[i_shift_offset+XX] += tx;
730 fshift[i_shift_offset+YY] += ty;
731 fshift[i_shift_offset+ZZ] += tz;
733 ggid = gid[iidx];
734 /* Update potential energies */
735 kernel_data->energygrp_elec[ggid] += velecsum;
736 kernel_data->energygrp_vdw[ggid] += vvdwsum;
738 /* Increment number of inner iterations */
739 inneriter += j_index_end - j_index_start;
741 /* Outer loop uses 41 flops */
744 /* Increment number of outer iterations */
745 outeriter += nri;
747 /* Update outer/inner flops */
749 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*424);
752 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_F_c
753 * Electrostatics interaction: CubicSplineTable
754 * VdW interaction: CubicSplineTable
755 * Geometry: Water4-Water4
756 * Calculate force/pot: Force
758 void
759 nb_kernel_ElecCSTab_VdwCSTab_GeomW4W4_F_c
760 (t_nblist * gmx_restrict nlist,
761 rvec * gmx_restrict xx,
762 rvec * gmx_restrict ff,
763 t_forcerec * gmx_restrict fr,
764 t_mdatoms * gmx_restrict mdatoms,
765 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
766 t_nrnb * gmx_restrict nrnb)
768 int i_shift_offset,i_coord_offset,j_coord_offset;
769 int j_index_start,j_index_end;
770 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
771 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
772 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
773 real *shiftvec,*fshift,*x,*f;
774 int vdwioffset0;
775 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
776 int vdwioffset1;
777 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
778 int vdwioffset2;
779 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
780 int vdwioffset3;
781 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
782 int vdwjidx0;
783 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
784 int vdwjidx1;
785 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
786 int vdwjidx2;
787 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
788 int vdwjidx3;
789 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
790 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
791 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
792 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
793 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
794 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
795 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
796 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
797 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
798 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
799 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
800 real velec,felec,velecsum,facel,crf,krf,krf2;
801 real *charge;
802 int nvdwtype;
803 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
804 int *vdwtype;
805 real *vdwparam;
806 int vfitab;
807 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
808 real *vftab;
810 x = xx[0];
811 f = ff[0];
813 nri = nlist->nri;
814 iinr = nlist->iinr;
815 jindex = nlist->jindex;
816 jjnr = nlist->jjnr;
817 shiftidx = nlist->shift;
818 gid = nlist->gid;
819 shiftvec = fr->shift_vec[0];
820 fshift = fr->fshift[0];
821 facel = fr->epsfac;
822 charge = mdatoms->chargeA;
823 nvdwtype = fr->ntype;
824 vdwparam = fr->nbfp;
825 vdwtype = mdatoms->typeA;
827 vftab = kernel_data->table_elec_vdw->data;
828 vftabscale = kernel_data->table_elec_vdw->scale;
830 /* Setup water-specific parameters */
831 inr = nlist->iinr[0];
832 iq1 = facel*charge[inr+1];
833 iq2 = facel*charge[inr+2];
834 iq3 = facel*charge[inr+3];
835 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
837 jq1 = charge[inr+1];
838 jq2 = charge[inr+2];
839 jq3 = charge[inr+3];
840 vdwjidx0 = 2*vdwtype[inr+0];
841 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
842 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
843 qq11 = iq1*jq1;
844 qq12 = iq1*jq2;
845 qq13 = iq1*jq3;
846 qq21 = iq2*jq1;
847 qq22 = iq2*jq2;
848 qq23 = iq2*jq3;
849 qq31 = iq3*jq1;
850 qq32 = iq3*jq2;
851 qq33 = iq3*jq3;
853 outeriter = 0;
854 inneriter = 0;
856 /* Start outer loop over neighborlists */
857 for(iidx=0; iidx<nri; iidx++)
859 /* Load shift vector for this list */
860 i_shift_offset = DIM*shiftidx[iidx];
861 shX = shiftvec[i_shift_offset+XX];
862 shY = shiftvec[i_shift_offset+YY];
863 shZ = shiftvec[i_shift_offset+ZZ];
865 /* Load limits for loop over neighbors */
866 j_index_start = jindex[iidx];
867 j_index_end = jindex[iidx+1];
869 /* Get outer coordinate index */
870 inr = iinr[iidx];
871 i_coord_offset = DIM*inr;
873 /* Load i particle coords and add shift vector */
874 ix0 = shX + x[i_coord_offset+DIM*0+XX];
875 iy0 = shY + x[i_coord_offset+DIM*0+YY];
876 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
877 ix1 = shX + x[i_coord_offset+DIM*1+XX];
878 iy1 = shY + x[i_coord_offset+DIM*1+YY];
879 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
880 ix2 = shX + x[i_coord_offset+DIM*2+XX];
881 iy2 = shY + x[i_coord_offset+DIM*2+YY];
882 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
883 ix3 = shX + x[i_coord_offset+DIM*3+XX];
884 iy3 = shY + x[i_coord_offset+DIM*3+YY];
885 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
887 fix0 = 0.0;
888 fiy0 = 0.0;
889 fiz0 = 0.0;
890 fix1 = 0.0;
891 fiy1 = 0.0;
892 fiz1 = 0.0;
893 fix2 = 0.0;
894 fiy2 = 0.0;
895 fiz2 = 0.0;
896 fix3 = 0.0;
897 fiy3 = 0.0;
898 fiz3 = 0.0;
900 /* Start inner kernel loop */
901 for(jidx=j_index_start; jidx<j_index_end; jidx++)
903 /* Get j neighbor index, and coordinate index */
904 jnr = jjnr[jidx];
905 j_coord_offset = DIM*jnr;
907 /* load j atom coordinates */
908 jx0 = x[j_coord_offset+DIM*0+XX];
909 jy0 = x[j_coord_offset+DIM*0+YY];
910 jz0 = x[j_coord_offset+DIM*0+ZZ];
911 jx1 = x[j_coord_offset+DIM*1+XX];
912 jy1 = x[j_coord_offset+DIM*1+YY];
913 jz1 = x[j_coord_offset+DIM*1+ZZ];
914 jx2 = x[j_coord_offset+DIM*2+XX];
915 jy2 = x[j_coord_offset+DIM*2+YY];
916 jz2 = x[j_coord_offset+DIM*2+ZZ];
917 jx3 = x[j_coord_offset+DIM*3+XX];
918 jy3 = x[j_coord_offset+DIM*3+YY];
919 jz3 = x[j_coord_offset+DIM*3+ZZ];
921 /* Calculate displacement vector */
922 dx00 = ix0 - jx0;
923 dy00 = iy0 - jy0;
924 dz00 = iz0 - jz0;
925 dx11 = ix1 - jx1;
926 dy11 = iy1 - jy1;
927 dz11 = iz1 - jz1;
928 dx12 = ix1 - jx2;
929 dy12 = iy1 - jy2;
930 dz12 = iz1 - jz2;
931 dx13 = ix1 - jx3;
932 dy13 = iy1 - jy3;
933 dz13 = iz1 - jz3;
934 dx21 = ix2 - jx1;
935 dy21 = iy2 - jy1;
936 dz21 = iz2 - jz1;
937 dx22 = ix2 - jx2;
938 dy22 = iy2 - jy2;
939 dz22 = iz2 - jz2;
940 dx23 = ix2 - jx3;
941 dy23 = iy2 - jy3;
942 dz23 = iz2 - jz3;
943 dx31 = ix3 - jx1;
944 dy31 = iy3 - jy1;
945 dz31 = iz3 - jz1;
946 dx32 = ix3 - jx2;
947 dy32 = iy3 - jy2;
948 dz32 = iz3 - jz2;
949 dx33 = ix3 - jx3;
950 dy33 = iy3 - jy3;
951 dz33 = iz3 - jz3;
953 /* Calculate squared distance and things based on it */
954 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
955 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
956 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
957 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
958 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
959 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
960 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
961 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
962 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
963 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
965 rinv00 = gmx_invsqrt(rsq00);
966 rinv11 = gmx_invsqrt(rsq11);
967 rinv12 = gmx_invsqrt(rsq12);
968 rinv13 = gmx_invsqrt(rsq13);
969 rinv21 = gmx_invsqrt(rsq21);
970 rinv22 = gmx_invsqrt(rsq22);
971 rinv23 = gmx_invsqrt(rsq23);
972 rinv31 = gmx_invsqrt(rsq31);
973 rinv32 = gmx_invsqrt(rsq32);
974 rinv33 = gmx_invsqrt(rsq33);
976 /**************************
977 * CALCULATE INTERACTIONS *
978 **************************/
980 r00 = rsq00*rinv00;
982 /* Calculate table index by multiplying r with table scale and truncate to integer */
983 rt = r00*vftabscale;
984 vfitab = rt;
985 vfeps = rt-vfitab;
986 vfitab = 3*4*vfitab;
988 /* CUBIC SPLINE TABLE DISPERSION */
989 vfitab += 4;
990 F = vftab[vfitab+1];
991 Geps = vfeps*vftab[vfitab+2];
992 Heps2 = vfeps*vfeps*vftab[vfitab+3];
993 Fp = F+Geps+Heps2;
994 FF = Fp+Geps+2.0*Heps2;
995 fvdw6 = c6_00*FF;
997 /* CUBIC SPLINE TABLE REPULSION */
998 F = vftab[vfitab+5];
999 Geps = vfeps*vftab[vfitab+6];
1000 Heps2 = vfeps*vfeps*vftab[vfitab+7];
1001 Fp = F+Geps+Heps2;
1002 FF = Fp+Geps+2.0*Heps2;
1003 fvdw12 = c12_00*FF;
1004 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
1006 fscal = fvdw;
1008 /* Calculate temporary vectorial force */
1009 tx = fscal*dx00;
1010 ty = fscal*dy00;
1011 tz = fscal*dz00;
1013 /* Update vectorial force */
1014 fix0 += tx;
1015 fiy0 += ty;
1016 fiz0 += tz;
1017 f[j_coord_offset+DIM*0+XX] -= tx;
1018 f[j_coord_offset+DIM*0+YY] -= ty;
1019 f[j_coord_offset+DIM*0+ZZ] -= tz;
1021 /**************************
1022 * CALCULATE INTERACTIONS *
1023 **************************/
1025 r11 = rsq11*rinv11;
1027 /* Calculate table index by multiplying r with table scale and truncate to integer */
1028 rt = r11*vftabscale;
1029 vfitab = rt;
1030 vfeps = rt-vfitab;
1031 vfitab = 3*4*vfitab;
1033 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1034 F = vftab[vfitab+1];
1035 Geps = vfeps*vftab[vfitab+2];
1036 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1037 Fp = F+Geps+Heps2;
1038 FF = Fp+Geps+2.0*Heps2;
1039 felec = -qq11*FF*vftabscale*rinv11;
1041 fscal = felec;
1043 /* Calculate temporary vectorial force */
1044 tx = fscal*dx11;
1045 ty = fscal*dy11;
1046 tz = fscal*dz11;
1048 /* Update vectorial force */
1049 fix1 += tx;
1050 fiy1 += ty;
1051 fiz1 += tz;
1052 f[j_coord_offset+DIM*1+XX] -= tx;
1053 f[j_coord_offset+DIM*1+YY] -= ty;
1054 f[j_coord_offset+DIM*1+ZZ] -= tz;
1056 /**************************
1057 * CALCULATE INTERACTIONS *
1058 **************************/
1060 r12 = rsq12*rinv12;
1062 /* Calculate table index by multiplying r with table scale and truncate to integer */
1063 rt = r12*vftabscale;
1064 vfitab = rt;
1065 vfeps = rt-vfitab;
1066 vfitab = 3*4*vfitab;
1068 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1069 F = vftab[vfitab+1];
1070 Geps = vfeps*vftab[vfitab+2];
1071 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1072 Fp = F+Geps+Heps2;
1073 FF = Fp+Geps+2.0*Heps2;
1074 felec = -qq12*FF*vftabscale*rinv12;
1076 fscal = felec;
1078 /* Calculate temporary vectorial force */
1079 tx = fscal*dx12;
1080 ty = fscal*dy12;
1081 tz = fscal*dz12;
1083 /* Update vectorial force */
1084 fix1 += tx;
1085 fiy1 += ty;
1086 fiz1 += tz;
1087 f[j_coord_offset+DIM*2+XX] -= tx;
1088 f[j_coord_offset+DIM*2+YY] -= ty;
1089 f[j_coord_offset+DIM*2+ZZ] -= tz;
1091 /**************************
1092 * CALCULATE INTERACTIONS *
1093 **************************/
1095 r13 = rsq13*rinv13;
1097 /* Calculate table index by multiplying r with table scale and truncate to integer */
1098 rt = r13*vftabscale;
1099 vfitab = rt;
1100 vfeps = rt-vfitab;
1101 vfitab = 3*4*vfitab;
1103 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1104 F = vftab[vfitab+1];
1105 Geps = vfeps*vftab[vfitab+2];
1106 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1107 Fp = F+Geps+Heps2;
1108 FF = Fp+Geps+2.0*Heps2;
1109 felec = -qq13*FF*vftabscale*rinv13;
1111 fscal = felec;
1113 /* Calculate temporary vectorial force */
1114 tx = fscal*dx13;
1115 ty = fscal*dy13;
1116 tz = fscal*dz13;
1118 /* Update vectorial force */
1119 fix1 += tx;
1120 fiy1 += ty;
1121 fiz1 += tz;
1122 f[j_coord_offset+DIM*3+XX] -= tx;
1123 f[j_coord_offset+DIM*3+YY] -= ty;
1124 f[j_coord_offset+DIM*3+ZZ] -= tz;
1126 /**************************
1127 * CALCULATE INTERACTIONS *
1128 **************************/
1130 r21 = rsq21*rinv21;
1132 /* Calculate table index by multiplying r with table scale and truncate to integer */
1133 rt = r21*vftabscale;
1134 vfitab = rt;
1135 vfeps = rt-vfitab;
1136 vfitab = 3*4*vfitab;
1138 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1139 F = vftab[vfitab+1];
1140 Geps = vfeps*vftab[vfitab+2];
1141 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1142 Fp = F+Geps+Heps2;
1143 FF = Fp+Geps+2.0*Heps2;
1144 felec = -qq21*FF*vftabscale*rinv21;
1146 fscal = felec;
1148 /* Calculate temporary vectorial force */
1149 tx = fscal*dx21;
1150 ty = fscal*dy21;
1151 tz = fscal*dz21;
1153 /* Update vectorial force */
1154 fix2 += tx;
1155 fiy2 += ty;
1156 fiz2 += tz;
1157 f[j_coord_offset+DIM*1+XX] -= tx;
1158 f[j_coord_offset+DIM*1+YY] -= ty;
1159 f[j_coord_offset+DIM*1+ZZ] -= tz;
1161 /**************************
1162 * CALCULATE INTERACTIONS *
1163 **************************/
1165 r22 = rsq22*rinv22;
1167 /* Calculate table index by multiplying r with table scale and truncate to integer */
1168 rt = r22*vftabscale;
1169 vfitab = rt;
1170 vfeps = rt-vfitab;
1171 vfitab = 3*4*vfitab;
1173 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1174 F = vftab[vfitab+1];
1175 Geps = vfeps*vftab[vfitab+2];
1176 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1177 Fp = F+Geps+Heps2;
1178 FF = Fp+Geps+2.0*Heps2;
1179 felec = -qq22*FF*vftabscale*rinv22;
1181 fscal = felec;
1183 /* Calculate temporary vectorial force */
1184 tx = fscal*dx22;
1185 ty = fscal*dy22;
1186 tz = fscal*dz22;
1188 /* Update vectorial force */
1189 fix2 += tx;
1190 fiy2 += ty;
1191 fiz2 += tz;
1192 f[j_coord_offset+DIM*2+XX] -= tx;
1193 f[j_coord_offset+DIM*2+YY] -= ty;
1194 f[j_coord_offset+DIM*2+ZZ] -= tz;
1196 /**************************
1197 * CALCULATE INTERACTIONS *
1198 **************************/
1200 r23 = rsq23*rinv23;
1202 /* Calculate table index by multiplying r with table scale and truncate to integer */
1203 rt = r23*vftabscale;
1204 vfitab = rt;
1205 vfeps = rt-vfitab;
1206 vfitab = 3*4*vfitab;
1208 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1209 F = vftab[vfitab+1];
1210 Geps = vfeps*vftab[vfitab+2];
1211 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1212 Fp = F+Geps+Heps2;
1213 FF = Fp+Geps+2.0*Heps2;
1214 felec = -qq23*FF*vftabscale*rinv23;
1216 fscal = felec;
1218 /* Calculate temporary vectorial force */
1219 tx = fscal*dx23;
1220 ty = fscal*dy23;
1221 tz = fscal*dz23;
1223 /* Update vectorial force */
1224 fix2 += tx;
1225 fiy2 += ty;
1226 fiz2 += tz;
1227 f[j_coord_offset+DIM*3+XX] -= tx;
1228 f[j_coord_offset+DIM*3+YY] -= ty;
1229 f[j_coord_offset+DIM*3+ZZ] -= tz;
1231 /**************************
1232 * CALCULATE INTERACTIONS *
1233 **************************/
1235 r31 = rsq31*rinv31;
1237 /* Calculate table index by multiplying r with table scale and truncate to integer */
1238 rt = r31*vftabscale;
1239 vfitab = rt;
1240 vfeps = rt-vfitab;
1241 vfitab = 3*4*vfitab;
1243 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1244 F = vftab[vfitab+1];
1245 Geps = vfeps*vftab[vfitab+2];
1246 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1247 Fp = F+Geps+Heps2;
1248 FF = Fp+Geps+2.0*Heps2;
1249 felec = -qq31*FF*vftabscale*rinv31;
1251 fscal = felec;
1253 /* Calculate temporary vectorial force */
1254 tx = fscal*dx31;
1255 ty = fscal*dy31;
1256 tz = fscal*dz31;
1258 /* Update vectorial force */
1259 fix3 += tx;
1260 fiy3 += ty;
1261 fiz3 += tz;
1262 f[j_coord_offset+DIM*1+XX] -= tx;
1263 f[j_coord_offset+DIM*1+YY] -= ty;
1264 f[j_coord_offset+DIM*1+ZZ] -= tz;
1266 /**************************
1267 * CALCULATE INTERACTIONS *
1268 **************************/
1270 r32 = rsq32*rinv32;
1272 /* Calculate table index by multiplying r with table scale and truncate to integer */
1273 rt = r32*vftabscale;
1274 vfitab = rt;
1275 vfeps = rt-vfitab;
1276 vfitab = 3*4*vfitab;
1278 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1279 F = vftab[vfitab+1];
1280 Geps = vfeps*vftab[vfitab+2];
1281 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1282 Fp = F+Geps+Heps2;
1283 FF = Fp+Geps+2.0*Heps2;
1284 felec = -qq32*FF*vftabscale*rinv32;
1286 fscal = felec;
1288 /* Calculate temporary vectorial force */
1289 tx = fscal*dx32;
1290 ty = fscal*dy32;
1291 tz = fscal*dz32;
1293 /* Update vectorial force */
1294 fix3 += tx;
1295 fiy3 += ty;
1296 fiz3 += tz;
1297 f[j_coord_offset+DIM*2+XX] -= tx;
1298 f[j_coord_offset+DIM*2+YY] -= ty;
1299 f[j_coord_offset+DIM*2+ZZ] -= tz;
1301 /**************************
1302 * CALCULATE INTERACTIONS *
1303 **************************/
1305 r33 = rsq33*rinv33;
1307 /* Calculate table index by multiplying r with table scale and truncate to integer */
1308 rt = r33*vftabscale;
1309 vfitab = rt;
1310 vfeps = rt-vfitab;
1311 vfitab = 3*4*vfitab;
1313 /* CUBIC SPLINE TABLE ELECTROSTATICS */
1314 F = vftab[vfitab+1];
1315 Geps = vfeps*vftab[vfitab+2];
1316 Heps2 = vfeps*vfeps*vftab[vfitab+3];
1317 Fp = F+Geps+Heps2;
1318 FF = Fp+Geps+2.0*Heps2;
1319 felec = -qq33*FF*vftabscale*rinv33;
1321 fscal = felec;
1323 /* Calculate temporary vectorial force */
1324 tx = fscal*dx33;
1325 ty = fscal*dy33;
1326 tz = fscal*dz33;
1328 /* Update vectorial force */
1329 fix3 += tx;
1330 fiy3 += ty;
1331 fiz3 += tz;
1332 f[j_coord_offset+DIM*3+XX] -= tx;
1333 f[j_coord_offset+DIM*3+YY] -= ty;
1334 f[j_coord_offset+DIM*3+ZZ] -= tz;
1336 /* Inner loop uses 380 flops */
1338 /* End of innermost loop */
1340 tx = ty = tz = 0;
1341 f[i_coord_offset+DIM*0+XX] += fix0;
1342 f[i_coord_offset+DIM*0+YY] += fiy0;
1343 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1344 tx += fix0;
1345 ty += fiy0;
1346 tz += fiz0;
1347 f[i_coord_offset+DIM*1+XX] += fix1;
1348 f[i_coord_offset+DIM*1+YY] += fiy1;
1349 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1350 tx += fix1;
1351 ty += fiy1;
1352 tz += fiz1;
1353 f[i_coord_offset+DIM*2+XX] += fix2;
1354 f[i_coord_offset+DIM*2+YY] += fiy2;
1355 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1356 tx += fix2;
1357 ty += fiy2;
1358 tz += fiz2;
1359 f[i_coord_offset+DIM*3+XX] += fix3;
1360 f[i_coord_offset+DIM*3+YY] += fiy3;
1361 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1362 tx += fix3;
1363 ty += fiy3;
1364 tz += fiz3;
1365 fshift[i_shift_offset+XX] += tx;
1366 fshift[i_shift_offset+YY] += ty;
1367 fshift[i_shift_offset+ZZ] += tz;
1369 /* Increment number of inner iterations */
1370 inneriter += j_index_end - j_index_start;
1372 /* Outer loop uses 39 flops */
1375 /* Increment number of outer iterations */
1376 outeriter += nri;
1378 /* Update outer/inner flops */
1380 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*380);