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_ElecCoul_VdwBham_GeomW3P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_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;
89 vdwtype = mdatoms->typeA;
91 /* Setup water-specific parameters */
93 iq0 = facel*charge[inr+0];
94 iq1 = facel*charge[inr+1];
95 iq2 = facel*charge[inr+2];
96 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
101 /* Start outer loop over neighborlists */
102 for(iidx=0; iidx<nri; iidx++)
104 /* Load shift vector for this list */
105 i_shift_offset = DIM*shiftidx[iidx];
106 shX = shiftvec[i_shift_offset+XX];
107 shY = shiftvec[i_shift_offset+YY];
108 shZ = shiftvec[i_shift_offset+ZZ];
110 /* Load limits for loop over neighbors */
111 j_index_start = jindex[iidx];
112 j_index_end = jindex[iidx+1];
114 /* Get outer coordinate index */
116 i_coord_offset = DIM*inr;
118 /* Load i particle coords and add shift vector */
119 ix0 = shX + x[i_coord_offset+DIM*0+XX];
120 iy0 = shY + x[i_coord_offset+DIM*0+YY];
121 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
122 ix1 = shX + x[i_coord_offset+DIM*1+XX];
123 iy1 = shY + x[i_coord_offset+DIM*1+YY];
124 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
125 ix2 = shX + x[i_coord_offset+DIM*2+XX];
126 iy2 = shY + x[i_coord_offset+DIM*2+YY];
127 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
139 /* Reset potential sums */
143 /* Start inner kernel loop */
144 for(jidx=j_index_start; jidx<j_index_end; jidx++)
146 /* Get j neighbor index, and coordinate index */
148 j_coord_offset = DIM*jnr;
150 /* load j atom coordinates */
151 jx0 = x[j_coord_offset+DIM*0+XX];
152 jy0 = x[j_coord_offset+DIM*0+YY];
153 jz0 = x[j_coord_offset+DIM*0+ZZ];
155 /* Calculate displacement vector */
166 /* Calculate squared distance and things based on it */
167 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
168 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
169 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
171 rinv00 = gmx_invsqrt(rsq00);
172 rinv10 = gmx_invsqrt(rsq10);
173 rinv20 = gmx_invsqrt(rsq20);
175 rinvsq00 = rinv00*rinv00;
176 rinvsq10 = rinv10*rinv10;
177 rinvsq20 = rinv20*rinv20;
179 /* Load parameters for j particles */
181 vdwjidx0 = 3*vdwtype[jnr+0];
183 /**************************
184 * CALCULATE INTERACTIONS *
185 **************************/
190 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
191 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
192 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
194 /* COULOMB ELECTROSTATICS */
196 felec = velec*rinvsq00;
198 /* BUCKINGHAM DISPERSION/REPULSION */
199 rinvsix = rinvsq00*rinvsq00*rinvsq00;
200 vvdw6 = c6_00*rinvsix;
202 vvdwexp = cexp1_00*exp(-br);
203 vvdw = vvdwexp - vvdw6*(1.0/6.0);
204 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
206 /* Update potential sums from outer loop */
212 /* Calculate temporary vectorial force */
217 /* Update vectorial force */
221 f[j_coord_offset+DIM*0+XX] -= tx;
222 f[j_coord_offset+DIM*0+YY] -= ty;
223 f[j_coord_offset+DIM*0+ZZ] -= tz;
225 /**************************
226 * CALCULATE INTERACTIONS *
227 **************************/
231 /* COULOMB ELECTROSTATICS */
233 felec = velec*rinvsq10;
235 /* Update potential sums from outer loop */
240 /* Calculate temporary vectorial force */
245 /* Update vectorial force */
249 f[j_coord_offset+DIM*0+XX] -= tx;
250 f[j_coord_offset+DIM*0+YY] -= ty;
251 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
259 /* COULOMB ELECTROSTATICS */
261 felec = velec*rinvsq20;
263 /* Update potential sums from outer loop */
268 /* Calculate temporary vectorial force */
273 /* Update vectorial force */
277 f[j_coord_offset+DIM*0+XX] -= tx;
278 f[j_coord_offset+DIM*0+YY] -= ty;
279 f[j_coord_offset+DIM*0+ZZ] -= tz;
281 /* Inner loop uses 123 flops */
283 /* End of innermost loop */
286 f[i_coord_offset+DIM*0+XX] += fix0;
287 f[i_coord_offset+DIM*0+YY] += fiy0;
288 f[i_coord_offset+DIM*0+ZZ] += fiz0;
292 f[i_coord_offset+DIM*1+XX] += fix1;
293 f[i_coord_offset+DIM*1+YY] += fiy1;
294 f[i_coord_offset+DIM*1+ZZ] += fiz1;
298 f[i_coord_offset+DIM*2+XX] += fix2;
299 f[i_coord_offset+DIM*2+YY] += fiy2;
300 f[i_coord_offset+DIM*2+ZZ] += fiz2;
304 fshift[i_shift_offset+XX] += tx;
305 fshift[i_shift_offset+YY] += ty;
306 fshift[i_shift_offset+ZZ] += tz;
309 /* Update potential energies */
310 kernel_data->energygrp_elec[ggid] += velecsum;
311 kernel_data->energygrp_vdw[ggid] += vvdwsum;
313 /* Increment number of inner iterations */
314 inneriter += j_index_end - j_index_start;
316 /* Outer loop uses 32 flops */
319 /* Increment number of outer iterations */
322 /* Update outer/inner flops */
324 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*123);
327 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW3P1_F_c
328 * Electrostatics interaction: Coulomb
329 * VdW interaction: Buckingham
330 * Geometry: Water3-Particle
331 * Calculate force/pot: Force
334 nb_kernel_ElecCoul_VdwBham_GeomW3P1_F_c
335 (t_nblist * gmx_restrict nlist,
336 rvec * gmx_restrict xx,
337 rvec * gmx_restrict ff,
338 t_forcerec * gmx_restrict fr,
339 t_mdatoms * gmx_restrict mdatoms,
340 nb_kernel_data_t * gmx_restrict kernel_data,
341 t_nrnb * gmx_restrict nrnb)
343 int i_shift_offset,i_coord_offset,j_coord_offset;
344 int j_index_start,j_index_end;
345 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
346 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
347 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
348 real *shiftvec,*fshift,*x,*f;
350 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
352 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
354 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
356 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
357 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
358 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
359 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
360 real velec,felec,velecsum,facel,crf,krf,krf2;
363 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
372 jindex = nlist->jindex;
374 shiftidx = nlist->shift;
376 shiftvec = fr->shift_vec[0];
377 fshift = fr->fshift[0];
379 charge = mdatoms->chargeA;
380 nvdwtype = fr->ntype;
382 vdwtype = mdatoms->typeA;
384 /* Setup water-specific parameters */
385 inr = nlist->iinr[0];
386 iq0 = facel*charge[inr+0];
387 iq1 = facel*charge[inr+1];
388 iq2 = facel*charge[inr+2];
389 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
394 /* Start outer loop over neighborlists */
395 for(iidx=0; iidx<nri; iidx++)
397 /* Load shift vector for this list */
398 i_shift_offset = DIM*shiftidx[iidx];
399 shX = shiftvec[i_shift_offset+XX];
400 shY = shiftvec[i_shift_offset+YY];
401 shZ = shiftvec[i_shift_offset+ZZ];
403 /* Load limits for loop over neighbors */
404 j_index_start = jindex[iidx];
405 j_index_end = jindex[iidx+1];
407 /* Get outer coordinate index */
409 i_coord_offset = DIM*inr;
411 /* Load i particle coords and add shift vector */
412 ix0 = shX + x[i_coord_offset+DIM*0+XX];
413 iy0 = shY + x[i_coord_offset+DIM*0+YY];
414 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
415 ix1 = shX + x[i_coord_offset+DIM*1+XX];
416 iy1 = shY + x[i_coord_offset+DIM*1+YY];
417 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
418 ix2 = shX + x[i_coord_offset+DIM*2+XX];
419 iy2 = shY + x[i_coord_offset+DIM*2+YY];
420 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
432 /* Start inner kernel loop */
433 for(jidx=j_index_start; jidx<j_index_end; jidx++)
435 /* Get j neighbor index, and coordinate index */
437 j_coord_offset = DIM*jnr;
439 /* load j atom coordinates */
440 jx0 = x[j_coord_offset+DIM*0+XX];
441 jy0 = x[j_coord_offset+DIM*0+YY];
442 jz0 = x[j_coord_offset+DIM*0+ZZ];
444 /* Calculate displacement vector */
455 /* Calculate squared distance and things based on it */
456 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
457 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
458 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
460 rinv00 = gmx_invsqrt(rsq00);
461 rinv10 = gmx_invsqrt(rsq10);
462 rinv20 = gmx_invsqrt(rsq20);
464 rinvsq00 = rinv00*rinv00;
465 rinvsq10 = rinv10*rinv10;
466 rinvsq20 = rinv20*rinv20;
468 /* Load parameters for j particles */
470 vdwjidx0 = 3*vdwtype[jnr+0];
472 /**************************
473 * CALCULATE INTERACTIONS *
474 **************************/
479 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
480 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
481 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
483 /* COULOMB ELECTROSTATICS */
485 felec = velec*rinvsq00;
487 /* BUCKINGHAM DISPERSION/REPULSION */
488 rinvsix = rinvsq00*rinvsq00*rinvsq00;
489 vvdw6 = c6_00*rinvsix;
491 vvdwexp = cexp1_00*exp(-br);
492 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
496 /* Calculate temporary vectorial force */
501 /* Update vectorial force */
505 f[j_coord_offset+DIM*0+XX] -= tx;
506 f[j_coord_offset+DIM*0+YY] -= ty;
507 f[j_coord_offset+DIM*0+ZZ] -= tz;
509 /**************************
510 * CALCULATE INTERACTIONS *
511 **************************/
515 /* COULOMB ELECTROSTATICS */
517 felec = velec*rinvsq10;
521 /* Calculate temporary vectorial force */
526 /* Update vectorial force */
530 f[j_coord_offset+DIM*0+XX] -= tx;
531 f[j_coord_offset+DIM*0+YY] -= ty;
532 f[j_coord_offset+DIM*0+ZZ] -= tz;
534 /**************************
535 * CALCULATE INTERACTIONS *
536 **************************/
540 /* COULOMB ELECTROSTATICS */
542 felec = velec*rinvsq20;
546 /* Calculate temporary vectorial force */
551 /* Update vectorial force */
555 f[j_coord_offset+DIM*0+XX] -= tx;
556 f[j_coord_offset+DIM*0+YY] -= ty;
557 f[j_coord_offset+DIM*0+ZZ] -= tz;
559 /* Inner loop uses 117 flops */
561 /* End of innermost loop */
564 f[i_coord_offset+DIM*0+XX] += fix0;
565 f[i_coord_offset+DIM*0+YY] += fiy0;
566 f[i_coord_offset+DIM*0+ZZ] += fiz0;
570 f[i_coord_offset+DIM*1+XX] += fix1;
571 f[i_coord_offset+DIM*1+YY] += fiy1;
572 f[i_coord_offset+DIM*1+ZZ] += fiz1;
576 f[i_coord_offset+DIM*2+XX] += fix2;
577 f[i_coord_offset+DIM*2+YY] += fiy2;
578 f[i_coord_offset+DIM*2+ZZ] += fiz2;
582 fshift[i_shift_offset+XX] += tx;
583 fshift[i_shift_offset+YY] += ty;
584 fshift[i_shift_offset+ZZ] += tz;
586 /* Increment number of inner iterations */
587 inneriter += j_index_end - j_index_start;
589 /* Outer loop uses 30 flops */
592 /* Increment number of outer iterations */
595 /* Update outer/inner flops */
597 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);