2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomP1P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: None
51 * Geometry: Particle-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwNone_GeomP1P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
74 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
75 real velec,felec,velecsum,facel,crf,krf,krf2;
83 jindex = nlist->jindex;
85 shiftidx = nlist->shift;
87 shiftvec = fr->shift_vec[0];
88 fshift = fr->fshift[0];
90 charge = mdatoms->chargeA;
95 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
96 rcutoff = fr->rcoulomb;
97 rcutoff2 = rcutoff*rcutoff;
102 /* Start outer loop over neighborlists */
103 for(iidx=0; iidx<nri; iidx++)
105 /* Load shift vector for this list */
106 i_shift_offset = DIM*shiftidx[iidx];
107 shX = shiftvec[i_shift_offset+XX];
108 shY = shiftvec[i_shift_offset+YY];
109 shZ = shiftvec[i_shift_offset+ZZ];
111 /* Load limits for loop over neighbors */
112 j_index_start = jindex[iidx];
113 j_index_end = jindex[iidx+1];
115 /* Get outer coordinate index */
117 i_coord_offset = DIM*inr;
119 /* Load i particle coords and add shift vector */
120 ix0 = shX + x[i_coord_offset+DIM*0+XX];
121 iy0 = shY + x[i_coord_offset+DIM*0+YY];
122 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
128 /* Load parameters for i particles */
129 iq0 = facel*charge[inr+0];
131 /* Reset potential sums */
134 /* Start inner kernel loop */
135 for(jidx=j_index_start; jidx<j_index_end; jidx++)
137 /* Get j neighbor index, and coordinate index */
139 j_coord_offset = DIM*jnr;
141 /* load j atom coordinates */
142 jx0 = x[j_coord_offset+DIM*0+XX];
143 jy0 = x[j_coord_offset+DIM*0+YY];
144 jz0 = x[j_coord_offset+DIM*0+ZZ];
146 /* Calculate displacement vector */
151 /* Calculate squared distance and things based on it */
152 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
154 rinv00 = gmx_invsqrt(rsq00);
156 rinvsq00 = rinv00*rinv00;
158 /* Load parameters for j particles */
161 /**************************
162 * CALCULATE INTERACTIONS *
163 **************************/
170 /* REACTION-FIELD ELECTROSTATICS */
171 velec = qq00*(rinv00+krf*rsq00-crf);
172 felec = qq00*(rinv00*rinvsq00-krf2);
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 32 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*32);
227 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomP1P1_F_c
228 * Electrostatics interaction: ReactionField
229 * VdW interaction: None
230 * Geometry: Particle-Particle
231 * Calculate force/pot: Force
234 nb_kernel_ElecRFCut_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_unused * 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;
262 jindex = nlist->jindex;
264 shiftidx = nlist->shift;
266 shiftvec = fr->shift_vec[0];
267 fshift = fr->fshift[0];
269 charge = mdatoms->chargeA;
274 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
275 rcutoff = fr->rcoulomb;
276 rcutoff2 = rcutoff*rcutoff;
281 /* Start outer loop over neighborlists */
282 for(iidx=0; iidx<nri; iidx++)
284 /* Load shift vector for this list */
285 i_shift_offset = DIM*shiftidx[iidx];
286 shX = shiftvec[i_shift_offset+XX];
287 shY = shiftvec[i_shift_offset+YY];
288 shZ = shiftvec[i_shift_offset+ZZ];
290 /* Load limits for loop over neighbors */
291 j_index_start = jindex[iidx];
292 j_index_end = jindex[iidx+1];
294 /* Get outer coordinate index */
296 i_coord_offset = DIM*inr;
298 /* Load i particle coords and add shift vector */
299 ix0 = shX + x[i_coord_offset+DIM*0+XX];
300 iy0 = shY + x[i_coord_offset+DIM*0+YY];
301 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
307 /* Load parameters for i particles */
308 iq0 = facel*charge[inr+0];
310 /* Start inner kernel loop */
311 for(jidx=j_index_start; jidx<j_index_end; jidx++)
313 /* Get j neighbor index, and coordinate index */
315 j_coord_offset = DIM*jnr;
317 /* load j atom coordinates */
318 jx0 = x[j_coord_offset+DIM*0+XX];
319 jy0 = x[j_coord_offset+DIM*0+YY];
320 jz0 = x[j_coord_offset+DIM*0+ZZ];
322 /* Calculate displacement vector */
327 /* Calculate squared distance and things based on it */
328 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
330 rinv00 = gmx_invsqrt(rsq00);
332 rinvsq00 = rinv00*rinv00;
334 /* Load parameters for j particles */
337 /**************************
338 * CALCULATE INTERACTIONS *
339 **************************/
346 /* REACTION-FIELD ELECTROSTATICS */
347 felec = qq00*(rinv00*rinvsq00-krf2);
351 /* Calculate temporary vectorial force */
356 /* Update vectorial force */
360 f[j_coord_offset+DIM*0+XX] -= tx;
361 f[j_coord_offset+DIM*0+YY] -= ty;
362 f[j_coord_offset+DIM*0+ZZ] -= tz;
366 /* Inner loop uses 27 flops */
368 /* End of innermost loop */
371 f[i_coord_offset+DIM*0+XX] += fix0;
372 f[i_coord_offset+DIM*0+YY] += fiy0;
373 f[i_coord_offset+DIM*0+ZZ] += fiz0;
377 fshift[i_shift_offset+XX] += tx;
378 fshift[i_shift_offset+YY] += ty;
379 fshift[i_shift_offset+ZZ] += tz;
381 /* Increment number of inner iterations */
382 inneriter += j_index_end - j_index_start;
384 /* Outer loop uses 13 flops */
387 /* Increment number of outer iterations */
390 /* Update outer/inner flops */
392 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*13 + inneriter*27);