File: | gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_ElecEwSw_VdwBhamSw_GeomW3P1_c.c |
Location: | line 111, column 5 |
Description: | Value stored to 'sh_ewald' 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_VdwBhamSw_GeomW3P1_VF_c |
51 | * Electrostatics interaction: Ewald |
52 | * VdW interaction: Buckingham |
53 | * Geometry: Water3-Particle |
54 | * Calculate force/pot: PotentialAndForce |
55 | */ |
56 | void |
57 | nb_kernel_ElecEwSw_VdwBhamSw_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; |
Value stored to 'sh_ewald' is never read | |
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 = 3*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 = 3*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 | cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1]; |
234 | cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2]; |
235 | |
236 | /* EWALD ELECTROSTATICS */ |
237 | |
238 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
239 | ewrt = r00*ewtabscale; |
240 | ewitab = ewrt; |
241 | eweps = ewrt-ewitab; |
242 | ewitab = 4*ewitab; |
243 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
244 | velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
245 | felec = qq00*rinv00*(rinvsq00-felec); |
246 | |
247 | /* BUCKINGHAM DISPERSION/REPULSION */ |
248 | rinvsix = rinvsq00*rinvsq00*rinvsq00; |
249 | vvdw6 = c6_00*rinvsix; |
250 | br = cexp2_00*r00; |
251 | vvdwexp = cexp1_00*exp(-br); |
252 | vvdw = vvdwexp - vvdw6*(1.0/6.0); |
253 | fvdw = (br*vvdwexp-vvdw6)*rinvsq00; |
254 | |
255 | d = r00-rswitch; |
256 | d = (d>0.0) ? d : 0.0; |
257 | d2 = d*d; |
258 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
259 | |
260 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
261 | |
262 | /* Evaluate switch function */ |
263 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
264 | felec = felec*sw - rinv00*velec*dsw; |
265 | fvdw = fvdw*sw - rinv00*vvdw*dsw; |
266 | velec *= sw; |
267 | vvdw *= sw; |
268 | |
269 | /* Update potential sums from outer loop */ |
270 | velecsum += velec; |
271 | vvdwsum += vvdw; |
272 | |
273 | fscal = felec+fvdw; |
274 | |
275 | /* Calculate temporary vectorial force */ |
276 | tx = fscal*dx00; |
277 | ty = fscal*dy00; |
278 | tz = fscal*dz00; |
279 | |
280 | /* Update vectorial force */ |
281 | fix0 += tx; |
282 | fiy0 += ty; |
283 | fiz0 += tz; |
284 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
285 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
286 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
287 | |
288 | } |
289 | |
290 | /************************** |
291 | * CALCULATE INTERACTIONS * |
292 | **************************/ |
293 | |
294 | if (rsq10<rcutoff2) |
295 | { |
296 | |
297 | r10 = rsq10*rinv10; |
298 | |
299 | qq10 = iq1*jq0; |
300 | |
301 | /* EWALD ELECTROSTATICS */ |
302 | |
303 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
304 | ewrt = r10*ewtabscale; |
305 | ewitab = ewrt; |
306 | eweps = ewrt-ewitab; |
307 | ewitab = 4*ewitab; |
308 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
309 | velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
310 | felec = qq10*rinv10*(rinvsq10-felec); |
311 | |
312 | d = r10-rswitch; |
313 | d = (d>0.0) ? d : 0.0; |
314 | d2 = d*d; |
315 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
316 | |
317 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
318 | |
319 | /* Evaluate switch function */ |
320 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
321 | felec = felec*sw - rinv10*velec*dsw; |
322 | velec *= sw; |
323 | |
324 | /* Update potential sums from outer loop */ |
325 | velecsum += velec; |
326 | |
327 | fscal = felec; |
328 | |
329 | /* Calculate temporary vectorial force */ |
330 | tx = fscal*dx10; |
331 | ty = fscal*dy10; |
332 | tz = fscal*dz10; |
333 | |
334 | /* Update vectorial force */ |
335 | fix1 += tx; |
336 | fiy1 += ty; |
337 | fiz1 += tz; |
338 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
339 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
340 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
341 | |
342 | } |
343 | |
344 | /************************** |
345 | * CALCULATE INTERACTIONS * |
346 | **************************/ |
347 | |
348 | if (rsq20<rcutoff2) |
349 | { |
350 | |
351 | r20 = rsq20*rinv20; |
352 | |
353 | qq20 = iq2*jq0; |
354 | |
355 | /* EWALD ELECTROSTATICS */ |
356 | |
357 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
358 | ewrt = r20*ewtabscale; |
359 | ewitab = ewrt; |
360 | eweps = ewrt-ewitab; |
361 | ewitab = 4*ewitab; |
362 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
363 | velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
364 | felec = qq20*rinv20*(rinvsq20-felec); |
365 | |
366 | d = r20-rswitch; |
367 | d = (d>0.0) ? d : 0.0; |
368 | d2 = d*d; |
369 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
370 | |
371 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
372 | |
373 | /* Evaluate switch function */ |
374 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
375 | felec = felec*sw - rinv20*velec*dsw; |
376 | velec *= sw; |
377 | |
378 | /* Update potential sums from outer loop */ |
379 | velecsum += velec; |
380 | |
381 | fscal = felec; |
382 | |
383 | /* Calculate temporary vectorial force */ |
384 | tx = fscal*dx20; |
385 | ty = fscal*dy20; |
386 | tz = fscal*dz20; |
387 | |
388 | /* Update vectorial force */ |
389 | fix2 += tx; |
390 | fiy2 += ty; |
391 | fiz2 += tz; |
392 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
393 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
394 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
395 | |
396 | } |
397 | |
398 | /* Inner loop uses 219 flops */ |
399 | } |
400 | /* End of innermost loop */ |
401 | |
402 | tx = ty = tz = 0; |
403 | f[i_coord_offset+DIM3*0+XX0] += fix0; |
404 | f[i_coord_offset+DIM3*0+YY1] += fiy0; |
405 | f[i_coord_offset+DIM3*0+ZZ2] += fiz0; |
406 | tx += fix0; |
407 | ty += fiy0; |
408 | tz += fiz0; |
409 | f[i_coord_offset+DIM3*1+XX0] += fix1; |
410 | f[i_coord_offset+DIM3*1+YY1] += fiy1; |
411 | f[i_coord_offset+DIM3*1+ZZ2] += fiz1; |
412 | tx += fix1; |
413 | ty += fiy1; |
414 | tz += fiz1; |
415 | f[i_coord_offset+DIM3*2+XX0] += fix2; |
416 | f[i_coord_offset+DIM3*2+YY1] += fiy2; |
417 | f[i_coord_offset+DIM3*2+ZZ2] += fiz2; |
418 | tx += fix2; |
419 | ty += fiy2; |
420 | tz += fiz2; |
421 | fshift[i_shift_offset+XX0] += tx; |
422 | fshift[i_shift_offset+YY1] += ty; |
423 | fshift[i_shift_offset+ZZ2] += tz; |
424 | |
425 | ggid = gid[iidx]; |
426 | /* Update potential energies */ |
427 | kernel_data->energygrp_elec[ggid] += velecsum; |
428 | kernel_data->energygrp_vdw[ggid] += vvdwsum; |
429 | |
430 | /* Increment number of inner iterations */ |
431 | inneriter += j_index_end - j_index_start; |
432 | |
433 | /* Outer loop uses 32 flops */ |
434 | } |
435 | |
436 | /* Increment number of outer iterations */ |
437 | outeriter += nri; |
438 | |
439 | /* Update outer/inner flops */ |
440 | |
441 | inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*219)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_W3_VF] += outeriter*32 + inneriter *219; |
442 | } |
443 | /* |
444 | * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwBhamSw_GeomW3P1_F_c |
445 | * Electrostatics interaction: Ewald |
446 | * VdW interaction: Buckingham |
447 | * Geometry: Water3-Particle |
448 | * Calculate force/pot: Force |
449 | */ |
450 | void |
451 | nb_kernel_ElecEwSw_VdwBhamSw_GeomW3P1_F_c |
452 | (t_nblist * gmx_restrict__restrict nlist, |
453 | rvec * gmx_restrict__restrict xx, |
454 | rvec * gmx_restrict__restrict ff, |
455 | t_forcerec * gmx_restrict__restrict fr, |
456 | t_mdatoms * gmx_restrict__restrict mdatoms, |
457 | nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict__restrict kernel_data, |
458 | t_nrnb * gmx_restrict__restrict nrnb) |
459 | { |
460 | int i_shift_offset,i_coord_offset,j_coord_offset; |
461 | int j_index_start,j_index_end; |
462 | int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter; |
463 | real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2; |
464 | int *iinr,*jindex,*jjnr,*shiftidx,*gid; |
465 | real *shiftvec,*fshift,*x,*f; |
466 | int vdwioffset0; |
467 | real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0; |
468 | int vdwioffset1; |
469 | real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1; |
470 | int vdwioffset2; |
471 | real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2; |
472 | int vdwjidx0; |
473 | real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0; |
474 | real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00; |
475 | real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10; |
476 | real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20; |
477 | real velec,felec,velecsum,facel,crf,krf,krf2; |
478 | real *charge; |
479 | int nvdwtype; |
480 | real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6; |
481 | int *vdwtype; |
482 | real *vdwparam; |
483 | int ewitab; |
484 | real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace; |
485 | real *ewtab; |
486 | real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw; |
487 | |
488 | x = xx[0]; |
489 | f = ff[0]; |
490 | |
491 | nri = nlist->nri; |
492 | iinr = nlist->iinr; |
493 | jindex = nlist->jindex; |
494 | jjnr = nlist->jjnr; |
495 | shiftidx = nlist->shift; |
496 | gid = nlist->gid; |
497 | shiftvec = fr->shift_vec[0]; |
498 | fshift = fr->fshift[0]; |
499 | facel = fr->epsfac; |
500 | charge = mdatoms->chargeA; |
501 | nvdwtype = fr->ntype; |
502 | vdwparam = fr->nbfp; |
503 | vdwtype = mdatoms->typeA; |
504 | |
505 | sh_ewald = fr->ic->sh_ewald; |
506 | ewtab = fr->ic->tabq_coul_FDV0; |
507 | ewtabscale = fr->ic->tabq_scale; |
508 | ewtabhalfspace = 0.5/ewtabscale; |
509 | |
510 | /* Setup water-specific parameters */ |
511 | inr = nlist->iinr[0]; |
512 | iq0 = facel*charge[inr+0]; |
513 | iq1 = facel*charge[inr+1]; |
514 | iq2 = facel*charge[inr+2]; |
515 | vdwioffset0 = 3*nvdwtype*vdwtype[inr+0]; |
516 | |
517 | /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */ |
518 | rcutoff = fr->rcoulomb; |
519 | rcutoff2 = rcutoff*rcutoff; |
520 | |
521 | rswitch = fr->rcoulomb_switch; |
522 | /* Setup switch parameters */ |
523 | d = rcutoff-rswitch; |
524 | swV3 = -10.0/(d*d*d); |
525 | swV4 = 15.0/(d*d*d*d); |
526 | swV5 = -6.0/(d*d*d*d*d); |
527 | swF2 = -30.0/(d*d*d); |
528 | swF3 = 60.0/(d*d*d*d); |
529 | swF4 = -30.0/(d*d*d*d*d); |
530 | |
531 | outeriter = 0; |
532 | inneriter = 0; |
533 | |
534 | /* Start outer loop over neighborlists */ |
535 | for(iidx=0; iidx<nri; iidx++) |
536 | { |
537 | /* Load shift vector for this list */ |
538 | i_shift_offset = DIM3*shiftidx[iidx]; |
539 | shX = shiftvec[i_shift_offset+XX0]; |
540 | shY = shiftvec[i_shift_offset+YY1]; |
541 | shZ = shiftvec[i_shift_offset+ZZ2]; |
542 | |
543 | /* Load limits for loop over neighbors */ |
544 | j_index_start = jindex[iidx]; |
545 | j_index_end = jindex[iidx+1]; |
546 | |
547 | /* Get outer coordinate index */ |
548 | inr = iinr[iidx]; |
549 | i_coord_offset = DIM3*inr; |
550 | |
551 | /* Load i particle coords and add shift vector */ |
552 | ix0 = shX + x[i_coord_offset+DIM3*0+XX0]; |
553 | iy0 = shY + x[i_coord_offset+DIM3*0+YY1]; |
554 | iz0 = shZ + x[i_coord_offset+DIM3*0+ZZ2]; |
555 | ix1 = shX + x[i_coord_offset+DIM3*1+XX0]; |
556 | iy1 = shY + x[i_coord_offset+DIM3*1+YY1]; |
557 | iz1 = shZ + x[i_coord_offset+DIM3*1+ZZ2]; |
558 | ix2 = shX + x[i_coord_offset+DIM3*2+XX0]; |
559 | iy2 = shY + x[i_coord_offset+DIM3*2+YY1]; |
560 | iz2 = shZ + x[i_coord_offset+DIM3*2+ZZ2]; |
561 | |
562 | fix0 = 0.0; |
563 | fiy0 = 0.0; |
564 | fiz0 = 0.0; |
565 | fix1 = 0.0; |
566 | fiy1 = 0.0; |
567 | fiz1 = 0.0; |
568 | fix2 = 0.0; |
569 | fiy2 = 0.0; |
570 | fiz2 = 0.0; |
571 | |
572 | /* Start inner kernel loop */ |
573 | for(jidx=j_index_start; jidx<j_index_end; jidx++) |
574 | { |
575 | /* Get j neighbor index, and coordinate index */ |
576 | jnr = jjnr[jidx]; |
577 | j_coord_offset = DIM3*jnr; |
578 | |
579 | /* load j atom coordinates */ |
580 | jx0 = x[j_coord_offset+DIM3*0+XX0]; |
581 | jy0 = x[j_coord_offset+DIM3*0+YY1]; |
582 | jz0 = x[j_coord_offset+DIM3*0+ZZ2]; |
583 | |
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 | |
595 | /* Calculate squared distance and things based on it */ |
596 | rsq00 = dx00*dx00+dy00*dy00+dz00*dz00; |
597 | rsq10 = dx10*dx10+dy10*dy10+dz10*dz10; |
598 | rsq20 = dx20*dx20+dy20*dy20+dz20*dz20; |
599 | |
600 | rinv00 = gmx_invsqrt(rsq00)gmx_software_invsqrt(rsq00); |
601 | rinv10 = gmx_invsqrt(rsq10)gmx_software_invsqrt(rsq10); |
602 | rinv20 = gmx_invsqrt(rsq20)gmx_software_invsqrt(rsq20); |
603 | |
604 | rinvsq00 = rinv00*rinv00; |
605 | rinvsq10 = rinv10*rinv10; |
606 | rinvsq20 = rinv20*rinv20; |
607 | |
608 | /* Load parameters for j particles */ |
609 | jq0 = charge[jnr+0]; |
610 | vdwjidx0 = 3*vdwtype[jnr+0]; |
611 | |
612 | /************************** |
613 | * CALCULATE INTERACTIONS * |
614 | **************************/ |
615 | |
616 | if (rsq00<rcutoff2) |
617 | { |
618 | |
619 | r00 = rsq00*rinv00; |
620 | |
621 | qq00 = iq0*jq0; |
622 | c6_00 = vdwparam[vdwioffset0+vdwjidx0]; |
623 | cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1]; |
624 | cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2]; |
625 | |
626 | /* EWALD ELECTROSTATICS */ |
627 | |
628 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
629 | ewrt = r00*ewtabscale; |
630 | ewitab = ewrt; |
631 | eweps = ewrt-ewitab; |
632 | ewitab = 4*ewitab; |
633 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
634 | velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
635 | felec = qq00*rinv00*(rinvsq00-felec); |
636 | |
637 | /* BUCKINGHAM DISPERSION/REPULSION */ |
638 | rinvsix = rinvsq00*rinvsq00*rinvsq00; |
639 | vvdw6 = c6_00*rinvsix; |
640 | br = cexp2_00*r00; |
641 | vvdwexp = cexp1_00*exp(-br); |
642 | vvdw = vvdwexp - vvdw6*(1.0/6.0); |
643 | fvdw = (br*vvdwexp-vvdw6)*rinvsq00; |
644 | |
645 | d = r00-rswitch; |
646 | d = (d>0.0) ? d : 0.0; |
647 | d2 = d*d; |
648 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
649 | |
650 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
651 | |
652 | /* Evaluate switch function */ |
653 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
654 | felec = felec*sw - rinv00*velec*dsw; |
655 | fvdw = fvdw*sw - rinv00*vvdw*dsw; |
656 | |
657 | fscal = felec+fvdw; |
658 | |
659 | /* Calculate temporary vectorial force */ |
660 | tx = fscal*dx00; |
661 | ty = fscal*dy00; |
662 | tz = fscal*dz00; |
663 | |
664 | /* Update vectorial force */ |
665 | fix0 += tx; |
666 | fiy0 += ty; |
667 | fiz0 += tz; |
668 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
669 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
670 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
671 | |
672 | } |
673 | |
674 | /************************** |
675 | * CALCULATE INTERACTIONS * |
676 | **************************/ |
677 | |
678 | if (rsq10<rcutoff2) |
679 | { |
680 | |
681 | r10 = rsq10*rinv10; |
682 | |
683 | qq10 = iq1*jq0; |
684 | |
685 | /* EWALD ELECTROSTATICS */ |
686 | |
687 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
688 | ewrt = r10*ewtabscale; |
689 | ewitab = ewrt; |
690 | eweps = ewrt-ewitab; |
691 | ewitab = 4*ewitab; |
692 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
693 | velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
694 | felec = qq10*rinv10*(rinvsq10-felec); |
695 | |
696 | d = r10-rswitch; |
697 | d = (d>0.0) ? d : 0.0; |
698 | d2 = d*d; |
699 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
700 | |
701 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
702 | |
703 | /* Evaluate switch function */ |
704 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
705 | felec = felec*sw - rinv10*velec*dsw; |
706 | |
707 | fscal = felec; |
708 | |
709 | /* Calculate temporary vectorial force */ |
710 | tx = fscal*dx10; |
711 | ty = fscal*dy10; |
712 | tz = fscal*dz10; |
713 | |
714 | /* Update vectorial force */ |
715 | fix1 += tx; |
716 | fiy1 += ty; |
717 | fiz1 += tz; |
718 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
719 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
720 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
721 | |
722 | } |
723 | |
724 | /************************** |
725 | * CALCULATE INTERACTIONS * |
726 | **************************/ |
727 | |
728 | if (rsq20<rcutoff2) |
729 | { |
730 | |
731 | r20 = rsq20*rinv20; |
732 | |
733 | qq20 = iq2*jq0; |
734 | |
735 | /* EWALD ELECTROSTATICS */ |
736 | |
737 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
738 | ewrt = r20*ewtabscale; |
739 | ewitab = ewrt; |
740 | eweps = ewrt-ewitab; |
741 | ewitab = 4*ewitab; |
742 | felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; |
743 | velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); |
744 | felec = qq20*rinv20*(rinvsq20-felec); |
745 | |
746 | d = r20-rswitch; |
747 | d = (d>0.0) ? d : 0.0; |
748 | d2 = d*d; |
749 | sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); |
750 | |
751 | dsw = d2*(swF2+d*(swF3+d*swF4)); |
752 | |
753 | /* Evaluate switch function */ |
754 | /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */ |
755 | felec = felec*sw - rinv20*velec*dsw; |
756 | |
757 | fscal = felec; |
758 | |
759 | /* Calculate temporary vectorial force */ |
760 | tx = fscal*dx20; |
761 | ty = fscal*dy20; |
762 | tz = fscal*dz20; |
763 | |
764 | /* Update vectorial force */ |
765 | fix2 += tx; |
766 | fiy2 += ty; |
767 | fiz2 += tz; |
768 | f[j_coord_offset+DIM3*0+XX0] -= tx; |
769 | f[j_coord_offset+DIM3*0+YY1] -= ty; |
770 | f[j_coord_offset+DIM3*0+ZZ2] -= tz; |
771 | |
772 | } |
773 | |
774 | /* Inner loop uses 211 flops */ |
775 | } |
776 | /* End of innermost loop */ |
777 | |
778 | tx = ty = tz = 0; |
779 | f[i_coord_offset+DIM3*0+XX0] += fix0; |
780 | f[i_coord_offset+DIM3*0+YY1] += fiy0; |
781 | f[i_coord_offset+DIM3*0+ZZ2] += fiz0; |
782 | tx += fix0; |
783 | ty += fiy0; |
784 | tz += fiz0; |
785 | f[i_coord_offset+DIM3*1+XX0] += fix1; |
786 | f[i_coord_offset+DIM3*1+YY1] += fiy1; |
787 | f[i_coord_offset+DIM3*1+ZZ2] += fiz1; |
788 | tx += fix1; |
789 | ty += fiy1; |
790 | tz += fiz1; |
791 | f[i_coord_offset+DIM3*2+XX0] += fix2; |
792 | f[i_coord_offset+DIM3*2+YY1] += fiy2; |
793 | f[i_coord_offset+DIM3*2+ZZ2] += fiz2; |
794 | tx += fix2; |
795 | ty += fiy2; |
796 | tz += fiz2; |
797 | fshift[i_shift_offset+XX0] += tx; |
798 | fshift[i_shift_offset+YY1] += ty; |
799 | fshift[i_shift_offset+ZZ2] += tz; |
800 | |
801 | /* Increment number of inner iterations */ |
802 | inneriter += j_index_end - j_index_start; |
803 | |
804 | /* Outer loop uses 30 flops */ |
805 | } |
806 | |
807 | /* Increment number of outer iterations */ |
808 | outeriter += nri; |
809 | |
810 | /* Update outer/inner flops */ |
811 | |
812 | inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*211)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_W3_F] += outeriter*30 + inneriter *211; |
813 | } |