Remove all unnecessary HAVE_CONFIG_H
[gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRF_VdwNone_GeomW4W4_c.c
blob1e7071ad88de7e54719af7ccb4e11ce0d50d29ea
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
38 #include "config.h"
40 #include <math.h>
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: None
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
54 void
55 nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
70 int vdwioffset1;
71 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
72 int vdwioffset2;
73 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
74 int vdwioffset3;
75 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
76 int vdwjidx1;
77 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
78 int vdwjidx2;
79 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
80 int vdwjidx3;
81 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
82 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
83 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
84 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
85 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
86 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
87 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
88 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
89 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
90 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
92 real *charge;
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->epsfac;
106 charge = mdatoms->chargeA;
107 krf = fr->ic->k_rf;
108 krf2 = krf*2.0;
109 crf = fr->ic->c_rf;
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];
117 jq1 = charge[inr+1];
118 jq2 = charge[inr+2];
119 jq3 = charge[inr+3];
120 qq11 = iq1*jq1;
121 qq12 = iq1*jq2;
122 qq13 = iq1*jq3;
123 qq21 = iq2*jq1;
124 qq22 = iq2*jq2;
125 qq23 = iq2*jq3;
126 qq31 = iq3*jq1;
127 qq32 = iq3*jq2;
128 qq33 = iq3*jq3;
130 outeriter = 0;
131 inneriter = 0;
133 /* Start outer loop over neighborlists */
134 for(iidx=0; iidx<nri; iidx++)
136 /* Load shift vector for this list */
137 i_shift_offset = DIM*shiftidx[iidx];
138 shX = shiftvec[i_shift_offset+XX];
139 shY = shiftvec[i_shift_offset+YY];
140 shZ = shiftvec[i_shift_offset+ZZ];
142 /* Load limits for loop over neighbors */
143 j_index_start = jindex[iidx];
144 j_index_end = jindex[iidx+1];
146 /* Get outer coordinate index */
147 inr = iinr[iidx];
148 i_coord_offset = DIM*inr;
150 /* Load i particle coords and add shift vector */
151 ix1 = shX + x[i_coord_offset+DIM*1+XX];
152 iy1 = shY + x[i_coord_offset+DIM*1+YY];
153 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
154 ix2 = shX + x[i_coord_offset+DIM*2+XX];
155 iy2 = shY + x[i_coord_offset+DIM*2+YY];
156 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
157 ix3 = shX + x[i_coord_offset+DIM*3+XX];
158 iy3 = shY + x[i_coord_offset+DIM*3+YY];
159 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
161 fix1 = 0.0;
162 fiy1 = 0.0;
163 fiz1 = 0.0;
164 fix2 = 0.0;
165 fiy2 = 0.0;
166 fiz2 = 0.0;
167 fix3 = 0.0;
168 fiy3 = 0.0;
169 fiz3 = 0.0;
171 /* Reset potential sums */
172 velecsum = 0.0;
174 /* Start inner kernel loop */
175 for(jidx=j_index_start; jidx<j_index_end; jidx++)
177 /* Get j neighbor index, and coordinate index */
178 jnr = jjnr[jidx];
179 j_coord_offset = DIM*jnr;
181 /* load j atom coordinates */
182 jx1 = x[j_coord_offset+DIM*1+XX];
183 jy1 = x[j_coord_offset+DIM*1+YY];
184 jz1 = x[j_coord_offset+DIM*1+ZZ];
185 jx2 = x[j_coord_offset+DIM*2+XX];
186 jy2 = x[j_coord_offset+DIM*2+YY];
187 jz2 = x[j_coord_offset+DIM*2+ZZ];
188 jx3 = x[j_coord_offset+DIM*3+XX];
189 jy3 = x[j_coord_offset+DIM*3+YY];
190 jz3 = x[j_coord_offset+DIM*3+ZZ];
192 /* Calculate displacement vector */
193 dx11 = ix1 - jx1;
194 dy11 = iy1 - jy1;
195 dz11 = iz1 - jz1;
196 dx12 = ix1 - jx2;
197 dy12 = iy1 - jy2;
198 dz12 = iz1 - jz2;
199 dx13 = ix1 - jx3;
200 dy13 = iy1 - jy3;
201 dz13 = iz1 - jz3;
202 dx21 = ix2 - jx1;
203 dy21 = iy2 - jy1;
204 dz21 = iz2 - jz1;
205 dx22 = ix2 - jx2;
206 dy22 = iy2 - jy2;
207 dz22 = iz2 - jz2;
208 dx23 = ix2 - jx3;
209 dy23 = iy2 - jy3;
210 dz23 = iz2 - jz3;
211 dx31 = ix3 - jx1;
212 dy31 = iy3 - jy1;
213 dz31 = iz3 - jz1;
214 dx32 = ix3 - jx2;
215 dy32 = iy3 - jy2;
216 dz32 = iz3 - jz2;
217 dx33 = ix3 - jx3;
218 dy33 = iy3 - jy3;
219 dz33 = iz3 - jz3;
221 /* Calculate squared distance and things based on it */
222 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
223 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
224 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
225 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
226 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
227 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
228 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
229 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
230 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
232 rinv11 = gmx_invsqrt(rsq11);
233 rinv12 = gmx_invsqrt(rsq12);
234 rinv13 = gmx_invsqrt(rsq13);
235 rinv21 = gmx_invsqrt(rsq21);
236 rinv22 = gmx_invsqrt(rsq22);
237 rinv23 = gmx_invsqrt(rsq23);
238 rinv31 = gmx_invsqrt(rsq31);
239 rinv32 = gmx_invsqrt(rsq32);
240 rinv33 = gmx_invsqrt(rsq33);
242 rinvsq11 = rinv11*rinv11;
243 rinvsq12 = rinv12*rinv12;
244 rinvsq13 = rinv13*rinv13;
245 rinvsq21 = rinv21*rinv21;
246 rinvsq22 = rinv22*rinv22;
247 rinvsq23 = rinv23*rinv23;
248 rinvsq31 = rinv31*rinv31;
249 rinvsq32 = rinv32*rinv32;
250 rinvsq33 = rinv33*rinv33;
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
256 /* REACTION-FIELD ELECTROSTATICS */
257 velec = qq11*(rinv11+krf*rsq11-crf);
258 felec = qq11*(rinv11*rinvsq11-krf2);
260 /* Update potential sums from outer loop */
261 velecsum += velec;
263 fscal = felec;
265 /* Calculate temporary vectorial force */
266 tx = fscal*dx11;
267 ty = fscal*dy11;
268 tz = fscal*dz11;
270 /* Update vectorial force */
271 fix1 += tx;
272 fiy1 += ty;
273 fiz1 += tz;
274 f[j_coord_offset+DIM*1+XX] -= tx;
275 f[j_coord_offset+DIM*1+YY] -= ty;
276 f[j_coord_offset+DIM*1+ZZ] -= tz;
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
282 /* REACTION-FIELD ELECTROSTATICS */
283 velec = qq12*(rinv12+krf*rsq12-crf);
284 felec = qq12*(rinv12*rinvsq12-krf2);
286 /* Update potential sums from outer loop */
287 velecsum += velec;
289 fscal = felec;
291 /* Calculate temporary vectorial force */
292 tx = fscal*dx12;
293 ty = fscal*dy12;
294 tz = fscal*dz12;
296 /* Update vectorial force */
297 fix1 += tx;
298 fiy1 += ty;
299 fiz1 += tz;
300 f[j_coord_offset+DIM*2+XX] -= tx;
301 f[j_coord_offset+DIM*2+YY] -= ty;
302 f[j_coord_offset+DIM*2+ZZ] -= tz;
304 /**************************
305 * CALCULATE INTERACTIONS *
306 **************************/
308 /* REACTION-FIELD ELECTROSTATICS */
309 velec = qq13*(rinv13+krf*rsq13-crf);
310 felec = qq13*(rinv13*rinvsq13-krf2);
312 /* Update potential sums from outer loop */
313 velecsum += velec;
315 fscal = felec;
317 /* Calculate temporary vectorial force */
318 tx = fscal*dx13;
319 ty = fscal*dy13;
320 tz = fscal*dz13;
322 /* Update vectorial force */
323 fix1 += tx;
324 fiy1 += ty;
325 fiz1 += tz;
326 f[j_coord_offset+DIM*3+XX] -= tx;
327 f[j_coord_offset+DIM*3+YY] -= ty;
328 f[j_coord_offset+DIM*3+ZZ] -= tz;
330 /**************************
331 * CALCULATE INTERACTIONS *
332 **************************/
334 /* REACTION-FIELD ELECTROSTATICS */
335 velec = qq21*(rinv21+krf*rsq21-crf);
336 felec = qq21*(rinv21*rinvsq21-krf2);
338 /* Update potential sums from outer loop */
339 velecsum += velec;
341 fscal = felec;
343 /* Calculate temporary vectorial force */
344 tx = fscal*dx21;
345 ty = fscal*dy21;
346 tz = fscal*dz21;
348 /* Update vectorial force */
349 fix2 += tx;
350 fiy2 += ty;
351 fiz2 += tz;
352 f[j_coord_offset+DIM*1+XX] -= tx;
353 f[j_coord_offset+DIM*1+YY] -= ty;
354 f[j_coord_offset+DIM*1+ZZ] -= tz;
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = qq22*(rinv22+krf*rsq22-crf);
362 felec = qq22*(rinv22*rinvsq22-krf2);
364 /* Update potential sums from outer loop */
365 velecsum += velec;
367 fscal = felec;
369 /* Calculate temporary vectorial force */
370 tx = fscal*dx22;
371 ty = fscal*dy22;
372 tz = fscal*dz22;
374 /* Update vectorial force */
375 fix2 += tx;
376 fiy2 += ty;
377 fiz2 += tz;
378 f[j_coord_offset+DIM*2+XX] -= tx;
379 f[j_coord_offset+DIM*2+YY] -= ty;
380 f[j_coord_offset+DIM*2+ZZ] -= tz;
382 /**************************
383 * CALCULATE INTERACTIONS *
384 **************************/
386 /* REACTION-FIELD ELECTROSTATICS */
387 velec = qq23*(rinv23+krf*rsq23-crf);
388 felec = qq23*(rinv23*rinvsq23-krf2);
390 /* Update potential sums from outer loop */
391 velecsum += velec;
393 fscal = felec;
395 /* Calculate temporary vectorial force */
396 tx = fscal*dx23;
397 ty = fscal*dy23;
398 tz = fscal*dz23;
400 /* Update vectorial force */
401 fix2 += tx;
402 fiy2 += ty;
403 fiz2 += tz;
404 f[j_coord_offset+DIM*3+XX] -= tx;
405 f[j_coord_offset+DIM*3+YY] -= ty;
406 f[j_coord_offset+DIM*3+ZZ] -= tz;
408 /**************************
409 * CALCULATE INTERACTIONS *
410 **************************/
412 /* REACTION-FIELD ELECTROSTATICS */
413 velec = qq31*(rinv31+krf*rsq31-crf);
414 felec = qq31*(rinv31*rinvsq31-krf2);
416 /* Update potential sums from outer loop */
417 velecsum += velec;
419 fscal = felec;
421 /* Calculate temporary vectorial force */
422 tx = fscal*dx31;
423 ty = fscal*dy31;
424 tz = fscal*dz31;
426 /* Update vectorial force */
427 fix3 += tx;
428 fiy3 += ty;
429 fiz3 += tz;
430 f[j_coord_offset+DIM*1+XX] -= tx;
431 f[j_coord_offset+DIM*1+YY] -= ty;
432 f[j_coord_offset+DIM*1+ZZ] -= tz;
434 /**************************
435 * CALCULATE INTERACTIONS *
436 **************************/
438 /* REACTION-FIELD ELECTROSTATICS */
439 velec = qq32*(rinv32+krf*rsq32-crf);
440 felec = qq32*(rinv32*rinvsq32-krf2);
442 /* Update potential sums from outer loop */
443 velecsum += velec;
445 fscal = felec;
447 /* Calculate temporary vectorial force */
448 tx = fscal*dx32;
449 ty = fscal*dy32;
450 tz = fscal*dz32;
452 /* Update vectorial force */
453 fix3 += tx;
454 fiy3 += ty;
455 fiz3 += tz;
456 f[j_coord_offset+DIM*2+XX] -= tx;
457 f[j_coord_offset+DIM*2+YY] -= ty;
458 f[j_coord_offset+DIM*2+ZZ] -= tz;
460 /**************************
461 * CALCULATE INTERACTIONS *
462 **************************/
464 /* REACTION-FIELD ELECTROSTATICS */
465 velec = qq33*(rinv33+krf*rsq33-crf);
466 felec = qq33*(rinv33*rinvsq33-krf2);
468 /* Update potential sums from outer loop */
469 velecsum += velec;
471 fscal = felec;
473 /* Calculate temporary vectorial force */
474 tx = fscal*dx33;
475 ty = fscal*dy33;
476 tz = fscal*dz33;
478 /* Update vectorial force */
479 fix3 += tx;
480 fiy3 += ty;
481 fiz3 += tz;
482 f[j_coord_offset+DIM*3+XX] -= tx;
483 f[j_coord_offset+DIM*3+YY] -= ty;
484 f[j_coord_offset+DIM*3+ZZ] -= tz;
486 /* Inner loop uses 279 flops */
488 /* End of innermost loop */
490 tx = ty = tz = 0;
491 f[i_coord_offset+DIM*1+XX] += fix1;
492 f[i_coord_offset+DIM*1+YY] += fiy1;
493 f[i_coord_offset+DIM*1+ZZ] += fiz1;
494 tx += fix1;
495 ty += fiy1;
496 tz += fiz1;
497 f[i_coord_offset+DIM*2+XX] += fix2;
498 f[i_coord_offset+DIM*2+YY] += fiy2;
499 f[i_coord_offset+DIM*2+ZZ] += fiz2;
500 tx += fix2;
501 ty += fiy2;
502 tz += fiz2;
503 f[i_coord_offset+DIM*3+XX] += fix3;
504 f[i_coord_offset+DIM*3+YY] += fiy3;
505 f[i_coord_offset+DIM*3+ZZ] += fiz3;
506 tx += fix3;
507 ty += fiy3;
508 tz += fiz3;
509 fshift[i_shift_offset+XX] += tx;
510 fshift[i_shift_offset+YY] += ty;
511 fshift[i_shift_offset+ZZ] += tz;
513 ggid = gid[iidx];
514 /* Update potential energies */
515 kernel_data->energygrp_elec[ggid] += velecsum;
517 /* Increment number of inner iterations */
518 inneriter += j_index_end - j_index_start;
520 /* Outer loop uses 31 flops */
523 /* Increment number of outer iterations */
524 outeriter += nri;
526 /* Update outer/inner flops */
528 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*279);
531 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_F_c
532 * Electrostatics interaction: ReactionField
533 * VdW interaction: None
534 * Geometry: Water4-Water4
535 * Calculate force/pot: Force
537 void
538 nb_kernel_ElecRF_VdwNone_GeomW4W4_F_c
539 (t_nblist * gmx_restrict nlist,
540 rvec * gmx_restrict xx,
541 rvec * gmx_restrict ff,
542 t_forcerec * gmx_restrict fr,
543 t_mdatoms * gmx_restrict mdatoms,
544 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
545 t_nrnb * gmx_restrict nrnb)
547 int i_shift_offset,i_coord_offset,j_coord_offset;
548 int j_index_start,j_index_end;
549 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
550 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
551 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
552 real *shiftvec,*fshift,*x,*f;
553 int vdwioffset1;
554 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
555 int vdwioffset2;
556 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
557 int vdwioffset3;
558 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
559 int vdwjidx1;
560 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
561 int vdwjidx2;
562 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
563 int vdwjidx3;
564 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
565 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
566 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
567 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
568 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
569 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
570 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
571 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
572 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
573 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
574 real velec,felec,velecsum,facel,crf,krf,krf2;
575 real *charge;
577 x = xx[0];
578 f = ff[0];
580 nri = nlist->nri;
581 iinr = nlist->iinr;
582 jindex = nlist->jindex;
583 jjnr = nlist->jjnr;
584 shiftidx = nlist->shift;
585 gid = nlist->gid;
586 shiftvec = fr->shift_vec[0];
587 fshift = fr->fshift[0];
588 facel = fr->epsfac;
589 charge = mdatoms->chargeA;
590 krf = fr->ic->k_rf;
591 krf2 = krf*2.0;
592 crf = fr->ic->c_rf;
594 /* Setup water-specific parameters */
595 inr = nlist->iinr[0];
596 iq1 = facel*charge[inr+1];
597 iq2 = facel*charge[inr+2];
598 iq3 = facel*charge[inr+3];
600 jq1 = charge[inr+1];
601 jq2 = charge[inr+2];
602 jq3 = charge[inr+3];
603 qq11 = iq1*jq1;
604 qq12 = iq1*jq2;
605 qq13 = iq1*jq3;
606 qq21 = iq2*jq1;
607 qq22 = iq2*jq2;
608 qq23 = iq2*jq3;
609 qq31 = iq3*jq1;
610 qq32 = iq3*jq2;
611 qq33 = iq3*jq3;
613 outeriter = 0;
614 inneriter = 0;
616 /* Start outer loop over neighborlists */
617 for(iidx=0; iidx<nri; iidx++)
619 /* Load shift vector for this list */
620 i_shift_offset = DIM*shiftidx[iidx];
621 shX = shiftvec[i_shift_offset+XX];
622 shY = shiftvec[i_shift_offset+YY];
623 shZ = shiftvec[i_shift_offset+ZZ];
625 /* Load limits for loop over neighbors */
626 j_index_start = jindex[iidx];
627 j_index_end = jindex[iidx+1];
629 /* Get outer coordinate index */
630 inr = iinr[iidx];
631 i_coord_offset = DIM*inr;
633 /* Load i particle coords and add shift vector */
634 ix1 = shX + x[i_coord_offset+DIM*1+XX];
635 iy1 = shY + x[i_coord_offset+DIM*1+YY];
636 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
637 ix2 = shX + x[i_coord_offset+DIM*2+XX];
638 iy2 = shY + x[i_coord_offset+DIM*2+YY];
639 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
640 ix3 = shX + x[i_coord_offset+DIM*3+XX];
641 iy3 = shY + x[i_coord_offset+DIM*3+YY];
642 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
644 fix1 = 0.0;
645 fiy1 = 0.0;
646 fiz1 = 0.0;
647 fix2 = 0.0;
648 fiy2 = 0.0;
649 fiz2 = 0.0;
650 fix3 = 0.0;
651 fiy3 = 0.0;
652 fiz3 = 0.0;
654 /* Start inner kernel loop */
655 for(jidx=j_index_start; jidx<j_index_end; jidx++)
657 /* Get j neighbor index, and coordinate index */
658 jnr = jjnr[jidx];
659 j_coord_offset = DIM*jnr;
661 /* load j atom coordinates */
662 jx1 = x[j_coord_offset+DIM*1+XX];
663 jy1 = x[j_coord_offset+DIM*1+YY];
664 jz1 = x[j_coord_offset+DIM*1+ZZ];
665 jx2 = x[j_coord_offset+DIM*2+XX];
666 jy2 = x[j_coord_offset+DIM*2+YY];
667 jz2 = x[j_coord_offset+DIM*2+ZZ];
668 jx3 = x[j_coord_offset+DIM*3+XX];
669 jy3 = x[j_coord_offset+DIM*3+YY];
670 jz3 = x[j_coord_offset+DIM*3+ZZ];
672 /* Calculate displacement vector */
673 dx11 = ix1 - jx1;
674 dy11 = iy1 - jy1;
675 dz11 = iz1 - jz1;
676 dx12 = ix1 - jx2;
677 dy12 = iy1 - jy2;
678 dz12 = iz1 - jz2;
679 dx13 = ix1 - jx3;
680 dy13 = iy1 - jy3;
681 dz13 = iz1 - jz3;
682 dx21 = ix2 - jx1;
683 dy21 = iy2 - jy1;
684 dz21 = iz2 - jz1;
685 dx22 = ix2 - jx2;
686 dy22 = iy2 - jy2;
687 dz22 = iz2 - jz2;
688 dx23 = ix2 - jx3;
689 dy23 = iy2 - jy3;
690 dz23 = iz2 - jz3;
691 dx31 = ix3 - jx1;
692 dy31 = iy3 - jy1;
693 dz31 = iz3 - jz1;
694 dx32 = ix3 - jx2;
695 dy32 = iy3 - jy2;
696 dz32 = iz3 - jz2;
697 dx33 = ix3 - jx3;
698 dy33 = iy3 - jy3;
699 dz33 = iz3 - jz3;
701 /* Calculate squared distance and things based on it */
702 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
703 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
704 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
705 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
706 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
707 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
708 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
709 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
710 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
712 rinv11 = gmx_invsqrt(rsq11);
713 rinv12 = gmx_invsqrt(rsq12);
714 rinv13 = gmx_invsqrt(rsq13);
715 rinv21 = gmx_invsqrt(rsq21);
716 rinv22 = gmx_invsqrt(rsq22);
717 rinv23 = gmx_invsqrt(rsq23);
718 rinv31 = gmx_invsqrt(rsq31);
719 rinv32 = gmx_invsqrt(rsq32);
720 rinv33 = gmx_invsqrt(rsq33);
722 rinvsq11 = rinv11*rinv11;
723 rinvsq12 = rinv12*rinv12;
724 rinvsq13 = rinv13*rinv13;
725 rinvsq21 = rinv21*rinv21;
726 rinvsq22 = rinv22*rinv22;
727 rinvsq23 = rinv23*rinv23;
728 rinvsq31 = rinv31*rinv31;
729 rinvsq32 = rinv32*rinv32;
730 rinvsq33 = rinv33*rinv33;
732 /**************************
733 * CALCULATE INTERACTIONS *
734 **************************/
736 /* REACTION-FIELD ELECTROSTATICS */
737 felec = qq11*(rinv11*rinvsq11-krf2);
739 fscal = felec;
741 /* Calculate temporary vectorial force */
742 tx = fscal*dx11;
743 ty = fscal*dy11;
744 tz = fscal*dz11;
746 /* Update vectorial force */
747 fix1 += tx;
748 fiy1 += ty;
749 fiz1 += tz;
750 f[j_coord_offset+DIM*1+XX] -= tx;
751 f[j_coord_offset+DIM*1+YY] -= ty;
752 f[j_coord_offset+DIM*1+ZZ] -= tz;
754 /**************************
755 * CALCULATE INTERACTIONS *
756 **************************/
758 /* REACTION-FIELD ELECTROSTATICS */
759 felec = qq12*(rinv12*rinvsq12-krf2);
761 fscal = felec;
763 /* Calculate temporary vectorial force */
764 tx = fscal*dx12;
765 ty = fscal*dy12;
766 tz = fscal*dz12;
768 /* Update vectorial force */
769 fix1 += tx;
770 fiy1 += ty;
771 fiz1 += tz;
772 f[j_coord_offset+DIM*2+XX] -= tx;
773 f[j_coord_offset+DIM*2+YY] -= ty;
774 f[j_coord_offset+DIM*2+ZZ] -= tz;
776 /**************************
777 * CALCULATE INTERACTIONS *
778 **************************/
780 /* REACTION-FIELD ELECTROSTATICS */
781 felec = qq13*(rinv13*rinvsq13-krf2);
783 fscal = felec;
785 /* Calculate temporary vectorial force */
786 tx = fscal*dx13;
787 ty = fscal*dy13;
788 tz = fscal*dz13;
790 /* Update vectorial force */
791 fix1 += tx;
792 fiy1 += ty;
793 fiz1 += tz;
794 f[j_coord_offset+DIM*3+XX] -= tx;
795 f[j_coord_offset+DIM*3+YY] -= ty;
796 f[j_coord_offset+DIM*3+ZZ] -= tz;
798 /**************************
799 * CALCULATE INTERACTIONS *
800 **************************/
802 /* REACTION-FIELD ELECTROSTATICS */
803 felec = qq21*(rinv21*rinvsq21-krf2);
805 fscal = felec;
807 /* Calculate temporary vectorial force */
808 tx = fscal*dx21;
809 ty = fscal*dy21;
810 tz = fscal*dz21;
812 /* Update vectorial force */
813 fix2 += tx;
814 fiy2 += ty;
815 fiz2 += tz;
816 f[j_coord_offset+DIM*1+XX] -= tx;
817 f[j_coord_offset+DIM*1+YY] -= ty;
818 f[j_coord_offset+DIM*1+ZZ] -= tz;
820 /**************************
821 * CALCULATE INTERACTIONS *
822 **************************/
824 /* REACTION-FIELD ELECTROSTATICS */
825 felec = qq22*(rinv22*rinvsq22-krf2);
827 fscal = felec;
829 /* Calculate temporary vectorial force */
830 tx = fscal*dx22;
831 ty = fscal*dy22;
832 tz = fscal*dz22;
834 /* Update vectorial force */
835 fix2 += tx;
836 fiy2 += ty;
837 fiz2 += tz;
838 f[j_coord_offset+DIM*2+XX] -= tx;
839 f[j_coord_offset+DIM*2+YY] -= ty;
840 f[j_coord_offset+DIM*2+ZZ] -= tz;
842 /**************************
843 * CALCULATE INTERACTIONS *
844 **************************/
846 /* REACTION-FIELD ELECTROSTATICS */
847 felec = qq23*(rinv23*rinvsq23-krf2);
849 fscal = felec;
851 /* Calculate temporary vectorial force */
852 tx = fscal*dx23;
853 ty = fscal*dy23;
854 tz = fscal*dz23;
856 /* Update vectorial force */
857 fix2 += tx;
858 fiy2 += ty;
859 fiz2 += tz;
860 f[j_coord_offset+DIM*3+XX] -= tx;
861 f[j_coord_offset+DIM*3+YY] -= ty;
862 f[j_coord_offset+DIM*3+ZZ] -= tz;
864 /**************************
865 * CALCULATE INTERACTIONS *
866 **************************/
868 /* REACTION-FIELD ELECTROSTATICS */
869 felec = qq31*(rinv31*rinvsq31-krf2);
871 fscal = felec;
873 /* Calculate temporary vectorial force */
874 tx = fscal*dx31;
875 ty = fscal*dy31;
876 tz = fscal*dz31;
878 /* Update vectorial force */
879 fix3 += tx;
880 fiy3 += ty;
881 fiz3 += tz;
882 f[j_coord_offset+DIM*1+XX] -= tx;
883 f[j_coord_offset+DIM*1+YY] -= ty;
884 f[j_coord_offset+DIM*1+ZZ] -= tz;
886 /**************************
887 * CALCULATE INTERACTIONS *
888 **************************/
890 /* REACTION-FIELD ELECTROSTATICS */
891 felec = qq32*(rinv32*rinvsq32-krf2);
893 fscal = felec;
895 /* Calculate temporary vectorial force */
896 tx = fscal*dx32;
897 ty = fscal*dy32;
898 tz = fscal*dz32;
900 /* Update vectorial force */
901 fix3 += tx;
902 fiy3 += ty;
903 fiz3 += tz;
904 f[j_coord_offset+DIM*2+XX] -= tx;
905 f[j_coord_offset+DIM*2+YY] -= ty;
906 f[j_coord_offset+DIM*2+ZZ] -= tz;
908 /**************************
909 * CALCULATE INTERACTIONS *
910 **************************/
912 /* REACTION-FIELD ELECTROSTATICS */
913 felec = qq33*(rinv33*rinvsq33-krf2);
915 fscal = felec;
917 /* Calculate temporary vectorial force */
918 tx = fscal*dx33;
919 ty = fscal*dy33;
920 tz = fscal*dz33;
922 /* Update vectorial force */
923 fix3 += tx;
924 fiy3 += ty;
925 fiz3 += tz;
926 f[j_coord_offset+DIM*3+XX] -= tx;
927 f[j_coord_offset+DIM*3+YY] -= ty;
928 f[j_coord_offset+DIM*3+ZZ] -= tz;
930 /* Inner loop uses 234 flops */
932 /* End of innermost loop */
934 tx = ty = tz = 0;
935 f[i_coord_offset+DIM*1+XX] += fix1;
936 f[i_coord_offset+DIM*1+YY] += fiy1;
937 f[i_coord_offset+DIM*1+ZZ] += fiz1;
938 tx += fix1;
939 ty += fiy1;
940 tz += fiz1;
941 f[i_coord_offset+DIM*2+XX] += fix2;
942 f[i_coord_offset+DIM*2+YY] += fiy2;
943 f[i_coord_offset+DIM*2+ZZ] += fiz2;
944 tx += fix2;
945 ty += fiy2;
946 tz += fiz2;
947 f[i_coord_offset+DIM*3+XX] += fix3;
948 f[i_coord_offset+DIM*3+YY] += fiy3;
949 f[i_coord_offset+DIM*3+ZZ] += fiz3;
950 tx += fix3;
951 ty += fiy3;
952 tz += fiz3;
953 fshift[i_shift_offset+XX] += tx;
954 fshift[i_shift_offset+YY] += ty;
955 fshift[i_shift_offset+ZZ] += tz;
957 /* Increment number of inner iterations */
958 inneriter += j_index_end - j_index_start;
960 /* Outer loop uses 30 flops */
963 /* Increment number of outer iterations */
964 outeriter += nri;
966 /* Update outer/inner flops */
968 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*234);