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_VdwNone_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: None
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_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;
69 jindex = nlist->jindex;
71 shiftidx = nlist->shift;
73 shiftvec = fr->shift_vec[0];
74 fshift = fr->fshift[0];
76 charge = mdatoms->chargeA;
81 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
82 rcutoff = fr->rcoulomb;
83 rcutoff2 = rcutoff*rcutoff;
88 /* Start outer loop over neighborlists */
89 for(iidx=0; iidx<nri; iidx++)
91 /* Load shift vector for this list */
92 i_shift_offset = DIM*shiftidx[iidx];
93 shX = shiftvec[i_shift_offset+XX];
94 shY = shiftvec[i_shift_offset+YY];
95 shZ = shiftvec[i_shift_offset+ZZ];
97 /* Load limits for loop over neighbors */
98 j_index_start = jindex[iidx];
99 j_index_end = jindex[iidx+1];
101 /* Get outer coordinate index */
103 i_coord_offset = DIM*inr;
105 /* Load i particle coords and add shift vector */
106 ix0 = shX + x[i_coord_offset+DIM*0+XX];
107 iy0 = shY + x[i_coord_offset+DIM*0+YY];
108 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
114 /* Load parameters for i particles */
115 iq0 = facel*charge[inr+0];
117 /* Reset potential sums */
120 /* Start inner kernel loop */
121 for(jidx=j_index_start; jidx<j_index_end; jidx++)
123 /* Get j neighbor index, and coordinate index */
125 j_coord_offset = DIM*jnr;
127 /* load j atom coordinates */
128 jx0 = x[j_coord_offset+DIM*0+XX];
129 jy0 = x[j_coord_offset+DIM*0+YY];
130 jz0 = x[j_coord_offset+DIM*0+ZZ];
132 /* Calculate displacement vector */
137 /* Calculate squared distance and things based on it */
138 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
140 rinv00 = gmx_invsqrt(rsq00);
142 rinvsq00 = rinv00*rinv00;
144 /* Load parameters for j particles */
147 /**************************
148 * CALCULATE INTERACTIONS *
149 **************************/
156 /* REACTION-FIELD ELECTROSTATICS */
157 velec = qq00*(rinv00+krf*rsq00-crf);
158 felec = qq00*(rinv00*rinvsq00-krf2);
160 /* Update potential sums from outer loop */
165 /* Calculate temporary vectorial force */
170 /* Update vectorial force */
174 f[j_coord_offset+DIM*0+XX] -= tx;
175 f[j_coord_offset+DIM*0+YY] -= ty;
176 f[j_coord_offset+DIM*0+ZZ] -= tz;
180 /* Inner loop uses 32 flops */
182 /* End of innermost loop */
185 f[i_coord_offset+DIM*0+XX] += fix0;
186 f[i_coord_offset+DIM*0+YY] += fiy0;
187 f[i_coord_offset+DIM*0+ZZ] += fiz0;
191 fshift[i_shift_offset+XX] += tx;
192 fshift[i_shift_offset+YY] += ty;
193 fshift[i_shift_offset+ZZ] += tz;
196 /* Update potential energies */
197 kernel_data->energygrp_elec[ggid] += velecsum;
199 /* Increment number of inner iterations */
200 inneriter += j_index_end - j_index_start;
202 /* Outer loop uses 14 flops */
205 /* Increment number of outer iterations */
208 /* Update outer/inner flops */
210 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*14 + inneriter*32);
213 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomP1P1_F_c
214 * Electrostatics interaction: ReactionField
215 * VdW interaction: None
216 * Geometry: Particle-Particle
217 * Calculate force/pot: Force
220 nb_kernel_ElecRFCut_VdwNone_GeomP1P1_F_c
221 (t_nblist * gmx_restrict nlist,
222 rvec * gmx_restrict xx,
223 rvec * gmx_restrict ff,
224 t_forcerec * gmx_restrict fr,
225 t_mdatoms * gmx_restrict mdatoms,
226 nb_kernel_data_t * gmx_restrict kernel_data,
227 t_nrnb * gmx_restrict nrnb)
229 int i_shift_offset,i_coord_offset,j_coord_offset;
230 int j_index_start,j_index_end;
231 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
232 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
233 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
234 real *shiftvec,*fshift,*x,*f;
236 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
238 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
239 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
240 real velec,felec,velecsum,facel,crf,krf,krf2;
248 jindex = nlist->jindex;
250 shiftidx = nlist->shift;
252 shiftvec = fr->shift_vec[0];
253 fshift = fr->fshift[0];
255 charge = mdatoms->chargeA;
260 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
261 rcutoff = fr->rcoulomb;
262 rcutoff2 = rcutoff*rcutoff;
267 /* Start outer loop over neighborlists */
268 for(iidx=0; iidx<nri; iidx++)
270 /* Load shift vector for this list */
271 i_shift_offset = DIM*shiftidx[iidx];
272 shX = shiftvec[i_shift_offset+XX];
273 shY = shiftvec[i_shift_offset+YY];
274 shZ = shiftvec[i_shift_offset+ZZ];
276 /* Load limits for loop over neighbors */
277 j_index_start = jindex[iidx];
278 j_index_end = jindex[iidx+1];
280 /* Get outer coordinate index */
282 i_coord_offset = DIM*inr;
284 /* Load i particle coords and add shift vector */
285 ix0 = shX + x[i_coord_offset+DIM*0+XX];
286 iy0 = shY + x[i_coord_offset+DIM*0+YY];
287 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
293 /* Load parameters for i particles */
294 iq0 = facel*charge[inr+0];
296 /* Start inner kernel loop */
297 for(jidx=j_index_start; jidx<j_index_end; jidx++)
299 /* Get j neighbor index, and coordinate index */
301 j_coord_offset = DIM*jnr;
303 /* load j atom coordinates */
304 jx0 = x[j_coord_offset+DIM*0+XX];
305 jy0 = x[j_coord_offset+DIM*0+YY];
306 jz0 = x[j_coord_offset+DIM*0+ZZ];
308 /* Calculate displacement vector */
313 /* Calculate squared distance and things based on it */
314 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
316 rinv00 = gmx_invsqrt(rsq00);
318 rinvsq00 = rinv00*rinv00;
320 /* Load parameters for j particles */
323 /**************************
324 * CALCULATE INTERACTIONS *
325 **************************/
332 /* REACTION-FIELD ELECTROSTATICS */
333 felec = qq00*(rinv00*rinvsq00-krf2);
337 /* Calculate temporary vectorial force */
342 /* Update vectorial force */
346 f[j_coord_offset+DIM*0+XX] -= tx;
347 f[j_coord_offset+DIM*0+YY] -= ty;
348 f[j_coord_offset+DIM*0+ZZ] -= tz;
352 /* Inner loop uses 27 flops */
354 /* End of innermost loop */
357 f[i_coord_offset+DIM*0+XX] += fix0;
358 f[i_coord_offset+DIM*0+YY] += fiy0;
359 f[i_coord_offset+DIM*0+ZZ] += fiz0;
363 fshift[i_shift_offset+XX] += tx;
364 fshift[i_shift_offset+YY] += ty;
365 fshift[i_shift_offset+ZZ] += tz;
367 /* Increment number of inner iterations */
368 inneriter += j_index_end - j_index_start;
370 /* Outer loop uses 13 flops */
373 /* Increment number of outer iterations */
376 /* Update outer/inner flops */
378 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*27);