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_ElecCoul_VdwBham_GeomW3P1_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwBham_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;
101 nvdwtype = fr->ntype;
103 vdwtype = mdatoms->typeA;
105 /* Setup water-specific parameters */
106 inr = nlist->iinr[0];
107 iq0 = facel*charge[inr+0];
108 iq1 = facel*charge[inr+1];
109 iq2 = facel*charge[inr+2];
110 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
115 /* Start outer loop over neighborlists */
116 for(iidx=0; iidx<nri; iidx++)
118 /* Load shift vector for this list */
119 i_shift_offset = DIM*shiftidx[iidx];
120 shX = shiftvec[i_shift_offset+XX];
121 shY = shiftvec[i_shift_offset+YY];
122 shZ = shiftvec[i_shift_offset+ZZ];
124 /* Load limits for loop over neighbors */
125 j_index_start = jindex[iidx];
126 j_index_end = jindex[iidx+1];
128 /* Get outer coordinate index */
130 i_coord_offset = DIM*inr;
132 /* Load i particle coords and add shift vector */
133 ix0 = shX + x[i_coord_offset+DIM*0+XX];
134 iy0 = shY + x[i_coord_offset+DIM*0+YY];
135 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
136 ix1 = shX + x[i_coord_offset+DIM*1+XX];
137 iy1 = shY + x[i_coord_offset+DIM*1+YY];
138 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
139 ix2 = shX + x[i_coord_offset+DIM*2+XX];
140 iy2 = shY + x[i_coord_offset+DIM*2+YY];
141 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
153 /* Reset potential sums */
157 /* Start inner kernel loop */
158 for(jidx=j_index_start; jidx<j_index_end; jidx++)
160 /* Get j neighbor index, and coordinate index */
162 j_coord_offset = DIM*jnr;
164 /* load j atom coordinates */
165 jx0 = x[j_coord_offset+DIM*0+XX];
166 jy0 = x[j_coord_offset+DIM*0+YY];
167 jz0 = x[j_coord_offset+DIM*0+ZZ];
169 /* Calculate displacement vector */
180 /* Calculate squared distance and things based on it */
181 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
182 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
183 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
185 rinv00 = gmx_invsqrt(rsq00);
186 rinv10 = gmx_invsqrt(rsq10);
187 rinv20 = gmx_invsqrt(rsq20);
189 rinvsq00 = rinv00*rinv00;
190 rinvsq10 = rinv10*rinv10;
191 rinvsq20 = rinv20*rinv20;
193 /* Load parameters for j particles */
195 vdwjidx0 = 3*vdwtype[jnr+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
204 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
205 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
206 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
208 /* COULOMB ELECTROSTATICS */
210 felec = velec*rinvsq00;
212 /* BUCKINGHAM DISPERSION/REPULSION */
213 rinvsix = rinvsq00*rinvsq00*rinvsq00;
214 vvdw6 = c6_00*rinvsix;
216 vvdwexp = cexp1_00*exp(-br);
217 vvdw = vvdwexp - vvdw6*(1.0/6.0);
218 fvdw = (br*vvdwexp-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 **************************/
245 /* COULOMB ELECTROSTATICS */
247 felec = velec*rinvsq10;
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;
267 /**************************
268 * CALCULATE INTERACTIONS *
269 **************************/
273 /* COULOMB ELECTROSTATICS */
275 felec = velec*rinvsq20;
277 /* Update potential sums from outer loop */
282 /* Calculate temporary vectorial force */
287 /* Update vectorial force */
291 f[j_coord_offset+DIM*0+XX] -= tx;
292 f[j_coord_offset+DIM*0+YY] -= ty;
293 f[j_coord_offset+DIM*0+ZZ] -= tz;
295 /* Inner loop uses 123 flops */
297 /* End of innermost loop */
300 f[i_coord_offset+DIM*0+XX] += fix0;
301 f[i_coord_offset+DIM*0+YY] += fiy0;
302 f[i_coord_offset+DIM*0+ZZ] += fiz0;
306 f[i_coord_offset+DIM*1+XX] += fix1;
307 f[i_coord_offset+DIM*1+YY] += fiy1;
308 f[i_coord_offset+DIM*1+ZZ] += fiz1;
312 f[i_coord_offset+DIM*2+XX] += fix2;
313 f[i_coord_offset+DIM*2+YY] += fiy2;
314 f[i_coord_offset+DIM*2+ZZ] += fiz2;
318 fshift[i_shift_offset+XX] += tx;
319 fshift[i_shift_offset+YY] += ty;
320 fshift[i_shift_offset+ZZ] += tz;
323 /* Update potential energies */
324 kernel_data->energygrp_elec[ggid] += velecsum;
325 kernel_data->energygrp_vdw[ggid] += vvdwsum;
327 /* Increment number of inner iterations */
328 inneriter += j_index_end - j_index_start;
330 /* Outer loop uses 32 flops */
333 /* Increment number of outer iterations */
336 /* Update outer/inner flops */
338 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*123);
341 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW3P1_F_c
342 * Electrostatics interaction: Coulomb
343 * VdW interaction: Buckingham
344 * Geometry: Water3-Particle
345 * Calculate force/pot: Force
348 nb_kernel_ElecCoul_VdwBham_GeomW3P1_F_c
349 (t_nblist * gmx_restrict nlist,
350 rvec * gmx_restrict xx,
351 rvec * gmx_restrict ff,
352 t_forcerec * gmx_restrict fr,
353 t_mdatoms * gmx_restrict mdatoms,
354 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
355 t_nrnb * gmx_restrict nrnb)
357 int i_shift_offset,i_coord_offset,j_coord_offset;
358 int j_index_start,j_index_end;
359 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
360 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
361 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
362 real *shiftvec,*fshift,*x,*f;
364 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
366 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
368 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
370 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
371 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
372 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
373 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
374 real velec,felec,velecsum,facel,crf,krf,krf2;
377 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
386 jindex = nlist->jindex;
388 shiftidx = nlist->shift;
390 shiftvec = fr->shift_vec[0];
391 fshift = fr->fshift[0];
393 charge = mdatoms->chargeA;
394 nvdwtype = fr->ntype;
396 vdwtype = mdatoms->typeA;
398 /* Setup water-specific parameters */
399 inr = nlist->iinr[0];
400 iq0 = facel*charge[inr+0];
401 iq1 = facel*charge[inr+1];
402 iq2 = facel*charge[inr+2];
403 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
408 /* Start outer loop over neighborlists */
409 for(iidx=0; iidx<nri; iidx++)
411 /* Load shift vector for this list */
412 i_shift_offset = DIM*shiftidx[iidx];
413 shX = shiftvec[i_shift_offset+XX];
414 shY = shiftvec[i_shift_offset+YY];
415 shZ = shiftvec[i_shift_offset+ZZ];
417 /* Load limits for loop over neighbors */
418 j_index_start = jindex[iidx];
419 j_index_end = jindex[iidx+1];
421 /* Get outer coordinate index */
423 i_coord_offset = DIM*inr;
425 /* Load i particle coords and add shift vector */
426 ix0 = shX + x[i_coord_offset+DIM*0+XX];
427 iy0 = shY + x[i_coord_offset+DIM*0+YY];
428 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
429 ix1 = shX + x[i_coord_offset+DIM*1+XX];
430 iy1 = shY + x[i_coord_offset+DIM*1+YY];
431 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
432 ix2 = shX + x[i_coord_offset+DIM*2+XX];
433 iy2 = shY + x[i_coord_offset+DIM*2+YY];
434 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
446 /* Start inner kernel loop */
447 for(jidx=j_index_start; jidx<j_index_end; jidx++)
449 /* Get j neighbor index, and coordinate index */
451 j_coord_offset = DIM*jnr;
453 /* load j atom coordinates */
454 jx0 = x[j_coord_offset+DIM*0+XX];
455 jy0 = x[j_coord_offset+DIM*0+YY];
456 jz0 = x[j_coord_offset+DIM*0+ZZ];
458 /* Calculate displacement vector */
469 /* Calculate squared distance and things based on it */
470 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
471 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
472 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
474 rinv00 = gmx_invsqrt(rsq00);
475 rinv10 = gmx_invsqrt(rsq10);
476 rinv20 = gmx_invsqrt(rsq20);
478 rinvsq00 = rinv00*rinv00;
479 rinvsq10 = rinv10*rinv10;
480 rinvsq20 = rinv20*rinv20;
482 /* Load parameters for j particles */
484 vdwjidx0 = 3*vdwtype[jnr+0];
486 /**************************
487 * CALCULATE INTERACTIONS *
488 **************************/
493 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
494 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
495 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
497 /* COULOMB ELECTROSTATICS */
499 felec = velec*rinvsq00;
501 /* BUCKINGHAM DISPERSION/REPULSION */
502 rinvsix = rinvsq00*rinvsq00*rinvsq00;
503 vvdw6 = c6_00*rinvsix;
505 vvdwexp = cexp1_00*exp(-br);
506 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*0+XX] -= tx;
520 f[j_coord_offset+DIM*0+YY] -= ty;
521 f[j_coord_offset+DIM*0+ZZ] -= tz;
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
529 /* COULOMB ELECTROSTATICS */
531 felec = velec*rinvsq10;
535 /* Calculate temporary vectorial force */
540 /* Update vectorial force */
544 f[j_coord_offset+DIM*0+XX] -= tx;
545 f[j_coord_offset+DIM*0+YY] -= ty;
546 f[j_coord_offset+DIM*0+ZZ] -= tz;
548 /**************************
549 * CALCULATE INTERACTIONS *
550 **************************/
554 /* COULOMB ELECTROSTATICS */
556 felec = velec*rinvsq20;
560 /* Calculate temporary vectorial force */
565 /* Update vectorial force */
569 f[j_coord_offset+DIM*0+XX] -= tx;
570 f[j_coord_offset+DIM*0+YY] -= ty;
571 f[j_coord_offset+DIM*0+ZZ] -= tz;
573 /* Inner loop uses 117 flops */
575 /* End of innermost loop */
578 f[i_coord_offset+DIM*0+XX] += fix0;
579 f[i_coord_offset+DIM*0+YY] += fiy0;
580 f[i_coord_offset+DIM*0+ZZ] += fiz0;
584 f[i_coord_offset+DIM*1+XX] += fix1;
585 f[i_coord_offset+DIM*1+YY] += fiy1;
586 f[i_coord_offset+DIM*1+ZZ] += fiz1;
590 f[i_coord_offset+DIM*2+XX] += fix2;
591 f[i_coord_offset+DIM*2+YY] += fiy2;
592 f[i_coord_offset+DIM*2+ZZ] += fiz2;
596 fshift[i_shift_offset+XX] += tx;
597 fshift[i_shift_offset+YY] += ty;
598 fshift[i_shift_offset+ZZ] += tz;
600 /* Increment number of inner iterations */
601 inneriter += j_index_end - j_index_start;
603 /* Outer loop uses 30 flops */
606 /* Increment number of outer iterations */
609 /* Update outer/inner flops */
611 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);