2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_VF_c
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
77 real velec,felec,velecsum,facel,crf,krf,krf2;
80 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
88 jindex = nlist->jindex;
90 shiftidx = nlist->shift;
92 shiftvec = fr->shift_vec[0];
93 fshift = fr->fshift[0];
95 charge = mdatoms->chargeA;
97 sh_ewald = fr->ic->sh_ewald;
98 ewtab = fr->ic->tabq_coul_FDV0;
99 ewtabscale = fr->ic->tabq_scale;
100 ewtabhalfspace = 0.5/ewtabscale;
102 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
103 rcutoff = fr->rcoulomb;
104 rcutoff2 = rcutoff*rcutoff;
109 /* Start outer loop over neighborlists */
110 for(iidx=0; iidx<nri; iidx++)
112 /* Load shift vector for this list */
113 i_shift_offset = DIM*shiftidx[iidx];
114 shX = shiftvec[i_shift_offset+XX];
115 shY = shiftvec[i_shift_offset+YY];
116 shZ = shiftvec[i_shift_offset+ZZ];
118 /* Load limits for loop over neighbors */
119 j_index_start = jindex[iidx];
120 j_index_end = jindex[iidx+1];
122 /* Get outer coordinate index */
124 i_coord_offset = DIM*inr;
126 /* Load i particle coords and add shift vector */
127 ix0 = shX + x[i_coord_offset+DIM*0+XX];
128 iy0 = shY + x[i_coord_offset+DIM*0+YY];
129 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
135 /* Load parameters for i particles */
136 iq0 = facel*charge[inr+0];
138 /* Reset potential sums */
141 /* Start inner kernel loop */
142 for(jidx=j_index_start; jidx<j_index_end; jidx++)
144 /* Get j neighbor index, and coordinate index */
146 j_coord_offset = DIM*jnr;
148 /* load j atom coordinates */
149 jx0 = x[j_coord_offset+DIM*0+XX];
150 jy0 = x[j_coord_offset+DIM*0+YY];
151 jz0 = x[j_coord_offset+DIM*0+ZZ];
153 /* Calculate displacement vector */
158 /* Calculate squared distance and things based on it */
159 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
161 rinv00 = gmx_invsqrt(rsq00);
163 rinvsq00 = rinv00*rinv00;
165 /* Load parameters for j particles */
168 /**************************
169 * CALCULATE INTERACTIONS *
170 **************************/
179 /* EWALD ELECTROSTATICS */
181 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
182 ewrt = r00*ewtabscale;
186 felec = ewtab[ewitab]+eweps*ewtab[ewitab+1];
187 velec = qq00*((rinv00-sh_ewald)-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec)));
188 felec = qq00*rinv00*(rinvsq00-felec);
190 /* Update potential sums from outer loop */
195 /* Calculate temporary vectorial force */
200 /* Update vectorial force */
204 f[j_coord_offset+DIM*0+XX] -= tx;
205 f[j_coord_offset+DIM*0+YY] -= ty;
206 f[j_coord_offset+DIM*0+ZZ] -= tz;
210 /* Inner loop uses 42 flops */
212 /* End of innermost loop */
215 f[i_coord_offset+DIM*0+XX] += fix0;
216 f[i_coord_offset+DIM*0+YY] += fiy0;
217 f[i_coord_offset+DIM*0+ZZ] += fiz0;
221 fshift[i_shift_offset+XX] += tx;
222 fshift[i_shift_offset+YY] += ty;
223 fshift[i_shift_offset+ZZ] += tz;
226 /* Update potential energies */
227 kernel_data->energygrp_elec[ggid] += velecsum;
229 /* Increment number of inner iterations */
230 inneriter += j_index_end - j_index_start;
232 /* Outer loop uses 14 flops */
235 /* Increment number of outer iterations */
238 /* Update outer/inner flops */
240 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*14 + inneriter*42);
243 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_c
244 * Electrostatics interaction: Ewald
245 * VdW interaction: None
246 * Geometry: Particle-Particle
247 * Calculate force/pot: Force
250 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_c
251 (t_nblist * gmx_restrict nlist,
252 rvec * gmx_restrict xx,
253 rvec * gmx_restrict ff,
254 t_forcerec * gmx_restrict fr,
255 t_mdatoms * gmx_restrict mdatoms,
256 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
257 t_nrnb * gmx_restrict nrnb)
259 int i_shift_offset,i_coord_offset,j_coord_offset;
260 int j_index_start,j_index_end;
261 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
262 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
263 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
264 real *shiftvec,*fshift,*x,*f;
266 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
268 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
269 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
270 real velec,felec,velecsum,facel,crf,krf,krf2;
273 real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace;
281 jindex = nlist->jindex;
283 shiftidx = nlist->shift;
285 shiftvec = fr->shift_vec[0];
286 fshift = fr->fshift[0];
288 charge = mdatoms->chargeA;
290 sh_ewald = fr->ic->sh_ewald;
291 ewtab = fr->ic->tabq_coul_F;
292 ewtabscale = fr->ic->tabq_scale;
293 ewtabhalfspace = 0.5/ewtabscale;
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;
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];
331 /* Start inner kernel loop */
332 for(jidx=j_index_start; jidx<j_index_end; jidx++)
334 /* Get j neighbor index, and coordinate index */
336 j_coord_offset = DIM*jnr;
338 /* load j atom coordinates */
339 jx0 = x[j_coord_offset+DIM*0+XX];
340 jy0 = x[j_coord_offset+DIM*0+YY];
341 jz0 = x[j_coord_offset+DIM*0+ZZ];
343 /* Calculate displacement vector */
348 /* Calculate squared distance and things based on it */
349 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
351 rinv00 = gmx_invsqrt(rsq00);
353 rinvsq00 = rinv00*rinv00;
355 /* Load parameters for j particles */
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
369 /* EWALD ELECTROSTATICS */
371 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
372 ewrt = r00*ewtabscale;
375 felec = (1.0-eweps)*ewtab[ewitab]+eweps*ewtab[ewitab+1];
376 felec = qq00*rinv00*(rinvsq00-felec);
380 /* Calculate temporary vectorial force */
385 /* Update vectorial force */
389 f[j_coord_offset+DIM*0+XX] -= tx;
390 f[j_coord_offset+DIM*0+YY] -= ty;
391 f[j_coord_offset+DIM*0+ZZ] -= tz;
395 /* Inner loop uses 34 flops */
397 /* End of innermost loop */
400 f[i_coord_offset+DIM*0+XX] += fix0;
401 f[i_coord_offset+DIM*0+YY] += fiy0;
402 f[i_coord_offset+DIM*0+ZZ] += fiz0;
406 fshift[i_shift_offset+XX] += tx;
407 fshift[i_shift_offset+YY] += ty;
408 fshift[i_shift_offset+ZZ] += tz;
410 /* Increment number of inner iterations */
411 inneriter += j_index_end - j_index_start;
413 /* Outer loop uses 13 flops */
416 /* Increment number of outer iterations */
419 /* Update outer/inner flops */
421 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*34);