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_ElecEwSh_VdwNone_GeomW3P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
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 iq0 = facel*charge[inr+0];
95 iq1 = facel*charge[inr+1];
96 iq2 = facel*charge[inr+2];
98 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
99 rcutoff = fr->rcoulomb;
100 rcutoff2 = rcutoff*rcutoff;
105 /* Start outer loop over neighborlists */
106 for(iidx=0; iidx<nri; iidx++)
108 /* Load shift vector for this list */
109 i_shift_offset = DIM*shiftidx[iidx];
110 shX = shiftvec[i_shift_offset+XX];
111 shY = shiftvec[i_shift_offset+YY];
112 shZ = shiftvec[i_shift_offset+ZZ];
114 /* Load limits for loop over neighbors */
115 j_index_start = jindex[iidx];
116 j_index_end = jindex[iidx+1];
118 /* Get outer coordinate index */
120 i_coord_offset = DIM*inr;
122 /* Load i particle coords and add shift vector */
123 ix0 = shX + x[i_coord_offset+DIM*0+XX];
124 iy0 = shY + x[i_coord_offset+DIM*0+YY];
125 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
126 ix1 = shX + x[i_coord_offset+DIM*1+XX];
127 iy1 = shY + x[i_coord_offset+DIM*1+YY];
128 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
129 ix2 = shX + x[i_coord_offset+DIM*2+XX];
130 iy2 = shY + x[i_coord_offset+DIM*2+YY];
131 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
143 /* Reset potential sums */
146 /* Start inner kernel loop */
147 for(jidx=j_index_start; jidx<j_index_end; jidx++)
149 /* Get j neighbor index, and coordinate index */
151 j_coord_offset = DIM*jnr;
153 /* load j atom coordinates */
154 jx0 = x[j_coord_offset+DIM*0+XX];
155 jy0 = x[j_coord_offset+DIM*0+YY];
156 jz0 = x[j_coord_offset+DIM*0+ZZ];
158 /* Calculate displacement vector */
169 /* Calculate squared distance and things based on it */
170 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
171 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
172 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
174 rinv00 = gmx_invsqrt(rsq00);
175 rinv10 = gmx_invsqrt(rsq10);
176 rinv20 = gmx_invsqrt(rsq20);
178 rinvsq00 = rinv00*rinv00;
179 rinvsq10 = rinv10*rinv10;
180 rinvsq20 = rinv20*rinv20;
182 /* Load parameters for j particles */
185 /**************************
186 * CALCULATE INTERACTIONS *
187 **************************/
196 /* EWALD ELECTROSTATICS */
198 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
199 ewrt = r00*ewtabscale;
203 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
204 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
205 felec = qq00*rinv00*(rinvsq00-felec);
207 /* Update potential sums from outer loop */
212 /* Calculate temporary vectorial force */
217 /* Update vectorial force */
221 f[j_coord_offset+DIM*0+XX] -= tx;
222 f[j_coord_offset+DIM*0+YY] -= ty;
223 f[j_coord_offset+DIM*0+ZZ] -= tz;
227 /**************************
228 * CALCULATE INTERACTIONS *
229 **************************/
238 /* EWALD ELECTROSTATICS */
240 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
241 ewrt = r10*ewtabscale;
245 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
246 velec = qq10*((rinv10-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
247 felec = qq10*rinv10*(rinvsq10-felec);
249 /* Update potential sums from outer loop */
254 /* Calculate temporary vectorial force */
259 /* Update vectorial force */
263 f[j_coord_offset+DIM*0+XX] -= tx;
264 f[j_coord_offset+DIM*0+YY] -= ty;
265 f[j_coord_offset+DIM*0+ZZ] -= tz;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
280 /* EWALD ELECTROSTATICS */
282 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
283 ewrt = r20*ewtabscale;
287 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
288 velec = qq20*((rinv20-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
289 felec = qq20*rinv20*(rinvsq20-felec);
291 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
311 /* Inner loop uses 126 flops */
313 /* End of innermost loop */
316 f[i_coord_offset+DIM*0+XX] += fix0;
317 f[i_coord_offset+DIM*0+YY] += fiy0;
318 f[i_coord_offset+DIM*0+ZZ] += fiz0;
322 f[i_coord_offset+DIM*1+XX] += fix1;
323 f[i_coord_offset+DIM*1+YY] += fiy1;
324 f[i_coord_offset+DIM*1+ZZ] += fiz1;
328 f[i_coord_offset+DIM*2+XX] += fix2;
329 f[i_coord_offset+DIM*2+YY] += fiy2;
330 f[i_coord_offset+DIM*2+ZZ] += fiz2;
334 fshift[i_shift_offset+XX] += tx;
335 fshift[i_shift_offset+YY] += ty;
336 fshift[i_shift_offset+ZZ] += tz;
339 /* Update potential energies */
340 kernel_data->energygrp_elec[ggid] += velecsum;
342 /* Increment number of inner iterations */
343 inneriter += j_index_end - j_index_start;
345 /* Outer loop uses 31 flops */
348 /* Increment number of outer iterations */
351 /* Update outer/inner flops */
353 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*126);
356 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_c
357 * Electrostatics interaction: Ewald
358 * VdW interaction: None
359 * Geometry: Water3-Particle
360 * Calculate force/pot: Force
363 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_c
364 (t_nblist * gmx_restrict nlist,
365 rvec * gmx_restrict xx,
366 rvec * gmx_restrict ff,
367 t_forcerec * gmx_restrict fr,
368 t_mdatoms * gmx_restrict mdatoms,
369 nb_kernel_data_t * gmx_restrict kernel_data,
370 t_nrnb * gmx_restrict nrnb)
372 int i_shift_offset,i_coord_offset,j_coord_offset;
373 int j_index_start,j_index_end;
374 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
375 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
376 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
377 real *shiftvec,*fshift,*x,*f;
379 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
381 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
383 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
385 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
386 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
387 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
388 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
389 real velec,felec,velecsum,facel,crf,krf,krf2;
392 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
400 jindex = nlist->jindex;
402 shiftidx = nlist->shift;
404 shiftvec = fr->shift_vec[0];
405 fshift = fr->fshift[0];
407 charge = mdatoms->chargeA;
409 sh_ewald = fr->ic->sh_ewald;
410 ewtab = fr->ic->tabq_coul_F;
411 ewtabscale = fr->ic->tabq_scale;
412 ewtabhalfspace = 0.5/ewtabscale;
414 /* Setup water-specific parameters */
415 inr = nlist->iinr[0];
416 iq0 = facel*charge[inr+0];
417 iq1 = facel*charge[inr+1];
418 iq2 = facel*charge[inr+2];
420 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
421 rcutoff = fr->rcoulomb;
422 rcutoff2 = rcutoff*rcutoff;
427 /* Start outer loop over neighborlists */
428 for(iidx=0; iidx<nri; iidx++)
430 /* Load shift vector for this list */
431 i_shift_offset = DIM*shiftidx[iidx];
432 shX = shiftvec[i_shift_offset+XX];
433 shY = shiftvec[i_shift_offset+YY];
434 shZ = shiftvec[i_shift_offset+ZZ];
436 /* Load limits for loop over neighbors */
437 j_index_start = jindex[iidx];
438 j_index_end = jindex[iidx+1];
440 /* Get outer coordinate index */
442 i_coord_offset = DIM*inr;
444 /* Load i particle coords and add shift vector */
445 ix0 = shX + x[i_coord_offset+DIM*0+XX];
446 iy0 = shY + x[i_coord_offset+DIM*0+YY];
447 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
448 ix1 = shX + x[i_coord_offset+DIM*1+XX];
449 iy1 = shY + x[i_coord_offset+DIM*1+YY];
450 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
451 ix2 = shX + x[i_coord_offset+DIM*2+XX];
452 iy2 = shY + x[i_coord_offset+DIM*2+YY];
453 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
465 /* Start inner kernel loop */
466 for(jidx=j_index_start; jidx<j_index_end; jidx++)
468 /* Get j neighbor index, and coordinate index */
470 j_coord_offset = DIM*jnr;
472 /* load j atom coordinates */
473 jx0 = x[j_coord_offset+DIM*0+XX];
474 jy0 = x[j_coord_offset+DIM*0+YY];
475 jz0 = x[j_coord_offset+DIM*0+ZZ];
477 /* Calculate displacement vector */
488 /* Calculate squared distance and things based on it */
489 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
490 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
491 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
493 rinv00 = gmx_invsqrt(rsq00);
494 rinv10 = gmx_invsqrt(rsq10);
495 rinv20 = gmx_invsqrt(rsq20);
497 rinvsq00 = rinv00*rinv00;
498 rinvsq10 = rinv10*rinv10;
499 rinvsq20 = rinv20*rinv20;
501 /* Load parameters for j particles */
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
515 /* EWALD ELECTROSTATICS */
517 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
518 ewrt = r00*ewtabscale;
521 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
522 felec = qq00*rinv00*(rinvsq00-felec);
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*0+XX] -= tx;
536 f[j_coord_offset+DIM*0+YY] -= ty;
537 f[j_coord_offset+DIM*0+ZZ] -= tz;
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
552 /* EWALD ELECTROSTATICS */
554 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
555 ewrt = r10*ewtabscale;
558 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
559 felec = qq10*rinv10*(rinvsq10-felec);
563 /* Calculate temporary vectorial force */
568 /* Update vectorial force */
572 f[j_coord_offset+DIM*0+XX] -= tx;
573 f[j_coord_offset+DIM*0+YY] -= ty;
574 f[j_coord_offset+DIM*0+ZZ] -= tz;
578 /**************************
579 * CALCULATE INTERACTIONS *
580 **************************/
589 /* EWALD ELECTROSTATICS */
591 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
592 ewrt = r20*ewtabscale;
595 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
596 felec = qq20*rinv20*(rinvsq20-felec);
600 /* Calculate temporary vectorial force */
605 /* Update vectorial force */
609 f[j_coord_offset+DIM*0+XX] -= tx;
610 f[j_coord_offset+DIM*0+YY] -= ty;
611 f[j_coord_offset+DIM*0+ZZ] -= tz;
615 /* Inner loop uses 102 flops */
617 /* End of innermost loop */
620 f[i_coord_offset+DIM*0+XX] += fix0;
621 f[i_coord_offset+DIM*0+YY] += fiy0;
622 f[i_coord_offset+DIM*0+ZZ] += fiz0;
626 f[i_coord_offset+DIM*1+XX] += fix1;
627 f[i_coord_offset+DIM*1+YY] += fiy1;
628 f[i_coord_offset+DIM*1+ZZ] += fiz1;
632 f[i_coord_offset+DIM*2+XX] += fix2;
633 f[i_coord_offset+DIM*2+YY] += fiy2;
634 f[i_coord_offset+DIM*2+ZZ] += fiz2;
638 fshift[i_shift_offset+XX] += tx;
639 fshift[i_shift_offset+YY] += ty;
640 fshift[i_shift_offset+ZZ] += tz;
642 /* Increment number of inner iterations */
643 inneriter += j_index_end - j_index_start;
645 /* Outer loop uses 30 flops */
648 /* Increment number of outer iterations */
651 /* Update outer/inner flops */
653 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*102);