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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: CubicSplineTable
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwCSTab_GeomW3P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real velec,felec,velecsum,facel,crf,krf,krf2;
86 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
90 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
93 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
108 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 vftab = kernel_data->table_vdw->data;
114 vftabscale = kernel_data->table_vdw->scale;
116 sh_ewald = fr->ic->sh_ewald;
117 ewtab = fr->ic->tabq_coul_FDV0;
118 ewtabscale = fr->ic->tabq_scale;
119 ewtabhalfspace = 0.5/ewtabscale;
121 /* Setup water-specific parameters */
122 inr = nlist->iinr[0];
123 iq0 = facel*charge[inr+0];
124 iq1 = facel*charge[inr+1];
125 iq2 = facel*charge[inr+2];
126 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
131 /* Start outer loop over neighborlists */
132 for(iidx=0; iidx<nri; iidx++)
134 /* Load shift vector for this list */
135 i_shift_offset = DIM*shiftidx[iidx];
136 shX = shiftvec[i_shift_offset+XX];
137 shY = shiftvec[i_shift_offset+YY];
138 shZ = shiftvec[i_shift_offset+ZZ];
140 /* Load limits for loop over neighbors */
141 j_index_start = jindex[iidx];
142 j_index_end = jindex[iidx+1];
144 /* Get outer coordinate index */
146 i_coord_offset = DIM*inr;
148 /* Load i particle coords and add shift vector */
149 ix0 = shX + x[i_coord_offset+DIM*0+XX];
150 iy0 = shY + x[i_coord_offset+DIM*0+YY];
151 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
152 ix1 = shX + x[i_coord_offset+DIM*1+XX];
153 iy1 = shY + x[i_coord_offset+DIM*1+YY];
154 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
155 ix2 = shX + x[i_coord_offset+DIM*2+XX];
156 iy2 = shY + x[i_coord_offset+DIM*2+YY];
157 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
169 /* Reset potential sums */
173 /* Start inner kernel loop */
174 for(jidx=j_index_start; jidx<j_index_end; jidx++)
176 /* Get j neighbor index, and coordinate index */
178 j_coord_offset = DIM*jnr;
180 /* load j atom coordinates */
181 jx0 = x[j_coord_offset+DIM*0+XX];
182 jy0 = x[j_coord_offset+DIM*0+YY];
183 jz0 = x[j_coord_offset+DIM*0+ZZ];
185 /* Calculate displacement vector */
196 /* Calculate squared distance and things based on it */
197 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
198 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
199 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
201 rinv00 = gmx_invsqrt(rsq00);
202 rinv10 = gmx_invsqrt(rsq10);
203 rinv20 = gmx_invsqrt(rsq20);
205 rinvsq00 = rinv00*rinv00;
206 rinvsq10 = rinv10*rinv10;
207 rinvsq20 = rinv20*rinv20;
209 /* Load parameters for j particles */
211 vdwjidx0 = 2*vdwtype[jnr+0];
213 /**************************
214 * CALCULATE INTERACTIONS *
215 **************************/
220 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
221 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
223 /* Calculate table index by multiplying r with table scale and truncate to integer */
229 /* EWALD ELECTROSTATICS */
231 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
232 ewrt = r00*ewtabscale;
236 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
237 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
238 felec = qq00*rinv00*(rinvsq00-felec);
240 /* CUBIC SPLINE TABLE DISPERSION */
244 Geps = vfeps*vftab[vfitab+2];
245 Heps2 = vfeps*vfeps*vftab[vfitab+3];
249 FF = Fp+Geps+2.0*Heps2;
252 /* CUBIC SPLINE TABLE REPULSION */
255 Geps = vfeps*vftab[vfitab+6];
256 Heps2 = vfeps*vfeps*vftab[vfitab+7];
260 FF = Fp+Geps+2.0*Heps2;
263 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
265 /* Update potential sums from outer loop */
271 /* Calculate temporary vectorial force */
276 /* Update vectorial force */
280 f[j_coord_offset+DIM*0+XX] -= tx;
281 f[j_coord_offset+DIM*0+YY] -= ty;
282 f[j_coord_offset+DIM*0+ZZ] -= tz;
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
292 /* EWALD ELECTROSTATICS */
294 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
295 ewrt = r10*ewtabscale;
299 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
300 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
301 felec = qq10*rinv10*(rinvsq10-felec);
303 /* Update potential sums from outer loop */
308 /* Calculate temporary vectorial force */
313 /* Update vectorial force */
317 f[j_coord_offset+DIM*0+XX] -= tx;
318 f[j_coord_offset+DIM*0+YY] -= ty;
319 f[j_coord_offset+DIM*0+ZZ] -= tz;
321 /**************************
322 * CALCULATE INTERACTIONS *
323 **************************/
329 /* EWALD ELECTROSTATICS */
331 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
332 ewrt = r20*ewtabscale;
336 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
337 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
338 felec = qq20*rinv20*(rinvsq20-felec);
340 /* Update potential sums from outer loop */
345 /* Calculate temporary vectorial force */
350 /* Update vectorial force */
354 f[j_coord_offset+DIM*0+XX] -= tx;
355 f[j_coord_offset+DIM*0+YY] -= ty;
356 f[j_coord_offset+DIM*0+ZZ] -= tz;
358 /* Inner loop uses 156 flops */
360 /* End of innermost loop */
363 f[i_coord_offset+DIM*0+XX] += fix0;
364 f[i_coord_offset+DIM*0+YY] += fiy0;
365 f[i_coord_offset+DIM*0+ZZ] += fiz0;
369 f[i_coord_offset+DIM*1+XX] += fix1;
370 f[i_coord_offset+DIM*1+YY] += fiy1;
371 f[i_coord_offset+DIM*1+ZZ] += fiz1;
375 f[i_coord_offset+DIM*2+XX] += fix2;
376 f[i_coord_offset+DIM*2+YY] += fiy2;
377 f[i_coord_offset+DIM*2+ZZ] += fiz2;
381 fshift[i_shift_offset+XX] += tx;
382 fshift[i_shift_offset+YY] += ty;
383 fshift[i_shift_offset+ZZ] += tz;
386 /* Update potential energies */
387 kernel_data->energygrp_elec[ggid] += velecsum;
388 kernel_data->energygrp_vdw[ggid] += vvdwsum;
390 /* Increment number of inner iterations */
391 inneriter += j_index_end - j_index_start;
393 /* Outer loop uses 32 flops */
396 /* Increment number of outer iterations */
399 /* Update outer/inner flops */
401 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*156);
404 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3P1_F_c
405 * Electrostatics interaction: Ewald
406 * VdW interaction: CubicSplineTable
407 * Geometry: Water3-Particle
408 * Calculate force/pot: Force
411 nb_kernel_ElecEw_VdwCSTab_GeomW3P1_F_c
412 (t_nblist * gmx_restrict nlist,
413 rvec * gmx_restrict xx,
414 rvec * gmx_restrict ff,
415 t_forcerec * gmx_restrict fr,
416 t_mdatoms * gmx_restrict mdatoms,
417 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
418 t_nrnb * gmx_restrict nrnb)
420 int i_shift_offset,i_coord_offset,j_coord_offset;
421 int j_index_start,j_index_end;
422 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
423 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
424 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
425 real *shiftvec,*fshift,*x,*f;
427 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
429 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
431 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
433 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
434 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
435 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
436 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
437 real velec,felec,velecsum,facel,crf,krf,krf2;
440 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
444 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
447 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
455 jindex = nlist->jindex;
457 shiftidx = nlist->shift;
459 shiftvec = fr->shift_vec[0];
460 fshift = fr->fshift[0];
462 charge = mdatoms->chargeA;
463 nvdwtype = fr->ntype;
465 vdwtype = mdatoms->typeA;
467 vftab = kernel_data->table_vdw->data;
468 vftabscale = kernel_data->table_vdw->scale;
470 sh_ewald = fr->ic->sh_ewald;
471 ewtab = fr->ic->tabq_coul_F;
472 ewtabscale = fr->ic->tabq_scale;
473 ewtabhalfspace = 0.5/ewtabscale;
475 /* Setup water-specific parameters */
476 inr = nlist->iinr[0];
477 iq0 = facel*charge[inr+0];
478 iq1 = facel*charge[inr+1];
479 iq2 = facel*charge[inr+2];
480 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
485 /* Start outer loop over neighborlists */
486 for(iidx=0; iidx<nri; iidx++)
488 /* Load shift vector for this list */
489 i_shift_offset = DIM*shiftidx[iidx];
490 shX = shiftvec[i_shift_offset+XX];
491 shY = shiftvec[i_shift_offset+YY];
492 shZ = shiftvec[i_shift_offset+ZZ];
494 /* Load limits for loop over neighbors */
495 j_index_start = jindex[iidx];
496 j_index_end = jindex[iidx+1];
498 /* Get outer coordinate index */
500 i_coord_offset = DIM*inr;
502 /* Load i particle coords and add shift vector */
503 ix0 = shX + x[i_coord_offset+DIM*0+XX];
504 iy0 = shY + x[i_coord_offset+DIM*0+YY];
505 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
506 ix1 = shX + x[i_coord_offset+DIM*1+XX];
507 iy1 = shY + x[i_coord_offset+DIM*1+YY];
508 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
509 ix2 = shX + x[i_coord_offset+DIM*2+XX];
510 iy2 = shY + x[i_coord_offset+DIM*2+YY];
511 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
523 /* Start inner kernel loop */
524 for(jidx=j_index_start; jidx<j_index_end; jidx++)
526 /* Get j neighbor index, and coordinate index */
528 j_coord_offset = DIM*jnr;
530 /* load j atom coordinates */
531 jx0 = x[j_coord_offset+DIM*0+XX];
532 jy0 = x[j_coord_offset+DIM*0+YY];
533 jz0 = x[j_coord_offset+DIM*0+ZZ];
535 /* Calculate displacement vector */
546 /* Calculate squared distance and things based on it */
547 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
548 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
549 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
551 rinv00 = gmx_invsqrt(rsq00);
552 rinv10 = gmx_invsqrt(rsq10);
553 rinv20 = gmx_invsqrt(rsq20);
555 rinvsq00 = rinv00*rinv00;
556 rinvsq10 = rinv10*rinv10;
557 rinvsq20 = rinv20*rinv20;
559 /* Load parameters for j particles */
561 vdwjidx0 = 2*vdwtype[jnr+0];
563 /**************************
564 * CALCULATE INTERACTIONS *
565 **************************/
570 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
571 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
573 /* Calculate table index by multiplying r with table scale and truncate to integer */
579 /* EWALD ELECTROSTATICS */
581 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
582 ewrt = r00*ewtabscale;
585 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
586 felec = qq00*rinv00*(rinvsq00-felec);
588 /* CUBIC SPLINE TABLE DISPERSION */
591 Geps = vfeps*vftab[vfitab+2];
592 Heps2 = vfeps*vfeps*vftab[vfitab+3];
594 FF = Fp+Geps+2.0*Heps2;
597 /* CUBIC SPLINE TABLE REPULSION */
599 Geps = vfeps*vftab[vfitab+6];
600 Heps2 = vfeps*vfeps*vftab[vfitab+7];
602 FF = Fp+Geps+2.0*Heps2;
604 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
608 /* Calculate temporary vectorial force */
613 /* Update vectorial force */
617 f[j_coord_offset+DIM*0+XX] -= tx;
618 f[j_coord_offset+DIM*0+YY] -= ty;
619 f[j_coord_offset+DIM*0+ZZ] -= tz;
621 /**************************
622 * CALCULATE INTERACTIONS *
623 **************************/
629 /* EWALD ELECTROSTATICS */
631 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
632 ewrt = r10*ewtabscale;
635 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
636 felec = qq10*rinv10*(rinvsq10-felec);
640 /* Calculate temporary vectorial force */
645 /* Update vectorial force */
649 f[j_coord_offset+DIM*0+XX] -= tx;
650 f[j_coord_offset+DIM*0+YY] -= ty;
651 f[j_coord_offset+DIM*0+ZZ] -= tz;
653 /**************************
654 * CALCULATE INTERACTIONS *
655 **************************/
661 /* EWALD ELECTROSTATICS */
663 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
664 ewrt = r20*ewtabscale;
667 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
668 felec = qq20*rinv20*(rinvsq20-felec);
672 /* Calculate temporary vectorial force */
677 /* Update vectorial force */
681 f[j_coord_offset+DIM*0+XX] -= tx;
682 f[j_coord_offset+DIM*0+YY] -= ty;
683 f[j_coord_offset+DIM*0+ZZ] -= tz;
685 /* Inner loop uses 127 flops */
687 /* End of innermost loop */
690 f[i_coord_offset+DIM*0+XX] += fix0;
691 f[i_coord_offset+DIM*0+YY] += fiy0;
692 f[i_coord_offset+DIM*0+ZZ] += fiz0;
696 f[i_coord_offset+DIM*1+XX] += fix1;
697 f[i_coord_offset+DIM*1+YY] += fiy1;
698 f[i_coord_offset+DIM*1+ZZ] += fiz1;
702 f[i_coord_offset+DIM*2+XX] += fix2;
703 f[i_coord_offset+DIM*2+YY] += fiy2;
704 f[i_coord_offset+DIM*2+ZZ] += fiz2;
708 fshift[i_shift_offset+XX] += tx;
709 fshift[i_shift_offset+YY] += ty;
710 fshift[i_shift_offset+ZZ] += tz;
712 /* Increment number of inner iterations */
713 inneriter += j_index_end - j_index_start;
715 /* Outer loop uses 30 flops */
718 /* Increment number of outer iterations */
721 /* Update outer/inner flops */
723 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*127);