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_ElecCoul_VdwNone_GeomW4P1_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: None
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwNone_GeomW4P1_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
73 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
75 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
79 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
80 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
89 jindex = nlist->jindex;
91 shiftidx = nlist->shift;
93 shiftvec = fr->shift_vec[0];
94 fshift = fr->fshift[0];
96 charge = mdatoms->chargeA;
98 /* Setup water-specific parameters */
100 iq1 = facel*charge[inr+1];
101 iq2 = facel*charge[inr+2];
102 iq3 = facel*charge[inr+3];
107 /* Start outer loop over neighborlists */
108 for(iidx=0; iidx<nri; iidx++)
110 /* Load shift vector for this list */
111 i_shift_offset = DIM*shiftidx[iidx];
112 shX = shiftvec[i_shift_offset+XX];
113 shY = shiftvec[i_shift_offset+YY];
114 shZ = shiftvec[i_shift_offset+ZZ];
116 /* Load limits for loop over neighbors */
117 j_index_start = jindex[iidx];
118 j_index_end = jindex[iidx+1];
120 /* Get outer coordinate index */
122 i_coord_offset = DIM*inr;
124 /* Load i particle coords and add shift vector */
125 ix1 = shX + x[i_coord_offset+DIM*1+XX];
126 iy1 = shY + x[i_coord_offset+DIM*1+YY];
127 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
128 ix2 = shX + x[i_coord_offset+DIM*2+XX];
129 iy2 = shY + x[i_coord_offset+DIM*2+YY];
130 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
131 ix3 = shX + x[i_coord_offset+DIM*3+XX];
132 iy3 = shY + x[i_coord_offset+DIM*3+YY];
133 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
145 /* Reset potential sums */
148 /* Start inner kernel loop */
149 for(jidx=j_index_start; jidx<j_index_end; jidx++)
151 /* Get j neighbor index, and coordinate index */
153 j_coord_offset = DIM*jnr;
155 /* load j atom coordinates */
156 jx0 = x[j_coord_offset+DIM*0+XX];
157 jy0 = x[j_coord_offset+DIM*0+YY];
158 jz0 = x[j_coord_offset+DIM*0+ZZ];
160 /* Calculate displacement vector */
171 /* Calculate squared distance and things based on it */
172 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
173 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
174 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
176 rinv10 = gmx_invsqrt(rsq10);
177 rinv20 = gmx_invsqrt(rsq20);
178 rinv30 = gmx_invsqrt(rsq30);
180 rinvsq10 = rinv10*rinv10;
181 rinvsq20 = rinv20*rinv20;
182 rinvsq30 = rinv30*rinv30;
184 /* Load parameters for j particles */
187 /**************************
188 * CALCULATE INTERACTIONS *
189 **************************/
193 /* COULOMB ELECTROSTATICS */
195 felec = velec*rinvsq10;
197 /* Update potential sums from outer loop */
202 /* Calculate temporary vectorial force */
207 /* Update vectorial force */
211 f[j_coord_offset+DIM*0+XX] -= tx;
212 f[j_coord_offset+DIM*0+YY] -= ty;
213 f[j_coord_offset+DIM*0+ZZ] -= tz;
215 /**************************
216 * CALCULATE INTERACTIONS *
217 **************************/
221 /* COULOMB ELECTROSTATICS */
223 felec = velec*rinvsq20;
225 /* Update potential sums from outer loop */
230 /* Calculate temporary vectorial force */
235 /* Update vectorial force */
239 f[j_coord_offset+DIM*0+XX] -= tx;
240 f[j_coord_offset+DIM*0+YY] -= ty;
241 f[j_coord_offset+DIM*0+ZZ] -= tz;
243 /**************************
244 * CALCULATE INTERACTIONS *
245 **************************/
249 /* COULOMB ELECTROSTATICS */
251 felec = velec*rinvsq30;
253 /* Update potential sums from outer loop */
258 /* Calculate temporary vectorial force */
263 /* Update vectorial force */
267 f[j_coord_offset+DIM*0+XX] -= tx;
268 f[j_coord_offset+DIM*0+YY] -= ty;
269 f[j_coord_offset+DIM*0+ZZ] -= tz;
271 /* Inner loop uses 84 flops */
273 /* End of innermost loop */
276 f[i_coord_offset+DIM*1+XX] += fix1;
277 f[i_coord_offset+DIM*1+YY] += fiy1;
278 f[i_coord_offset+DIM*1+ZZ] += fiz1;
282 f[i_coord_offset+DIM*2+XX] += fix2;
283 f[i_coord_offset+DIM*2+YY] += fiy2;
284 f[i_coord_offset+DIM*2+ZZ] += fiz2;
288 f[i_coord_offset+DIM*3+XX] += fix3;
289 f[i_coord_offset+DIM*3+YY] += fiy3;
290 f[i_coord_offset+DIM*3+ZZ] += fiz3;
294 fshift[i_shift_offset+XX] += tx;
295 fshift[i_shift_offset+YY] += ty;
296 fshift[i_shift_offset+ZZ] += tz;
299 /* Update potential energies */
300 kernel_data->energygrp_elec[ggid] += velecsum;
302 /* Increment number of inner iterations */
303 inneriter += j_index_end - j_index_start;
305 /* Outer loop uses 31 flops */
308 /* Increment number of outer iterations */
311 /* Update outer/inner flops */
313 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*84);
316 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_c
317 * Electrostatics interaction: Coulomb
318 * VdW interaction: None
319 * Geometry: Water4-Particle
320 * Calculate force/pot: Force
323 nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_c
324 (t_nblist * gmx_restrict nlist,
325 rvec * gmx_restrict xx,
326 rvec * gmx_restrict ff,
327 t_forcerec * gmx_restrict fr,
328 t_mdatoms * gmx_restrict mdatoms,
329 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
330 t_nrnb * gmx_restrict nrnb)
332 int i_shift_offset,i_coord_offset,j_coord_offset;
333 int j_index_start,j_index_end;
334 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
335 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
336 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
337 real *shiftvec,*fshift,*x,*f;
339 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
341 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
343 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
345 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
346 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
347 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
348 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
349 real velec,felec,velecsum,facel,crf,krf,krf2;
357 jindex = nlist->jindex;
359 shiftidx = nlist->shift;
361 shiftvec = fr->shift_vec[0];
362 fshift = fr->fshift[0];
364 charge = mdatoms->chargeA;
366 /* Setup water-specific parameters */
367 inr = nlist->iinr[0];
368 iq1 = facel*charge[inr+1];
369 iq2 = facel*charge[inr+2];
370 iq3 = facel*charge[inr+3];
375 /* Start outer loop over neighborlists */
376 for(iidx=0; iidx<nri; iidx++)
378 /* Load shift vector for this list */
379 i_shift_offset = DIM*shiftidx[iidx];
380 shX = shiftvec[i_shift_offset+XX];
381 shY = shiftvec[i_shift_offset+YY];
382 shZ = shiftvec[i_shift_offset+ZZ];
384 /* Load limits for loop over neighbors */
385 j_index_start = jindex[iidx];
386 j_index_end = jindex[iidx+1];
388 /* Get outer coordinate index */
390 i_coord_offset = DIM*inr;
392 /* Load i particle coords and add shift vector */
393 ix1 = shX + x[i_coord_offset+DIM*1+XX];
394 iy1 = shY + x[i_coord_offset+DIM*1+YY];
395 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
396 ix2 = shX + x[i_coord_offset+DIM*2+XX];
397 iy2 = shY + x[i_coord_offset+DIM*2+YY];
398 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
399 ix3 = shX + x[i_coord_offset+DIM*3+XX];
400 iy3 = shY + x[i_coord_offset+DIM*3+YY];
401 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
413 /* Start inner kernel loop */
414 for(jidx=j_index_start; jidx<j_index_end; jidx++)
416 /* Get j neighbor index, and coordinate index */
418 j_coord_offset = DIM*jnr;
420 /* load j atom coordinates */
421 jx0 = x[j_coord_offset+DIM*0+XX];
422 jy0 = x[j_coord_offset+DIM*0+YY];
423 jz0 = x[j_coord_offset+DIM*0+ZZ];
425 /* Calculate displacement vector */
436 /* Calculate squared distance and things based on it */
437 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
438 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
439 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
441 rinv10 = gmx_invsqrt(rsq10);
442 rinv20 = gmx_invsqrt(rsq20);
443 rinv30 = gmx_invsqrt(rsq30);
445 rinvsq10 = rinv10*rinv10;
446 rinvsq20 = rinv20*rinv20;
447 rinvsq30 = rinv30*rinv30;
449 /* Load parameters for j particles */
452 /**************************
453 * CALCULATE INTERACTIONS *
454 **************************/
458 /* COULOMB ELECTROSTATICS */
460 felec = velec*rinvsq10;
464 /* Calculate temporary vectorial force */
469 /* Update vectorial force */
473 f[j_coord_offset+DIM*0+XX] -= tx;
474 f[j_coord_offset+DIM*0+YY] -= ty;
475 f[j_coord_offset+DIM*0+ZZ] -= tz;
477 /**************************
478 * CALCULATE INTERACTIONS *
479 **************************/
483 /* COULOMB ELECTROSTATICS */
485 felec = velec*rinvsq20;
489 /* Calculate temporary vectorial force */
494 /* Update vectorial force */
498 f[j_coord_offset+DIM*0+XX] -= tx;
499 f[j_coord_offset+DIM*0+YY] -= ty;
500 f[j_coord_offset+DIM*0+ZZ] -= tz;
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
508 /* COULOMB ELECTROSTATICS */
510 felec = velec*rinvsq30;
514 /* Calculate temporary vectorial force */
519 /* Update vectorial force */
523 f[j_coord_offset+DIM*0+XX] -= tx;
524 f[j_coord_offset+DIM*0+YY] -= ty;
525 f[j_coord_offset+DIM*0+ZZ] -= tz;
527 /* Inner loop uses 81 flops */
529 /* End of innermost loop */
532 f[i_coord_offset+DIM*1+XX] += fix1;
533 f[i_coord_offset+DIM*1+YY] += fiy1;
534 f[i_coord_offset+DIM*1+ZZ] += fiz1;
538 f[i_coord_offset+DIM*2+XX] += fix2;
539 f[i_coord_offset+DIM*2+YY] += fiy2;
540 f[i_coord_offset+DIM*2+ZZ] += fiz2;
544 f[i_coord_offset+DIM*3+XX] += fix3;
545 f[i_coord_offset+DIM*3+YY] += fiy3;
546 f[i_coord_offset+DIM*3+ZZ] += fiz3;
550 fshift[i_shift_offset+XX] += tx;
551 fshift[i_shift_offset+YY] += ty;
552 fshift[i_shift_offset+ZZ] += tz;
554 /* Increment number of inner iterations */
555 inneriter += j_index_end - j_index_start;
557 /* Outer loop uses 30 flops */
560 /* Increment number of outer iterations */
563 /* Update outer/inner flops */
565 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*81);