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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomW4P1_VF_c
49 * Electrostatics interaction: CubicSplineTable
50 * VdW interaction: None
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCSTab_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;
84 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
92 jindex = nlist->jindex;
94 shiftidx = nlist->shift;
96 shiftvec = fr->shift_vec[0];
97 fshift = fr->fshift[0];
99 charge = mdatoms->chargeA;
101 vftab = kernel_data->table_elec->data;
102 vftabscale = kernel_data->table_elec->scale;
104 /* Setup water-specific parameters */
105 inr = nlist->iinr[0];
106 iq1 = facel*charge[inr+1];
107 iq2 = facel*charge[inr+2];
108 iq3 = facel*charge[inr+3];
113 /* Start outer loop over neighborlists */
114 for(iidx=0; iidx<nri; iidx++)
116 /* Load shift vector for this list */
117 i_shift_offset = DIM*shiftidx[iidx];
118 shX = shiftvec[i_shift_offset+XX];
119 shY = shiftvec[i_shift_offset+YY];
120 shZ = shiftvec[i_shift_offset+ZZ];
122 /* Load limits for loop over neighbors */
123 j_index_start = jindex[iidx];
124 j_index_end = jindex[iidx+1];
126 /* Get outer coordinate index */
128 i_coord_offset = DIM*inr;
130 /* Load i particle coords and add shift vector */
131 ix1 = shX + x[i_coord_offset+DIM*1+XX];
132 iy1 = shY + x[i_coord_offset+DIM*1+YY];
133 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
134 ix2 = shX + x[i_coord_offset+DIM*2+XX];
135 iy2 = shY + x[i_coord_offset+DIM*2+YY];
136 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
137 ix3 = shX + x[i_coord_offset+DIM*3+XX];
138 iy3 = shY + x[i_coord_offset+DIM*3+YY];
139 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
151 /* Reset potential sums */
154 /* Start inner kernel loop */
155 for(jidx=j_index_start; jidx<j_index_end; jidx++)
157 /* Get j neighbor index, and coordinate index */
159 j_coord_offset = DIM*jnr;
161 /* load j atom coordinates */
162 jx0 = x[j_coord_offset+DIM*0+XX];
163 jy0 = x[j_coord_offset+DIM*0+YY];
164 jz0 = x[j_coord_offset+DIM*0+ZZ];
166 /* Calculate displacement vector */
177 /* Calculate squared distance and things based on it */
178 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
179 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
180 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
182 rinv10 = gmx_invsqrt(rsq10);
183 rinv20 = gmx_invsqrt(rsq20);
184 rinv30 = gmx_invsqrt(rsq30);
186 /* Load parameters for j particles */
189 /**************************
190 * CALCULATE INTERACTIONS *
191 **************************/
197 /* Calculate table index by multiplying r with table scale and truncate to integer */
203 /* CUBIC SPLINE TABLE ELECTROSTATICS */
206 Geps = vfeps*vftab[vfitab+2];
207 Heps2 = vfeps*vfeps*vftab[vfitab+3];
211 FF = Fp+Geps+2.0*Heps2;
212 felec = -qq10*FF*vftabscale*rinv10;
214 /* Update potential sums from outer loop */
219 /* Calculate temporary vectorial force */
224 /* Update vectorial force */
228 f[j_coord_offset+DIM*0+XX] -= tx;
229 f[j_coord_offset+DIM*0+YY] -= ty;
230 f[j_coord_offset+DIM*0+ZZ] -= tz;
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
240 /* Calculate table index by multiplying r with table scale and truncate to integer */
246 /* CUBIC SPLINE TABLE ELECTROSTATICS */
249 Geps = vfeps*vftab[vfitab+2];
250 Heps2 = vfeps*vfeps*vftab[vfitab+3];
254 FF = Fp+Geps+2.0*Heps2;
255 felec = -qq20*FF*vftabscale*rinv20;
257 /* Update potential sums from outer loop */
262 /* Calculate temporary vectorial force */
267 /* Update vectorial force */
271 f[j_coord_offset+DIM*0+XX] -= tx;
272 f[j_coord_offset+DIM*0+YY] -= ty;
273 f[j_coord_offset+DIM*0+ZZ] -= tz;
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
283 /* Calculate table index by multiplying r with table scale and truncate to integer */
289 /* CUBIC SPLINE TABLE ELECTROSTATICS */
292 Geps = vfeps*vftab[vfitab+2];
293 Heps2 = vfeps*vfeps*vftab[vfitab+3];
297 FF = Fp+Geps+2.0*Heps2;
298 felec = -qq30*FF*vftabscale*rinv30;
300 /* Update potential sums from outer loop */
305 /* Calculate temporary vectorial force */
310 /* Update vectorial force */
314 f[j_coord_offset+DIM*0+XX] -= tx;
315 f[j_coord_offset+DIM*0+YY] -= ty;
316 f[j_coord_offset+DIM*0+ZZ] -= tz;
318 /* Inner loop uses 126 flops */
320 /* End of innermost loop */
323 f[i_coord_offset+DIM*1+XX] += fix1;
324 f[i_coord_offset+DIM*1+YY] += fiy1;
325 f[i_coord_offset+DIM*1+ZZ] += fiz1;
329 f[i_coord_offset+DIM*2+XX] += fix2;
330 f[i_coord_offset+DIM*2+YY] += fiy2;
331 f[i_coord_offset+DIM*2+ZZ] += fiz2;
335 f[i_coord_offset+DIM*3+XX] += fix3;
336 f[i_coord_offset+DIM*3+YY] += fiy3;
337 f[i_coord_offset+DIM*3+ZZ] += fiz3;
341 fshift[i_shift_offset+XX] += tx;
342 fshift[i_shift_offset+YY] += ty;
343 fshift[i_shift_offset+ZZ] += tz;
346 /* Update potential energies */
347 kernel_data->energygrp_elec[ggid] += velecsum;
349 /* Increment number of inner iterations */
350 inneriter += j_index_end - j_index_start;
352 /* Outer loop uses 31 flops */
355 /* Increment number of outer iterations */
358 /* Update outer/inner flops */
360 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*126);
363 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomW4P1_F_c
364 * Electrostatics interaction: CubicSplineTable
365 * VdW interaction: None
366 * Geometry: Water4-Particle
367 * Calculate force/pot: Force
370 nb_kernel_ElecCSTab_VdwNone_GeomW4P1_F_c
371 (t_nblist * gmx_restrict nlist,
372 rvec * gmx_restrict xx,
373 rvec * gmx_restrict ff,
374 t_forcerec * gmx_restrict fr,
375 t_mdatoms * gmx_restrict mdatoms,
376 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
377 t_nrnb * gmx_restrict nrnb)
379 int i_shift_offset,i_coord_offset,j_coord_offset;
380 int j_index_start,j_index_end;
381 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
382 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
383 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
384 real *shiftvec,*fshift,*x,*f;
386 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
388 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
390 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
392 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
393 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
394 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
395 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
396 real velec,felec,velecsum,facel,crf,krf,krf2;
399 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
407 jindex = nlist->jindex;
409 shiftidx = nlist->shift;
411 shiftvec = fr->shift_vec[0];
412 fshift = fr->fshift[0];
414 charge = mdatoms->chargeA;
416 vftab = kernel_data->table_elec->data;
417 vftabscale = kernel_data->table_elec->scale;
419 /* Setup water-specific parameters */
420 inr = nlist->iinr[0];
421 iq1 = facel*charge[inr+1];
422 iq2 = facel*charge[inr+2];
423 iq3 = facel*charge[inr+3];
428 /* Start outer loop over neighborlists */
429 for(iidx=0; iidx<nri; iidx++)
431 /* Load shift vector for this list */
432 i_shift_offset = DIM*shiftidx[iidx];
433 shX = shiftvec[i_shift_offset+XX];
434 shY = shiftvec[i_shift_offset+YY];
435 shZ = shiftvec[i_shift_offset+ZZ];
437 /* Load limits for loop over neighbors */
438 j_index_start = jindex[iidx];
439 j_index_end = jindex[iidx+1];
441 /* Get outer coordinate index */
443 i_coord_offset = DIM*inr;
445 /* Load i particle coords and add shift vector */
446 ix1 = shX + x[i_coord_offset+DIM*1+XX];
447 iy1 = shY + x[i_coord_offset+DIM*1+YY];
448 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
449 ix2 = shX + x[i_coord_offset+DIM*2+XX];
450 iy2 = shY + x[i_coord_offset+DIM*2+YY];
451 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
452 ix3 = shX + x[i_coord_offset+DIM*3+XX];
453 iy3 = shY + x[i_coord_offset+DIM*3+YY];
454 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
466 /* Start inner kernel loop */
467 for(jidx=j_index_start; jidx<j_index_end; jidx++)
469 /* Get j neighbor index, and coordinate index */
471 j_coord_offset = DIM*jnr;
473 /* load j atom coordinates */
474 jx0 = x[j_coord_offset+DIM*0+XX];
475 jy0 = x[j_coord_offset+DIM*0+YY];
476 jz0 = x[j_coord_offset+DIM*0+ZZ];
478 /* Calculate displacement vector */
489 /* Calculate squared distance and things based on it */
490 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
491 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
492 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
494 rinv10 = gmx_invsqrt(rsq10);
495 rinv20 = gmx_invsqrt(rsq20);
496 rinv30 = gmx_invsqrt(rsq30);
498 /* Load parameters for j particles */
501 /**************************
502 * CALCULATE INTERACTIONS *
503 **************************/
509 /* Calculate table index by multiplying r with table scale and truncate to integer */
515 /* CUBIC SPLINE TABLE ELECTROSTATICS */
517 Geps = vfeps*vftab[vfitab+2];
518 Heps2 = vfeps*vfeps*vftab[vfitab+3];
520 FF = Fp+Geps+2.0*Heps2;
521 felec = -qq10*FF*vftabscale*rinv10;
525 /* Calculate temporary vectorial force */
530 /* Update vectorial force */
534 f[j_coord_offset+DIM*0+XX] -= tx;
535 f[j_coord_offset+DIM*0+YY] -= ty;
536 f[j_coord_offset+DIM*0+ZZ] -= tz;
538 /**************************
539 * CALCULATE INTERACTIONS *
540 **************************/
546 /* Calculate table index by multiplying r with table scale and truncate to integer */
552 /* CUBIC SPLINE TABLE ELECTROSTATICS */
554 Geps = vfeps*vftab[vfitab+2];
555 Heps2 = vfeps*vfeps*vftab[vfitab+3];
557 FF = Fp+Geps+2.0*Heps2;
558 felec = -qq20*FF*vftabscale*rinv20;
562 /* Calculate temporary vectorial force */
567 /* Update vectorial force */
571 f[j_coord_offset+DIM*0+XX] -= tx;
572 f[j_coord_offset+DIM*0+YY] -= ty;
573 f[j_coord_offset+DIM*0+ZZ] -= tz;
575 /**************************
576 * CALCULATE INTERACTIONS *
577 **************************/
583 /* Calculate table index by multiplying r with table scale and truncate to integer */
589 /* CUBIC SPLINE TABLE ELECTROSTATICS */
591 Geps = vfeps*vftab[vfitab+2];
592 Heps2 = vfeps*vfeps*vftab[vfitab+3];
594 FF = Fp+Geps+2.0*Heps2;
595 felec = -qq30*FF*vftabscale*rinv30;
599 /* Calculate temporary vectorial force */
604 /* Update vectorial force */
608 f[j_coord_offset+DIM*0+XX] -= tx;
609 f[j_coord_offset+DIM*0+YY] -= ty;
610 f[j_coord_offset+DIM*0+ZZ] -= tz;
612 /* Inner loop uses 114 flops */
614 /* End of innermost loop */
617 f[i_coord_offset+DIM*1+XX] += fix1;
618 f[i_coord_offset+DIM*1+YY] += fiy1;
619 f[i_coord_offset+DIM*1+ZZ] += fiz1;
623 f[i_coord_offset+DIM*2+XX] += fix2;
624 f[i_coord_offset+DIM*2+YY] += fiy2;
625 f[i_coord_offset+DIM*2+ZZ] += fiz2;
629 f[i_coord_offset+DIM*3+XX] += fix3;
630 f[i_coord_offset+DIM*3+YY] += fiy3;
631 f[i_coord_offset+DIM*3+ZZ] += fiz3;
635 fshift[i_shift_offset+XX] += tx;
636 fshift[i_shift_offset+YY] += ty;
637 fshift[i_shift_offset+ZZ] += tz;
639 /* Increment number of inner iterations */
640 inneriter += j_index_end - j_index_start;
642 /* Outer loop uses 30 flops */
645 /* Increment number of outer iterations */
648 /* Update outer/inner flops */
650 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*114);