2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW4P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: None
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_VdwNone_GeomW4P1_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
59 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
61 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
65 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
66 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
75 jindex = nlist->jindex;
77 shiftidx = nlist->shift;
79 shiftvec = fr->shift_vec[0];
80 fshift = fr->fshift[0];
82 charge = mdatoms->chargeA;
84 /* Setup water-specific parameters */
86 iq1 = facel*charge[inr+1];
87 iq2 = facel*charge[inr+2];
88 iq3 = facel*charge[inr+3];
93 /* Start outer loop over neighborlists */
94 for(iidx=0; iidx<nri; iidx++)
96 /* Load shift vector for this list */
97 i_shift_offset = DIM*shiftidx[iidx];
98 shX = shiftvec[i_shift_offset+XX];
99 shY = shiftvec[i_shift_offset+YY];
100 shZ = shiftvec[i_shift_offset+ZZ];
102 /* Load limits for loop over neighbors */
103 j_index_start = jindex[iidx];
104 j_index_end = jindex[iidx+1];
106 /* Get outer coordinate index */
108 i_coord_offset = DIM*inr;
110 /* Load i particle coords and add shift vector */
111 ix1 = shX + x[i_coord_offset+DIM*1+XX];
112 iy1 = shY + x[i_coord_offset+DIM*1+YY];
113 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
114 ix2 = shX + x[i_coord_offset+DIM*2+XX];
115 iy2 = shY + x[i_coord_offset+DIM*2+YY];
116 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
117 ix3 = shX + x[i_coord_offset+DIM*3+XX];
118 iy3 = shY + x[i_coord_offset+DIM*3+YY];
119 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
131 /* Reset potential sums */
134 /* Start inner kernel loop */
135 for(jidx=j_index_start; jidx<j_index_end; jidx++)
137 /* Get j neighbor index, and coordinate index */
139 j_coord_offset = DIM*jnr;
141 /* load j atom coordinates */
142 jx0 = x[j_coord_offset+DIM*0+XX];
143 jy0 = x[j_coord_offset+DIM*0+YY];
144 jz0 = x[j_coord_offset+DIM*0+ZZ];
146 /* Calculate displacement vector */
157 /* Calculate squared distance and things based on it */
158 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
159 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
160 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
162 rinv10 = gmx_invsqrt(rsq10);
163 rinv20 = gmx_invsqrt(rsq20);
164 rinv30 = gmx_invsqrt(rsq30);
166 rinvsq10 = rinv10*rinv10;
167 rinvsq20 = rinv20*rinv20;
168 rinvsq30 = rinv30*rinv30;
170 /* Load parameters for j particles */
173 /**************************
174 * CALCULATE INTERACTIONS *
175 **************************/
179 /* COULOMB ELECTROSTATICS */
181 felec = velec*rinvsq10;
183 /* Update potential sums from outer loop */
188 /* Calculate temporary vectorial force */
193 /* Update vectorial force */
197 f[j_coord_offset+DIM*0+XX] -= tx;
198 f[j_coord_offset+DIM*0+YY] -= ty;
199 f[j_coord_offset+DIM*0+ZZ] -= tz;
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
207 /* COULOMB ELECTROSTATICS */
209 felec = velec*rinvsq20;
211 /* Update potential sums from outer loop */
216 /* Calculate temporary vectorial force */
221 /* Update vectorial force */
225 f[j_coord_offset+DIM*0+XX] -= tx;
226 f[j_coord_offset+DIM*0+YY] -= ty;
227 f[j_coord_offset+DIM*0+ZZ] -= tz;
229 /**************************
230 * CALCULATE INTERACTIONS *
231 **************************/
235 /* COULOMB ELECTROSTATICS */
237 felec = velec*rinvsq30;
239 /* Update potential sums from outer loop */
244 /* Calculate temporary vectorial force */
249 /* Update vectorial force */
253 f[j_coord_offset+DIM*0+XX] -= tx;
254 f[j_coord_offset+DIM*0+YY] -= ty;
255 f[j_coord_offset+DIM*0+ZZ] -= tz;
257 /* Inner loop uses 84 flops */
259 /* End of innermost loop */
262 f[i_coord_offset+DIM*1+XX] += fix1;
263 f[i_coord_offset+DIM*1+YY] += fiy1;
264 f[i_coord_offset+DIM*1+ZZ] += fiz1;
268 f[i_coord_offset+DIM*2+XX] += fix2;
269 f[i_coord_offset+DIM*2+YY] += fiy2;
270 f[i_coord_offset+DIM*2+ZZ] += fiz2;
274 f[i_coord_offset+DIM*3+XX] += fix3;
275 f[i_coord_offset+DIM*3+YY] += fiy3;
276 f[i_coord_offset+DIM*3+ZZ] += fiz3;
280 fshift[i_shift_offset+XX] += tx;
281 fshift[i_shift_offset+YY] += ty;
282 fshift[i_shift_offset+ZZ] += tz;
285 /* Update potential energies */
286 kernel_data->energygrp_elec[ggid] += velecsum;
288 /* Increment number of inner iterations */
289 inneriter += j_index_end - j_index_start;
291 /* Outer loop uses 31 flops */
294 /* Increment number of outer iterations */
297 /* Update outer/inner flops */
299 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*84);
302 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_c
303 * Electrostatics interaction: Coulomb
304 * VdW interaction: None
305 * Geometry: Water4-Particle
306 * Calculate force/pot: Force
309 nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_c
310 (t_nblist * gmx_restrict nlist,
311 rvec * gmx_restrict xx,
312 rvec * gmx_restrict ff,
313 t_forcerec * gmx_restrict fr,
314 t_mdatoms * gmx_restrict mdatoms,
315 nb_kernel_data_t * gmx_restrict kernel_data,
316 t_nrnb * gmx_restrict nrnb)
318 int i_shift_offset,i_coord_offset,j_coord_offset;
319 int j_index_start,j_index_end;
320 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
321 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
322 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
323 real *shiftvec,*fshift,*x,*f;
325 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
327 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
329 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
331 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
332 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
333 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
334 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
335 real velec,felec,velecsum,facel,crf,krf,krf2;
343 jindex = nlist->jindex;
345 shiftidx = nlist->shift;
347 shiftvec = fr->shift_vec[0];
348 fshift = fr->fshift[0];
350 charge = mdatoms->chargeA;
352 /* Setup water-specific parameters */
353 inr = nlist->iinr[0];
354 iq1 = facel*charge[inr+1];
355 iq2 = facel*charge[inr+2];
356 iq3 = facel*charge[inr+3];
361 /* Start outer loop over neighborlists */
362 for(iidx=0; iidx<nri; iidx++)
364 /* Load shift vector for this list */
365 i_shift_offset = DIM*shiftidx[iidx];
366 shX = shiftvec[i_shift_offset+XX];
367 shY = shiftvec[i_shift_offset+YY];
368 shZ = shiftvec[i_shift_offset+ZZ];
370 /* Load limits for loop over neighbors */
371 j_index_start = jindex[iidx];
372 j_index_end = jindex[iidx+1];
374 /* Get outer coordinate index */
376 i_coord_offset = DIM*inr;
378 /* Load i particle coords and add shift vector */
379 ix1 = shX + x[i_coord_offset+DIM*1+XX];
380 iy1 = shY + x[i_coord_offset+DIM*1+YY];
381 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
382 ix2 = shX + x[i_coord_offset+DIM*2+XX];
383 iy2 = shY + x[i_coord_offset+DIM*2+YY];
384 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
385 ix3 = shX + x[i_coord_offset+DIM*3+XX];
386 iy3 = shY + x[i_coord_offset+DIM*3+YY];
387 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
399 /* Start inner kernel loop */
400 for(jidx=j_index_start; jidx<j_index_end; jidx++)
402 /* Get j neighbor index, and coordinate index */
404 j_coord_offset = DIM*jnr;
406 /* load j atom coordinates */
407 jx0 = x[j_coord_offset+DIM*0+XX];
408 jy0 = x[j_coord_offset+DIM*0+YY];
409 jz0 = x[j_coord_offset+DIM*0+ZZ];
411 /* Calculate displacement vector */
422 /* Calculate squared distance and things based on it */
423 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
424 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
425 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
427 rinv10 = gmx_invsqrt(rsq10);
428 rinv20 = gmx_invsqrt(rsq20);
429 rinv30 = gmx_invsqrt(rsq30);
431 rinvsq10 = rinv10*rinv10;
432 rinvsq20 = rinv20*rinv20;
433 rinvsq30 = rinv30*rinv30;
435 /* Load parameters for j particles */
438 /**************************
439 * CALCULATE INTERACTIONS *
440 **************************/
444 /* COULOMB ELECTROSTATICS */
446 felec = velec*rinvsq10;
450 /* Calculate temporary vectorial force */
455 /* Update vectorial force */
459 f[j_coord_offset+DIM*0+XX] -= tx;
460 f[j_coord_offset+DIM*0+YY] -= ty;
461 f[j_coord_offset+DIM*0+ZZ] -= tz;
463 /**************************
464 * CALCULATE INTERACTIONS *
465 **************************/
469 /* COULOMB ELECTROSTATICS */
471 felec = velec*rinvsq20;
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f[j_coord_offset+DIM*0+XX] -= tx;
485 f[j_coord_offset+DIM*0+YY] -= ty;
486 f[j_coord_offset+DIM*0+ZZ] -= tz;
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
494 /* COULOMB ELECTROSTATICS */
496 felec = velec*rinvsq30;
500 /* Calculate temporary vectorial force */
505 /* Update vectorial force */
509 f[j_coord_offset+DIM*0+XX] -= tx;
510 f[j_coord_offset+DIM*0+YY] -= ty;
511 f[j_coord_offset+DIM*0+ZZ] -= tz;
513 /* Inner loop uses 81 flops */
515 /* End of innermost loop */
518 f[i_coord_offset+DIM*1+XX] += fix1;
519 f[i_coord_offset+DIM*1+YY] += fiy1;
520 f[i_coord_offset+DIM*1+ZZ] += fiz1;
524 f[i_coord_offset+DIM*2+XX] += fix2;
525 f[i_coord_offset+DIM*2+YY] += fiy2;
526 f[i_coord_offset+DIM*2+ZZ] += fiz2;
530 f[i_coord_offset+DIM*3+XX] += fix3;
531 f[i_coord_offset+DIM*3+YY] += fiy3;
532 f[i_coord_offset+DIM*3+ZZ] += fiz3;
536 fshift[i_shift_offset+XX] += tx;
537 fshift[i_shift_offset+YY] += ty;
538 fshift[i_shift_offset+ZZ] += tz;
540 /* Increment number of inner iterations */
541 inneriter += j_index_end - j_index_start;
543 /* Outer loop uses 30 flops */
546 /* Increment number of outer iterations */
549 /* Update outer/inner flops */
551 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*81);