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_ElecNone_VdwLJSw_GeomP1P1_VF_c
49 * Electrostatics interaction: None
50 * VdW interaction: LennardJones
51 * Geometry: Particle-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
76 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
79 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
86 jindex = nlist->jindex;
88 shiftidx = nlist->shift;
90 shiftvec = fr->shift_vec[0];
91 fshift = fr->fshift[0];
94 vdwtype = mdatoms->typeA;
97 rcutoff2 = rcutoff*rcutoff;
99 rswitch = fr->rvdw_switch;
100 /* Setup switch parameters */
102 swV3 = -10.0/(d*d*d);
103 swV4 = 15.0/(d*d*d*d);
104 swV5 = -6.0/(d*d*d*d*d);
105 swF2 = -30.0/(d*d*d);
106 swF3 = 60.0/(d*d*d*d);
107 swF4 = -30.0/(d*d*d*d*d);
112 /* Start outer loop over neighborlists */
113 for(iidx=0; iidx<nri; iidx++)
115 /* Load shift vector for this list */
116 i_shift_offset = DIM*shiftidx[iidx];
117 shX = shiftvec[i_shift_offset+XX];
118 shY = shiftvec[i_shift_offset+YY];
119 shZ = shiftvec[i_shift_offset+ZZ];
121 /* Load limits for loop over neighbors */
122 j_index_start = jindex[iidx];
123 j_index_end = jindex[iidx+1];
125 /* Get outer coordinate index */
127 i_coord_offset = DIM*inr;
129 /* Load i particle coords and add shift vector */
130 ix0 = shX + x[i_coord_offset+DIM*0+XX];
131 iy0 = shY + x[i_coord_offset+DIM*0+YY];
132 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
138 /* Load parameters for i particles */
139 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
141 /* Reset potential sums */
144 /* Start inner kernel loop */
145 for(jidx=j_index_start; jidx<j_index_end; jidx++)
147 /* Get j neighbor index, and coordinate index */
149 j_coord_offset = DIM*jnr;
151 /* load j atom coordinates */
152 jx0 = x[j_coord_offset+DIM*0+XX];
153 jy0 = x[j_coord_offset+DIM*0+YY];
154 jz0 = x[j_coord_offset+DIM*0+ZZ];
156 /* Calculate displacement vector */
161 /* Calculate squared distance and things based on it */
162 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
164 rinv00 = gmx_invsqrt(rsq00);
166 rinvsq00 = rinv00*rinv00;
168 /* Load parameters for j particles */
169 vdwjidx0 = 2*vdwtype[jnr+0];
171 /**************************
172 * CALCULATE INTERACTIONS *
173 **************************/
180 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
181 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
183 /* LENNARD-JONES DISPERSION/REPULSION */
185 rinvsix = rinvsq00*rinvsq00*rinvsq00;
186 vvdw6 = c6_00*rinvsix;
187 vvdw12 = c12_00*rinvsix*rinvsix;
188 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
189 fvdw = (vvdw12-vvdw6)*rinvsq00;
192 d = (d>0.0) ? d : 0.0;
194 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
196 dsw = d2*(swF2+d*(swF3+d*swF4));
198 /* Evaluate switch function */
199 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
200 fvdw = fvdw*sw - rinv00*vvdw*dsw;
203 /* Update potential sums from outer loop */
208 /* Calculate temporary vectorial force */
213 /* Update vectorial force */
217 f[j_coord_offset+DIM*0+XX] -= tx;
218 f[j_coord_offset+DIM*0+YY] -= ty;
219 f[j_coord_offset+DIM*0+ZZ] -= tz;
223 /* Inner loop uses 53 flops */
225 /* End of innermost loop */
228 f[i_coord_offset+DIM*0+XX] += fix0;
229 f[i_coord_offset+DIM*0+YY] += fiy0;
230 f[i_coord_offset+DIM*0+ZZ] += fiz0;
234 fshift[i_shift_offset+XX] += tx;
235 fshift[i_shift_offset+YY] += ty;
236 fshift[i_shift_offset+ZZ] += tz;
239 /* Update potential energies */
240 kernel_data->energygrp_vdw[ggid] += vvdwsum;
242 /* Increment number of inner iterations */
243 inneriter += j_index_end - j_index_start;
245 /* Outer loop uses 13 flops */
248 /* Increment number of outer iterations */
251 /* Update outer/inner flops */
253 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*13 + inneriter*53);
256 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_c
257 * Electrostatics interaction: None
258 * VdW interaction: LennardJones
259 * Geometry: Particle-Particle
260 * Calculate force/pot: Force
263 nb_kernel_ElecNone_VdwLJSw_GeomP1P1_F_c
264 (t_nblist * gmx_restrict nlist,
265 rvec * gmx_restrict xx,
266 rvec * gmx_restrict ff,
267 t_forcerec * gmx_restrict fr,
268 t_mdatoms * gmx_restrict mdatoms,
269 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
270 t_nrnb * gmx_restrict nrnb)
272 int i_shift_offset,i_coord_offset,j_coord_offset;
273 int j_index_start,j_index_end;
274 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
275 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
276 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
277 real *shiftvec,*fshift,*x,*f;
279 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
281 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
282 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
284 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
287 real rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
294 jindex = nlist->jindex;
296 shiftidx = nlist->shift;
298 shiftvec = fr->shift_vec[0];
299 fshift = fr->fshift[0];
300 nvdwtype = fr->ntype;
302 vdwtype = mdatoms->typeA;
305 rcutoff2 = rcutoff*rcutoff;
307 rswitch = fr->rvdw_switch;
308 /* Setup switch parameters */
310 swV3 = -10.0/(d*d*d);
311 swV4 = 15.0/(d*d*d*d);
312 swV5 = -6.0/(d*d*d*d*d);
313 swF2 = -30.0/(d*d*d);
314 swF3 = 60.0/(d*d*d*d);
315 swF4 = -30.0/(d*d*d*d*d);
320 /* Start outer loop over neighborlists */
321 for(iidx=0; iidx<nri; iidx++)
323 /* Load shift vector for this list */
324 i_shift_offset = DIM*shiftidx[iidx];
325 shX = shiftvec[i_shift_offset+XX];
326 shY = shiftvec[i_shift_offset+YY];
327 shZ = shiftvec[i_shift_offset+ZZ];
329 /* Load limits for loop over neighbors */
330 j_index_start = jindex[iidx];
331 j_index_end = jindex[iidx+1];
333 /* Get outer coordinate index */
335 i_coord_offset = DIM*inr;
337 /* Load i particle coords and add shift vector */
338 ix0 = shX + x[i_coord_offset+DIM*0+XX];
339 iy0 = shY + x[i_coord_offset+DIM*0+YY];
340 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
346 /* Load parameters for i particles */
347 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
349 /* Start inner kernel loop */
350 for(jidx=j_index_start; jidx<j_index_end; jidx++)
352 /* Get j neighbor index, and coordinate index */
354 j_coord_offset = DIM*jnr;
356 /* load j atom coordinates */
357 jx0 = x[j_coord_offset+DIM*0+XX];
358 jy0 = x[j_coord_offset+DIM*0+YY];
359 jz0 = x[j_coord_offset+DIM*0+ZZ];
361 /* Calculate displacement vector */
366 /* Calculate squared distance and things based on it */
367 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
369 rinv00 = gmx_invsqrt(rsq00);
371 rinvsq00 = rinv00*rinv00;
373 /* Load parameters for j particles */
374 vdwjidx0 = 2*vdwtype[jnr+0];
376 /**************************
377 * CALCULATE INTERACTIONS *
378 **************************/
385 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
386 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
388 /* LENNARD-JONES DISPERSION/REPULSION */
390 rinvsix = rinvsq00*rinvsq00*rinvsq00;
391 vvdw6 = c6_00*rinvsix;
392 vvdw12 = c12_00*rinvsix*rinvsix;
393 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
394 fvdw = (vvdw12-vvdw6)*rinvsq00;
397 d = (d>0.0) ? d : 0.0;
399 sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5));
401 dsw = d2*(swF2+d*(swF3+d*swF4));
403 /* Evaluate switch function */
404 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
405 fvdw = fvdw*sw - rinv00*vvdw*dsw;
409 /* Calculate temporary vectorial force */
414 /* Update vectorial force */
418 f[j_coord_offset+DIM*0+XX] -= tx;
419 f[j_coord_offset+DIM*0+YY] -= ty;
420 f[j_coord_offset+DIM*0+ZZ] -= tz;
424 /* Inner loop uses 51 flops */
426 /* End of innermost loop */
429 f[i_coord_offset+DIM*0+XX] += fix0;
430 f[i_coord_offset+DIM*0+YY] += fiy0;
431 f[i_coord_offset+DIM*0+ZZ] += fiz0;
435 fshift[i_shift_offset+XX] += tx;
436 fshift[i_shift_offset+YY] += ty;
437 fshift[i_shift_offset+ZZ] += tz;
439 /* Increment number of inner iterations */
440 inneriter += j_index_end - j_index_start;
442 /* Outer loop uses 12 flops */
445 /* Increment number of outer iterations */
448 /* Update outer/inner flops */
450 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*12 + inneriter*51);