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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwBhamSh_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;
93 jindex = nlist->jindex;
95 shiftidx = nlist->shift;
97 shiftvec = fr->shift_vec[0];
98 fshift = fr->fshift[0];
100 charge = mdatoms->chargeA;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq0 = facel*charge[inr+0];
111 iq1 = facel*charge[inr+1];
112 iq2 = facel*charge[inr+2];
113 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
115 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
116 rcutoff = fr->rcoulomb;
117 rcutoff2 = rcutoff*rcutoff;
119 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
125 /* Start outer loop over neighborlists */
126 for(iidx=0; iidx<nri; iidx++)
128 /* Load shift vector for this list */
129 i_shift_offset = DIM*shiftidx[iidx];
130 shX = shiftvec[i_shift_offset+XX];
131 shY = shiftvec[i_shift_offset+YY];
132 shZ = shiftvec[i_shift_offset+ZZ];
134 /* Load limits for loop over neighbors */
135 j_index_start = jindex[iidx];
136 j_index_end = jindex[iidx+1];
138 /* Get outer coordinate index */
140 i_coord_offset = DIM*inr;
142 /* Load i particle coords and add shift vector */
143 ix0 = shX + x[i_coord_offset+DIM*0+XX];
144 iy0 = shY + x[i_coord_offset+DIM*0+YY];
145 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
146 ix1 = shX + x[i_coord_offset+DIM*1+XX];
147 iy1 = shY + x[i_coord_offset+DIM*1+YY];
148 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
149 ix2 = shX + x[i_coord_offset+DIM*2+XX];
150 iy2 = shY + x[i_coord_offset+DIM*2+YY];
151 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
163 /* Reset potential sums */
167 /* Start inner kernel loop */
168 for(jidx=j_index_start; jidx<j_index_end; jidx++)
170 /* Get j neighbor index, and coordinate index */
172 j_coord_offset = DIM*jnr;
174 /* load j atom coordinates */
175 jx0 = x[j_coord_offset+DIM*0+XX];
176 jy0 = x[j_coord_offset+DIM*0+YY];
177 jz0 = x[j_coord_offset+DIM*0+ZZ];
179 /* Calculate displacement vector */
190 /* Calculate squared distance and things based on it */
191 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
192 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
193 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
195 rinv00 = gmx_invsqrt(rsq00);
196 rinv10 = gmx_invsqrt(rsq10);
197 rinv20 = gmx_invsqrt(rsq20);
199 rinvsq00 = rinv00*rinv00;
200 rinvsq10 = rinv10*rinv10;
201 rinvsq20 = rinv20*rinv20;
203 /* Load parameters for j particles */
205 vdwjidx0 = 3*vdwtype[jnr+0];
207 /**************************
208 * CALCULATE INTERACTIONS *
209 **************************/
217 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
218 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
219 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
221 /* REACTION-FIELD ELECTROSTATICS */
222 velec = qq00*(rinv00+krf*rsq00-crf);
223 felec = qq00*(rinv00*rinvsq00-krf2);
225 /* BUCKINGHAM DISPERSION/REPULSION */
226 rinvsix = rinvsq00*rinvsq00*rinvsq00;
227 vvdw6 = c6_00*rinvsix;
229 vvdwexp = cexp1_00*exp(-br);
230 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
231 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
233 /* Update potential sums from outer loop */
239 /* Calculate temporary vectorial force */
244 /* Update vectorial force */
248 f[j_coord_offset+DIM*0+XX] -= tx;
249 f[j_coord_offset+DIM*0+YY] -= ty;
250 f[j_coord_offset+DIM*0+ZZ] -= tz;
254 /**************************
255 * CALCULATE INTERACTIONS *
256 **************************/
263 /* REACTION-FIELD ELECTROSTATICS */
264 velec = qq10*(rinv10+krf*rsq10-crf);
265 felec = qq10*(rinv10*rinvsq10-krf2);
267 /* Update potential sums from outer loop */
272 /* Calculate temporary vectorial force */
277 /* Update vectorial force */
281 f[j_coord_offset+DIM*0+XX] -= tx;
282 f[j_coord_offset+DIM*0+YY] -= ty;
283 f[j_coord_offset+DIM*0+ZZ] -= tz;
287 /**************************
288 * CALCULATE INTERACTIONS *
289 **************************/
296 /* REACTION-FIELD ELECTROSTATICS */
297 velec = qq20*(rinv20+krf*rsq20-crf);
298 felec = qq20*(rinv20*rinvsq20-krf2);
300 /* Update potential sums from outer loop */
305 /* Calculate temporary vectorial force */
310 /* Update vectorial force */
314 f[j_coord_offset+DIM*0+XX] -= tx;
315 f[j_coord_offset+DIM*0+YY] -= ty;
316 f[j_coord_offset+DIM*0+ZZ] -= tz;
320 /* Inner loop uses 166 flops */
322 /* End of innermost loop */
325 f[i_coord_offset+DIM*0+XX] += fix0;
326 f[i_coord_offset+DIM*0+YY] += fiy0;
327 f[i_coord_offset+DIM*0+ZZ] += fiz0;
331 f[i_coord_offset+DIM*1+XX] += fix1;
332 f[i_coord_offset+DIM*1+YY] += fiy1;
333 f[i_coord_offset+DIM*1+ZZ] += fiz1;
337 f[i_coord_offset+DIM*2+XX] += fix2;
338 f[i_coord_offset+DIM*2+YY] += fiy2;
339 f[i_coord_offset+DIM*2+ZZ] += fiz2;
343 fshift[i_shift_offset+XX] += tx;
344 fshift[i_shift_offset+YY] += ty;
345 fshift[i_shift_offset+ZZ] += tz;
348 /* Update potential energies */
349 kernel_data->energygrp_elec[ggid] += velecsum;
350 kernel_data->energygrp_vdw[ggid] += vvdwsum;
352 /* Increment number of inner iterations */
353 inneriter += j_index_end - j_index_start;
355 /* Outer loop uses 32 flops */
358 /* Increment number of outer iterations */
361 /* Update outer/inner flops */
363 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*166);
366 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
367 * Electrostatics interaction: ReactionField
368 * VdW interaction: Buckingham
369 * Geometry: Water3-Particle
370 * Calculate force/pot: Force
373 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
374 (t_nblist * gmx_restrict nlist,
375 rvec * gmx_restrict xx,
376 rvec * gmx_restrict ff,
377 t_forcerec * gmx_restrict fr,
378 t_mdatoms * gmx_restrict mdatoms,
379 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
380 t_nrnb * gmx_restrict nrnb)
382 int i_shift_offset,i_coord_offset,j_coord_offset;
383 int j_index_start,j_index_end;
384 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
385 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
386 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
387 real *shiftvec,*fshift,*x,*f;
389 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
391 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
393 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
395 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
396 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
397 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
398 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
399 real velec,felec,velecsum,facel,crf,krf,krf2;
402 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
411 jindex = nlist->jindex;
413 shiftidx = nlist->shift;
415 shiftvec = fr->shift_vec[0];
416 fshift = fr->fshift[0];
418 charge = mdatoms->chargeA;
422 nvdwtype = fr->ntype;
424 vdwtype = mdatoms->typeA;
426 /* Setup water-specific parameters */
427 inr = nlist->iinr[0];
428 iq0 = facel*charge[inr+0];
429 iq1 = facel*charge[inr+1];
430 iq2 = facel*charge[inr+2];
431 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
433 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
434 rcutoff = fr->rcoulomb;
435 rcutoff2 = rcutoff*rcutoff;
437 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
443 /* Start outer loop over neighborlists */
444 for(iidx=0; iidx<nri; iidx++)
446 /* Load shift vector for this list */
447 i_shift_offset = DIM*shiftidx[iidx];
448 shX = shiftvec[i_shift_offset+XX];
449 shY = shiftvec[i_shift_offset+YY];
450 shZ = shiftvec[i_shift_offset+ZZ];
452 /* Load limits for loop over neighbors */
453 j_index_start = jindex[iidx];
454 j_index_end = jindex[iidx+1];
456 /* Get outer coordinate index */
458 i_coord_offset = DIM*inr;
460 /* Load i particle coords and add shift vector */
461 ix0 = shX + x[i_coord_offset+DIM*0+XX];
462 iy0 = shY + x[i_coord_offset+DIM*0+YY];
463 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
464 ix1 = shX + x[i_coord_offset+DIM*1+XX];
465 iy1 = shY + x[i_coord_offset+DIM*1+YY];
466 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
467 ix2 = shX + x[i_coord_offset+DIM*2+XX];
468 iy2 = shY + x[i_coord_offset+DIM*2+YY];
469 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
481 /* Start inner kernel loop */
482 for(jidx=j_index_start; jidx<j_index_end; jidx++)
484 /* Get j neighbor index, and coordinate index */
486 j_coord_offset = DIM*jnr;
488 /* load j atom coordinates */
489 jx0 = x[j_coord_offset+DIM*0+XX];
490 jy0 = x[j_coord_offset+DIM*0+YY];
491 jz0 = x[j_coord_offset+DIM*0+ZZ];
493 /* Calculate displacement vector */
504 /* Calculate squared distance and things based on it */
505 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
506 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
507 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
509 rinv00 = gmx_invsqrt(rsq00);
510 rinv10 = gmx_invsqrt(rsq10);
511 rinv20 = gmx_invsqrt(rsq20);
513 rinvsq00 = rinv00*rinv00;
514 rinvsq10 = rinv10*rinv10;
515 rinvsq20 = rinv20*rinv20;
517 /* Load parameters for j particles */
519 vdwjidx0 = 3*vdwtype[jnr+0];
521 /**************************
522 * CALCULATE INTERACTIONS *
523 **************************/
531 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
532 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
533 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
535 /* REACTION-FIELD ELECTROSTATICS */
536 felec = qq00*(rinv00*rinvsq00-krf2);
538 /* BUCKINGHAM DISPERSION/REPULSION */
539 rinvsix = rinvsq00*rinvsq00*rinvsq00;
540 vvdw6 = c6_00*rinvsix;
542 vvdwexp = cexp1_00*exp(-br);
543 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
547 /* Calculate temporary vectorial force */
552 /* Update vectorial force */
556 f[j_coord_offset+DIM*0+XX] -= tx;
557 f[j_coord_offset+DIM*0+YY] -= ty;
558 f[j_coord_offset+DIM*0+ZZ] -= tz;
562 /**************************
563 * CALCULATE INTERACTIONS *
564 **************************/
571 /* REACTION-FIELD ELECTROSTATICS */
572 felec = qq10*(rinv10*rinvsq10-krf2);
576 /* Calculate temporary vectorial force */
581 /* Update vectorial force */
585 f[j_coord_offset+DIM*0+XX] -= tx;
586 f[j_coord_offset+DIM*0+YY] -= ty;
587 f[j_coord_offset+DIM*0+ZZ] -= tz;
591 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
600 /* REACTION-FIELD ELECTROSTATICS */
601 felec = qq20*(rinv20*rinvsq20-krf2);
605 /* Calculate temporary vectorial force */
610 /* Update vectorial force */
614 f[j_coord_offset+DIM*0+XX] -= tx;
615 f[j_coord_offset+DIM*0+YY] -= ty;
616 f[j_coord_offset+DIM*0+ZZ] -= tz;
620 /* Inner loop uses 117 flops */
622 /* End of innermost loop */
625 f[i_coord_offset+DIM*0+XX] += fix0;
626 f[i_coord_offset+DIM*0+YY] += fiy0;
627 f[i_coord_offset+DIM*0+ZZ] += fiz0;
631 f[i_coord_offset+DIM*1+XX] += fix1;
632 f[i_coord_offset+DIM*1+YY] += fiy1;
633 f[i_coord_offset+DIM*1+ZZ] += fiz1;
637 f[i_coord_offset+DIM*2+XX] += fix2;
638 f[i_coord_offset+DIM*2+YY] += fiy2;
639 f[i_coord_offset+DIM*2+ZZ] += fiz2;
643 fshift[i_shift_offset+XX] += tx;
644 fshift[i_shift_offset+YY] += ty;
645 fshift[i_shift_offset+ZZ] += tz;
647 /* Increment number of inner iterations */
648 inneriter += j_index_end - j_index_start;
650 /* Outer loop uses 30 flops */
653 /* Increment number of outer iterations */
656 /* Update outer/inner flops */
658 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);