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_ElecRF_VdwBham_GeomW3P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwBham_GeomW3P1_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 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
79 jindex = nlist->jindex;
81 shiftidx = nlist->shift;
83 shiftvec = fr->shift_vec[0];
84 fshift = fr->fshift[0];
86 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 /* Setup water-specific parameters */
96 iq0 = facel*charge[inr+0];
97 iq1 = facel*charge[inr+1];
98 iq2 = facel*charge[inr+2];
99 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
104 /* Start outer loop over neighborlists */
105 for(iidx=0; iidx<nri; iidx++)
107 /* Load shift vector for this list */
108 i_shift_offset = DIM*shiftidx[iidx];
109 shX = shiftvec[i_shift_offset+XX];
110 shY = shiftvec[i_shift_offset+YY];
111 shZ = shiftvec[i_shift_offset+ZZ];
113 /* Load limits for loop over neighbors */
114 j_index_start = jindex[iidx];
115 j_index_end = jindex[iidx+1];
117 /* Get outer coordinate index */
119 i_coord_offset = DIM*inr;
121 /* Load i particle coords and add shift vector */
122 ix0 = shX + x[i_coord_offset+DIM*0+XX];
123 iy0 = shY + x[i_coord_offset+DIM*0+YY];
124 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
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];
142 /* Reset potential sums */
146 /* Start inner kernel loop */
147 for(jidx=j_index_start; jidx<j_index_end; jidx++)
149 /* Get j neighbor index, and coordinate index */
151 j_coord_offset = DIM*jnr;
153 /* load j atom coordinates */
154 jx0 = x[j_coord_offset+DIM*0+XX];
155 jy0 = x[j_coord_offset+DIM*0+YY];
156 jz0 = x[j_coord_offset+DIM*0+ZZ];
158 /* Calculate displacement vector */
169 /* Calculate squared distance and things based on it */
170 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
171 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
172 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
174 rinv00 = gmx_invsqrt(rsq00);
175 rinv10 = gmx_invsqrt(rsq10);
176 rinv20 = gmx_invsqrt(rsq20);
178 rinvsq00 = rinv00*rinv00;
179 rinvsq10 = rinv10*rinv10;
180 rinvsq20 = rinv20*rinv20;
182 /* Load parameters for j particles */
184 vdwjidx0 = 3*vdwtype[jnr+0];
186 /**************************
187 * CALCULATE INTERACTIONS *
188 **************************/
193 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
194 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
195 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
197 /* REACTION-FIELD ELECTROSTATICS */
198 velec = qq00*(rinv00+krf*rsq00-crf);
199 felec = qq00*(rinv00*rinvsq00-krf2);
201 /* BUCKINGHAM DISPERSION/REPULSION */
202 rinvsix = rinvsq00*rinvsq00*rinvsq00;
203 vvdw6 = c6_00*rinvsix;
205 vvdwexp = cexp1_00*exp(-br);
206 vvdw = vvdwexp - vvdw6*(1.0/6.0);
207 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
209 /* Update potential sums from outer loop */
215 /* Calculate temporary vectorial force */
220 /* Update vectorial force */
224 f[j_coord_offset+DIM*0+XX] -= tx;
225 f[j_coord_offset+DIM*0+YY] -= ty;
226 f[j_coord_offset+DIM*0+ZZ] -= tz;
228 /**************************
229 * CALCULATE INTERACTIONS *
230 **************************/
234 /* REACTION-FIELD ELECTROSTATICS */
235 velec = qq10*(rinv10+krf*rsq10-crf);
236 felec = qq10*(rinv10*rinvsq10-krf2);
238 /* Update potential sums from outer loop */
243 /* Calculate temporary vectorial force */
248 /* Update vectorial force */
252 f[j_coord_offset+DIM*0+XX] -= tx;
253 f[j_coord_offset+DIM*0+YY] -= ty;
254 f[j_coord_offset+DIM*0+ZZ] -= tz;
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
262 /* REACTION-FIELD ELECTROSTATICS */
263 velec = qq20*(rinv20+krf*rsq20-crf);
264 felec = qq20*(rinv20*rinvsq20-krf2);
266 /* Update potential sums from outer loop */
271 /* Calculate temporary vectorial force */
276 /* Update vectorial force */
280 f[j_coord_offset+DIM*0+XX] -= tx;
281 f[j_coord_offset+DIM*0+YY] -= ty;
282 f[j_coord_offset+DIM*0+ZZ] -= tz;
284 /* Inner loop uses 135 flops */
286 /* End of innermost loop */
289 f[i_coord_offset+DIM*0+XX] += fix0;
290 f[i_coord_offset+DIM*0+YY] += fiy0;
291 f[i_coord_offset+DIM*0+ZZ] += fiz0;
295 f[i_coord_offset+DIM*1+XX] += fix1;
296 f[i_coord_offset+DIM*1+YY] += fiy1;
297 f[i_coord_offset+DIM*1+ZZ] += fiz1;
301 f[i_coord_offset+DIM*2+XX] += fix2;
302 f[i_coord_offset+DIM*2+YY] += fiy2;
303 f[i_coord_offset+DIM*2+ZZ] += fiz2;
307 fshift[i_shift_offset+XX] += tx;
308 fshift[i_shift_offset+YY] += ty;
309 fshift[i_shift_offset+ZZ] += tz;
312 /* Update potential energies */
313 kernel_data->energygrp_elec[ggid] += velecsum;
314 kernel_data->energygrp_vdw[ggid] += vvdwsum;
316 /* Increment number of inner iterations */
317 inneriter += j_index_end - j_index_start;
319 /* Outer loop uses 32 flops */
322 /* Increment number of outer iterations */
325 /* Update outer/inner flops */
327 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*135);
330 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW3P1_F_c
331 * Electrostatics interaction: ReactionField
332 * VdW interaction: Buckingham
333 * Geometry: Water3-Particle
334 * Calculate force/pot: Force
337 nb_kernel_ElecRF_VdwBham_GeomW3P1_F_c
338 (t_nblist * gmx_restrict nlist,
339 rvec * gmx_restrict xx,
340 rvec * gmx_restrict ff,
341 t_forcerec * gmx_restrict fr,
342 t_mdatoms * gmx_restrict mdatoms,
343 nb_kernel_data_t * gmx_restrict kernel_data,
344 t_nrnb * gmx_restrict nrnb)
346 int i_shift_offset,i_coord_offset,j_coord_offset;
347 int j_index_start,j_index_end;
348 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
349 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
350 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
351 real *shiftvec,*fshift,*x,*f;
353 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
355 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
357 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
359 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
360 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
361 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
362 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
363 real velec,felec,velecsum,facel,crf,krf,krf2;
366 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
375 jindex = nlist->jindex;
377 shiftidx = nlist->shift;
379 shiftvec = fr->shift_vec[0];
380 fshift = fr->fshift[0];
382 charge = mdatoms->chargeA;
386 nvdwtype = fr->ntype;
388 vdwtype = mdatoms->typeA;
390 /* Setup water-specific parameters */
391 inr = nlist->iinr[0];
392 iq0 = facel*charge[inr+0];
393 iq1 = facel*charge[inr+1];
394 iq2 = facel*charge[inr+2];
395 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
400 /* Start outer loop over neighborlists */
401 for(iidx=0; iidx<nri; iidx++)
403 /* Load shift vector for this list */
404 i_shift_offset = DIM*shiftidx[iidx];
405 shX = shiftvec[i_shift_offset+XX];
406 shY = shiftvec[i_shift_offset+YY];
407 shZ = shiftvec[i_shift_offset+ZZ];
409 /* Load limits for loop over neighbors */
410 j_index_start = jindex[iidx];
411 j_index_end = jindex[iidx+1];
413 /* Get outer coordinate index */
415 i_coord_offset = DIM*inr;
417 /* Load i particle coords and add shift vector */
418 ix0 = shX + x[i_coord_offset+DIM*0+XX];
419 iy0 = shY + x[i_coord_offset+DIM*0+YY];
420 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
421 ix1 = shX + x[i_coord_offset+DIM*1+XX];
422 iy1 = shY + x[i_coord_offset+DIM*1+YY];
423 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
424 ix2 = shX + x[i_coord_offset+DIM*2+XX];
425 iy2 = shY + x[i_coord_offset+DIM*2+YY];
426 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
438 /* Start inner kernel loop */
439 for(jidx=j_index_start; jidx<j_index_end; jidx++)
441 /* Get j neighbor index, and coordinate index */
443 j_coord_offset = DIM*jnr;
445 /* load j atom coordinates */
446 jx0 = x[j_coord_offset+DIM*0+XX];
447 jy0 = x[j_coord_offset+DIM*0+YY];
448 jz0 = x[j_coord_offset+DIM*0+ZZ];
450 /* Calculate displacement vector */
461 /* Calculate squared distance and things based on it */
462 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
463 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
464 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
466 rinv00 = gmx_invsqrt(rsq00);
467 rinv10 = gmx_invsqrt(rsq10);
468 rinv20 = gmx_invsqrt(rsq20);
470 rinvsq00 = rinv00*rinv00;
471 rinvsq10 = rinv10*rinv10;
472 rinvsq20 = rinv20*rinv20;
474 /* Load parameters for j particles */
476 vdwjidx0 = 3*vdwtype[jnr+0];
478 /**************************
479 * CALCULATE INTERACTIONS *
480 **************************/
485 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
486 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
487 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
489 /* REACTION-FIELD ELECTROSTATICS */
490 felec = qq00*(rinv00*rinvsq00-krf2);
492 /* BUCKINGHAM DISPERSION/REPULSION */
493 rinvsix = rinvsq00*rinvsq00*rinvsq00;
494 vvdw6 = c6_00*rinvsix;
496 vvdwexp = cexp1_00*exp(-br);
497 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
501 /* Calculate temporary vectorial force */
506 /* Update vectorial force */
510 f[j_coord_offset+DIM*0+XX] -= tx;
511 f[j_coord_offset+DIM*0+YY] -= ty;
512 f[j_coord_offset+DIM*0+ZZ] -= tz;
514 /**************************
515 * CALCULATE INTERACTIONS *
516 **************************/
520 /* REACTION-FIELD ELECTROSTATICS */
521 felec = qq10*(rinv10*rinvsq10-krf2);
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 **************************/
544 /* REACTION-FIELD ELECTROSTATICS */
545 felec = qq20*(rinv20*rinvsq20-krf2);
549 /* Calculate temporary vectorial force */
554 /* Update vectorial force */
558 f[j_coord_offset+DIM*0+XX] -= tx;
559 f[j_coord_offset+DIM*0+YY] -= ty;
560 f[j_coord_offset+DIM*0+ZZ] -= tz;
562 /* Inner loop uses 117 flops */
564 /* End of innermost loop */
567 f[i_coord_offset+DIM*0+XX] += fix0;
568 f[i_coord_offset+DIM*0+YY] += fiy0;
569 f[i_coord_offset+DIM*0+ZZ] += fiz0;
573 f[i_coord_offset+DIM*1+XX] += fix1;
574 f[i_coord_offset+DIM*1+YY] += fiy1;
575 f[i_coord_offset+DIM*1+ZZ] += fiz1;
579 f[i_coord_offset+DIM*2+XX] += fix2;
580 f[i_coord_offset+DIM*2+YY] += fiy2;
581 f[i_coord_offset+DIM*2+ZZ] += fiz2;
585 fshift[i_shift_offset+XX] += tx;
586 fshift[i_shift_offset+YY] += ty;
587 fshift[i_shift_offset+ZZ] += tz;
589 /* Increment number of inner iterations */
590 inneriter += j_index_end - j_index_start;
592 /* Outer loop uses 30 flops */
595 /* Increment number of outer iterations */
598 /* Update outer/inner flops */
600 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);