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_VdwLJSh_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwLJSh_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 = 2*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 = 2*vdwtype[jnr+0];
160 /**************************
161 * CALCULATE INTERACTIONS *
162 **************************/
168 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
169 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
171 /* REACTION-FIELD ELECTROSTATICS */
172 velec = qq00*(rinv00+krf*rsq00-crf);
173 felec = qq00*(rinv00*rinvsq00-krf2);
175 /* LENNARD-JONES DISPERSION/REPULSION */
177 rinvsix = rinvsq00*rinvsq00*rinvsq00;
178 vvdw6 = c6_00*rinvsix;
179 vvdw12 = c12_00*rinvsix*rinvsix;
180 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
181 fvdw = (vvdw12-vvdw6)*rinvsq00;
183 /* Update potential sums from outer loop */
189 /* Calculate temporary vectorial force */
194 /* Update vectorial force */
198 f[j_coord_offset+DIM*0+XX] -= tx;
199 f[j_coord_offset+DIM*0+YY] -= ty;
200 f[j_coord_offset+DIM*0+ZZ] -= tz;
204 /* Inner loop uses 49 flops */
206 /* End of innermost loop */
209 f[i_coord_offset+DIM*0+XX] += fix0;
210 f[i_coord_offset+DIM*0+YY] += fiy0;
211 f[i_coord_offset+DIM*0+ZZ] += fiz0;
215 fshift[i_shift_offset+XX] += tx;
216 fshift[i_shift_offset+YY] += ty;
217 fshift[i_shift_offset+ZZ] += tz;
220 /* Update potential energies */
221 kernel_data->energygrp_elec[ggid] += velecsum;
222 kernel_data->energygrp_vdw[ggid] += vvdwsum;
224 /* Increment number of inner iterations */
225 inneriter += j_index_end - j_index_start;
227 /* Outer loop uses 15 flops */
230 /* Increment number of outer iterations */
233 /* Update outer/inner flops */
235 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*15 + inneriter*49);
238 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_c
239 * Electrostatics interaction: ReactionField
240 * VdW interaction: LennardJones
241 * Geometry: Particle-Particle
242 * Calculate force/pot: Force
245 nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_c
246 (t_nblist * gmx_restrict nlist,
247 rvec * gmx_restrict xx,
248 rvec * gmx_restrict ff,
249 t_forcerec * gmx_restrict fr,
250 t_mdatoms * gmx_restrict mdatoms,
251 nb_kernel_data_t * gmx_restrict kernel_data,
252 t_nrnb * gmx_restrict nrnb)
254 int i_shift_offset,i_coord_offset,j_coord_offset;
255 int j_index_start,j_index_end;
256 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
257 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
258 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
259 real *shiftvec,*fshift,*x,*f;
261 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
263 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
264 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
265 real velec,felec,velecsum,facel,crf,krf,krf2;
268 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
277 jindex = nlist->jindex;
279 shiftidx = nlist->shift;
281 shiftvec = fr->shift_vec[0];
282 fshift = fr->fshift[0];
284 charge = mdatoms->chargeA;
288 nvdwtype = fr->ntype;
290 vdwtype = mdatoms->typeA;
292 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
293 rcutoff = fr->rcoulomb;
294 rcutoff2 = rcutoff*rcutoff;
296 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
302 /* Start outer loop over neighborlists */
303 for(iidx=0; iidx<nri; iidx++)
305 /* Load shift vector for this list */
306 i_shift_offset = DIM*shiftidx[iidx];
307 shX = shiftvec[i_shift_offset+XX];
308 shY = shiftvec[i_shift_offset+YY];
309 shZ = shiftvec[i_shift_offset+ZZ];
311 /* Load limits for loop over neighbors */
312 j_index_start = jindex[iidx];
313 j_index_end = jindex[iidx+1];
315 /* Get outer coordinate index */
317 i_coord_offset = DIM*inr;
319 /* Load i particle coords and add shift vector */
320 ix0 = shX + x[i_coord_offset+DIM*0+XX];
321 iy0 = shY + x[i_coord_offset+DIM*0+YY];
322 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
328 /* Load parameters for i particles */
329 iq0 = facel*charge[inr+0];
330 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
332 /* Start inner kernel loop */
333 for(jidx=j_index_start; jidx<j_index_end; jidx++)
335 /* Get j neighbor index, and coordinate index */
337 j_coord_offset = DIM*jnr;
339 /* load j atom coordinates */
340 jx0 = x[j_coord_offset+DIM*0+XX];
341 jy0 = x[j_coord_offset+DIM*0+YY];
342 jz0 = x[j_coord_offset+DIM*0+ZZ];
344 /* Calculate displacement vector */
349 /* Calculate squared distance and things based on it */
350 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
352 rinv00 = gmx_invsqrt(rsq00);
354 rinvsq00 = rinv00*rinv00;
356 /* Load parameters for j particles */
358 vdwjidx0 = 2*vdwtype[jnr+0];
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
368 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
369 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
371 /* REACTION-FIELD ELECTROSTATICS */
372 felec = qq00*(rinv00*rinvsq00-krf2);
374 /* LENNARD-JONES DISPERSION/REPULSION */
376 rinvsix = rinvsq00*rinvsq00*rinvsq00;
377 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
381 /* Calculate temporary vectorial force */
386 /* Update vectorial force */
390 f[j_coord_offset+DIM*0+XX] -= tx;
391 f[j_coord_offset+DIM*0+YY] -= ty;
392 f[j_coord_offset+DIM*0+ZZ] -= tz;
396 /* Inner loop uses 34 flops */
398 /* End of innermost loop */
401 f[i_coord_offset+DIM*0+XX] += fix0;
402 f[i_coord_offset+DIM*0+YY] += fiy0;
403 f[i_coord_offset+DIM*0+ZZ] += fiz0;
407 fshift[i_shift_offset+XX] += tx;
408 fshift[i_shift_offset+YY] += ty;
409 fshift[i_shift_offset+ZZ] += tz;
411 /* Increment number of inner iterations */
412 inneriter += j_index_end - j_index_start;
414 /* Outer loop uses 13 flops */
417 /* Increment number of outer iterations */
420 /* Update outer/inner flops */
422 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*13 + inneriter*34);