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_ElecEwSh_VdwNone_GeomP1P1_VF_c
35 * Electrostatics interaction: Ewald
36 * VdW interaction: None
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecEwSh_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;
86 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
87 rcutoff = fr->rcoulomb;
88 rcutoff2 = rcutoff*rcutoff;
93 /* Start outer loop over neighborlists */
94 for(iidx=0; iidx<nri; iidx++)
96 /* Load shift vector for this list */
97 i_shift_offset = DIM*shiftidx[iidx];
98 shX = shiftvec[i_shift_offset+XX];
99 shY = shiftvec[i_shift_offset+YY];
100 shZ = shiftvec[i_shift_offset+ZZ];
102 /* Load limits for loop over neighbors */
103 j_index_start = jindex[iidx];
104 j_index_end = jindex[iidx+1];
106 /* Get outer coordinate index */
108 i_coord_offset = DIM*inr;
110 /* Load i particle coords and add shift vector */
111 ix0 = shX + x[i_coord_offset+DIM*0+XX];
112 iy0 = shY + x[i_coord_offset+DIM*0+YY];
113 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
119 /* Load parameters for i particles */
120 iq0 = facel*charge[inr+0];
122 /* Reset potential sums */
125 /* Start inner kernel loop */
126 for(jidx=j_index_start; jidx<j_index_end; jidx++)
128 /* Get j neighbor index, and coordinate index */
130 j_coord_offset = DIM*jnr;
132 /* load j atom coordinates */
133 jx0 = x[j_coord_offset+DIM*0+XX];
134 jy0 = x[j_coord_offset+DIM*0+YY];
135 jz0 = x[j_coord_offset+DIM*0+ZZ];
137 /* Calculate displacement vector */
142 /* Calculate squared distance and things based on it */
143 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
145 rinv00 = gmx_invsqrt(rsq00);
147 rinvsq00 = rinv00*rinv00;
149 /* Load parameters for j particles */
152 /**************************
153 * CALCULATE INTERACTIONS *
154 **************************/
163 /* EWALD ELECTROSTATICS */
165 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
166 ewrt = r00*ewtabscale;
170 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
171 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
172 felec = qq00*rinv00*(rinvsq00-felec);
174 /* 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;
194 /* Inner loop uses 42 flops */
196 /* End of innermost loop */
199 f[i_coord_offset+DIM*0+XX] += fix0;
200 f[i_coord_offset+DIM*0+YY] += fiy0;
201 f[i_coord_offset+DIM*0+ZZ] += fiz0;
205 fshift[i_shift_offset+XX] += tx;
206 fshift[i_shift_offset+YY] += ty;
207 fshift[i_shift_offset+ZZ] += tz;
210 /* Update potential energies */
211 kernel_data->energygrp_elec[ggid] += velecsum;
213 /* Increment number of inner iterations */
214 inneriter += j_index_end - j_index_start;
216 /* Outer loop uses 14 flops */
219 /* Increment number of outer iterations */
222 /* Update outer/inner flops */
224 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*14 + inneriter*42);
227 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_c
228 * Electrostatics interaction: Ewald
229 * VdW interaction: None
230 * Geometry: Particle-Particle
231 * Calculate force/pot: Force
234 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_c
235 (t_nblist * gmx_restrict nlist,
236 rvec * gmx_restrict xx,
237 rvec * gmx_restrict ff,
238 t_forcerec * gmx_restrict fr,
239 t_mdatoms * gmx_restrict mdatoms,
240 nb_kernel_data_t * gmx_restrict kernel_data,
241 t_nrnb * gmx_restrict nrnb)
243 int i_shift_offset,i_coord_offset,j_coord_offset;
244 int j_index_start,j_index_end;
245 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
246 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
247 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
248 real *shiftvec,*fshift,*x,*f;
250 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
252 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
253 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
254 real velec,felec,velecsum,facel,crf,krf,krf2;
257 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
265 jindex = nlist->jindex;
267 shiftidx = nlist->shift;
269 shiftvec = fr->shift_vec[0];
270 fshift = fr->fshift[0];
272 charge = mdatoms->chargeA;
274 sh_ewald = fr->ic->sh_ewald;
275 ewtab = fr->ic->tabq_coul_F;
276 ewtabscale = fr->ic->tabq_scale;
277 ewtabhalfspace = 0.5/ewtabscale;
279 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
280 rcutoff = fr->rcoulomb;
281 rcutoff2 = rcutoff*rcutoff;
286 /* Start outer loop over neighborlists */
287 for(iidx=0; iidx<nri; iidx++)
289 /* Load shift vector for this list */
290 i_shift_offset = DIM*shiftidx[iidx];
291 shX = shiftvec[i_shift_offset+XX];
292 shY = shiftvec[i_shift_offset+YY];
293 shZ = shiftvec[i_shift_offset+ZZ];
295 /* Load limits for loop over neighbors */
296 j_index_start = jindex[iidx];
297 j_index_end = jindex[iidx+1];
299 /* Get outer coordinate index */
301 i_coord_offset = DIM*inr;
303 /* Load i particle coords and add shift vector */
304 ix0 = shX + x[i_coord_offset+DIM*0+XX];
305 iy0 = shY + x[i_coord_offset+DIM*0+YY];
306 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
312 /* Load parameters for i particles */
313 iq0 = facel*charge[inr+0];
315 /* Start inner kernel loop */
316 for(jidx=j_index_start; jidx<j_index_end; jidx++)
318 /* Get j neighbor index, and coordinate index */
320 j_coord_offset = DIM*jnr;
322 /* load j atom coordinates */
323 jx0 = x[j_coord_offset+DIM*0+XX];
324 jy0 = x[j_coord_offset+DIM*0+YY];
325 jz0 = x[j_coord_offset+DIM*0+ZZ];
327 /* Calculate displacement vector */
332 /* Calculate squared distance and things based on it */
333 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
335 rinv00 = gmx_invsqrt(rsq00);
337 rinvsq00 = rinv00*rinv00;
339 /* Load parameters for j particles */
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
353 /* EWALD ELECTROSTATICS */
355 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
356 ewrt = r00*ewtabscale;
359 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
360 felec = qq00*rinv00*(rinvsq00-felec);
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f[j_coord_offset+DIM*0+XX] -= tx;
374 f[j_coord_offset+DIM*0+YY] -= ty;
375 f[j_coord_offset+DIM*0+ZZ] -= tz;
379 /* Inner loop uses 34 flops */
381 /* End of innermost loop */
384 f[i_coord_offset+DIM*0+XX] += fix0;
385 f[i_coord_offset+DIM*0+YY] += fiy0;
386 f[i_coord_offset+DIM*0+ZZ] += fiz0;
390 fshift[i_shift_offset+XX] += tx;
391 fshift[i_shift_offset+YY] += ty;
392 fshift[i_shift_offset+ZZ] += tz;
394 /* Increment number of inner iterations */
395 inneriter += j_index_end - j_index_start;
397 /* Outer loop uses 13 flops */
400 /* Increment number of outer iterations */
403 /* Update outer/inner flops */
405 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*34);