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_ElecEw_VdwNone_GeomP1P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEw_VdwNone_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
72 jindex = nlist->jindex;
74 shiftidx = nlist->shift;
76 shiftvec = fr->shift_vec[0];
77 fshift = fr->fshift[0];
79 charge = mdatoms->chargeA;
81 sh_ewald = fr->ic->sh_ewald;
82 ewtab = fr->ic->tabq_coul_FDV0;
83 ewtabscale = fr->ic->tabq_scale;
84 ewtabhalfspace = 0.5/ewtabscale;
89 /* Start outer loop over neighborlists */
90 for(iidx=0; iidx<nri; iidx++)
92 /* Load shift vector for this list */
93 i_shift_offset = DIM*shiftidx[iidx];
94 shX = shiftvec[i_shift_offset+XX];
95 shY = shiftvec[i_shift_offset+YY];
96 shZ = shiftvec[i_shift_offset+ZZ];
98 /* Load limits for loop over neighbors */
99 j_index_start = jindex[iidx];
100 j_index_end = jindex[iidx+1];
102 /* Get outer coordinate index */
104 i_coord_offset = DIM*inr;
106 /* Load i particle coords and add shift vector */
107 ix0 = shX + x[i_coord_offset+DIM*0+XX];
108 iy0 = shY + x[i_coord_offset+DIM*0+YY];
109 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
115 /* Load parameters for i particles */
116 iq0 = facel*charge[inr+0];
118 /* Reset potential sums */
121 /* Start inner kernel loop */
122 for(jidx=j_index_start; jidx<j_index_end; jidx++)
124 /* Get j neighbor index, and coordinate index */
126 j_coord_offset = DIM*jnr;
128 /* load j atom coordinates */
129 jx0 = x[j_coord_offset+DIM*0+XX];
130 jy0 = x[j_coord_offset+DIM*0+YY];
131 jz0 = x[j_coord_offset+DIM*0+ZZ];
133 /* Calculate displacement vector */
138 /* Calculate squared distance and things based on it */
139 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
141 rinv00 = gmx_invsqrt(rsq00);
143 rinvsq00 = rinv00*rinv00;
145 /* Load parameters for j particles */
148 /**************************
149 * CALCULATE INTERACTIONS *
150 **************************/
156 /* EWALD ELECTROSTATICS */
158 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
159 ewrt = r00*ewtabscale;
163 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
164 velec = qq00*(rinv00-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
165 felec = qq00*rinv00*(rinvsq00-felec);
167 /* Update potential sums from outer loop */
172 /* Calculate temporary vectorial force */
177 /* Update vectorial force */
181 f[j_coord_offset+DIM*0+XX] -= tx;
182 f[j_coord_offset+DIM*0+YY] -= ty;
183 f[j_coord_offset+DIM*0+ZZ] -= tz;
185 /* Inner loop uses 41 flops */
187 /* End of innermost loop */
190 f[i_coord_offset+DIM*0+XX] += fix0;
191 f[i_coord_offset+DIM*0+YY] += fiy0;
192 f[i_coord_offset+DIM*0+ZZ] += fiz0;
196 fshift[i_shift_offset+XX] += tx;
197 fshift[i_shift_offset+YY] += ty;
198 fshift[i_shift_offset+ZZ] += tz;
201 /* Update potential energies */
202 kernel_data->energygrp_elec[ggid] += velecsum;
204 /* Increment number of inner iterations */
205 inneriter += j_index_end - j_index_start;
207 /* Outer loop uses 14 flops */
210 /* Increment number of outer iterations */
213 /* Update outer/inner flops */
215 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*14 + inneriter*41);
218 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomP1P1_F_c
219 * Electrostatics interaction: Ewald
220 * VdW interaction: None
221 * Geometry: Particle-Particle
222 * Calculate force/pot: Force
225 nb_kernel_ElecEw_VdwNone_GeomP1P1_F_c
226 (t_nblist * gmx_restrict nlist,
227 rvec * gmx_restrict xx,
228 rvec * gmx_restrict ff,
229 t_forcerec * gmx_restrict fr,
230 t_mdatoms * gmx_restrict mdatoms,
231 nb_kernel_data_t * gmx_restrict kernel_data,
232 t_nrnb * gmx_restrict nrnb)
234 int i_shift_offset,i_coord_offset,j_coord_offset;
235 int j_index_start,j_index_end;
236 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
237 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
238 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
239 real *shiftvec,*fshift,*x,*f;
241 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
243 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
244 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
245 real velec,felec,velecsum,facel,crf,krf,krf2;
248 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
256 jindex = nlist->jindex;
258 shiftidx = nlist->shift;
260 shiftvec = fr->shift_vec[0];
261 fshift = fr->fshift[0];
263 charge = mdatoms->chargeA;
265 sh_ewald = fr->ic->sh_ewald;
266 ewtab = fr->ic->tabq_coul_F;
267 ewtabscale = fr->ic->tabq_scale;
268 ewtabhalfspace = 0.5/ewtabscale;
273 /* Start outer loop over neighborlists */
274 for(iidx=0; iidx<nri; iidx++)
276 /* Load shift vector for this list */
277 i_shift_offset = DIM*shiftidx[iidx];
278 shX = shiftvec[i_shift_offset+XX];
279 shY = shiftvec[i_shift_offset+YY];
280 shZ = shiftvec[i_shift_offset+ZZ];
282 /* Load limits for loop over neighbors */
283 j_index_start = jindex[iidx];
284 j_index_end = jindex[iidx+1];
286 /* Get outer coordinate index */
288 i_coord_offset = DIM*inr;
290 /* Load i particle coords and add shift vector */
291 ix0 = shX + x[i_coord_offset+DIM*0+XX];
292 iy0 = shY + x[i_coord_offset+DIM*0+YY];
293 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
299 /* Load parameters for i particles */
300 iq0 = facel*charge[inr+0];
302 /* Start inner kernel loop */
303 for(jidx=j_index_start; jidx<j_index_end; jidx++)
305 /* Get j neighbor index, and coordinate index */
307 j_coord_offset = DIM*jnr;
309 /* load j atom coordinates */
310 jx0 = x[j_coord_offset+DIM*0+XX];
311 jy0 = x[j_coord_offset+DIM*0+YY];
312 jz0 = x[j_coord_offset+DIM*0+ZZ];
314 /* Calculate displacement vector */
319 /* Calculate squared distance and things based on it */
320 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
322 rinv00 = gmx_invsqrt(rsq00);
324 rinvsq00 = rinv00*rinv00;
326 /* Load parameters for j particles */
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
337 /* EWALD ELECTROSTATICS */
339 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
340 ewrt = r00*ewtabscale;
343 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
344 felec = qq00*rinv00*(rinvsq00-felec);
348 /* Calculate temporary vectorial force */
353 /* Update vectorial force */
357 f[j_coord_offset+DIM*0+XX] -= tx;
358 f[j_coord_offset+DIM*0+YY] -= ty;
359 f[j_coord_offset+DIM*0+ZZ] -= tz;
361 /* Inner loop uses 34 flops */
363 /* End of innermost loop */
366 f[i_coord_offset+DIM*0+XX] += fix0;
367 f[i_coord_offset+DIM*0+YY] += fiy0;
368 f[i_coord_offset+DIM*0+ZZ] += fiz0;
372 fshift[i_shift_offset+XX] += tx;
373 fshift[i_shift_offset+YY] += ty;
374 fshift[i_shift_offset+ZZ] += tz;
376 /* Increment number of inner iterations */
377 inneriter += j_index_end - j_index_start;
379 /* Outer loop uses 13 flops */
382 /* Increment number of outer iterations */
385 /* Update outer/inner flops */
387 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*34);