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_ElecRFCut_VdwBhamSh_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwBhamSh_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;
86 vdwtype = mdatoms->typeA;
88 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
89 rcutoff = fr->rcoulomb;
90 rcutoff2 = rcutoff*rcutoff;
92 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
98 /* Start outer loop over neighborlists */
99 for(iidx=0; iidx<nri; iidx++)
101 /* Load shift vector for this list */
102 i_shift_offset = DIM*shiftidx[iidx];
103 shX = shiftvec[i_shift_offset+XX];
104 shY = shiftvec[i_shift_offset+YY];
105 shZ = shiftvec[i_shift_offset+ZZ];
107 /* Load limits for loop over neighbors */
108 j_index_start = jindex[iidx];
109 j_index_end = jindex[iidx+1];
111 /* Get outer coordinate index */
113 i_coord_offset = DIM*inr;
115 /* Load i particle coords and add shift vector */
116 ix0 = shX + x[i_coord_offset+DIM*0+XX];
117 iy0 = shY + x[i_coord_offset+DIM*0+YY];
118 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
124 /* Load parameters for i particles */
125 iq0 = facel*charge[inr+0];
126 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
128 /* Reset potential sums */
132 /* Start inner kernel loop */
133 for(jidx=j_index_start; jidx<j_index_end; jidx++)
135 /* Get j neighbor index, and coordinate index */
137 j_coord_offset = DIM*jnr;
139 /* load j atom coordinates */
140 jx0 = x[j_coord_offset+DIM*0+XX];
141 jy0 = x[j_coord_offset+DIM*0+YY];
142 jz0 = x[j_coord_offset+DIM*0+ZZ];
144 /* Calculate displacement vector */
149 /* Calculate squared distance and things based on it */
150 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
152 rinv00 = gmx_invsqrt(rsq00);
154 rinvsq00 = rinv00*rinv00;
156 /* Load parameters for j particles */
158 vdwjidx0 = 3*vdwtype[jnr+0];
160 /**************************
161 * CALCULATE INTERACTIONS *
162 **************************/
170 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
171 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
172 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
174 /* REACTION-FIELD ELECTROSTATICS */
175 velec = qq00*(rinv00+krf*rsq00-crf);
176 felec = qq00*(rinv00*rinvsq00-krf2);
178 /* BUCKINGHAM DISPERSION/REPULSION */
179 rinvsix = rinvsq00*rinvsq00*rinvsq00;
180 vvdw6 = c6_00*rinvsix;
182 vvdwexp = cexp1_00*exp(-br);
183 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
184 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
186 /* Update potential sums from outer loop */
192 /* Calculate temporary vectorial force */
197 /* Update vectorial force */
201 f[j_coord_offset+DIM*0+XX] -= tx;
202 f[j_coord_offset+DIM*0+YY] -= ty;
203 f[j_coord_offset+DIM*0+ZZ] -= tz;
207 /* Inner loop uses 102 flops */
209 /* End of innermost loop */
212 f[i_coord_offset+DIM*0+XX] += fix0;
213 f[i_coord_offset+DIM*0+YY] += fiy0;
214 f[i_coord_offset+DIM*0+ZZ] += fiz0;
218 fshift[i_shift_offset+XX] += tx;
219 fshift[i_shift_offset+YY] += ty;
220 fshift[i_shift_offset+ZZ] += tz;
223 /* Update potential energies */
224 kernel_data->energygrp_elec[ggid] += velecsum;
225 kernel_data->energygrp_vdw[ggid] += vvdwsum;
227 /* Increment number of inner iterations */
228 inneriter += j_index_end - j_index_start;
230 /* Outer loop uses 15 flops */
233 /* Increment number of outer iterations */
236 /* Update outer/inner flops */
238 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*102);
241 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomP1P1_F_c
242 * Electrostatics interaction: ReactionField
243 * VdW interaction: Buckingham
244 * Geometry: Particle-Particle
245 * Calculate force/pot: Force
248 nb_kernel_ElecRFCut_VdwBhamSh_GeomP1P1_F_c
249 (t_nblist * gmx_restrict nlist,
250 rvec * gmx_restrict xx,
251 rvec * gmx_restrict ff,
252 t_forcerec * gmx_restrict fr,
253 t_mdatoms * gmx_restrict mdatoms,
254 nb_kernel_data_t * gmx_restrict kernel_data,
255 t_nrnb * gmx_restrict nrnb)
257 int i_shift_offset,i_coord_offset,j_coord_offset;
258 int j_index_start,j_index_end;
259 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
260 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
261 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
262 real *shiftvec,*fshift,*x,*f;
264 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
266 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
267 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
268 real velec,felec,velecsum,facel,crf,krf,krf2;
271 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
280 jindex = nlist->jindex;
282 shiftidx = nlist->shift;
284 shiftvec = fr->shift_vec[0];
285 fshift = fr->fshift[0];
287 charge = mdatoms->chargeA;
291 nvdwtype = fr->ntype;
293 vdwtype = mdatoms->typeA;
295 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
296 rcutoff = fr->rcoulomb;
297 rcutoff2 = rcutoff*rcutoff;
299 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
305 /* Start outer loop over neighborlists */
306 for(iidx=0; iidx<nri; iidx++)
308 /* Load shift vector for this list */
309 i_shift_offset = DIM*shiftidx[iidx];
310 shX = shiftvec[i_shift_offset+XX];
311 shY = shiftvec[i_shift_offset+YY];
312 shZ = shiftvec[i_shift_offset+ZZ];
314 /* Load limits for loop over neighbors */
315 j_index_start = jindex[iidx];
316 j_index_end = jindex[iidx+1];
318 /* Get outer coordinate index */
320 i_coord_offset = DIM*inr;
322 /* Load i particle coords and add shift vector */
323 ix0 = shX + x[i_coord_offset+DIM*0+XX];
324 iy0 = shY + x[i_coord_offset+DIM*0+YY];
325 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
331 /* Load parameters for i particles */
332 iq0 = facel*charge[inr+0];
333 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
335 /* Start inner kernel loop */
336 for(jidx=j_index_start; jidx<j_index_end; jidx++)
338 /* Get j neighbor index, and coordinate index */
340 j_coord_offset = DIM*jnr;
342 /* load j atom coordinates */
343 jx0 = x[j_coord_offset+DIM*0+XX];
344 jy0 = x[j_coord_offset+DIM*0+YY];
345 jz0 = x[j_coord_offset+DIM*0+ZZ];
347 /* Calculate displacement vector */
352 /* Calculate squared distance and things based on it */
353 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
355 rinv00 = gmx_invsqrt(rsq00);
357 rinvsq00 = rinv00*rinv00;
359 /* Load parameters for j particles */
361 vdwjidx0 = 3*vdwtype[jnr+0];
363 /**************************
364 * CALCULATE INTERACTIONS *
365 **************************/
373 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
374 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
375 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
377 /* REACTION-FIELD ELECTROSTATICS */
378 felec = qq00*(rinv00*rinvsq00-krf2);
380 /* BUCKINGHAM DISPERSION/REPULSION */
381 rinvsix = rinvsq00*rinvsq00*rinvsq00;
382 vvdw6 = c6_00*rinvsix;
384 vvdwexp = cexp1_00*exp(-br);
385 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
389 /* Calculate temporary vectorial force */
394 /* Update vectorial force */
398 f[j_coord_offset+DIM*0+XX] -= tx;
399 f[j_coord_offset+DIM*0+YY] -= ty;
400 f[j_coord_offset+DIM*0+ZZ] -= tz;
404 /* Inner loop uses 63 flops */
406 /* End of innermost loop */
409 f[i_coord_offset+DIM*0+XX] += fix0;
410 f[i_coord_offset+DIM*0+YY] += fiy0;
411 f[i_coord_offset+DIM*0+ZZ] += fiz0;
415 fshift[i_shift_offset+XX] += tx;
416 fshift[i_shift_offset+YY] += ty;
417 fshift[i_shift_offset+ZZ] += tz;
419 /* Increment number of inner iterations */
420 inneriter += j_index_end - j_index_start;
422 /* Outer loop uses 13 flops */
425 /* Increment number of outer iterations */
428 /* Update outer/inner flops */
430 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*63);