Remove nb-parameters from t_forcerec
[gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_c.c
blob15618123bdf60852c258792e1b1afdc019ecdf0c
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014.2015,2017, 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 "gmxpre.h"
40 #include "config.h"
42 #include <math.h>
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
54 void
55 nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 struct 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 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;
85 real *charge;
86 int nvdwtype;
87 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
88 int *vdwtype;
89 real *vdwparam;
90 int vfitab;
91 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
92 real *vftab;
94 x = xx[0];
95 f = ff[0];
97 nri = nlist->nri;
98 iinr = nlist->iinr;
99 jindex = nlist->jindex;
100 jjnr = nlist->jjnr;
101 shiftidx = nlist->shift;
102 gid = nlist->gid;
103 shiftvec = fr->shift_vec[0];
104 fshift = fr->fshift[0];
105 facel = fr->ic->epsfac;
106 charge = mdatoms->chargeA;
107 nvdwtype = fr->ntype;
108 vdwparam = fr->nbfp;
109 vdwtype = mdatoms->typeA;
111 vftab = kernel_data->table_elec_vdw->data;
112 vftabscale = kernel_data->table_elec_vdw->scale;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq1 = facel*charge[inr+1];
117 iq2 = facel*charge[inr+2];
118 iq3 = facel*charge[inr+3];
119 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
121 outeriter = 0;
122 inneriter = 0;
124 /* Start outer loop over neighborlists */
125 for(iidx=0; iidx<nri; iidx++)
127 /* Load shift vector for this list */
128 i_shift_offset = DIM*shiftidx[iidx];
129 shX = shiftvec[i_shift_offset+XX];
130 shY = shiftvec[i_shift_offset+YY];
131 shZ = shiftvec[i_shift_offset+ZZ];
133 /* Load limits for loop over neighbors */
134 j_index_start = jindex[iidx];
135 j_index_end = jindex[iidx+1];
137 /* Get outer coordinate index */
138 inr = iinr[iidx];
139 i_coord_offset = DIM*inr;
141 /* Load i particle coords and add shift vector */
142 ix0 = shX + x[i_coord_offset+DIM*0+XX];
143 iy0 = shY + x[i_coord_offset+DIM*0+YY];
144 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
145 ix1 = shX + x[i_coord_offset+DIM*1+XX];
146 iy1 = shY + x[i_coord_offset+DIM*1+YY];
147 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
148 ix2 = shX + x[i_coord_offset+DIM*2+XX];
149 iy2 = shY + x[i_coord_offset+DIM*2+YY];
150 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
151 ix3 = shX + x[i_coord_offset+DIM*3+XX];
152 iy3 = shY + x[i_coord_offset+DIM*3+YY];
153 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
155 fix0 = 0.0;
156 fiy0 = 0.0;
157 fiz0 = 0.0;
158 fix1 = 0.0;
159 fiy1 = 0.0;
160 fiz1 = 0.0;
161 fix2 = 0.0;
162 fiy2 = 0.0;
163 fiz2 = 0.0;
164 fix3 = 0.0;
165 fiy3 = 0.0;
166 fiz3 = 0.0;
168 /* Reset potential sums */
169 velecsum = 0.0;
170 vvdwsum = 0.0;
172 /* Start inner kernel loop */
173 for(jidx=j_index_start; jidx<j_index_end; jidx++)
175 /* Get j neighbor index, and coordinate index */
176 jnr = jjnr[jidx];
177 j_coord_offset = DIM*jnr;
179 /* load j atom coordinates */
180 jx0 = x[j_coord_offset+DIM*0+XX];
181 jy0 = x[j_coord_offset+DIM*0+YY];
182 jz0 = x[j_coord_offset+DIM*0+ZZ];
184 /* Calculate displacement vector */
185 dx00 = ix0 - jx0;
186 dy00 = iy0 - jy0;
187 dz00 = iz0 - jz0;
188 dx10 = ix1 - jx0;
189 dy10 = iy1 - jy0;
190 dz10 = iz1 - jz0;
191 dx20 = ix2 - jx0;
192 dy20 = iy2 - jy0;
193 dz20 = iz2 - jz0;
194 dx30 = ix3 - jx0;
195 dy30 = iy3 - jy0;
196 dz30 = iz3 - jz0;
198 /* Calculate squared distance and things based on it */
199 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
200 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
201 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
202 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
204 rinv00 = 1.0/sqrt(rsq00);
205 rinv10 = 1.0/sqrt(rsq10);
206 rinv20 = 1.0/sqrt(rsq20);
207 rinv30 = 1.0/sqrt(rsq30);
209 /* Load parameters for j particles */
210 jq0 = charge[jnr+0];
211 vdwjidx0 = 2*vdwtype[jnr+0];
213 /**************************
214 * CALCULATE INTERACTIONS *
215 **************************/
217 r00 = rsq00*rinv00;
219 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
220 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
222 /* Calculate table index by multiplying r with table scale and truncate to integer */
223 rt = r00*vftabscale;
224 vfitab = rt;
225 vfeps = rt-vfitab;
226 vfitab = 3*4*vfitab;
228 /* CUBIC SPLINE TABLE DISPERSION */
229 vfitab += 4;
230 Y = vftab[vfitab];
231 F = vftab[vfitab+1];
232 Geps = vfeps*vftab[vfitab+2];
233 Heps2 = vfeps*vfeps*vftab[vfitab+3];
234 Fp = F+Geps+Heps2;
235 VV = Y+vfeps*Fp;
236 vvdw6 = c6_00*VV;
237 FF = Fp+Geps+2.0*Heps2;
238 fvdw6 = c6_00*FF;
240 /* CUBIC SPLINE TABLE REPULSION */
241 Y = vftab[vfitab+4];
242 F = vftab[vfitab+5];
243 Geps = vfeps*vftab[vfitab+6];
244 Heps2 = vfeps*vfeps*vftab[vfitab+7];
245 Fp = F+Geps+Heps2;
246 VV = Y+vfeps*Fp;
247 vvdw12 = c12_00*VV;
248 FF = Fp+Geps+2.0*Heps2;
249 fvdw12 = c12_00*FF;
250 vvdw = vvdw12+vvdw6;
251 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
253 /* Update potential sums from outer loop */
254 vvdwsum += vvdw;
256 fscal = fvdw;
258 /* Calculate temporary vectorial force */
259 tx = fscal*dx00;
260 ty = fscal*dy00;
261 tz = fscal*dz00;
263 /* Update vectorial force */
264 fix0 += tx;
265 fiy0 += ty;
266 fiz0 += tz;
267 f[j_coord_offset+DIM*0+XX] -= tx;
268 f[j_coord_offset+DIM*0+YY] -= ty;
269 f[j_coord_offset+DIM*0+ZZ] -= tz;
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
275 r10 = rsq10*rinv10;
277 qq10 = iq1*jq0;
279 /* Calculate table index by multiplying r with table scale and truncate to integer */
280 rt = r10*vftabscale;
281 vfitab = rt;
282 vfeps = rt-vfitab;
283 vfitab = 3*4*vfitab;
285 /* CUBIC SPLINE TABLE ELECTROSTATICS */
286 Y = vftab[vfitab];
287 F = vftab[vfitab+1];
288 Geps = vfeps*vftab[vfitab+2];
289 Heps2 = vfeps*vfeps*vftab[vfitab+3];
290 Fp = F+Geps+Heps2;
291 VV = Y+vfeps*Fp;
292 velec = qq10*VV;
293 FF = Fp+Geps+2.0*Heps2;
294 felec = -qq10*FF*vftabscale*rinv10;
296 /* Update potential sums from outer loop */
297 velecsum += velec;
299 fscal = felec;
301 /* Calculate temporary vectorial force */
302 tx = fscal*dx10;
303 ty = fscal*dy10;
304 tz = fscal*dz10;
306 /* Update vectorial force */
307 fix1 += tx;
308 fiy1 += ty;
309 fiz1 += tz;
310 f[j_coord_offset+DIM*0+XX] -= tx;
311 f[j_coord_offset+DIM*0+YY] -= ty;
312 f[j_coord_offset+DIM*0+ZZ] -= tz;
314 /**************************
315 * CALCULATE INTERACTIONS *
316 **************************/
318 r20 = rsq20*rinv20;
320 qq20 = iq2*jq0;
322 /* Calculate table index by multiplying r with table scale and truncate to integer */
323 rt = r20*vftabscale;
324 vfitab = rt;
325 vfeps = rt-vfitab;
326 vfitab = 3*4*vfitab;
328 /* CUBIC SPLINE TABLE ELECTROSTATICS */
329 Y = vftab[vfitab];
330 F = vftab[vfitab+1];
331 Geps = vfeps*vftab[vfitab+2];
332 Heps2 = vfeps*vfeps*vftab[vfitab+3];
333 Fp = F+Geps+Heps2;
334 VV = Y+vfeps*Fp;
335 velec = qq20*VV;
336 FF = Fp+Geps+2.0*Heps2;
337 felec = -qq20*FF*vftabscale*rinv20;
339 /* Update potential sums from outer loop */
340 velecsum += velec;
342 fscal = felec;
344 /* Calculate temporary vectorial force */
345 tx = fscal*dx20;
346 ty = fscal*dy20;
347 tz = fscal*dz20;
349 /* Update vectorial force */
350 fix2 += tx;
351 fiy2 += ty;
352 fiz2 += tz;
353 f[j_coord_offset+DIM*0+XX] -= tx;
354 f[j_coord_offset+DIM*0+YY] -= ty;
355 f[j_coord_offset+DIM*0+ZZ] -= tz;
357 /**************************
358 * CALCULATE INTERACTIONS *
359 **************************/
361 r30 = rsq30*rinv30;
363 qq30 = iq3*jq0;
365 /* Calculate table index by multiplying r with table scale and truncate to integer */
366 rt = r30*vftabscale;
367 vfitab = rt;
368 vfeps = rt-vfitab;
369 vfitab = 3*4*vfitab;
371 /* CUBIC SPLINE TABLE ELECTROSTATICS */
372 Y = vftab[vfitab];
373 F = vftab[vfitab+1];
374 Geps = vfeps*vftab[vfitab+2];
375 Heps2 = vfeps*vfeps*vftab[vfitab+3];
376 Fp = F+Geps+Heps2;
377 VV = Y+vfeps*Fp;
378 velec = qq30*VV;
379 FF = Fp+Geps+2.0*Heps2;
380 felec = -qq30*FF*vftabscale*rinv30;
382 /* Update potential sums from outer loop */
383 velecsum += velec;
385 fscal = felec;
387 /* Calculate temporary vectorial force */
388 tx = fscal*dx30;
389 ty = fscal*dy30;
390 tz = fscal*dz30;
392 /* Update vectorial force */
393 fix3 += tx;
394 fiy3 += ty;
395 fiz3 += tz;
396 f[j_coord_offset+DIM*0+XX] -= tx;
397 f[j_coord_offset+DIM*0+YY] -= ty;
398 f[j_coord_offset+DIM*0+ZZ] -= tz;
400 /* Inner loop uses 181 flops */
402 /* End of innermost loop */
404 tx = ty = tz = 0;
405 f[i_coord_offset+DIM*0+XX] += fix0;
406 f[i_coord_offset+DIM*0+YY] += fiy0;
407 f[i_coord_offset+DIM*0+ZZ] += fiz0;
408 tx += fix0;
409 ty += fiy0;
410 tz += fiz0;
411 f[i_coord_offset+DIM*1+XX] += fix1;
412 f[i_coord_offset+DIM*1+YY] += fiy1;
413 f[i_coord_offset+DIM*1+ZZ] += fiz1;
414 tx += fix1;
415 ty += fiy1;
416 tz += fiz1;
417 f[i_coord_offset+DIM*2+XX] += fix2;
418 f[i_coord_offset+DIM*2+YY] += fiy2;
419 f[i_coord_offset+DIM*2+ZZ] += fiz2;
420 tx += fix2;
421 ty += fiy2;
422 tz += fiz2;
423 f[i_coord_offset+DIM*3+XX] += fix3;
424 f[i_coord_offset+DIM*3+YY] += fiy3;
425 f[i_coord_offset+DIM*3+ZZ] += fiz3;
426 tx += fix3;
427 ty += fiy3;
428 tz += fiz3;
429 fshift[i_shift_offset+XX] += tx;
430 fshift[i_shift_offset+YY] += ty;
431 fshift[i_shift_offset+ZZ] += tz;
433 ggid = gid[iidx];
434 /* Update potential energies */
435 kernel_data->energygrp_elec[ggid] += velecsum;
436 kernel_data->energygrp_vdw[ggid] += vvdwsum;
438 /* Increment number of inner iterations */
439 inneriter += j_index_end - j_index_start;
441 /* Outer loop uses 41 flops */
444 /* Increment number of outer iterations */
445 outeriter += nri;
447 /* Update outer/inner flops */
449 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*181);
452 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_F_c
453 * Electrostatics interaction: CubicSplineTable
454 * VdW interaction: CubicSplineTable
455 * Geometry: Water4-Particle
456 * Calculate force/pot: Force
458 void
459 nb_kernel_ElecCSTab_VdwCSTab_GeomW4P1_F_c
460 (t_nblist * gmx_restrict nlist,
461 rvec * gmx_restrict xx,
462 rvec * gmx_restrict ff,
463 struct t_forcerec * gmx_restrict fr,
464 t_mdatoms * gmx_restrict mdatoms,
465 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
466 t_nrnb * gmx_restrict nrnb)
468 int i_shift_offset,i_coord_offset,j_coord_offset;
469 int j_index_start,j_index_end;
470 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
471 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
472 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
473 real *shiftvec,*fshift,*x,*f;
474 int vdwioffset0;
475 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
476 int vdwioffset1;
477 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
478 int vdwioffset2;
479 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
480 int vdwioffset3;
481 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
482 int vdwjidx0;
483 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
484 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
485 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
486 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
487 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
488 real velec,felec,velecsum,facel,crf,krf,krf2;
489 real *charge;
490 int nvdwtype;
491 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
492 int *vdwtype;
493 real *vdwparam;
494 int vfitab;
495 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
496 real *vftab;
498 x = xx[0];
499 f = ff[0];
501 nri = nlist->nri;
502 iinr = nlist->iinr;
503 jindex = nlist->jindex;
504 jjnr = nlist->jjnr;
505 shiftidx = nlist->shift;
506 gid = nlist->gid;
507 shiftvec = fr->shift_vec[0];
508 fshift = fr->fshift[0];
509 facel = fr->ic->epsfac;
510 charge = mdatoms->chargeA;
511 nvdwtype = fr->ntype;
512 vdwparam = fr->nbfp;
513 vdwtype = mdatoms->typeA;
515 vftab = kernel_data->table_elec_vdw->data;
516 vftabscale = kernel_data->table_elec_vdw->scale;
518 /* Setup water-specific parameters */
519 inr = nlist->iinr[0];
520 iq1 = facel*charge[inr+1];
521 iq2 = facel*charge[inr+2];
522 iq3 = facel*charge[inr+3];
523 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
525 outeriter = 0;
526 inneriter = 0;
528 /* Start outer loop over neighborlists */
529 for(iidx=0; iidx<nri; iidx++)
531 /* Load shift vector for this list */
532 i_shift_offset = DIM*shiftidx[iidx];
533 shX = shiftvec[i_shift_offset+XX];
534 shY = shiftvec[i_shift_offset+YY];
535 shZ = shiftvec[i_shift_offset+ZZ];
537 /* Load limits for loop over neighbors */
538 j_index_start = jindex[iidx];
539 j_index_end = jindex[iidx+1];
541 /* Get outer coordinate index */
542 inr = iinr[iidx];
543 i_coord_offset = DIM*inr;
545 /* Load i particle coords and add shift vector */
546 ix0 = shX + x[i_coord_offset+DIM*0+XX];
547 iy0 = shY + x[i_coord_offset+DIM*0+YY];
548 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
549 ix1 = shX + x[i_coord_offset+DIM*1+XX];
550 iy1 = shY + x[i_coord_offset+DIM*1+YY];
551 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
552 ix2 = shX + x[i_coord_offset+DIM*2+XX];
553 iy2 = shY + x[i_coord_offset+DIM*2+YY];
554 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
555 ix3 = shX + x[i_coord_offset+DIM*3+XX];
556 iy3 = shY + x[i_coord_offset+DIM*3+YY];
557 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
559 fix0 = 0.0;
560 fiy0 = 0.0;
561 fiz0 = 0.0;
562 fix1 = 0.0;
563 fiy1 = 0.0;
564 fiz1 = 0.0;
565 fix2 = 0.0;
566 fiy2 = 0.0;
567 fiz2 = 0.0;
568 fix3 = 0.0;
569 fiy3 = 0.0;
570 fiz3 = 0.0;
572 /* Start inner kernel loop */
573 for(jidx=j_index_start; jidx<j_index_end; jidx++)
575 /* Get j neighbor index, and coordinate index */
576 jnr = jjnr[jidx];
577 j_coord_offset = DIM*jnr;
579 /* load j atom coordinates */
580 jx0 = x[j_coord_offset+DIM*0+XX];
581 jy0 = x[j_coord_offset+DIM*0+YY];
582 jz0 = x[j_coord_offset+DIM*0+ZZ];
584 /* Calculate displacement vector */
585 dx00 = ix0 - jx0;
586 dy00 = iy0 - jy0;
587 dz00 = iz0 - jz0;
588 dx10 = ix1 - jx0;
589 dy10 = iy1 - jy0;
590 dz10 = iz1 - jz0;
591 dx20 = ix2 - jx0;
592 dy20 = iy2 - jy0;
593 dz20 = iz2 - jz0;
594 dx30 = ix3 - jx0;
595 dy30 = iy3 - jy0;
596 dz30 = iz3 - jz0;
598 /* Calculate squared distance and things based on it */
599 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
600 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
601 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
602 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
604 rinv00 = 1.0/sqrt(rsq00);
605 rinv10 = 1.0/sqrt(rsq10);
606 rinv20 = 1.0/sqrt(rsq20);
607 rinv30 = 1.0/sqrt(rsq30);
609 /* Load parameters for j particles */
610 jq0 = charge[jnr+0];
611 vdwjidx0 = 2*vdwtype[jnr+0];
613 /**************************
614 * CALCULATE INTERACTIONS *
615 **************************/
617 r00 = rsq00*rinv00;
619 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
620 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
622 /* Calculate table index by multiplying r with table scale and truncate to integer */
623 rt = r00*vftabscale;
624 vfitab = rt;
625 vfeps = rt-vfitab;
626 vfitab = 3*4*vfitab;
628 /* CUBIC SPLINE TABLE DISPERSION */
629 vfitab += 4;
630 F = vftab[vfitab+1];
631 Geps = vfeps*vftab[vfitab+2];
632 Heps2 = vfeps*vfeps*vftab[vfitab+3];
633 Fp = F+Geps+Heps2;
634 FF = Fp+Geps+2.0*Heps2;
635 fvdw6 = c6_00*FF;
637 /* CUBIC SPLINE TABLE REPULSION */
638 F = vftab[vfitab+5];
639 Geps = vfeps*vftab[vfitab+6];
640 Heps2 = vfeps*vfeps*vftab[vfitab+7];
641 Fp = F+Geps+Heps2;
642 FF = Fp+Geps+2.0*Heps2;
643 fvdw12 = c12_00*FF;
644 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
646 fscal = fvdw;
648 /* Calculate temporary vectorial force */
649 tx = fscal*dx00;
650 ty = fscal*dy00;
651 tz = fscal*dz00;
653 /* Update vectorial force */
654 fix0 += tx;
655 fiy0 += ty;
656 fiz0 += tz;
657 f[j_coord_offset+DIM*0+XX] -= tx;
658 f[j_coord_offset+DIM*0+YY] -= ty;
659 f[j_coord_offset+DIM*0+ZZ] -= tz;
661 /**************************
662 * CALCULATE INTERACTIONS *
663 **************************/
665 r10 = rsq10*rinv10;
667 qq10 = iq1*jq0;
669 /* Calculate table index by multiplying r with table scale and truncate to integer */
670 rt = r10*vftabscale;
671 vfitab = rt;
672 vfeps = rt-vfitab;
673 vfitab = 3*4*vfitab;
675 /* CUBIC SPLINE TABLE ELECTROSTATICS */
676 F = vftab[vfitab+1];
677 Geps = vfeps*vftab[vfitab+2];
678 Heps2 = vfeps*vfeps*vftab[vfitab+3];
679 Fp = F+Geps+Heps2;
680 FF = Fp+Geps+2.0*Heps2;
681 felec = -qq10*FF*vftabscale*rinv10;
683 fscal = felec;
685 /* Calculate temporary vectorial force */
686 tx = fscal*dx10;
687 ty = fscal*dy10;
688 tz = fscal*dz10;
690 /* Update vectorial force */
691 fix1 += tx;
692 fiy1 += ty;
693 fiz1 += tz;
694 f[j_coord_offset+DIM*0+XX] -= tx;
695 f[j_coord_offset+DIM*0+YY] -= ty;
696 f[j_coord_offset+DIM*0+ZZ] -= tz;
698 /**************************
699 * CALCULATE INTERACTIONS *
700 **************************/
702 r20 = rsq20*rinv20;
704 qq20 = iq2*jq0;
706 /* Calculate table index by multiplying r with table scale and truncate to integer */
707 rt = r20*vftabscale;
708 vfitab = rt;
709 vfeps = rt-vfitab;
710 vfitab = 3*4*vfitab;
712 /* CUBIC SPLINE TABLE ELECTROSTATICS */
713 F = vftab[vfitab+1];
714 Geps = vfeps*vftab[vfitab+2];
715 Heps2 = vfeps*vfeps*vftab[vfitab+3];
716 Fp = F+Geps+Heps2;
717 FF = Fp+Geps+2.0*Heps2;
718 felec = -qq20*FF*vftabscale*rinv20;
720 fscal = felec;
722 /* Calculate temporary vectorial force */
723 tx = fscal*dx20;
724 ty = fscal*dy20;
725 tz = fscal*dz20;
727 /* Update vectorial force */
728 fix2 += tx;
729 fiy2 += ty;
730 fiz2 += tz;
731 f[j_coord_offset+DIM*0+XX] -= tx;
732 f[j_coord_offset+DIM*0+YY] -= ty;
733 f[j_coord_offset+DIM*0+ZZ] -= tz;
735 /**************************
736 * CALCULATE INTERACTIONS *
737 **************************/
739 r30 = rsq30*rinv30;
741 qq30 = iq3*jq0;
743 /* Calculate table index by multiplying r with table scale and truncate to integer */
744 rt = r30*vftabscale;
745 vfitab = rt;
746 vfeps = rt-vfitab;
747 vfitab = 3*4*vfitab;
749 /* CUBIC SPLINE TABLE ELECTROSTATICS */
750 F = vftab[vfitab+1];
751 Geps = vfeps*vftab[vfitab+2];
752 Heps2 = vfeps*vfeps*vftab[vfitab+3];
753 Fp = F+Geps+Heps2;
754 FF = Fp+Geps+2.0*Heps2;
755 felec = -qq30*FF*vftabscale*rinv30;
757 fscal = felec;
759 /* Calculate temporary vectorial force */
760 tx = fscal*dx30;
761 ty = fscal*dy30;
762 tz = fscal*dz30;
764 /* Update vectorial force */
765 fix3 += tx;
766 fiy3 += ty;
767 fiz3 += tz;
768 f[j_coord_offset+DIM*0+XX] -= tx;
769 f[j_coord_offset+DIM*0+YY] -= ty;
770 f[j_coord_offset+DIM*0+ZZ] -= tz;
772 /* Inner loop uses 161 flops */
774 /* End of innermost loop */
776 tx = ty = tz = 0;
777 f[i_coord_offset+DIM*0+XX] += fix0;
778 f[i_coord_offset+DIM*0+YY] += fiy0;
779 f[i_coord_offset+DIM*0+ZZ] += fiz0;
780 tx += fix0;
781 ty += fiy0;
782 tz += fiz0;
783 f[i_coord_offset+DIM*1+XX] += fix1;
784 f[i_coord_offset+DIM*1+YY] += fiy1;
785 f[i_coord_offset+DIM*1+ZZ] += fiz1;
786 tx += fix1;
787 ty += fiy1;
788 tz += fiz1;
789 f[i_coord_offset+DIM*2+XX] += fix2;
790 f[i_coord_offset+DIM*2+YY] += fiy2;
791 f[i_coord_offset+DIM*2+ZZ] += fiz2;
792 tx += fix2;
793 ty += fiy2;
794 tz += fiz2;
795 f[i_coord_offset+DIM*3+XX] += fix3;
796 f[i_coord_offset+DIM*3+YY] += fiy3;
797 f[i_coord_offset+DIM*3+ZZ] += fiz3;
798 tx += fix3;
799 ty += fiy3;
800 tz += fiz3;
801 fshift[i_shift_offset+XX] += tx;
802 fshift[i_shift_offset+YY] += ty;
803 fshift[i_shift_offset+ZZ] += tz;
805 /* Increment number of inner iterations */
806 inneriter += j_index_end - j_index_start;
808 /* Outer loop uses 39 flops */
811 /* Increment number of outer iterations */
812 outeriter += nri;
814 /* Update outer/inner flops */
816 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*161);