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_ElecCSTab_VdwNone_GeomW4P1_VF_c
35 * Electrostatics interaction: CubicSplineTable
36 * VdW interaction: None
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCSTab_VdwNone_GeomW4P1_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
59 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
61 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
65 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
66 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
78 jindex = nlist->jindex;
80 shiftidx = nlist->shift;
82 shiftvec = fr->shift_vec[0];
83 fshift = fr->fshift[0];
85 charge = mdatoms->chargeA;
87 vftab = kernel_data->table_elec->data;
88 vftabscale = kernel_data->table_elec->scale;
90 /* Setup water-specific parameters */
92 iq1 = facel*charge[inr+1];
93 iq2 = facel*charge[inr+2];
94 iq3 = facel*charge[inr+3];
99 /* Start outer loop over neighborlists */
100 for(iidx=0; iidx<nri; iidx++)
102 /* Load shift vector for this list */
103 i_shift_offset = DIM*shiftidx[iidx];
104 shX = shiftvec[i_shift_offset+XX];
105 shY = shiftvec[i_shift_offset+YY];
106 shZ = shiftvec[i_shift_offset+ZZ];
108 /* Load limits for loop over neighbors */
109 j_index_start = jindex[iidx];
110 j_index_end = jindex[iidx+1];
112 /* Get outer coordinate index */
114 i_coord_offset = DIM*inr;
116 /* Load i particle coords and add shift vector */
117 ix1 = shX + x[i_coord_offset+DIM*1+XX];
118 iy1 = shY + x[i_coord_offset+DIM*1+YY];
119 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
120 ix2 = shX + x[i_coord_offset+DIM*2+XX];
121 iy2 = shY + x[i_coord_offset+DIM*2+YY];
122 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
123 ix3 = shX + x[i_coord_offset+DIM*3+XX];
124 iy3 = shY + x[i_coord_offset+DIM*3+YY];
125 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
137 /* Reset potential sums */
140 /* Start inner kernel loop */
141 for(jidx=j_index_start; jidx<j_index_end; jidx++)
143 /* Get j neighbor index, and coordinate index */
145 j_coord_offset = DIM*jnr;
147 /* load j atom coordinates */
148 jx0 = x[j_coord_offset+DIM*0+XX];
149 jy0 = x[j_coord_offset+DIM*0+YY];
150 jz0 = x[j_coord_offset+DIM*0+ZZ];
152 /* Calculate displacement vector */
163 /* Calculate squared distance and things based on it */
164 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
165 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
166 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
168 rinv10 = gmx_invsqrt(rsq10);
169 rinv20 = gmx_invsqrt(rsq20);
170 rinv30 = gmx_invsqrt(rsq30);
172 /* Load parameters for j particles */
175 /**************************
176 * CALCULATE INTERACTIONS *
177 **************************/
183 /* Calculate table index by multiplying r with table scale and truncate to integer */
189 /* CUBIC SPLINE TABLE ELECTROSTATICS */
192 Geps = vfeps*vftab[vfitab+2];
193 Heps2 = vfeps*vfeps*vftab[vfitab+3];
197 FF = Fp+Geps+2.0*Heps2;
198 felec = -qq10*FF*vftabscale*rinv10;
200 /* Update potential sums from outer loop */
205 /* Calculate temporary vectorial force */
210 /* Update vectorial force */
214 f[j_coord_offset+DIM*0+XX] -= tx;
215 f[j_coord_offset+DIM*0+YY] -= ty;
216 f[j_coord_offset+DIM*0+ZZ] -= tz;
218 /**************************
219 * CALCULATE INTERACTIONS *
220 **************************/
226 /* Calculate table index by multiplying r with table scale and truncate to integer */
232 /* CUBIC SPLINE TABLE ELECTROSTATICS */
235 Geps = vfeps*vftab[vfitab+2];
236 Heps2 = vfeps*vfeps*vftab[vfitab+3];
240 FF = Fp+Geps+2.0*Heps2;
241 felec = -qq20*FF*vftabscale*rinv20;
243 /* Update potential sums from outer loop */
248 /* Calculate temporary vectorial force */
253 /* Update vectorial force */
257 f[j_coord_offset+DIM*0+XX] -= tx;
258 f[j_coord_offset+DIM*0+YY] -= ty;
259 f[j_coord_offset+DIM*0+ZZ] -= tz;
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
269 /* Calculate table index by multiplying r with table scale and truncate to integer */
275 /* CUBIC SPLINE TABLE ELECTROSTATICS */
278 Geps = vfeps*vftab[vfitab+2];
279 Heps2 = vfeps*vfeps*vftab[vfitab+3];
283 FF = Fp+Geps+2.0*Heps2;
284 felec = -qq30*FF*vftabscale*rinv30;
286 /* Update potential sums from outer loop */
291 /* Calculate temporary vectorial force */
296 /* Update vectorial force */
300 f[j_coord_offset+DIM*0+XX] -= tx;
301 f[j_coord_offset+DIM*0+YY] -= ty;
302 f[j_coord_offset+DIM*0+ZZ] -= tz;
304 /* Inner loop uses 126 flops */
306 /* End of innermost loop */
309 f[i_coord_offset+DIM*1+XX] += fix1;
310 f[i_coord_offset+DIM*1+YY] += fiy1;
311 f[i_coord_offset+DIM*1+ZZ] += fiz1;
315 f[i_coord_offset+DIM*2+XX] += fix2;
316 f[i_coord_offset+DIM*2+YY] += fiy2;
317 f[i_coord_offset+DIM*2+ZZ] += fiz2;
321 f[i_coord_offset+DIM*3+XX] += fix3;
322 f[i_coord_offset+DIM*3+YY] += fiy3;
323 f[i_coord_offset+DIM*3+ZZ] += fiz3;
327 fshift[i_shift_offset+XX] += tx;
328 fshift[i_shift_offset+YY] += ty;
329 fshift[i_shift_offset+ZZ] += tz;
332 /* Update potential energies */
333 kernel_data->energygrp_elec[ggid] += velecsum;
335 /* Increment number of inner iterations */
336 inneriter += j_index_end - j_index_start;
338 /* Outer loop uses 31 flops */
341 /* Increment number of outer iterations */
344 /* Update outer/inner flops */
346 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*126);
349 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomW4P1_F_c
350 * Electrostatics interaction: CubicSplineTable
351 * VdW interaction: None
352 * Geometry: Water4-Particle
353 * Calculate force/pot: Force
356 nb_kernel_ElecCSTab_VdwNone_GeomW4P1_F_c
357 (t_nblist * gmx_restrict nlist,
358 rvec * gmx_restrict xx,
359 rvec * gmx_restrict ff,
360 t_forcerec * gmx_restrict fr,
361 t_mdatoms * gmx_restrict mdatoms,
362 nb_kernel_data_t * gmx_restrict kernel_data,
363 t_nrnb * gmx_restrict nrnb)
365 int i_shift_offset,i_coord_offset,j_coord_offset;
366 int j_index_start,j_index_end;
367 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
368 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
369 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
370 real *shiftvec,*fshift,*x,*f;
372 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
374 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
376 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
378 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
379 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
380 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
381 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
382 real velec,felec,velecsum,facel,crf,krf,krf2;
385 real rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
393 jindex = nlist->jindex;
395 shiftidx = nlist->shift;
397 shiftvec = fr->shift_vec[0];
398 fshift = fr->fshift[0];
400 charge = mdatoms->chargeA;
402 vftab = kernel_data->table_elec->data;
403 vftabscale = kernel_data->table_elec->scale;
405 /* Setup water-specific parameters */
406 inr = nlist->iinr[0];
407 iq1 = facel*charge[inr+1];
408 iq2 = facel*charge[inr+2];
409 iq3 = facel*charge[inr+3];
414 /* Start outer loop over neighborlists */
415 for(iidx=0; iidx<nri; iidx++)
417 /* Load shift vector for this list */
418 i_shift_offset = DIM*shiftidx[iidx];
419 shX = shiftvec[i_shift_offset+XX];
420 shY = shiftvec[i_shift_offset+YY];
421 shZ = shiftvec[i_shift_offset+ZZ];
423 /* Load limits for loop over neighbors */
424 j_index_start = jindex[iidx];
425 j_index_end = jindex[iidx+1];
427 /* Get outer coordinate index */
429 i_coord_offset = DIM*inr;
431 /* Load i particle coords and add shift vector */
432 ix1 = shX + x[i_coord_offset+DIM*1+XX];
433 iy1 = shY + x[i_coord_offset+DIM*1+YY];
434 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
435 ix2 = shX + x[i_coord_offset+DIM*2+XX];
436 iy2 = shY + x[i_coord_offset+DIM*2+YY];
437 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
438 ix3 = shX + x[i_coord_offset+DIM*3+XX];
439 iy3 = shY + x[i_coord_offset+DIM*3+YY];
440 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
452 /* Start inner kernel loop */
453 for(jidx=j_index_start; jidx<j_index_end; jidx++)
455 /* Get j neighbor index, and coordinate index */
457 j_coord_offset = DIM*jnr;
459 /* load j atom coordinates */
460 jx0 = x[j_coord_offset+DIM*0+XX];
461 jy0 = x[j_coord_offset+DIM*0+YY];
462 jz0 = x[j_coord_offset+DIM*0+ZZ];
464 /* Calculate displacement vector */
475 /* Calculate squared distance and things based on it */
476 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
477 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
478 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
480 rinv10 = gmx_invsqrt(rsq10);
481 rinv20 = gmx_invsqrt(rsq20);
482 rinv30 = gmx_invsqrt(rsq30);
484 /* Load parameters for j particles */
487 /**************************
488 * CALCULATE INTERACTIONS *
489 **************************/
495 /* Calculate table index by multiplying r with table scale and truncate to integer */
501 /* CUBIC SPLINE TABLE ELECTROSTATICS */
504 Geps = vfeps*vftab[vfitab+2];
505 Heps2 = vfeps*vfeps*vftab[vfitab+3];
507 FF = Fp+Geps+2.0*Heps2;
508 felec = -qq10*FF*vftabscale*rinv10;
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*0+XX] -= tx;
522 f[j_coord_offset+DIM*0+YY] -= ty;
523 f[j_coord_offset+DIM*0+ZZ] -= tz;
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
533 /* Calculate table index by multiplying r with table scale and truncate to integer */
539 /* CUBIC SPLINE TABLE ELECTROSTATICS */
542 Geps = vfeps*vftab[vfitab+2];
543 Heps2 = vfeps*vfeps*vftab[vfitab+3];
545 FF = Fp+Geps+2.0*Heps2;
546 felec = -qq20*FF*vftabscale*rinv20;
550 /* Calculate temporary vectorial force */
555 /* Update vectorial force */
559 f[j_coord_offset+DIM*0+XX] -= tx;
560 f[j_coord_offset+DIM*0+YY] -= ty;
561 f[j_coord_offset+DIM*0+ZZ] -= tz;
563 /**************************
564 * CALCULATE INTERACTIONS *
565 **************************/
571 /* Calculate table index by multiplying r with table scale and truncate to integer */
577 /* CUBIC SPLINE TABLE ELECTROSTATICS */
580 Geps = vfeps*vftab[vfitab+2];
581 Heps2 = vfeps*vfeps*vftab[vfitab+3];
583 FF = Fp+Geps+2.0*Heps2;
584 felec = -qq30*FF*vftabscale*rinv30;
588 /* Calculate temporary vectorial force */
593 /* Update vectorial force */
597 f[j_coord_offset+DIM*0+XX] -= tx;
598 f[j_coord_offset+DIM*0+YY] -= ty;
599 f[j_coord_offset+DIM*0+ZZ] -= tz;
601 /* Inner loop uses 114 flops */
603 /* End of innermost loop */
606 f[i_coord_offset+DIM*1+XX] += fix1;
607 f[i_coord_offset+DIM*1+YY] += fiy1;
608 f[i_coord_offset+DIM*1+ZZ] += fiz1;
612 f[i_coord_offset+DIM*2+XX] += fix2;
613 f[i_coord_offset+DIM*2+YY] += fiy2;
614 f[i_coord_offset+DIM*2+ZZ] += fiz2;
618 f[i_coord_offset+DIM*3+XX] += fix3;
619 f[i_coord_offset+DIM*3+YY] += fiy3;
620 f[i_coord_offset+DIM*3+ZZ] += fiz3;
624 fshift[i_shift_offset+XX] += tx;
625 fshift[i_shift_offset+YY] += ty;
626 fshift[i_shift_offset+ZZ] += tz;
628 /* Increment number of inner iterations */
629 inneriter += j_index_end - j_index_start;
631 /* Outer loop uses 30 flops */
634 /* Increment number of outer iterations */
637 /* Update outer/inner flops */
639 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*114);