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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomW3P1_VF_c
51 * Electrostatics interaction: CubicSplineTable
52 * VdW interaction: None
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCSTab_VdwNone_GeomW3P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real velec,felec,velecsum,facel,crf,krf,krf2;
86 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
94 jindex = nlist->jindex;
96 shiftidx = nlist->shift;
98 shiftvec = fr->shift_vec[0];
99 fshift = fr->fshift[0];
101 charge = mdatoms->chargeA;
103 vftab = kernel_data->table_elec->data;
104 vftabscale = kernel_data->table_elec->scale;
106 /* Setup water-specific parameters */
107 inr = nlist->iinr[0];
108 iq0 = facel*charge[inr+0];
109 iq1 = facel*charge[inr+1];
110 iq2 = facel*charge[inr+2];
115 /* Start outer loop over neighborlists */
116 for(iidx=0; iidx<nri; iidx++)
118 /* Load shift vector for this list */
119 i_shift_offset = DIM*shiftidx[iidx];
120 shX = shiftvec[i_shift_offset+XX];
121 shY = shiftvec[i_shift_offset+YY];
122 shZ = shiftvec[i_shift_offset+ZZ];
124 /* Load limits for loop over neighbors */
125 j_index_start = jindex[iidx];
126 j_index_end = jindex[iidx+1];
128 /* Get outer coordinate index */
130 i_coord_offset = DIM*inr;
132 /* Load i particle coords and add shift vector */
133 ix0 = shX + x[i_coord_offset+DIM*0+XX];
134 iy0 = shY + x[i_coord_offset+DIM*0+YY];
135 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
136 ix1 = shX + x[i_coord_offset+DIM*1+XX];
137 iy1 = shY + x[i_coord_offset+DIM*1+YY];
138 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
139 ix2 = shX + x[i_coord_offset+DIM*2+XX];
140 iy2 = shY + x[i_coord_offset+DIM*2+YY];
141 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
153 /* Reset potential sums */
156 /* Start inner kernel loop */
157 for(jidx=j_index_start; jidx<j_index_end; jidx++)
159 /* Get j neighbor index, and coordinate index */
161 j_coord_offset = DIM*jnr;
163 /* load j atom coordinates */
164 jx0 = x[j_coord_offset+DIM*0+XX];
165 jy0 = x[j_coord_offset+DIM*0+YY];
166 jz0 = x[j_coord_offset+DIM*0+ZZ];
168 /* Calculate displacement vector */
179 /* Calculate squared distance and things based on it */
180 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
181 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
182 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
184 rinv00 = gmx_invsqrt(rsq00);
185 rinv10 = gmx_invsqrt(rsq10);
186 rinv20 = gmx_invsqrt(rsq20);
188 /* Load parameters for j particles */
191 /**************************
192 * CALCULATE INTERACTIONS *
193 **************************/
199 /* Calculate table index by multiplying r with table scale and truncate to integer */
205 /* CUBIC SPLINE TABLE ELECTROSTATICS */
208 Geps = vfeps*vftab[vfitab+2];
209 Heps2 = vfeps*vfeps*vftab[vfitab+3];
213 FF = Fp+Geps+2.0*Heps2;
214 felec = -qq00*FF*vftabscale*rinv00;
216 /* Update potential sums from outer loop */
221 /* Calculate temporary vectorial force */
226 /* Update vectorial force */
230 f[j_coord_offset+DIM*0+XX] -= tx;
231 f[j_coord_offset+DIM*0+YY] -= ty;
232 f[j_coord_offset+DIM*0+ZZ] -= tz;
234 /**************************
235 * CALCULATE INTERACTIONS *
236 **************************/
242 /* Calculate table index by multiplying r with table scale and truncate to integer */
248 /* CUBIC SPLINE TABLE ELECTROSTATICS */
251 Geps = vfeps*vftab[vfitab+2];
252 Heps2 = vfeps*vfeps*vftab[vfitab+3];
256 FF = Fp+Geps+2.0*Heps2;
257 felec = -qq10*FF*vftabscale*rinv10;
259 /* Update potential sums from outer loop */
264 /* Calculate temporary vectorial force */
269 /* Update vectorial force */
273 f[j_coord_offset+DIM*0+XX] -= tx;
274 f[j_coord_offset+DIM*0+YY] -= ty;
275 f[j_coord_offset+DIM*0+ZZ] -= tz;
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
285 /* Calculate table index by multiplying r with table scale and truncate to integer */
291 /* CUBIC SPLINE TABLE ELECTROSTATICS */
294 Geps = vfeps*vftab[vfitab+2];
295 Heps2 = vfeps*vfeps*vftab[vfitab+3];
299 FF = Fp+Geps+2.0*Heps2;
300 felec = -qq20*FF*vftabscale*rinv20;
302 /* Update potential sums from outer loop */
307 /* Calculate temporary vectorial force */
312 /* Update vectorial force */
316 f[j_coord_offset+DIM*0+XX] -= tx;
317 f[j_coord_offset+DIM*0+YY] -= ty;
318 f[j_coord_offset+DIM*0+ZZ] -= tz;
320 /* Inner loop uses 126 flops */
322 /* End of innermost loop */
325 f[i_coord_offset+DIM*0+XX] += fix0;
326 f[i_coord_offset+DIM*0+YY] += fiy0;
327 f[i_coord_offset+DIM*0+ZZ] += fiz0;
331 f[i_coord_offset+DIM*1+XX] += fix1;
332 f[i_coord_offset+DIM*1+YY] += fiy1;
333 f[i_coord_offset+DIM*1+ZZ] += fiz1;
337 f[i_coord_offset+DIM*2+XX] += fix2;
338 f[i_coord_offset+DIM*2+YY] += fiy2;
339 f[i_coord_offset+DIM*2+ZZ] += fiz2;
343 fshift[i_shift_offset+XX] += tx;
344 fshift[i_shift_offset+YY] += ty;
345 fshift[i_shift_offset+ZZ] += tz;
348 /* Update potential energies */
349 kernel_data->energygrp_elec[ggid] += velecsum;
351 /* Increment number of inner iterations */
352 inneriter += j_index_end - j_index_start;
354 /* Outer loop uses 31 flops */
357 /* Increment number of outer iterations */
360 /* Update outer/inner flops */
362 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*126);
365 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomW3P1_F_c
366 * Electrostatics interaction: CubicSplineTable
367 * VdW interaction: None
368 * Geometry: Water3-Particle
369 * Calculate force/pot: Force
372 nb_kernel_ElecCSTab_VdwNone_GeomW3P1_F_c
373 (t_nblist * gmx_restrict nlist,
374 rvec * gmx_restrict xx,
375 rvec * gmx_restrict ff,
376 t_forcerec * gmx_restrict fr,
377 t_mdatoms * gmx_restrict mdatoms,
378 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
379 t_nrnb * gmx_restrict nrnb)
381 int i_shift_offset,i_coord_offset,j_coord_offset;
382 int j_index_start,j_index_end;
383 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
384 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
385 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
386 real *shiftvec,*fshift,*x,*f;
388 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
390 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
392 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
394 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
395 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
396 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
397 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
398 real velec,felec,velecsum,facel,crf,krf,krf2;
401 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
409 jindex = nlist->jindex;
411 shiftidx = nlist->shift;
413 shiftvec = fr->shift_vec[0];
414 fshift = fr->fshift[0];
416 charge = mdatoms->chargeA;
418 vftab = kernel_data->table_elec->data;
419 vftabscale = kernel_data->table_elec->scale;
421 /* Setup water-specific parameters */
422 inr = nlist->iinr[0];
423 iq0 = facel*charge[inr+0];
424 iq1 = facel*charge[inr+1];
425 iq2 = facel*charge[inr+2];
430 /* Start outer loop over neighborlists */
431 for(iidx=0; iidx<nri; iidx++)
433 /* Load shift vector for this list */
434 i_shift_offset = DIM*shiftidx[iidx];
435 shX = shiftvec[i_shift_offset+XX];
436 shY = shiftvec[i_shift_offset+YY];
437 shZ = shiftvec[i_shift_offset+ZZ];
439 /* Load limits for loop over neighbors */
440 j_index_start = jindex[iidx];
441 j_index_end = jindex[iidx+1];
443 /* Get outer coordinate index */
445 i_coord_offset = DIM*inr;
447 /* Load i particle coords and add shift vector */
448 ix0 = shX + x[i_coord_offset+DIM*0+XX];
449 iy0 = shY + x[i_coord_offset+DIM*0+YY];
450 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
451 ix1 = shX + x[i_coord_offset+DIM*1+XX];
452 iy1 = shY + x[i_coord_offset+DIM*1+YY];
453 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
454 ix2 = shX + x[i_coord_offset+DIM*2+XX];
455 iy2 = shY + x[i_coord_offset+DIM*2+YY];
456 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
468 /* Start inner kernel loop */
469 for(jidx=j_index_start; jidx<j_index_end; jidx++)
471 /* Get j neighbor index, and coordinate index */
473 j_coord_offset = DIM*jnr;
475 /* load j atom coordinates */
476 jx0 = x[j_coord_offset+DIM*0+XX];
477 jy0 = x[j_coord_offset+DIM*0+YY];
478 jz0 = x[j_coord_offset+DIM*0+ZZ];
480 /* Calculate displacement vector */
491 /* Calculate squared distance and things based on it */
492 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
493 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
494 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
496 rinv00 = gmx_invsqrt(rsq00);
497 rinv10 = gmx_invsqrt(rsq10);
498 rinv20 = gmx_invsqrt(rsq20);
500 /* Load parameters for j particles */
503 /**************************
504 * CALCULATE INTERACTIONS *
505 **************************/
511 /* Calculate table index by multiplying r with table scale and truncate to integer */
517 /* CUBIC SPLINE TABLE ELECTROSTATICS */
519 Geps = vfeps*vftab[vfitab+2];
520 Heps2 = vfeps*vfeps*vftab[vfitab+3];
522 FF = Fp+Geps+2.0*Heps2;
523 felec = -qq00*FF*vftabscale*rinv00;
527 /* Calculate temporary vectorial force */
532 /* Update vectorial force */
536 f[j_coord_offset+DIM*0+XX] -= tx;
537 f[j_coord_offset+DIM*0+YY] -= ty;
538 f[j_coord_offset+DIM*0+ZZ] -= tz;
540 /**************************
541 * CALCULATE INTERACTIONS *
542 **************************/
548 /* Calculate table index by multiplying r with table scale and truncate to integer */
554 /* CUBIC SPLINE TABLE ELECTROSTATICS */
556 Geps = vfeps*vftab[vfitab+2];
557 Heps2 = vfeps*vfeps*vftab[vfitab+3];
559 FF = Fp+Geps+2.0*Heps2;
560 felec = -qq10*FF*vftabscale*rinv10;
564 /* Calculate temporary vectorial force */
569 /* Update vectorial force */
573 f[j_coord_offset+DIM*0+XX] -= tx;
574 f[j_coord_offset+DIM*0+YY] -= ty;
575 f[j_coord_offset+DIM*0+ZZ] -= tz;
577 /**************************
578 * CALCULATE INTERACTIONS *
579 **************************/
585 /* Calculate table index by multiplying r with table scale and truncate to integer */
591 /* CUBIC SPLINE TABLE ELECTROSTATICS */
593 Geps = vfeps*vftab[vfitab+2];
594 Heps2 = vfeps*vfeps*vftab[vfitab+3];
596 FF = Fp+Geps+2.0*Heps2;
597 felec = -qq20*FF*vftabscale*rinv20;
601 /* Calculate temporary vectorial force */
606 /* Update vectorial force */
610 f[j_coord_offset+DIM*0+XX] -= tx;
611 f[j_coord_offset+DIM*0+YY] -= ty;
612 f[j_coord_offset+DIM*0+ZZ] -= tz;
614 /* Inner loop uses 114 flops */
616 /* End of innermost loop */
619 f[i_coord_offset+DIM*0+XX] += fix0;
620 f[i_coord_offset+DIM*0+YY] += fiy0;
621 f[i_coord_offset+DIM*0+ZZ] += fiz0;
625 f[i_coord_offset+DIM*1+XX] += fix1;
626 f[i_coord_offset+DIM*1+YY] += fiy1;
627 f[i_coord_offset+DIM*1+ZZ] += fiz1;
631 f[i_coord_offset+DIM*2+XX] += fix2;
632 f[i_coord_offset+DIM*2+YY] += fiy2;
633 f[i_coord_offset+DIM*2+ZZ] += fiz2;
637 fshift[i_shift_offset+XX] += tx;
638 fshift[i_shift_offset+YY] += ty;
639 fshift[i_shift_offset+ZZ] += tz;
641 /* Increment number of inner iterations */
642 inneriter += j_index_end - j_index_start;
644 /* Outer loop uses 30 flops */
647 /* Increment number of outer iterations */
650 /* Update outer/inner flops */
652 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*114);