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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3P1_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: CubicSplineTable
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwCSTab_GeomW3P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
84 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
88 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
91 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
99 jindex = nlist->jindex;
101 shiftidx = nlist->shift;
103 shiftvec = fr->shift_vec[0];
104 fshift = fr->fshift[0];
106 charge = mdatoms->chargeA;
107 nvdwtype = fr->ntype;
109 vdwtype = mdatoms->typeA;
111 vftab = kernel_data->table_vdw->data;
112 vftabscale = kernel_data->table_vdw->scale;
114 sh_ewald = fr->ic->sh_ewald;
115 ewtab = fr->ic->tabq_coul_FDV0;
116 ewtabscale = fr->ic->tabq_scale;
117 ewtabhalfspace = 0.5/ewtabscale;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq0 = facel*charge[inr+0];
122 iq1 = facel*charge[inr+1];
123 iq2 = facel*charge[inr+2];
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
129 /* Start outer loop over neighborlists */
130 for(iidx=0; iidx<nri; iidx++)
132 /* Load shift vector for this list */
133 i_shift_offset = DIM*shiftidx[iidx];
134 shX = shiftvec[i_shift_offset+XX];
135 shY = shiftvec[i_shift_offset+YY];
136 shZ = shiftvec[i_shift_offset+ZZ];
138 /* Load limits for loop over neighbors */
139 j_index_start = jindex[iidx];
140 j_index_end = jindex[iidx+1];
142 /* Get outer coordinate index */
144 i_coord_offset = DIM*inr;
146 /* Load i particle coords and add shift vector */
147 ix0 = shX + x[i_coord_offset+DIM*0+XX];
148 iy0 = shY + x[i_coord_offset+DIM*0+YY];
149 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
150 ix1 = shX + x[i_coord_offset+DIM*1+XX];
151 iy1 = shY + x[i_coord_offset+DIM*1+YY];
152 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
153 ix2 = shX + x[i_coord_offset+DIM*2+XX];
154 iy2 = shY + x[i_coord_offset+DIM*2+YY];
155 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
167 /* Reset potential sums */
171 /* Start inner kernel loop */
172 for(jidx=j_index_start; jidx<j_index_end; jidx++)
174 /* Get j neighbor index, and coordinate index */
176 j_coord_offset = DIM*jnr;
178 /* load j atom coordinates */
179 jx0 = x[j_coord_offset+DIM*0+XX];
180 jy0 = x[j_coord_offset+DIM*0+YY];
181 jz0 = x[j_coord_offset+DIM*0+ZZ];
183 /* Calculate displacement vector */
194 /* Calculate squared distance and things based on it */
195 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
196 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
197 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
199 rinv00 = gmx_invsqrt(rsq00);
200 rinv10 = gmx_invsqrt(rsq10);
201 rinv20 = gmx_invsqrt(rsq20);
203 rinvsq00 = rinv00*rinv00;
204 rinvsq10 = rinv10*rinv10;
205 rinvsq20 = rinv20*rinv20;
207 /* Load parameters for j particles */
209 vdwjidx0 = 2*vdwtype[jnr+0];
211 /**************************
212 * CALCULATE INTERACTIONS *
213 **************************/
218 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
219 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
221 /* Calculate table index by multiplying r with table scale and truncate to integer */
227 /* EWALD ELECTROSTATICS */
229 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
230 ewrt = r00*ewtabscale;
234 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
235 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
236 felec = qq00*rinv00*(rinvsq00-felec);
238 /* CUBIC SPLINE TABLE DISPERSION */
242 Geps = vfeps*vftab[vfitab+2];
243 Heps2 = vfeps*vfeps*vftab[vfitab+3];
247 FF = Fp+Geps+2.0*Heps2;
250 /* CUBIC SPLINE TABLE REPULSION */
253 Geps = vfeps*vftab[vfitab+6];
254 Heps2 = vfeps*vfeps*vftab[vfitab+7];
258 FF = Fp+Geps+2.0*Heps2;
261 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
263 /* Update potential sums from outer loop */
269 /* Calculate temporary vectorial force */
274 /* Update vectorial force */
278 f[j_coord_offset+DIM*0+XX] -= tx;
279 f[j_coord_offset+DIM*0+YY] -= ty;
280 f[j_coord_offset+DIM*0+ZZ] -= tz;
282 /**************************
283 * CALCULATE INTERACTIONS *
284 **************************/
290 /* EWALD ELECTROSTATICS */
292 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
293 ewrt = r10*ewtabscale;
297 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
298 velec = qq10*(rinv10-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
299 felec = qq10*rinv10*(rinvsq10-felec);
301 /* Update potential sums from outer loop */
306 /* Calculate temporary vectorial force */
311 /* Update vectorial force */
315 f[j_coord_offset+DIM*0+XX] -= tx;
316 f[j_coord_offset+DIM*0+YY] -= ty;
317 f[j_coord_offset+DIM*0+ZZ] -= tz;
319 /**************************
320 * CALCULATE INTERACTIONS *
321 **************************/
327 /* EWALD ELECTROSTATICS */
329 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
330 ewrt = r20*ewtabscale;
334 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
335 velec = qq20*(rinv20-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
336 felec = qq20*rinv20*(rinvsq20-felec);
338 /* Update potential sums from outer loop */
343 /* Calculate temporary vectorial force */
348 /* Update vectorial force */
352 f[j_coord_offset+DIM*0+XX] -= tx;
353 f[j_coord_offset+DIM*0+YY] -= ty;
354 f[j_coord_offset+DIM*0+ZZ] -= tz;
356 /* Inner loop uses 156 flops */
358 /* End of innermost loop */
361 f[i_coord_offset+DIM*0+XX] += fix0;
362 f[i_coord_offset+DIM*0+YY] += fiy0;
363 f[i_coord_offset+DIM*0+ZZ] += fiz0;
367 f[i_coord_offset+DIM*1+XX] += fix1;
368 f[i_coord_offset+DIM*1+YY] += fiy1;
369 f[i_coord_offset+DIM*1+ZZ] += fiz1;
373 f[i_coord_offset+DIM*2+XX] += fix2;
374 f[i_coord_offset+DIM*2+YY] += fiy2;
375 f[i_coord_offset+DIM*2+ZZ] += fiz2;
379 fshift[i_shift_offset+XX] += tx;
380 fshift[i_shift_offset+YY] += ty;
381 fshift[i_shift_offset+ZZ] += tz;
384 /* Update potential energies */
385 kernel_data->energygrp_elec[ggid] += velecsum;
386 kernel_data->energygrp_vdw[ggid] += vvdwsum;
388 /* Increment number of inner iterations */
389 inneriter += j_index_end - j_index_start;
391 /* Outer loop uses 32 flops */
394 /* Increment number of outer iterations */
397 /* Update outer/inner flops */
399 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*156);
402 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomW3P1_F_c
403 * Electrostatics interaction: Ewald
404 * VdW interaction: CubicSplineTable
405 * Geometry: Water3-Particle
406 * Calculate force/pot: Force
409 nb_kernel_ElecEw_VdwCSTab_GeomW3P1_F_c
410 (t_nblist * gmx_restrict nlist,
411 rvec * gmx_restrict xx,
412 rvec * gmx_restrict ff,
413 t_forcerec * gmx_restrict fr,
414 t_mdatoms * gmx_restrict mdatoms,
415 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
416 t_nrnb * gmx_restrict nrnb)
418 int i_shift_offset,i_coord_offset,j_coord_offset;
419 int j_index_start,j_index_end;
420 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
421 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
422 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
423 real *shiftvec,*fshift,*x,*f;
425 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
427 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
429 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
431 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
432 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
433 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
434 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
435 real velec,felec,velecsum,facel,crf,krf,krf2;
438 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
442 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
445 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
453 jindex = nlist->jindex;
455 shiftidx = nlist->shift;
457 shiftvec = fr->shift_vec[0];
458 fshift = fr->fshift[0];
460 charge = mdatoms->chargeA;
461 nvdwtype = fr->ntype;
463 vdwtype = mdatoms->typeA;
465 vftab = kernel_data->table_vdw->data;
466 vftabscale = kernel_data->table_vdw->scale;
468 sh_ewald = fr->ic->sh_ewald;
469 ewtab = fr->ic->tabq_coul_F;
470 ewtabscale = fr->ic->tabq_scale;
471 ewtabhalfspace = 0.5/ewtabscale;
473 /* Setup water-specific parameters */
474 inr = nlist->iinr[0];
475 iq0 = facel*charge[inr+0];
476 iq1 = facel*charge[inr+1];
477 iq2 = facel*charge[inr+2];
478 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
483 /* Start outer loop over neighborlists */
484 for(iidx=0; iidx<nri; iidx++)
486 /* Load shift vector for this list */
487 i_shift_offset = DIM*shiftidx[iidx];
488 shX = shiftvec[i_shift_offset+XX];
489 shY = shiftvec[i_shift_offset+YY];
490 shZ = shiftvec[i_shift_offset+ZZ];
492 /* Load limits for loop over neighbors */
493 j_index_start = jindex[iidx];
494 j_index_end = jindex[iidx+1];
496 /* Get outer coordinate index */
498 i_coord_offset = DIM*inr;
500 /* Load i particle coords and add shift vector */
501 ix0 = shX + x[i_coord_offset+DIM*0+XX];
502 iy0 = shY + x[i_coord_offset+DIM*0+YY];
503 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
504 ix1 = shX + x[i_coord_offset+DIM*1+XX];
505 iy1 = shY + x[i_coord_offset+DIM*1+YY];
506 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
507 ix2 = shX + x[i_coord_offset+DIM*2+XX];
508 iy2 = shY + x[i_coord_offset+DIM*2+YY];
509 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
521 /* Start inner kernel loop */
522 for(jidx=j_index_start; jidx<j_index_end; jidx++)
524 /* Get j neighbor index, and coordinate index */
526 j_coord_offset = DIM*jnr;
528 /* load j atom coordinates */
529 jx0 = x[j_coord_offset+DIM*0+XX];
530 jy0 = x[j_coord_offset+DIM*0+YY];
531 jz0 = x[j_coord_offset+DIM*0+ZZ];
533 /* Calculate displacement vector */
544 /* Calculate squared distance and things based on it */
545 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
546 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
547 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
549 rinv00 = gmx_invsqrt(rsq00);
550 rinv10 = gmx_invsqrt(rsq10);
551 rinv20 = gmx_invsqrt(rsq20);
553 rinvsq00 = rinv00*rinv00;
554 rinvsq10 = rinv10*rinv10;
555 rinvsq20 = rinv20*rinv20;
557 /* Load parameters for j particles */
559 vdwjidx0 = 2*vdwtype[jnr+0];
561 /**************************
562 * CALCULATE INTERACTIONS *
563 **************************/
568 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
569 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
571 /* Calculate table index by multiplying r with table scale and truncate to integer */
577 /* EWALD ELECTROSTATICS */
579 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
580 ewrt = r00*ewtabscale;
583 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
584 felec = qq00*rinv00*(rinvsq00-felec);
586 /* CUBIC SPLINE TABLE DISPERSION */
589 Geps = vfeps*vftab[vfitab+2];
590 Heps2 = vfeps*vfeps*vftab[vfitab+3];
592 FF = Fp+Geps+2.0*Heps2;
595 /* CUBIC SPLINE TABLE REPULSION */
597 Geps = vfeps*vftab[vfitab+6];
598 Heps2 = vfeps*vfeps*vftab[vfitab+7];
600 FF = Fp+Geps+2.0*Heps2;
602 fvdw = -(fvdw6+fvdw12)*vftabscale*rinv00;
606 /* Calculate temporary vectorial force */
611 /* Update vectorial force */
615 f[j_coord_offset+DIM*0+XX] -= tx;
616 f[j_coord_offset+DIM*0+YY] -= ty;
617 f[j_coord_offset+DIM*0+ZZ] -= tz;
619 /**************************
620 * CALCULATE INTERACTIONS *
621 **************************/
627 /* EWALD ELECTROSTATICS */
629 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
630 ewrt = r10*ewtabscale;
633 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
634 felec = qq10*rinv10*(rinvsq10-felec);
638 /* Calculate temporary vectorial force */
643 /* Update vectorial force */
647 f[j_coord_offset+DIM*0+XX] -= tx;
648 f[j_coord_offset+DIM*0+YY] -= ty;
649 f[j_coord_offset+DIM*0+ZZ] -= tz;
651 /**************************
652 * CALCULATE INTERACTIONS *
653 **************************/
659 /* EWALD ELECTROSTATICS */
661 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
662 ewrt = r20*ewtabscale;
665 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
666 felec = qq20*rinv20*(rinvsq20-felec);
670 /* Calculate temporary vectorial force */
675 /* Update vectorial force */
679 f[j_coord_offset+DIM*0+XX] -= tx;
680 f[j_coord_offset+DIM*0+YY] -= ty;
681 f[j_coord_offset+DIM*0+ZZ] -= tz;
683 /* Inner loop uses 127 flops */
685 /* End of innermost loop */
688 f[i_coord_offset+DIM*0+XX] += fix0;
689 f[i_coord_offset+DIM*0+YY] += fiy0;
690 f[i_coord_offset+DIM*0+ZZ] += fiz0;
694 f[i_coord_offset+DIM*1+XX] += fix1;
695 f[i_coord_offset+DIM*1+YY] += fiy1;
696 f[i_coord_offset+DIM*1+ZZ] += fiz1;
700 f[i_coord_offset+DIM*2+XX] += fix2;
701 f[i_coord_offset+DIM*2+YY] += fiy2;
702 f[i_coord_offset+DIM*2+ZZ] += fiz2;
706 fshift[i_shift_offset+XX] += tx;
707 fshift[i_shift_offset+YY] += ty;
708 fshift[i_shift_offset+ZZ] += tz;
710 /* Increment number of inner iterations */
711 inneriter += j_index_end - j_index_start;
713 /* Outer loop uses 30 flops */
716 /* Increment number of outer iterations */
719 /* Update outer/inner flops */
721 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*127);