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_ElecRF_VdwNone_GeomP1P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: None
37 * Geometry: Particle-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_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;
84 /* Start outer loop over neighborlists */
85 for(iidx=0; iidx<nri; iidx++)
87 /* Load shift vector for this list */
88 i_shift_offset = DIM*shiftidx[iidx];
89 shX = shiftvec[i_shift_offset+XX];
90 shY = shiftvec[i_shift_offset+YY];
91 shZ = shiftvec[i_shift_offset+ZZ];
93 /* Load limits for loop over neighbors */
94 j_index_start = jindex[iidx];
95 j_index_end = jindex[iidx+1];
97 /* Get outer coordinate index */
99 i_coord_offset = DIM*inr;
101 /* Load i particle coords and add shift vector */
102 ix0 = shX + x[i_coord_offset+DIM*0+XX];
103 iy0 = shY + x[i_coord_offset+DIM*0+YY];
104 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
110 /* Load parameters for i particles */
111 iq0 = facel*charge[inr+0];
113 /* Reset potential sums */
116 /* Start inner kernel loop */
117 for(jidx=j_index_start; jidx<j_index_end; jidx++)
119 /* Get j neighbor index, and coordinate index */
121 j_coord_offset = DIM*jnr;
123 /* load j atom coordinates */
124 jx0 = x[j_coord_offset+DIM*0+XX];
125 jy0 = x[j_coord_offset+DIM*0+YY];
126 jz0 = x[j_coord_offset+DIM*0+ZZ];
128 /* Calculate displacement vector */
133 /* Calculate squared distance and things based on it */
134 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
136 rinv00 = gmx_invsqrt(rsq00);
138 rinvsq00 = rinv00*rinv00;
140 /* Load parameters for j particles */
143 /**************************
144 * CALCULATE INTERACTIONS *
145 **************************/
149 /* REACTION-FIELD ELECTROSTATICS */
150 velec = qq00*(rinv00+krf*rsq00-crf);
151 felec = qq00*(rinv00*rinvsq00-krf2);
153 /* Update potential sums from outer loop */
158 /* Calculate temporary vectorial force */
163 /* Update vectorial force */
167 f[j_coord_offset+DIM*0+XX] -= tx;
168 f[j_coord_offset+DIM*0+YY] -= ty;
169 f[j_coord_offset+DIM*0+ZZ] -= tz;
171 /* Inner loop uses 32 flops */
173 /* End of innermost loop */
176 f[i_coord_offset+DIM*0+XX] += fix0;
177 f[i_coord_offset+DIM*0+YY] += fiy0;
178 f[i_coord_offset+DIM*0+ZZ] += fiz0;
182 fshift[i_shift_offset+XX] += tx;
183 fshift[i_shift_offset+YY] += ty;
184 fshift[i_shift_offset+ZZ] += tz;
187 /* Update potential energies */
188 kernel_data->energygrp_elec[ggid] += velecsum;
190 /* Increment number of inner iterations */
191 inneriter += j_index_end - j_index_start;
193 /* Outer loop uses 14 flops */
196 /* Increment number of outer iterations */
199 /* Update outer/inner flops */
201 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*14 + inneriter*32);
204 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomP1P1_F_c
205 * Electrostatics interaction: ReactionField
206 * VdW interaction: None
207 * Geometry: Particle-Particle
208 * Calculate force/pot: Force
211 nb_kernel_ElecRF_VdwNone_GeomP1P1_F_c
212 (t_nblist * gmx_restrict nlist,
213 rvec * gmx_restrict xx,
214 rvec * gmx_restrict ff,
215 t_forcerec * gmx_restrict fr,
216 t_mdatoms * gmx_restrict mdatoms,
217 nb_kernel_data_t * gmx_restrict kernel_data,
218 t_nrnb * gmx_restrict nrnb)
220 int i_shift_offset,i_coord_offset,j_coord_offset;
221 int j_index_start,j_index_end;
222 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
223 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
224 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
225 real *shiftvec,*fshift,*x,*f;
227 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
229 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
230 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
231 real velec,felec,velecsum,facel,crf,krf,krf2;
239 jindex = nlist->jindex;
241 shiftidx = nlist->shift;
243 shiftvec = fr->shift_vec[0];
244 fshift = fr->fshift[0];
246 charge = mdatoms->chargeA;
254 /* Start outer loop over neighborlists */
255 for(iidx=0; iidx<nri; iidx++)
257 /* Load shift vector for this list */
258 i_shift_offset = DIM*shiftidx[iidx];
259 shX = shiftvec[i_shift_offset+XX];
260 shY = shiftvec[i_shift_offset+YY];
261 shZ = shiftvec[i_shift_offset+ZZ];
263 /* Load limits for loop over neighbors */
264 j_index_start = jindex[iidx];
265 j_index_end = jindex[iidx+1];
267 /* Get outer coordinate index */
269 i_coord_offset = DIM*inr;
271 /* Load i particle coords and add shift vector */
272 ix0 = shX + x[i_coord_offset+DIM*0+XX];
273 iy0 = shY + x[i_coord_offset+DIM*0+YY];
274 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
280 /* Load parameters for i particles */
281 iq0 = facel*charge[inr+0];
283 /* Start inner kernel loop */
284 for(jidx=j_index_start; jidx<j_index_end; jidx++)
286 /* Get j neighbor index, and coordinate index */
288 j_coord_offset = DIM*jnr;
290 /* load j atom coordinates */
291 jx0 = x[j_coord_offset+DIM*0+XX];
292 jy0 = x[j_coord_offset+DIM*0+YY];
293 jz0 = x[j_coord_offset+DIM*0+ZZ];
295 /* Calculate displacement vector */
300 /* Calculate squared distance and things based on it */
301 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
303 rinv00 = gmx_invsqrt(rsq00);
305 rinvsq00 = rinv00*rinv00;
307 /* Load parameters for j particles */
310 /**************************
311 * CALCULATE INTERACTIONS *
312 **************************/
316 /* REACTION-FIELD ELECTROSTATICS */
317 felec = qq00*(rinv00*rinvsq00-krf2);
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /* Inner loop uses 27 flops */
336 /* End of innermost loop */
339 f[i_coord_offset+DIM*0+XX] += fix0;
340 f[i_coord_offset+DIM*0+YY] += fiy0;
341 f[i_coord_offset+DIM*0+ZZ] += fiz0;
345 fshift[i_shift_offset+XX] += tx;
346 fshift[i_shift_offset+YY] += ty;
347 fshift[i_shift_offset+ZZ] += tz;
349 /* Increment number of inner iterations */
350 inneriter += j_index_end - j_index_start;
352 /* Outer loop uses 13 flops */
355 /* Increment number of outer iterations */
358 /* Update outer/inner flops */
360 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*27);