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_ElecEw_VdwNone_GeomW4P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_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;
70 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
78 jindex = nlist->jindex;
80 shiftidx = nlist->shift;
82 shiftvec = fr->shift_vec[0];
83 fshift = fr->fshift[0];
85 charge = mdatoms->chargeA;
87 sh_ewald = fr->ic->sh_ewald;
88 ewtab = fr->ic->tabq_coul_FDV0;
89 ewtabscale = fr->ic->tabq_scale;
90 ewtabhalfspace = 0.5/ewtabscale;
92 /* Setup water-specific parameters */
94 iq1 = facel*charge[inr+1];
95 iq2 = facel*charge[inr+2];
96 iq3 = facel*charge[inr+3];
101 /* Start outer loop over neighborlists */
102 for(iidx=0; iidx<nri; iidx++)
104 /* Load shift vector for this list */
105 i_shift_offset = DIM*shiftidx[iidx];
106 shX = shiftvec[i_shift_offset+XX];
107 shY = shiftvec[i_shift_offset+YY];
108 shZ = shiftvec[i_shift_offset+ZZ];
110 /* Load limits for loop over neighbors */
111 j_index_start = jindex[iidx];
112 j_index_end = jindex[iidx+1];
114 /* Get outer coordinate index */
116 i_coord_offset = DIM*inr;
118 /* Load i particle coords and add shift vector */
119 ix1 = shX + x[i_coord_offset+DIM*1+XX];
120 iy1 = shY + x[i_coord_offset+DIM*1+YY];
121 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
122 ix2 = shX + x[i_coord_offset+DIM*2+XX];
123 iy2 = shY + x[i_coord_offset+DIM*2+YY];
124 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
125 ix3 = shX + x[i_coord_offset+DIM*3+XX];
126 iy3 = shY + x[i_coord_offset+DIM*3+YY];
127 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
139 /* Reset potential sums */
142 /* Start inner kernel loop */
143 for(jidx=j_index_start; jidx<j_index_end; jidx++)
145 /* Get j neighbor index, and coordinate index */
147 j_coord_offset = DIM*jnr;
149 /* load j atom coordinates */
150 jx0 = x[j_coord_offset+DIM*0+XX];
151 jy0 = x[j_coord_offset+DIM*0+YY];
152 jz0 = x[j_coord_offset+DIM*0+ZZ];
154 /* Calculate displacement vector */
165 /* Calculate squared distance and things based on it */
166 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
167 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
168 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
170 rinv10 = gmx_invsqrt(rsq10);
171 rinv20 = gmx_invsqrt(rsq20);
172 rinv30 = gmx_invsqrt(rsq30);
174 rinvsq10 = rinv10*rinv10;
175 rinvsq20 = rinv20*rinv20;
176 rinvsq30 = rinv30*rinv30;
178 /* Load parameters for j particles */
181 /**************************
182 * CALCULATE INTERACTIONS *
183 **************************/
189 /* EWALD ELECTROSTATICS */
191 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
192 ewrt = r10*ewtabscale;
196 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
197 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
198 felec = qq10*rinv10*(rinvsq10-felec);
200 /* Update potential sums from outer loop */
205 /* Calculate temporary vectorial force */
210 /* Update vectorial force */
214 f[j_coord_offset+DIM*0+XX] -= tx;
215 f[j_coord_offset+DIM*0+YY] -= ty;
216 f[j_coord_offset+DIM*0+ZZ] -= tz;
218 /**************************
219 * CALCULATE INTERACTIONS *
220 **************************/
226 /* EWALD ELECTROSTATICS */
228 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
229 ewrt = r20*ewtabscale;
233 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
234 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
235 felec = qq20*rinv20*(rinvsq20-felec);
237 /* Update potential sums from outer loop */
242 /* Calculate temporary vectorial force */
247 /* Update vectorial force */
251 f[j_coord_offset+DIM*0+XX] -= tx;
252 f[j_coord_offset+DIM*0+YY] -= ty;
253 f[j_coord_offset+DIM*0+ZZ] -= tz;
255 /**************************
256 * CALCULATE INTERACTIONS *
257 **************************/
263 /* EWALD ELECTROSTATICS */
265 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
266 ewrt = r30*ewtabscale;
270 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
271 velec = qq30*(rinv30-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
272 felec = qq30*rinv30*(rinvsq30-felec);
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*0+XX] -= tx;
289 f[j_coord_offset+DIM*0+YY] -= ty;
290 f[j_coord_offset+DIM*0+ZZ] -= tz;
292 /* Inner loop uses 123 flops */
294 /* End of innermost loop */
297 f[i_coord_offset+DIM*1+XX] += fix1;
298 f[i_coord_offset+DIM*1+YY] += fiy1;
299 f[i_coord_offset+DIM*1+ZZ] += fiz1;
303 f[i_coord_offset+DIM*2+XX] += fix2;
304 f[i_coord_offset+DIM*2+YY] += fiy2;
305 f[i_coord_offset+DIM*2+ZZ] += fiz2;
309 f[i_coord_offset+DIM*3+XX] += fix3;
310 f[i_coord_offset+DIM*3+YY] += fiy3;
311 f[i_coord_offset+DIM*3+ZZ] += fiz3;
315 fshift[i_shift_offset+XX] += tx;
316 fshift[i_shift_offset+YY] += ty;
317 fshift[i_shift_offset+ZZ] += tz;
320 /* Update potential energies */
321 kernel_data->energygrp_elec[ggid] += velecsum;
323 /* Increment number of inner iterations */
324 inneriter += j_index_end - j_index_start;
326 /* Outer loop uses 31 flops */
329 /* Increment number of outer iterations */
332 /* Update outer/inner flops */
334 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*123);
337 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW4P1_F_c
338 * Electrostatics interaction: Ewald
339 * VdW interaction: None
340 * Geometry: Water4-Particle
341 * Calculate force/pot: Force
344 nb_kernel_ElecEw_VdwNone_GeomW4P1_F_c
345 (t_nblist * gmx_restrict nlist,
346 rvec * gmx_restrict xx,
347 rvec * gmx_restrict ff,
348 t_forcerec * gmx_restrict fr,
349 t_mdatoms * gmx_restrict mdatoms,
350 nb_kernel_data_t * gmx_restrict kernel_data,
351 t_nrnb * gmx_restrict nrnb)
353 int i_shift_offset,i_coord_offset,j_coord_offset;
354 int j_index_start,j_index_end;
355 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
356 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
357 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
358 real *shiftvec,*fshift,*x,*f;
360 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
362 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
364 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
366 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
367 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
368 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
369 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
370 real velec,felec,velecsum,facel,crf,krf,krf2;
373 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
381 jindex = nlist->jindex;
383 shiftidx = nlist->shift;
385 shiftvec = fr->shift_vec[0];
386 fshift = fr->fshift[0];
388 charge = mdatoms->chargeA;
390 sh_ewald = fr->ic->sh_ewald;
391 ewtab = fr->ic->tabq_coul_F;
392 ewtabscale = fr->ic->tabq_scale;
393 ewtabhalfspace = 0.5/ewtabscale;
395 /* Setup water-specific parameters */
396 inr = nlist->iinr[0];
397 iq1 = facel*charge[inr+1];
398 iq2 = facel*charge[inr+2];
399 iq3 = facel*charge[inr+3];
404 /* Start outer loop over neighborlists */
405 for(iidx=0; iidx<nri; iidx++)
407 /* Load shift vector for this list */
408 i_shift_offset = DIM*shiftidx[iidx];
409 shX = shiftvec[i_shift_offset+XX];
410 shY = shiftvec[i_shift_offset+YY];
411 shZ = shiftvec[i_shift_offset+ZZ];
413 /* Load limits for loop over neighbors */
414 j_index_start = jindex[iidx];
415 j_index_end = jindex[iidx+1];
417 /* Get outer coordinate index */
419 i_coord_offset = DIM*inr;
421 /* Load i particle coords and add shift vector */
422 ix1 = shX + x[i_coord_offset+DIM*1+XX];
423 iy1 = shY + x[i_coord_offset+DIM*1+YY];
424 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
425 ix2 = shX + x[i_coord_offset+DIM*2+XX];
426 iy2 = shY + x[i_coord_offset+DIM*2+YY];
427 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
428 ix3 = shX + x[i_coord_offset+DIM*3+XX];
429 iy3 = shY + x[i_coord_offset+DIM*3+YY];
430 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
442 /* Start inner kernel loop */
443 for(jidx=j_index_start; jidx<j_index_end; jidx++)
445 /* Get j neighbor index, and coordinate index */
447 j_coord_offset = DIM*jnr;
449 /* load j atom coordinates */
450 jx0 = x[j_coord_offset+DIM*0+XX];
451 jy0 = x[j_coord_offset+DIM*0+YY];
452 jz0 = x[j_coord_offset+DIM*0+ZZ];
454 /* Calculate displacement vector */
465 /* Calculate squared distance and things based on it */
466 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
467 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
468 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
470 rinv10 = gmx_invsqrt(rsq10);
471 rinv20 = gmx_invsqrt(rsq20);
472 rinv30 = gmx_invsqrt(rsq30);
474 rinvsq10 = rinv10*rinv10;
475 rinvsq20 = rinv20*rinv20;
476 rinvsq30 = rinv30*rinv30;
478 /* Load parameters for j particles */
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
489 /* EWALD ELECTROSTATICS */
491 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
492 ewrt = r10*ewtabscale;
495 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
496 felec = qq10*rinv10*(rinvsq10-felec);
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 /**************************
514 * CALCULATE INTERACTIONS *
515 **************************/
521 /* EWALD ELECTROSTATICS */
523 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
524 ewrt = r20*ewtabscale;
527 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
528 felec = qq20*rinv20*(rinvsq20-felec);
532 /* Calculate temporary vectorial force */
537 /* Update vectorial force */
541 f[j_coord_offset+DIM*0+XX] -= tx;
542 f[j_coord_offset+DIM*0+YY] -= ty;
543 f[j_coord_offset+DIM*0+ZZ] -= tz;
545 /**************************
546 * CALCULATE INTERACTIONS *
547 **************************/
553 /* EWALD ELECTROSTATICS */
555 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
556 ewrt = r30*ewtabscale;
559 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
560 felec = qq30*rinv30*(rinvsq30-felec);
564 /* Calculate temporary vectorial force */
569 /* Update vectorial force */
573 f[j_coord_offset+DIM*0+XX] -= tx;
574 f[j_coord_offset+DIM*0+YY] -= ty;
575 f[j_coord_offset+DIM*0+ZZ] -= tz;
577 /* Inner loop uses 102 flops */
579 /* End of innermost loop */
582 f[i_coord_offset+DIM*1+XX] += fix1;
583 f[i_coord_offset+DIM*1+YY] += fiy1;
584 f[i_coord_offset+DIM*1+ZZ] += fiz1;
588 f[i_coord_offset+DIM*2+XX] += fix2;
589 f[i_coord_offset+DIM*2+YY] += fiy2;
590 f[i_coord_offset+DIM*2+ZZ] += fiz2;
594 f[i_coord_offset+DIM*3+XX] += fix3;
595 f[i_coord_offset+DIM*3+YY] += fiy3;
596 f[i_coord_offset+DIM*3+ZZ] += fiz3;
600 fshift[i_shift_offset+XX] += tx;
601 fshift[i_shift_offset+YY] += ty;
602 fshift[i_shift_offset+ZZ] += tz;
604 /* Increment number of inner iterations */
605 inneriter += j_index_end - j_index_start;
607 /* Outer loop uses 30 flops */
610 /* Increment number of outer iterations */
613 /* Update outer/inner flops */
615 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*102);