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_VdwLJ_GeomW3P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwLJ_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 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
74 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
82 jindex = nlist->jindex;
84 shiftidx = nlist->shift;
86 shiftvec = fr->shift_vec[0];
87 fshift = fr->fshift[0];
89 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 sh_ewald = fr->ic->sh_ewald;
95 ewtab = fr->ic->tabq_coul_FDV0;
96 ewtabscale = fr->ic->tabq_scale;
97 ewtabhalfspace = 0.5/ewtabscale;
99 /* Setup water-specific parameters */
100 inr = nlist->iinr[0];
101 iq0 = facel*charge[inr+0];
102 iq1 = facel*charge[inr+1];
103 iq2 = facel*charge[inr+2];
104 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
109 /* Start outer loop over neighborlists */
110 for(iidx=0; iidx<nri; iidx++)
112 /* Load shift vector for this list */
113 i_shift_offset = DIM*shiftidx[iidx];
114 shX = shiftvec[i_shift_offset+XX];
115 shY = shiftvec[i_shift_offset+YY];
116 shZ = shiftvec[i_shift_offset+ZZ];
118 /* Load limits for loop over neighbors */
119 j_index_start = jindex[iidx];
120 j_index_end = jindex[iidx+1];
122 /* Get outer coordinate index */
124 i_coord_offset = DIM*inr;
126 /* Load i particle coords and add shift vector */
127 ix0 = shX + x[i_coord_offset+DIM*0+XX];
128 iy0 = shY + x[i_coord_offset+DIM*0+YY];
129 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
130 ix1 = shX + x[i_coord_offset+DIM*1+XX];
131 iy1 = shY + x[i_coord_offset+DIM*1+YY];
132 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
133 ix2 = shX + x[i_coord_offset+DIM*2+XX];
134 iy2 = shY + x[i_coord_offset+DIM*2+YY];
135 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
147 /* Reset potential sums */
151 /* Start inner kernel loop */
152 for(jidx=j_index_start; jidx<j_index_end; jidx++)
154 /* Get j neighbor index, and coordinate index */
156 j_coord_offset = DIM*jnr;
158 /* load j atom coordinates */
159 jx0 = x[j_coord_offset+DIM*0+XX];
160 jy0 = x[j_coord_offset+DIM*0+YY];
161 jz0 = x[j_coord_offset+DIM*0+ZZ];
163 /* Calculate displacement vector */
174 /* Calculate squared distance and things based on it */
175 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
176 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
177 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
179 rinv00 = gmx_invsqrt(rsq00);
180 rinv10 = gmx_invsqrt(rsq10);
181 rinv20 = gmx_invsqrt(rsq20);
183 rinvsq00 = rinv00*rinv00;
184 rinvsq10 = rinv10*rinv10;
185 rinvsq20 = rinv20*rinv20;
187 /* Load parameters for j particles */
189 vdwjidx0 = 2*vdwtype[jnr+0];
191 /**************************
192 * CALCULATE INTERACTIONS *
193 **************************/
198 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
199 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
201 /* EWALD ELECTROSTATICS */
203 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
204 ewrt = r00*ewtabscale;
208 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
209 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
210 felec = qq00*rinv00*(rinvsq00-felec);
212 /* LENNARD-JONES DISPERSION/REPULSION */
214 rinvsix = rinvsq00*rinvsq00*rinvsq00;
215 vvdw6 = c6_00*rinvsix;
216 vvdw12 = c12_00*rinvsix*rinvsix;
217 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
218 fvdw = (vvdw12-vvdw6)*rinvsq00;
220 /* Update potential sums from outer loop */
226 /* Calculate temporary vectorial force */
231 /* Update vectorial force */
235 f[j_coord_offset+DIM*0+XX] -= tx;
236 f[j_coord_offset+DIM*0+YY] -= ty;
237 f[j_coord_offset+DIM*0+ZZ] -= tz;
239 /**************************
240 * CALCULATE INTERACTIONS *
241 **************************/
247 /* EWALD ELECTROSTATICS */
249 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
250 ewrt = r10*ewtabscale;
254 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
255 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
256 felec = qq10*rinv10*(rinvsq10-felec);
258 /* Update potential sums from outer loop */
263 /* Calculate temporary vectorial force */
268 /* Update vectorial force */
272 f[j_coord_offset+DIM*0+XX] -= tx;
273 f[j_coord_offset+DIM*0+YY] -= ty;
274 f[j_coord_offset+DIM*0+ZZ] -= tz;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
284 /* EWALD ELECTROSTATICS */
286 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
287 ewrt = r20*ewtabscale;
291 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
292 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
293 felec = qq20*rinv20*(rinvsq20-felec);
295 /* Update potential sums from outer loop */
300 /* Calculate temporary vectorial force */
305 /* Update vectorial force */
309 f[j_coord_offset+DIM*0+XX] -= tx;
310 f[j_coord_offset+DIM*0+YY] -= ty;
311 f[j_coord_offset+DIM*0+ZZ] -= tz;
313 /* Inner loop uses 135 flops */
315 /* End of innermost loop */
318 f[i_coord_offset+DIM*0+XX] += fix0;
319 f[i_coord_offset+DIM*0+YY] += fiy0;
320 f[i_coord_offset+DIM*0+ZZ] += fiz0;
324 f[i_coord_offset+DIM*1+XX] += fix1;
325 f[i_coord_offset+DIM*1+YY] += fiy1;
326 f[i_coord_offset+DIM*1+ZZ] += fiz1;
330 f[i_coord_offset+DIM*2+XX] += fix2;
331 f[i_coord_offset+DIM*2+YY] += fiy2;
332 f[i_coord_offset+DIM*2+ZZ] += fiz2;
336 fshift[i_shift_offset+XX] += tx;
337 fshift[i_shift_offset+YY] += ty;
338 fshift[i_shift_offset+ZZ] += tz;
341 /* Update potential energies */
342 kernel_data->energygrp_elec[ggid] += velecsum;
343 kernel_data->energygrp_vdw[ggid] += vvdwsum;
345 /* Increment number of inner iterations */
346 inneriter += j_index_end - j_index_start;
348 /* Outer loop uses 32 flops */
351 /* Increment number of outer iterations */
354 /* Update outer/inner flops */
356 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*135);
359 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW3P1_F_c
360 * Electrostatics interaction: Ewald
361 * VdW interaction: LennardJones
362 * Geometry: Water3-Particle
363 * Calculate force/pot: Force
366 nb_kernel_ElecEw_VdwLJ_GeomW3P1_F_c
367 (t_nblist * gmx_restrict nlist,
368 rvec * gmx_restrict xx,
369 rvec * gmx_restrict ff,
370 t_forcerec * gmx_restrict fr,
371 t_mdatoms * gmx_restrict mdatoms,
372 nb_kernel_data_t * gmx_restrict kernel_data,
373 t_nrnb * gmx_restrict nrnb)
375 int i_shift_offset,i_coord_offset,j_coord_offset;
376 int j_index_start,j_index_end;
377 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
378 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
379 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
380 real *shiftvec,*fshift,*x,*f;
382 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
384 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
386 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
388 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
389 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
390 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
391 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
392 real velec,felec,velecsum,facel,crf,krf,krf2;
395 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
399 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
407 jindex = nlist->jindex;
409 shiftidx = nlist->shift;
411 shiftvec = fr->shift_vec[0];
412 fshift = fr->fshift[0];
414 charge = mdatoms->chargeA;
415 nvdwtype = fr->ntype;
417 vdwtype = mdatoms->typeA;
419 sh_ewald = fr->ic->sh_ewald;
420 ewtab = fr->ic->tabq_coul_F;
421 ewtabscale = fr->ic->tabq_scale;
422 ewtabhalfspace = 0.5/ewtabscale;
424 /* Setup water-specific parameters */
425 inr = nlist->iinr[0];
426 iq0 = facel*charge[inr+0];
427 iq1 = facel*charge[inr+1];
428 iq2 = facel*charge[inr+2];
429 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
434 /* Start outer loop over neighborlists */
435 for(iidx=0; iidx<nri; iidx++)
437 /* Load shift vector for this list */
438 i_shift_offset = DIM*shiftidx[iidx];
439 shX = shiftvec[i_shift_offset+XX];
440 shY = shiftvec[i_shift_offset+YY];
441 shZ = shiftvec[i_shift_offset+ZZ];
443 /* Load limits for loop over neighbors */
444 j_index_start = jindex[iidx];
445 j_index_end = jindex[iidx+1];
447 /* Get outer coordinate index */
449 i_coord_offset = DIM*inr;
451 /* Load i particle coords and add shift vector */
452 ix0 = shX + x[i_coord_offset+DIM*0+XX];
453 iy0 = shY + x[i_coord_offset+DIM*0+YY];
454 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
455 ix1 = shX + x[i_coord_offset+DIM*1+XX];
456 iy1 = shY + x[i_coord_offset+DIM*1+YY];
457 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
458 ix2 = shX + x[i_coord_offset+DIM*2+XX];
459 iy2 = shY + x[i_coord_offset+DIM*2+YY];
460 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
472 /* Start inner kernel loop */
473 for(jidx=j_index_start; jidx<j_index_end; jidx++)
475 /* Get j neighbor index, and coordinate index */
477 j_coord_offset = DIM*jnr;
479 /* load j atom coordinates */
480 jx0 = x[j_coord_offset+DIM*0+XX];
481 jy0 = x[j_coord_offset+DIM*0+YY];
482 jz0 = x[j_coord_offset+DIM*0+ZZ];
484 /* Calculate displacement vector */
495 /* Calculate squared distance and things based on it */
496 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
497 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
498 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
500 rinv00 = gmx_invsqrt(rsq00);
501 rinv10 = gmx_invsqrt(rsq10);
502 rinv20 = gmx_invsqrt(rsq20);
504 rinvsq00 = rinv00*rinv00;
505 rinvsq10 = rinv10*rinv10;
506 rinvsq20 = rinv20*rinv20;
508 /* Load parameters for j particles */
510 vdwjidx0 = 2*vdwtype[jnr+0];
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
519 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
520 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
522 /* EWALD ELECTROSTATICS */
524 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
525 ewrt = r00*ewtabscale;
528 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
529 felec = qq00*rinv00*(rinvsq00-felec);
531 /* LENNARD-JONES DISPERSION/REPULSION */
533 rinvsix = rinvsq00*rinvsq00*rinvsq00;
534 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
538 /* Calculate temporary vectorial force */
543 /* Update vectorial force */
547 f[j_coord_offset+DIM*0+XX] -= tx;
548 f[j_coord_offset+DIM*0+YY] -= ty;
549 f[j_coord_offset+DIM*0+ZZ] -= tz;
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
559 /* EWALD ELECTROSTATICS */
561 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
562 ewrt = r10*ewtabscale;
565 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
566 felec = qq10*rinv10*(rinvsq10-felec);
570 /* Calculate temporary vectorial force */
575 /* Update vectorial force */
579 f[j_coord_offset+DIM*0+XX] -= tx;
580 f[j_coord_offset+DIM*0+YY] -= ty;
581 f[j_coord_offset+DIM*0+ZZ] -= tz;
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
591 /* EWALD ELECTROSTATICS */
593 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
594 ewrt = r20*ewtabscale;
597 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
598 felec = qq20*rinv20*(rinvsq20-felec);
602 /* Calculate temporary vectorial force */
607 /* Update vectorial force */
611 f[j_coord_offset+DIM*0+XX] -= tx;
612 f[j_coord_offset+DIM*0+YY] -= ty;
613 f[j_coord_offset+DIM*0+ZZ] -= tz;
615 /* Inner loop uses 109 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_VDW_W3_F,outeriter*30 + inneriter*109);