File: | gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_c.c |
Location: | line 495, column 5 |
Description: | Value stored to 'gid' is never read |
1 | /* |
2 | * This file is part of the GROMACS molecular simulation package. |
3 | * |
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. |
8 | * |
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. |
13 | * |
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. |
18 | * |
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. |
23 | * |
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. |
31 | * |
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. |
34 | */ |
35 | /* |
36 | * Note: this file was generated by the GROMACS c kernel generator. |
37 | */ |
38 | #ifdef HAVE_CONFIG_H1 |
39 | #include <config.h> |
40 | #endif |
41 | |
42 | #include <math.h> |
43 | |
44 | #include "../nb_kernel.h" |
45 | #include "types/simple.h" |
46 | #include "gromacs/math/vec.h" |
47 | #include "nrnb.h" |
48 | |
49 | /* |
50 | * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_VF_c |
51 | * Electrostatics interaction: Ewald |
52 | * VdW interaction: LennardJones |
53 | * Geometry: Water3-Particle |
54 | * Calculate force/pot: PotentialAndForce |
55 | */ |
56 | void |
57 | nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_VF_c |
58 | (t_nblist * gmx_restrict__restrict nlist, |
59 | rvec * gmx_restrict__restrict xx, |
60 | rvec * gmx_restrict__restrict ff, |
61 | t_forcerec * gmx_restrict__restrict fr, |
62 | t_mdatoms * gmx_restrict__restrict mdatoms, |
63 | nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict__restrict kernel_data, |
64 | t_nrnb * gmx_restrict__restrict nrnb) |
65 | { |
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; |
72 | int vdwioffset0; |
73 | real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0; |
74 | int vdwioffset1; |
75 | real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1; |
76 | int vdwioffset2; |
77 | real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2; |
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 velec,felec,velecsum,facel,crf,krf,krf2; |
84 | real *charge; |
85 | int nvdwtype; |
86 | real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6; |
87 | int *vdwtype; |
88 | real *vdwparam; |
89 | int ewitab; |
90 | real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace; |
91 | real *ewtab; |
92 | real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw; |
93 | |
94 | x = xx[0]; |
95 | f = ff[0]; |
96 | |
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->epsfac; |
106 | charge = mdatoms->chargeA; |
107 | nvdwtype = fr->ntype; |
108 | vdwparam = fr->nbfp; |
109 | vdwtype = mdatoms->typeA; |
110 | |
111 | sh_ewald = fr->ic->sh_ewald; |
112 | ewtab = fr->ic->tabq_coul_FDV0; |
113 | ewtabscale = fr->ic->tabq_scale; |
114 | ewtabhalfspace = 0.5/ewtabscale; |
115 | |
116 | /* Setup water-specific parameters */ |
117 | inr = nlist->iinr[0]; |
118 | iq0 = facel*charge[inr+0]; |
119 | iq1 = facel*charge[inr+1]; |
120 | iq2 = facel*charge[inr+2]; |
121 | vdwioffset0 = 2*nvdwtype*vdwtype[inr+0]; |
122 | |
123 | /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */ |
124 | rcutoff = fr->rcoulomb; |
125 | rcutoff2 = rcutoff*rcutoff; |
126 | |
127 | rswitch = fr->rcoulomb_switch; |
128 | /* Setup switch parameters */ |
129 | d = rcutoff-rswitch; |
130 | swV3 = -10.0/(d*d*d); |
131 | swV4 = 15.0/(d*d*d*d); |
132 | swV5 = -6.0/(d*d*d*d*d); |
133 | swF2 = -30.0/(d*d*d); |
134 | swF3 = 60.0/(d*d*d*d); |
135 | swF4 = -30.0/(d*d*d*d*d); |
136 | |
137 | outeriter = 0; |
138 | inneriter = 0; |
139 | |
140 | /* Start outer loop over neighborlists */ |
141 | for(iidx=0; iidx<nri; iidx++) |
142 | { |
143 | /* Load shift vector for this list */ |
144 | i_shift_offset = DIM3*shiftidx[iidx]; |
145 | shX = shiftvec[i_shift_offset+XX0]; |
146 | shY = shiftvec[i_shift_offset+YY1]; |
147 | shZ = shiftvec[i_shift_offset+ZZ2]; |
148 | |
149 | /* Load limits for loop over neighbors */ |
150 | j_index_start = jindex[iidx]; |
151 | j_index_end = jindex[iidx+1]; |
152 | |
153 | /* Get outer coordinate index */ |
154 | inr = iinr[iidx]; |
155 | i_coord_offset = DIM3*inr; |
156 | |
157 | /* Load i particle coords and add shift vector */ |
158 | ix0 = shX + x[i_coord_offset+DIM3*0+XX0]; |
159 | iy0 = shY + x[i_coord_offset+DIM3*0+YY1]; |
160 | iz0 = shZ + x[i_coord_offset+DIM3*0+ZZ2]; |
161 | ix1 = shX + x[i_coord_offset+DIM3*1+XX0]; |
162 | iy1 = shY + x[i_coord_offset+DIM3*1+YY1]; |
163 | iz1 = shZ + x[i_coord_offset+DIM3*1+ZZ2]; |
164 | ix2 = shX + x[i_coord_offset+DIM3*2+XX0]; |
165 | iy2 = shY + x[i_coord_offset+DIM3*2+YY1]; |
166 | iz2 = shZ + x[i_coord_offset+DIM3*2+ZZ2]; |
167 | |
168 | fix0 = 0.0; |
169 | fiy0 = 0.0; |
170 | fiz0 = 0.0; |
171 | fix1 = 0.0; |
172 | fiy1 = 0.0; |
173 | fiz1 = 0.0; |
174 | fix2 = 0.0; |
175 | fiy2 = 0.0; |
176 | fiz2 = 0.0; |
177 | |
178 | /* Reset potential sums */ |
179 | velecsum = 0.0; |
180 | vvdwsum = 0.0; |
181 | |
182 | /* Start inner kernel loop */ |
183 | for(jidx=j_index_start; jidx<j_index_end; jidx++) |
184 | { |
185 | /* Get j neighbor index, and coordinate index */ |
186 | jnr = jjnr[jidx]; |
187 | j_coord_offset = DIM3*jnr; |
188 | |
189 | /* load j atom coordinates */ |
190 | jx0 = x[j_coord_offset+DIM3*0+XX0]; |
191 | jy0 = x[j_coord_offset+DIM3*0+YY1]; |
192 | jz0 = x[j_coord_offset+DIM3*0+ZZ2]; |
193 | |
194 | /* Calculate displacement vector */ |
195 | dx00 = ix0 - jx0; |
196 | dy00 = iy0 - jy0; |
197 | dz00 = iz0 - jz0; |
198 | dx10 = ix1 - jx0; |
199 | dy10 = iy1 - jy0; |
200 | dz10 = iz1 - jz0; |
201 | dx20 = ix2 - jx0; |
202 | dy20 = iy2 - jy0; |
203 | dz20 = iz2 - jz0; |
204 | |
205 | /* Calculate squared distance and things based on it */ |
206 | rsq00 = dx00*dx00+dy00*dy00+dz00*dz00; |
207 | rsq10 = dx10*dx10+dy10*dy10+dz10*dz10; |
208 | rsq20 = dx20*dx20+dy20*dy20+dz20*dz20; |
209 | |
210 | rinv00 = gmx_invsqrt(rsq00)gmx_software_invsqrt(rsq00); |
211 | rinv10 = gmx_invsqrt(rsq10)gmx_software_invsqrt(rsq10); |
212 | rinv20 = gmx_invsqrt(rsq20)gmx_software_invsqrt(rsq20); |
213 | |
214 | rinvsq00 = rinv00*rinv00; |
215 | rinvsq10 = rinv10*rinv10; |
216 | rinvsq20 = rinv20*rinv20; |
217 | |
218 | /* Load parameters for j particles */ |
219 | jq0 = charge[jnr+0]; |
220 | vdwjidx0 = 2*vdwtype[jnr+0]; |
221 | |
222 | /************************** |
223 | * CALCULATE INTERACTIONS * |
224 | **************************/ |
225 | |
226 | if (rsq00<rcutoff2) |
227 | { |
228 | |
229 | r00 = rsq00*rinv00; |
230 | |
231 | qq00 = iq0*jq0; |
232 | c6_00 = vdwparam[vdwioffset0+vdwjidx0]; |
233 | c12_00 = vdwparam[vdwioffset0+vdwjidx0+1]; |
234 | |
235 | /* EWALD ELECTROSTATICS */ |
236 | |
237 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
238 | ewrt = r00*ewtabscale; |
239 | ewitab = ewrt; |
240 | eweps = ewrt-ewitab; |
241 | ewitab = 4*ewitab; |
242 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
243 | velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
244 | felec = qq00*rinv00*(rinvsq00-felec); |
245 | |
246 | /* LENNARD-JONES DISPERSION/REPULSION */ |
247 | |
248 | rinvsix = rinvsq00*rinvsq00*rinvsq00; |
249 | vvdw6 = c6_00*rinvsix; |
250 | vvdw12 = c12_00*rinvsix*rinvsix; |
251 | vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0); |
252 | fvdw = (vvdw12-vvdw6)*rinvsq00; |
253 | |
254 | d = r00-rswitch; |
255 | d = (d>0.0) ? d : 0.0; |
256 | d2 = d*d; |
257 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
258 | |
259 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
260 | |
261 | /* Evaluate switch function */ |
262 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
263 | felec = felec*sw - rinv00*velec*dsw; |
264 | fvdw = fvdw*sw - rinv00*vvdw*dsw; |
265 | velec *= sw; |
266 | vvdw *= sw; |
267 | |
268 | /* Update potential sums from outer loop */ |
269 | velecsum += velec; |
270 | vvdwsum += vvdw; |
271 | |
272 | fscal = felec+fvdw; |
273 | |
274 | /* Calculate temporary vectorial force */ |
275 | tx = fscal*dx00; |
276 | ty = fscal*dy00; |
277 | tz = fscal*dz00; |
278 | |
279 | /* Update vectorial force */ |
280 | fix0 += tx; |
281 | fiy0 += ty; |
282 | fiz0 += tz; |
283 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
284 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
285 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
286 | |
287 | } |
288 | |
289 | /************************** |
290 | * CALCULATE INTERACTIONS * |
291 | **************************/ |
292 | |
293 | if (rsq10<rcutoff2) |
294 | { |
295 | |
296 | r10 = rsq10*rinv10; |
297 | |
298 | qq10 = iq1*jq0; |
299 | |
300 | /* EWALD ELECTROSTATICS */ |
301 | |
302 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
303 | ewrt = r10*ewtabscale; |
304 | ewitab = ewrt; |
305 | eweps = ewrt-ewitab; |
306 | ewitab = 4*ewitab; |
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); |
310 | |
311 | d = r10-rswitch; |
312 | d = (d>0.0) ? d : 0.0; |
313 | d2 = d*d; |
314 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
315 | |
316 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
317 | |
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; |
321 | velec *= sw; |
322 | |
323 | /* Update potential sums from outer loop */ |
324 | velecsum += velec; |
325 | |
326 | fscal = felec; |
327 | |
328 | /* Calculate temporary vectorial force */ |
329 | tx = fscal*dx10; |
330 | ty = fscal*dy10; |
331 | tz = fscal*dz10; |
332 | |
333 | /* Update vectorial force */ |
334 | fix1 += tx; |
335 | fiy1 += ty; |
336 | fiz1 += tz; |
337 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
338 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
339 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
340 | |
341 | } |
342 | |
343 | /************************** |
344 | * CALCULATE INTERACTIONS * |
345 | **************************/ |
346 | |
347 | if (rsq20<rcutoff2) |
348 | { |
349 | |
350 | r20 = rsq20*rinv20; |
351 | |
352 | qq20 = iq2*jq0; |
353 | |
354 | /* EWALD ELECTROSTATICS */ |
355 | |
356 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
357 | ewrt = r20*ewtabscale; |
358 | ewitab = ewrt; |
359 | eweps = ewrt-ewitab; |
360 | ewitab = 4*ewitab; |
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); |
364 | |
365 | d = r20-rswitch; |
366 | d = (d>0.0) ? d : 0.0; |
367 | d2 = d*d; |
368 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
369 | |
370 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
371 | |
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; |
375 | velec *= sw; |
376 | |
377 | /* Update potential sums from outer loop */ |
378 | velecsum += velec; |
379 | |
380 | fscal = felec; |
381 | |
382 | /* Calculate temporary vectorial force */ |
383 | tx = fscal*dx20; |
384 | ty = fscal*dy20; |
385 | tz = fscal*dz20; |
386 | |
387 | /* Update vectorial force */ |
388 | fix2 += tx; |
389 | fiy2 += ty; |
390 | fiz2 += tz; |
391 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
392 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
393 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
394 | |
395 | } |
396 | |
397 | /* Inner loop uses 193 flops */ |
398 | } |
399 | /* End of innermost loop */ |
400 | |
401 | tx = ty = tz = 0; |
402 | f[i_coord_offset+DIM3*0+XX0] += fix0; |
403 | f[i_coord_offset+DIM3*0+YY1] += fiy0; |
404 | f[i_coord_offset+DIM3*0+ZZ2] += fiz0; |
405 | tx += fix0; |
406 | ty += fiy0; |
407 | tz += fiz0; |
408 | f[i_coord_offset+DIM3*1+XX0] += fix1; |
409 | f[i_coord_offset+DIM3*1+YY1] += fiy1; |
410 | f[i_coord_offset+DIM3*1+ZZ2] += fiz1; |
411 | tx += fix1; |
412 | ty += fiy1; |
413 | tz += fiz1; |
414 | f[i_coord_offset+DIM3*2+XX0] += fix2; |
415 | f[i_coord_offset+DIM3*2+YY1] += fiy2; |
416 | f[i_coord_offset+DIM3*2+ZZ2] += fiz2; |
417 | tx += fix2; |
418 | ty += fiy2; |
419 | tz += fiz2; |
420 | fshift[i_shift_offset+XX0] += tx; |
421 | fshift[i_shift_offset+YY1] += ty; |
422 | fshift[i_shift_offset+ZZ2] += tz; |
423 | |
424 | ggid = gid[iidx]; |
425 | /* Update potential energies */ |
426 | kernel_data->energygrp_elec[ggid] += velecsum; |
427 | kernel_data->energygrp_vdw[ggid] += vvdwsum; |
428 | |
429 | /* Increment number of inner iterations */ |
430 | inneriter += j_index_end - j_index_start; |
431 | |
432 | /* Outer loop uses 32 flops */ |
433 | } |
434 | |
435 | /* Increment number of outer iterations */ |
436 | outeriter += nri; |
437 | |
438 | /* Update outer/inner flops */ |
439 | |
440 | inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*193)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_W3_VF] += outeriter*32 + inneriter *193; |
441 | } |
442 | /* |
443 | * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_F_c |
444 | * Electrostatics interaction: Ewald |
445 | * VdW interaction: LennardJones |
446 | * Geometry: Water3-Particle |
447 | * Calculate force/pot: Force |
448 | */ |
449 | void |
450 | nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_F_c |
451 | (t_nblist * gmx_restrict__restrict nlist, |
452 | rvec * gmx_restrict__restrict xx, |
453 | rvec * gmx_restrict__restrict ff, |
454 | t_forcerec * gmx_restrict__restrict fr, |
455 | t_mdatoms * gmx_restrict__restrict mdatoms, |
456 | nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict__restrict kernel_data, |
457 | t_nrnb * gmx_restrict__restrict nrnb) |
458 | { |
459 | int i_shift_offset,i_coord_offset,j_coord_offset; |
460 | int j_index_start,j_index_end; |
461 | int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter; |
462 | real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2; |
463 | int *iinr,*jindex,*jjnr,*shiftidx,*gid; |
464 | real *shiftvec,*fshift,*x,*f; |
465 | int vdwioffset0; |
466 | real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0; |
467 | int vdwioffset1; |
468 | real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1; |
469 | int vdwioffset2; |
470 | real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2; |
471 | int vdwjidx0; |
472 | real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0; |
473 | real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00; |
474 | real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10; |
475 | real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20; |
476 | real velec,felec,velecsum,facel,crf,krf,krf2; |
477 | real *charge; |
478 | int nvdwtype; |
479 | real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6; |
480 | int *vdwtype; |
481 | real *vdwparam; |
482 | int ewitab; |
483 | real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace; |
484 | real *ewtab; |
485 | real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw; |
486 | |
487 | x = xx[0]; |
488 | f = ff[0]; |
489 | |
490 | nri = nlist->nri; |
491 | iinr = nlist->iinr; |
492 | jindex = nlist->jindex; |
493 | jjnr = nlist->jjnr; |
494 | shiftidx = nlist->shift; |
495 | gid = nlist->gid; |
Value stored to 'gid' is never read | |
496 | shiftvec = fr->shift_vec[0]; |
497 | fshift = fr->fshift[0]; |
498 | facel = fr->epsfac; |
499 | charge = mdatoms->chargeA; |
500 | nvdwtype = fr->ntype; |
501 | vdwparam = fr->nbfp; |
502 | vdwtype = mdatoms->typeA; |
503 | |
504 | sh_ewald = fr->ic->sh_ewald; |
505 | ewtab = fr->ic->tabq_coul_FDV0; |
506 | ewtabscale = fr->ic->tabq_scale; |
507 | ewtabhalfspace = 0.5/ewtabscale; |
508 | |
509 | /* Setup water-specific parameters */ |
510 | inr = nlist->iinr[0]; |
511 | iq0 = facel*charge[inr+0]; |
512 | iq1 = facel*charge[inr+1]; |
513 | iq2 = facel*charge[inr+2]; |
514 | vdwioffset0 = 2*nvdwtype*vdwtype[inr+0]; |
515 | |
516 | /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */ |
517 | rcutoff = fr->rcoulomb; |
518 | rcutoff2 = rcutoff*rcutoff; |
519 | |
520 | rswitch = fr->rcoulomb_switch; |
521 | /* Setup switch parameters */ |
522 | d = rcutoff-rswitch; |
523 | swV3 = -10.0/(d*d*d); |
524 | swV4 = 15.0/(d*d*d*d); |
525 | swV5 = -6.0/(d*d*d*d*d); |
526 | swF2 = -30.0/(d*d*d); |
527 | swF3 = 60.0/(d*d*d*d); |
528 | swF4 = -30.0/(d*d*d*d*d); |
529 | |
530 | outeriter = 0; |
531 | inneriter = 0; |
532 | |
533 | /* Start outer loop over neighborlists */ |
534 | for(iidx=0; iidx<nri; iidx++) |
535 | { |
536 | /* Load shift vector for this list */ |
537 | i_shift_offset = DIM3*shiftidx[iidx]; |
538 | shX = shiftvec[i_shift_offset+XX0]; |
539 | shY = shiftvec[i_shift_offset+YY1]; |
540 | shZ = shiftvec[i_shift_offset+ZZ2]; |
541 | |
542 | /* Load limits for loop over neighbors */ |
543 | j_index_start = jindex[iidx]; |
544 | j_index_end = jindex[iidx+1]; |
545 | |
546 | /* Get outer coordinate index */ |
547 | inr = iinr[iidx]; |
548 | i_coord_offset = DIM3*inr; |
549 | |
550 | /* Load i particle coords and add shift vector */ |
551 | ix0 = shX + x[i_coord_offset+DIM3*0+XX0]; |
552 | iy0 = shY + x[i_coord_offset+DIM3*0+YY1]; |
553 | iz0 = shZ + x[i_coord_offset+DIM3*0+ZZ2]; |
554 | ix1 = shX + x[i_coord_offset+DIM3*1+XX0]; |
555 | iy1 = shY + x[i_coord_offset+DIM3*1+YY1]; |
556 | iz1 = shZ + x[i_coord_offset+DIM3*1+ZZ2]; |
557 | ix2 = shX + x[i_coord_offset+DIM3*2+XX0]; |
558 | iy2 = shY + x[i_coord_offset+DIM3*2+YY1]; |
559 | iz2 = shZ + x[i_coord_offset+DIM3*2+ZZ2]; |
560 | |
561 | fix0 = 0.0; |
562 | fiy0 = 0.0; |
563 | fiz0 = 0.0; |
564 | fix1 = 0.0; |
565 | fiy1 = 0.0; |
566 | fiz1 = 0.0; |
567 | fix2 = 0.0; |
568 | fiy2 = 0.0; |
569 | fiz2 = 0.0; |
570 | |
571 | /* Start inner kernel loop */ |
572 | for(jidx=j_index_start; jidx<j_index_end; jidx++) |
573 | { |
574 | /* Get j neighbor index, and coordinate index */ |
575 | jnr = jjnr[jidx]; |
576 | j_coord_offset = DIM3*jnr; |
577 | |
578 | /* load j atom coordinates */ |
579 | jx0 = x[j_coord_offset+DIM3*0+XX0]; |
580 | jy0 = x[j_coord_offset+DIM3*0+YY1]; |
581 | jz0 = x[j_coord_offset+DIM3*0+ZZ2]; |
582 | |
583 | /* Calculate displacement vector */ |
584 | dx00 = ix0 - jx0; |
585 | dy00 = iy0 - jy0; |
586 | dz00 = iz0 - jz0; |
587 | dx10 = ix1 - jx0; |
588 | dy10 = iy1 - jy0; |
589 | dz10 = iz1 - jz0; |
590 | dx20 = ix2 - jx0; |
591 | dy20 = iy2 - jy0; |
592 | dz20 = iz2 - jz0; |
593 | |
594 | /* Calculate squared distance and things based on it */ |
595 | rsq00 = dx00*dx00+dy00*dy00+dz00*dz00; |
596 | rsq10 = dx10*dx10+dy10*dy10+dz10*dz10; |
597 | rsq20 = dx20*dx20+dy20*dy20+dz20*dz20; |
598 | |
599 | rinv00 = gmx_invsqrt(rsq00)gmx_software_invsqrt(rsq00); |
600 | rinv10 = gmx_invsqrt(rsq10)gmx_software_invsqrt(rsq10); |
601 | rinv20 = gmx_invsqrt(rsq20)gmx_software_invsqrt(rsq20); |
602 | |
603 | rinvsq00 = rinv00*rinv00; |
604 | rinvsq10 = rinv10*rinv10; |
605 | rinvsq20 = rinv20*rinv20; |
606 | |
607 | /* Load parameters for j particles */ |
608 | jq0 = charge[jnr+0]; |
609 | vdwjidx0 = 2*vdwtype[jnr+0]; |
610 | |
611 | /************************** |
612 | * CALCULATE INTERACTIONS * |
613 | **************************/ |
614 | |
615 | if (rsq00<rcutoff2) |
616 | { |
617 | |
618 | r00 = rsq00*rinv00; |
619 | |
620 | qq00 = iq0*jq0; |
621 | c6_00 = vdwparam[vdwioffset0+vdwjidx0]; |
622 | c12_00 = vdwparam[vdwioffset0+vdwjidx0+1]; |
623 | |
624 | /* EWALD ELECTROSTATICS */ |
625 | |
626 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
627 | ewrt = r00*ewtabscale; |
628 | ewitab = ewrt; |
629 | eweps = ewrt-ewitab; |
630 | ewitab = 4*ewitab; |
631 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
632 | velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
633 | felec = qq00*rinv00*(rinvsq00-felec); |
634 | |
635 | /* LENNARD-JONES DISPERSION/REPULSION */ |
636 | |
637 | rinvsix = rinvsq00*rinvsq00*rinvsq00; |
638 | vvdw6 = c6_00*rinvsix; |
639 | vvdw12 = c12_00*rinvsix*rinvsix; |
640 | vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0); |
641 | fvdw = (vvdw12-vvdw6)*rinvsq00; |
642 | |
643 | d = r00-rswitch; |
644 | d = (d>0.0) ? d : 0.0; |
645 | d2 = d*d; |
646 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
647 | |
648 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
649 | |
650 | /* Evaluate switch function */ |
651 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
652 | felec = felec*sw - rinv00*velec*dsw; |
653 | fvdw = fvdw*sw - rinv00*vvdw*dsw; |
654 | |
655 | fscal = felec+fvdw; |
656 | |
657 | /* Calculate temporary vectorial force */ |
658 | tx = fscal*dx00; |
659 | ty = fscal*dy00; |
660 | tz = fscal*dz00; |
661 | |
662 | /* Update vectorial force */ |
663 | fix0 += tx; |
664 | fiy0 += ty; |
665 | fiz0 += tz; |
666 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
667 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
668 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
669 | |
670 | } |
671 | |
672 | /************************** |
673 | * CALCULATE INTERACTIONS * |
674 | **************************/ |
675 | |
676 | if (rsq10<rcutoff2) |
677 | { |
678 | |
679 | r10 = rsq10*rinv10; |
680 | |
681 | qq10 = iq1*jq0; |
682 | |
683 | /* EWALD ELECTROSTATICS */ |
684 | |
685 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
686 | ewrt = r10*ewtabscale; |
687 | ewitab = ewrt; |
688 | eweps = ewrt-ewitab; |
689 | ewitab = 4*ewitab; |
690 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
691 | velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
692 | felec = qq10*rinv10*(rinvsq10-felec); |
693 | |
694 | d = r10-rswitch; |
695 | d = (d>0.0) ? d : 0.0; |
696 | d2 = d*d; |
697 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
698 | |
699 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
700 | |
701 | /* Evaluate switch function */ |
702 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
703 | felec = felec*sw - rinv10*velec*dsw; |
704 | |
705 | fscal = felec; |
706 | |
707 | /* Calculate temporary vectorial force */ |
708 | tx = fscal*dx10; |
709 | ty = fscal*dy10; |
710 | tz = fscal*dz10; |
711 | |
712 | /* Update vectorial force */ |
713 | fix1 += tx; |
714 | fiy1 += ty; |
715 | fiz1 += tz; |
716 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
717 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
718 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
719 | |
720 | } |
721 | |
722 | /************************** |
723 | * CALCULATE INTERACTIONS * |
724 | **************************/ |
725 | |
726 | if (rsq20<rcutoff2) |
727 | { |
728 | |
729 | r20 = rsq20*rinv20; |
730 | |
731 | qq20 = iq2*jq0; |
732 | |
733 | /* EWALD ELECTROSTATICS */ |
734 | |
735 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
736 | ewrt = r20*ewtabscale; |
737 | ewitab = ewrt; |
738 | eweps = ewrt-ewitab; |
739 | ewitab = 4*ewitab; |
740 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
741 | velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
742 | felec = qq20*rinv20*(rinvsq20-felec); |
743 | |
744 | d = r20-rswitch; |
745 | d = (d>0.0) ? d : 0.0; |
746 | d2 = d*d; |
747 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
748 | |
749 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
750 | |
751 | /* Evaluate switch function */ |
752 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
753 | felec = felec*sw - rinv20*velec*dsw; |
754 | |
755 | fscal = felec; |
756 | |
757 | /* Calculate temporary vectorial force */ |
758 | tx = fscal*dx20; |
759 | ty = fscal*dy20; |
760 | tz = fscal*dz20; |
761 | |
762 | /* Update vectorial force */ |
763 | fix2 += tx; |
764 | fiy2 += ty; |
765 | fiz2 += tz; |
766 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
767 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
768 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
769 | |
770 | } |
771 | |
772 | /* Inner loop uses 185 flops */ |
773 | } |
774 | /* End of innermost loop */ |
775 | |
776 | tx = ty = tz = 0; |
777 | f[i_coord_offset+DIM3*0+XX0] += fix0; |
778 | f[i_coord_offset+DIM3*0+YY1] += fiy0; |
779 | f[i_coord_offset+DIM3*0+ZZ2] += fiz0; |
780 | tx += fix0; |
781 | ty += fiy0; |
782 | tz += fiz0; |
783 | f[i_coord_offset+DIM3*1+XX0] += fix1; |
784 | f[i_coord_offset+DIM3*1+YY1] += fiy1; |
785 | f[i_coord_offset+DIM3*1+ZZ2] += fiz1; |
786 | tx += fix1; |
787 | ty += fiy1; |
788 | tz += fiz1; |
789 | f[i_coord_offset+DIM3*2+XX0] += fix2; |
790 | f[i_coord_offset+DIM3*2+YY1] += fiy2; |
791 | f[i_coord_offset+DIM3*2+ZZ2] += fiz2; |
792 | tx += fix2; |
793 | ty += fiy2; |
794 | tz += fiz2; |
795 | fshift[i_shift_offset+XX0] += tx; |
796 | fshift[i_shift_offset+YY1] += ty; |
797 | fshift[i_shift_offset+ZZ2] += tz; |
798 | |
799 | /* Increment number of inner iterations */ |
800 | inneriter += j_index_end - j_index_start; |
801 | |
802 | /* Outer loop uses 30 flops */ |
803 | } |
804 | |
805 | /* Increment number of outer iterations */ |
806 | outeriter += nri; |
807 | |
808 | /* Update outer/inner flops */ |
809 | |
810 | inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*185)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_W3_F] += outeriter*30 + inneriter *185; |
811 | } |