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_ElecCoul_VdwBham_GeomP1P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_VdwBham_GeomP1P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
60 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
61 real velec,felec,velecsum,facel,crf,krf,krf2;
64 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
73 jindex = nlist->jindex;
75 shiftidx = nlist->shift;
77 shiftvec = fr->shift_vec[0];
78 fshift = fr->fshift[0];
80 charge = mdatoms->chargeA;
83 vdwtype = mdatoms->typeA;
88 /* Start outer loop over neighborlists */
89 for(iidx=0; iidx<nri; iidx++)
91 /* Load shift vector for this list */
92 i_shift_offset = DIM*shiftidx[iidx];
93 shX = shiftvec[i_shift_offset+XX];
94 shY = shiftvec[i_shift_offset+YY];
95 shZ = shiftvec[i_shift_offset+ZZ];
97 /* Load limits for loop over neighbors */
98 j_index_start = jindex[iidx];
99 j_index_end = jindex[iidx+1];
101 /* Get outer coordinate index */
103 i_coord_offset = DIM*inr;
105 /* Load i particle coords and add shift vector */
106 ix0 = shX + x[i_coord_offset+DIM*0+XX];
107 iy0 = shY + x[i_coord_offset+DIM*0+YY];
108 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
114 /* Load parameters for i particles */
115 iq0 = facel*charge[inr+0];
116 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
118 /* Reset potential sums */
122 /* Start inner kernel loop */
123 for(jidx=j_index_start; jidx<j_index_end; jidx++)
125 /* Get j neighbor index, and coordinate index */
127 j_coord_offset = DIM*jnr;
129 /* load j atom coordinates */
130 jx0 = x[j_coord_offset+DIM*0+XX];
131 jy0 = x[j_coord_offset+DIM*0+YY];
132 jz0 = x[j_coord_offset+DIM*0+ZZ];
134 /* Calculate displacement vector */
139 /* Calculate squared distance and things based on it */
140 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
142 rinv00 = gmx_invsqrt(rsq00);
144 rinvsq00 = rinv00*rinv00;
146 /* Load parameters for j particles */
148 vdwjidx0 = 3*vdwtype[jnr+0];
150 /**************************
151 * CALCULATE INTERACTIONS *
152 **************************/
157 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
158 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
159 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
161 /* COULOMB ELECTROSTATICS */
163 felec = velec*rinvsq00;
165 /* BUCKINGHAM DISPERSION/REPULSION */
166 rinvsix = rinvsq00*rinvsq00*rinvsq00;
167 vvdw6 = c6_00*rinvsix;
169 vvdwexp = cexp1_00*exp(-br);
170 vvdw = vvdwexp - vvdw6*(1.0/6.0);
171 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
173 /* Update potential sums from outer loop */
179 /* Calculate temporary vectorial force */
184 /* Update vectorial force */
188 f[j_coord_offset+DIM*0+XX] -= tx;
189 f[j_coord_offset+DIM*0+YY] -= ty;
190 f[j_coord_offset+DIM*0+ZZ] -= tz;
192 /* Inner loop uses 67 flops */
194 /* End of innermost loop */
197 f[i_coord_offset+DIM*0+XX] += fix0;
198 f[i_coord_offset+DIM*0+YY] += fiy0;
199 f[i_coord_offset+DIM*0+ZZ] += fiz0;
203 fshift[i_shift_offset+XX] += tx;
204 fshift[i_shift_offset+YY] += ty;
205 fshift[i_shift_offset+ZZ] += tz;
208 /* Update potential energies */
209 kernel_data->energygrp_elec[ggid] += velecsum;
210 kernel_data->energygrp_vdw[ggid] += vvdwsum;
212 /* Increment number of inner iterations */
213 inneriter += j_index_end - j_index_start;
215 /* Outer loop uses 15 flops */
218 /* Increment number of outer iterations */
221 /* Update outer/inner flops */
223 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*67);
226 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomP1P1_F_c
227 * Electrostatics interaction: Coulomb
228 * VdW interaction: Buckingham
229 * Geometry: Particle-Particle
230 * Calculate force/pot: Force
233 nb_kernel_ElecCoul_VdwBham_GeomP1P1_F_c
234 (t_nblist * gmx_restrict nlist,
235 rvec * gmx_restrict xx,
236 rvec * gmx_restrict ff,
237 t_forcerec * gmx_restrict fr,
238 t_mdatoms * gmx_restrict mdatoms,
239 nb_kernel_data_t * gmx_restrict kernel_data,
240 t_nrnb * gmx_restrict nrnb)
242 int i_shift_offset,i_coord_offset,j_coord_offset;
243 int j_index_start,j_index_end;
244 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
245 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
246 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
247 real *shiftvec,*fshift,*x,*f;
249 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
251 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
252 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
253 real velec,felec,velecsum,facel,crf,krf,krf2;
256 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
265 jindex = nlist->jindex;
267 shiftidx = nlist->shift;
269 shiftvec = fr->shift_vec[0];
270 fshift = fr->fshift[0];
272 charge = mdatoms->chargeA;
273 nvdwtype = fr->ntype;
275 vdwtype = mdatoms->typeA;
280 /* Start outer loop over neighborlists */
281 for(iidx=0; iidx<nri; iidx++)
283 /* Load shift vector for this list */
284 i_shift_offset = DIM*shiftidx[iidx];
285 shX = shiftvec[i_shift_offset+XX];
286 shY = shiftvec[i_shift_offset+YY];
287 shZ = shiftvec[i_shift_offset+ZZ];
289 /* Load limits for loop over neighbors */
290 j_index_start = jindex[iidx];
291 j_index_end = jindex[iidx+1];
293 /* Get outer coordinate index */
295 i_coord_offset = DIM*inr;
297 /* Load i particle coords and add shift vector */
298 ix0 = shX + x[i_coord_offset+DIM*0+XX];
299 iy0 = shY + x[i_coord_offset+DIM*0+YY];
300 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
306 /* Load parameters for i particles */
307 iq0 = facel*charge[inr+0];
308 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
310 /* Start inner kernel loop */
311 for(jidx=j_index_start; jidx<j_index_end; jidx++)
313 /* Get j neighbor index, and coordinate index */
315 j_coord_offset = DIM*jnr;
317 /* load j atom coordinates */
318 jx0 = x[j_coord_offset+DIM*0+XX];
319 jy0 = x[j_coord_offset+DIM*0+YY];
320 jz0 = x[j_coord_offset+DIM*0+ZZ];
322 /* Calculate displacement vector */
327 /* Calculate squared distance and things based on it */
328 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
330 rinv00 = gmx_invsqrt(rsq00);
332 rinvsq00 = rinv00*rinv00;
334 /* Load parameters for j particles */
336 vdwjidx0 = 3*vdwtype[jnr+0];
338 /**************************
339 * CALCULATE INTERACTIONS *
340 **************************/
345 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
346 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
347 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
349 /* COULOMB ELECTROSTATICS */
351 felec = velec*rinvsq00;
353 /* BUCKINGHAM DISPERSION/REPULSION */
354 rinvsix = rinvsq00*rinvsq00*rinvsq00;
355 vvdw6 = c6_00*rinvsix;
357 vvdwexp = cexp1_00*exp(-br);
358 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
362 /* Calculate temporary vectorial force */
367 /* Update vectorial force */
371 f[j_coord_offset+DIM*0+XX] -= tx;
372 f[j_coord_offset+DIM*0+YY] -= ty;
373 f[j_coord_offset+DIM*0+ZZ] -= tz;
375 /* Inner loop uses 63 flops */
377 /* End of innermost loop */
380 f[i_coord_offset+DIM*0+XX] += fix0;
381 f[i_coord_offset+DIM*0+YY] += fiy0;
382 f[i_coord_offset+DIM*0+ZZ] += fiz0;
386 fshift[i_shift_offset+XX] += tx;
387 fshift[i_shift_offset+YY] += ty;
388 fshift[i_shift_offset+ZZ] += tz;
390 /* Increment number of inner iterations */
391 inneriter += j_index_end - j_index_start;
393 /* Outer loop uses 13 flops */
396 /* Increment number of outer iterations */
399 /* Update outer/inner flops */
401 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*63);