Remove nb-parameters from t_forcerec
[gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRF_VdwLJ_GeomW4P1_c.c
blob677f5271daeedcc543fc8869bdc85f7bfdca0278
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_ElecRF_VdwLJ_GeomW4P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
54 void
55 nb_kernel_ElecRF_VdwLJ_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;
91 x = xx[0];
92 f = ff[0];
94 nri = nlist->nri;
95 iinr = nlist->iinr;
96 jindex = nlist->jindex;
97 jjnr = nlist->jjnr;
98 shiftidx = nlist->shift;
99 gid = nlist->gid;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
102 facel = fr->ic->epsfac;
103 charge = mdatoms->chargeA;
104 krf = fr->ic->k_rf;
105 krf2 = krf*2.0;
106 crf = fr->ic->c_rf;
107 nvdwtype = fr->ntype;
108 vdwparam = fr->nbfp;
109 vdwtype = mdatoms->typeA;
111 /* Setup water-specific parameters */
112 inr = nlist->iinr[0];
113 iq1 = facel*charge[inr+1];
114 iq2 = facel*charge[inr+2];
115 iq3 = facel*charge[inr+3];
116 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
118 outeriter = 0;
119 inneriter = 0;
121 /* Start outer loop over neighborlists */
122 for(iidx=0; iidx<nri; iidx++)
124 /* Load shift vector for this list */
125 i_shift_offset = DIM*shiftidx[iidx];
126 shX = shiftvec[i_shift_offset+XX];
127 shY = shiftvec[i_shift_offset+YY];
128 shZ = shiftvec[i_shift_offset+ZZ];
130 /* Load limits for loop over neighbors */
131 j_index_start = jindex[iidx];
132 j_index_end = jindex[iidx+1];
134 /* Get outer coordinate index */
135 inr = iinr[iidx];
136 i_coord_offset = DIM*inr;
138 /* Load i particle coords and add shift vector */
139 ix0 = shX + x[i_coord_offset+DIM*0+XX];
140 iy0 = shY + x[i_coord_offset+DIM*0+YY];
141 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
142 ix1 = shX + x[i_coord_offset+DIM*1+XX];
143 iy1 = shY + x[i_coord_offset+DIM*1+YY];
144 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
145 ix2 = shX + x[i_coord_offset+DIM*2+XX];
146 iy2 = shY + x[i_coord_offset+DIM*2+YY];
147 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
148 ix3 = shX + x[i_coord_offset+DIM*3+XX];
149 iy3 = shY + x[i_coord_offset+DIM*3+YY];
150 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
152 fix0 = 0.0;
153 fiy0 = 0.0;
154 fiz0 = 0.0;
155 fix1 = 0.0;
156 fiy1 = 0.0;
157 fiz1 = 0.0;
158 fix2 = 0.0;
159 fiy2 = 0.0;
160 fiz2 = 0.0;
161 fix3 = 0.0;
162 fiy3 = 0.0;
163 fiz3 = 0.0;
165 /* Reset potential sums */
166 velecsum = 0.0;
167 vvdwsum = 0.0;
169 /* Start inner kernel loop */
170 for(jidx=j_index_start; jidx<j_index_end; jidx++)
172 /* Get j neighbor index, and coordinate index */
173 jnr = jjnr[jidx];
174 j_coord_offset = DIM*jnr;
176 /* load j atom coordinates */
177 jx0 = x[j_coord_offset+DIM*0+XX];
178 jy0 = x[j_coord_offset+DIM*0+YY];
179 jz0 = x[j_coord_offset+DIM*0+ZZ];
181 /* Calculate displacement vector */
182 dx00 = ix0 - jx0;
183 dy00 = iy0 - jy0;
184 dz00 = iz0 - jz0;
185 dx10 = ix1 - jx0;
186 dy10 = iy1 - jy0;
187 dz10 = iz1 - jz0;
188 dx20 = ix2 - jx0;
189 dy20 = iy2 - jy0;
190 dz20 = iz2 - jz0;
191 dx30 = ix3 - jx0;
192 dy30 = iy3 - jy0;
193 dz30 = iz3 - jz0;
195 /* Calculate squared distance and things based on it */
196 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
197 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
198 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
199 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
201 rinv10 = 1.0/sqrt(rsq10);
202 rinv20 = 1.0/sqrt(rsq20);
203 rinv30 = 1.0/sqrt(rsq30);
205 rinvsq00 = 1.0/rsq00;
206 rinvsq10 = rinv10*rinv10;
207 rinvsq20 = rinv20*rinv20;
208 rinvsq30 = rinv30*rinv30;
210 /* Load parameters for j particles */
211 jq0 = charge[jnr+0];
212 vdwjidx0 = 2*vdwtype[jnr+0];
214 /**************************
215 * CALCULATE INTERACTIONS *
216 **************************/
218 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
219 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
221 /* LENNARD-JONES DISPERSION/REPULSION */
223 rinvsix = rinvsq00*rinvsq00*rinvsq00;
224 vvdw6 = c6_00*rinvsix;
225 vvdw12 = c12_00*rinvsix*rinvsix;
226 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
227 fvdw = (vvdw12-vvdw6)*rinvsq00;
229 /* Update potential sums from outer loop */
230 vvdwsum += vvdw;
232 fscal = fvdw;
234 /* Calculate temporary vectorial force */
235 tx = fscal*dx00;
236 ty = fscal*dy00;
237 tz = fscal*dz00;
239 /* Update vectorial force */
240 fix0 += tx;
241 fiy0 += ty;
242 fiz0 += tz;
243 f[j_coord_offset+DIM*0+XX] -= tx;
244 f[j_coord_offset+DIM*0+YY] -= ty;
245 f[j_coord_offset+DIM*0+ZZ] -= tz;
247 /**************************
248 * CALCULATE INTERACTIONS *
249 **************************/
251 qq10 = iq1*jq0;
253 /* REACTION-FIELD ELECTROSTATICS */
254 velec = qq10*(rinv10+krf*rsq10-crf);
255 felec = qq10*(rinv10*rinvsq10-krf2);
257 /* Update potential sums from outer loop */
258 velecsum += velec;
260 fscal = felec;
262 /* Calculate temporary vectorial force */
263 tx = fscal*dx10;
264 ty = fscal*dy10;
265 tz = fscal*dz10;
267 /* Update vectorial force */
268 fix1 += tx;
269 fiy1 += ty;
270 fiz1 += tz;
271 f[j_coord_offset+DIM*0+XX] -= tx;
272 f[j_coord_offset+DIM*0+YY] -= ty;
273 f[j_coord_offset+DIM*0+ZZ] -= tz;
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
279 qq20 = iq2*jq0;
281 /* REACTION-FIELD ELECTROSTATICS */
282 velec = qq20*(rinv20+krf*rsq20-crf);
283 felec = qq20*(rinv20*rinvsq20-krf2);
285 /* Update potential sums from outer loop */
286 velecsum += velec;
288 fscal = felec;
290 /* Calculate temporary vectorial force */
291 tx = fscal*dx20;
292 ty = fscal*dy20;
293 tz = fscal*dz20;
295 /* Update vectorial force */
296 fix2 += tx;
297 fiy2 += ty;
298 fiz2 += tz;
299 f[j_coord_offset+DIM*0+XX] -= tx;
300 f[j_coord_offset+DIM*0+YY] -= ty;
301 f[j_coord_offset+DIM*0+ZZ] -= tz;
303 /**************************
304 * CALCULATE INTERACTIONS *
305 **************************/
307 qq30 = iq3*jq0;
309 /* REACTION-FIELD ELECTROSTATICS */
310 velec = qq30*(rinv30+krf*rsq30-crf);
311 felec = qq30*(rinv30*rinvsq30-krf2);
313 /* Update potential sums from outer loop */
314 velecsum += velec;
316 fscal = felec;
318 /* Calculate temporary vectorial force */
319 tx = fscal*dx30;
320 ty = fscal*dy30;
321 tz = fscal*dz30;
323 /* Update vectorial force */
324 fix3 += tx;
325 fiy3 += ty;
326 fiz3 += 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 /* Inner loop uses 128 flops */
333 /* End of innermost loop */
335 tx = ty = tz = 0;
336 f[i_coord_offset+DIM*0+XX] += fix0;
337 f[i_coord_offset+DIM*0+YY] += fiy0;
338 f[i_coord_offset+DIM*0+ZZ] += fiz0;
339 tx += fix0;
340 ty += fiy0;
341 tz += fiz0;
342 f[i_coord_offset+DIM*1+XX] += fix1;
343 f[i_coord_offset+DIM*1+YY] += fiy1;
344 f[i_coord_offset+DIM*1+ZZ] += fiz1;
345 tx += fix1;
346 ty += fiy1;
347 tz += fiz1;
348 f[i_coord_offset+DIM*2+XX] += fix2;
349 f[i_coord_offset+DIM*2+YY] += fiy2;
350 f[i_coord_offset+DIM*2+ZZ] += fiz2;
351 tx += fix2;
352 ty += fiy2;
353 tz += fiz2;
354 f[i_coord_offset+DIM*3+XX] += fix3;
355 f[i_coord_offset+DIM*3+YY] += fiy3;
356 f[i_coord_offset+DIM*3+ZZ] += fiz3;
357 tx += fix3;
358 ty += fiy3;
359 tz += fiz3;
360 fshift[i_shift_offset+XX] += tx;
361 fshift[i_shift_offset+YY] += ty;
362 fshift[i_shift_offset+ZZ] += tz;
364 ggid = gid[iidx];
365 /* Update potential energies */
366 kernel_data->energygrp_elec[ggid] += velecsum;
367 kernel_data->energygrp_vdw[ggid] += vvdwsum;
369 /* Increment number of inner iterations */
370 inneriter += j_index_end - j_index_start;
372 /* Outer loop uses 41 flops */
375 /* Increment number of outer iterations */
376 outeriter += nri;
378 /* Update outer/inner flops */
380 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*128);
383 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
384 * Electrostatics interaction: ReactionField
385 * VdW interaction: LennardJones
386 * Geometry: Water4-Particle
387 * Calculate force/pot: Force
389 void
390 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
391 (t_nblist * gmx_restrict nlist,
392 rvec * gmx_restrict xx,
393 rvec * gmx_restrict ff,
394 struct t_forcerec * gmx_restrict fr,
395 t_mdatoms * gmx_restrict mdatoms,
396 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
397 t_nrnb * gmx_restrict nrnb)
399 int i_shift_offset,i_coord_offset,j_coord_offset;
400 int j_index_start,j_index_end;
401 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
402 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
403 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
404 real *shiftvec,*fshift,*x,*f;
405 int vdwioffset0;
406 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
407 int vdwioffset1;
408 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
409 int vdwioffset2;
410 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
411 int vdwioffset3;
412 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
413 int vdwjidx0;
414 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
415 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
416 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
417 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
418 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
419 real velec,felec,velecsum,facel,crf,krf,krf2;
420 real *charge;
421 int nvdwtype;
422 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
423 int *vdwtype;
424 real *vdwparam;
426 x = xx[0];
427 f = ff[0];
429 nri = nlist->nri;
430 iinr = nlist->iinr;
431 jindex = nlist->jindex;
432 jjnr = nlist->jjnr;
433 shiftidx = nlist->shift;
434 gid = nlist->gid;
435 shiftvec = fr->shift_vec[0];
436 fshift = fr->fshift[0];
437 facel = fr->ic->epsfac;
438 charge = mdatoms->chargeA;
439 krf = fr->ic->k_rf;
440 krf2 = krf*2.0;
441 crf = fr->ic->c_rf;
442 nvdwtype = fr->ntype;
443 vdwparam = fr->nbfp;
444 vdwtype = mdatoms->typeA;
446 /* Setup water-specific parameters */
447 inr = nlist->iinr[0];
448 iq1 = facel*charge[inr+1];
449 iq2 = facel*charge[inr+2];
450 iq3 = facel*charge[inr+3];
451 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
453 outeriter = 0;
454 inneriter = 0;
456 /* Start outer loop over neighborlists */
457 for(iidx=0; iidx<nri; iidx++)
459 /* Load shift vector for this list */
460 i_shift_offset = DIM*shiftidx[iidx];
461 shX = shiftvec[i_shift_offset+XX];
462 shY = shiftvec[i_shift_offset+YY];
463 shZ = shiftvec[i_shift_offset+ZZ];
465 /* Load limits for loop over neighbors */
466 j_index_start = jindex[iidx];
467 j_index_end = jindex[iidx+1];
469 /* Get outer coordinate index */
470 inr = iinr[iidx];
471 i_coord_offset = DIM*inr;
473 /* Load i particle coords and add shift vector */
474 ix0 = shX + x[i_coord_offset+DIM*0+XX];
475 iy0 = shY + x[i_coord_offset+DIM*0+YY];
476 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
477 ix1 = shX + x[i_coord_offset+DIM*1+XX];
478 iy1 = shY + x[i_coord_offset+DIM*1+YY];
479 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
480 ix2 = shX + x[i_coord_offset+DIM*2+XX];
481 iy2 = shY + x[i_coord_offset+DIM*2+YY];
482 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
483 ix3 = shX + x[i_coord_offset+DIM*3+XX];
484 iy3 = shY + x[i_coord_offset+DIM*3+YY];
485 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
487 fix0 = 0.0;
488 fiy0 = 0.0;
489 fiz0 = 0.0;
490 fix1 = 0.0;
491 fiy1 = 0.0;
492 fiz1 = 0.0;
493 fix2 = 0.0;
494 fiy2 = 0.0;
495 fiz2 = 0.0;
496 fix3 = 0.0;
497 fiy3 = 0.0;
498 fiz3 = 0.0;
500 /* Start inner kernel loop */
501 for(jidx=j_index_start; jidx<j_index_end; jidx++)
503 /* Get j neighbor index, and coordinate index */
504 jnr = jjnr[jidx];
505 j_coord_offset = DIM*jnr;
507 /* load j atom coordinates */
508 jx0 = x[j_coord_offset+DIM*0+XX];
509 jy0 = x[j_coord_offset+DIM*0+YY];
510 jz0 = x[j_coord_offset+DIM*0+ZZ];
512 /* Calculate displacement vector */
513 dx00 = ix0 - jx0;
514 dy00 = iy0 - jy0;
515 dz00 = iz0 - jz0;
516 dx10 = ix1 - jx0;
517 dy10 = iy1 - jy0;
518 dz10 = iz1 - jz0;
519 dx20 = ix2 - jx0;
520 dy20 = iy2 - jy0;
521 dz20 = iz2 - jz0;
522 dx30 = ix3 - jx0;
523 dy30 = iy3 - jy0;
524 dz30 = iz3 - jz0;
526 /* Calculate squared distance and things based on it */
527 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
528 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
529 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
530 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
532 rinv10 = 1.0/sqrt(rsq10);
533 rinv20 = 1.0/sqrt(rsq20);
534 rinv30 = 1.0/sqrt(rsq30);
536 rinvsq00 = 1.0/rsq00;
537 rinvsq10 = rinv10*rinv10;
538 rinvsq20 = rinv20*rinv20;
539 rinvsq30 = rinv30*rinv30;
541 /* Load parameters for j particles */
542 jq0 = charge[jnr+0];
543 vdwjidx0 = 2*vdwtype[jnr+0];
545 /**************************
546 * CALCULATE INTERACTIONS *
547 **************************/
549 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
550 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
552 /* LENNARD-JONES DISPERSION/REPULSION */
554 rinvsix = rinvsq00*rinvsq00*rinvsq00;
555 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
557 fscal = fvdw;
559 /* Calculate temporary vectorial force */
560 tx = fscal*dx00;
561 ty = fscal*dy00;
562 tz = fscal*dz00;
564 /* Update vectorial force */
565 fix0 += tx;
566 fiy0 += ty;
567 fiz0 += tz;
568 f[j_coord_offset+DIM*0+XX] -= tx;
569 f[j_coord_offset+DIM*0+YY] -= ty;
570 f[j_coord_offset+DIM*0+ZZ] -= tz;
572 /**************************
573 * CALCULATE INTERACTIONS *
574 **************************/
576 qq10 = iq1*jq0;
578 /* REACTION-FIELD ELECTROSTATICS */
579 felec = qq10*(rinv10*rinvsq10-krf2);
581 fscal = felec;
583 /* Calculate temporary vectorial force */
584 tx = fscal*dx10;
585 ty = fscal*dy10;
586 tz = fscal*dz10;
588 /* Update vectorial force */
589 fix1 += tx;
590 fiy1 += ty;
591 fiz1 += tz;
592 f[j_coord_offset+DIM*0+XX] -= tx;
593 f[j_coord_offset+DIM*0+YY] -= ty;
594 f[j_coord_offset+DIM*0+ZZ] -= tz;
596 /**************************
597 * CALCULATE INTERACTIONS *
598 **************************/
600 qq20 = iq2*jq0;
602 /* REACTION-FIELD ELECTROSTATICS */
603 felec = qq20*(rinv20*rinvsq20-krf2);
605 fscal = felec;
607 /* Calculate temporary vectorial force */
608 tx = fscal*dx20;
609 ty = fscal*dy20;
610 tz = fscal*dz20;
612 /* Update vectorial force */
613 fix2 += tx;
614 fiy2 += ty;
615 fiz2 += tz;
616 f[j_coord_offset+DIM*0+XX] -= tx;
617 f[j_coord_offset+DIM*0+YY] -= ty;
618 f[j_coord_offset+DIM*0+ZZ] -= tz;
620 /**************************
621 * CALCULATE INTERACTIONS *
622 **************************/
624 qq30 = iq3*jq0;
626 /* REACTION-FIELD ELECTROSTATICS */
627 felec = qq30*(rinv30*rinvsq30-krf2);
629 fscal = felec;
631 /* Calculate temporary vectorial force */
632 tx = fscal*dx30;
633 ty = fscal*dy30;
634 tz = fscal*dz30;
636 /* Update vectorial force */
637 fix3 += tx;
638 fiy3 += ty;
639 fiz3 += tz;
640 f[j_coord_offset+DIM*0+XX] -= tx;
641 f[j_coord_offset+DIM*0+YY] -= ty;
642 f[j_coord_offset+DIM*0+ZZ] -= tz;
644 /* Inner loop uses 108 flops */
646 /* End of innermost loop */
648 tx = ty = tz = 0;
649 f[i_coord_offset+DIM*0+XX] += fix0;
650 f[i_coord_offset+DIM*0+YY] += fiy0;
651 f[i_coord_offset+DIM*0+ZZ] += fiz0;
652 tx += fix0;
653 ty += fiy0;
654 tz += fiz0;
655 f[i_coord_offset+DIM*1+XX] += fix1;
656 f[i_coord_offset+DIM*1+YY] += fiy1;
657 f[i_coord_offset+DIM*1+ZZ] += fiz1;
658 tx += fix1;
659 ty += fiy1;
660 tz += fiz1;
661 f[i_coord_offset+DIM*2+XX] += fix2;
662 f[i_coord_offset+DIM*2+YY] += fiy2;
663 f[i_coord_offset+DIM*2+ZZ] += fiz2;
664 tx += fix2;
665 ty += fiy2;
666 tz += fiz2;
667 f[i_coord_offset+DIM*3+XX] += fix3;
668 f[i_coord_offset+DIM*3+YY] += fiy3;
669 f[i_coord_offset+DIM*3+ZZ] += fiz3;
670 tx += fix3;
671 ty += fiy3;
672 tz += fiz3;
673 fshift[i_shift_offset+XX] += tx;
674 fshift[i_shift_offset+YY] += ty;
675 fshift[i_shift_offset+ZZ] += tz;
677 /* Increment number of inner iterations */
678 inneriter += j_index_end - j_index_start;
680 /* Outer loop uses 39 flops */
683 /* Increment number of outer iterations */
684 outeriter += nri;
686 /* Update outer/inner flops */
688 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);