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_GeomW4P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: Buckingham
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_VdwBham_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 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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
66 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
67 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
68 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
69 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
70 real velec,felec,velecsum,facel,crf,krf,krf2;
73 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
82 jindex = nlist->jindex;
84 shiftidx = nlist->shift;
86 shiftvec = fr->shift_vec[0];
87 fshift = fr->fshift[0];
89 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 /* Setup water-specific parameters */
96 iq1 = facel*charge[inr+1];
97 iq2 = facel*charge[inr+2];
98 iq3 = facel*charge[inr+3];
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];
131 ix3 = shX + x[i_coord_offset+DIM*3+XX];
132 iy3 = shY + x[i_coord_offset+DIM*3+YY];
133 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
148 /* Reset potential sums */
152 /* Start inner kernel loop */
153 for(jidx=j_index_start; jidx<j_index_end; jidx++)
155 /* Get j neighbor index, and coordinate index */
157 j_coord_offset = DIM*jnr;
159 /* load j atom coordinates */
160 jx0 = x[j_coord_offset+DIM*0+XX];
161 jy0 = x[j_coord_offset+DIM*0+YY];
162 jz0 = x[j_coord_offset+DIM*0+ZZ];
164 /* Calculate displacement vector */
178 /* Calculate squared distance and things based on it */
179 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
180 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
181 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
182 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
184 rinv00 = gmx_invsqrt(rsq00);
185 rinv10 = gmx_invsqrt(rsq10);
186 rinv20 = gmx_invsqrt(rsq20);
187 rinv30 = gmx_invsqrt(rsq30);
189 rinvsq00 = rinv00*rinv00;
190 rinvsq10 = rinv10*rinv10;
191 rinvsq20 = rinv20*rinv20;
192 rinvsq30 = rinv30*rinv30;
194 /* Load parameters for j particles */
196 vdwjidx0 = 3*vdwtype[jnr+0];
198 /**************************
199 * CALCULATE INTERACTIONS *
200 **************************/
204 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
205 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
206 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
208 /* BUCKINGHAM DISPERSION/REPULSION */
209 rinvsix = rinvsq00*rinvsq00*rinvsq00;
210 vvdw6 = c6_00*rinvsix;
212 vvdwexp = cexp1_00*exp(-br);
213 vvdw = vvdwexp - vvdw6*(1.0/6.0);
214 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
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 **************************/
240 /* COULOMB ELECTROSTATICS */
242 felec = velec*rinvsq10;
244 /* Update potential sums from outer loop */
249 /* Calculate temporary vectorial force */
254 /* Update vectorial force */
258 f[j_coord_offset+DIM*0+XX] -= tx;
259 f[j_coord_offset+DIM*0+YY] -= ty;
260 f[j_coord_offset+DIM*0+ZZ] -= tz;
262 /**************************
263 * CALCULATE INTERACTIONS *
264 **************************/
268 /* COULOMB ELECTROSTATICS */
270 felec = velec*rinvsq20;
272 /* Update potential sums from outer loop */
277 /* Calculate temporary vectorial force */
282 /* Update vectorial force */
286 f[j_coord_offset+DIM*0+XX] -= tx;
287 f[j_coord_offset+DIM*0+YY] -= ty;
288 f[j_coord_offset+DIM*0+ZZ] -= tz;
290 /**************************
291 * CALCULATE INTERACTIONS *
292 **************************/
296 /* COULOMB ELECTROSTATICS */
298 felec = velec*rinvsq30;
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 145 flops */
320 /* End of innermost loop */
323 f[i_coord_offset+DIM*0+XX] += fix0;
324 f[i_coord_offset+DIM*0+YY] += fiy0;
325 f[i_coord_offset+DIM*0+ZZ] += fiz0;
329 f[i_coord_offset+DIM*1+XX] += fix1;
330 f[i_coord_offset+DIM*1+YY] += fiy1;
331 f[i_coord_offset+DIM*1+ZZ] += fiz1;
335 f[i_coord_offset+DIM*2+XX] += fix2;
336 f[i_coord_offset+DIM*2+YY] += fiy2;
337 f[i_coord_offset+DIM*2+ZZ] += fiz2;
341 f[i_coord_offset+DIM*3+XX] += fix3;
342 f[i_coord_offset+DIM*3+YY] += fiy3;
343 f[i_coord_offset+DIM*3+ZZ] += fiz3;
347 fshift[i_shift_offset+XX] += tx;
348 fshift[i_shift_offset+YY] += ty;
349 fshift[i_shift_offset+ZZ] += tz;
352 /* Update potential energies */
353 kernel_data->energygrp_elec[ggid] += velecsum;
354 kernel_data->energygrp_vdw[ggid] += vvdwsum;
356 /* Increment number of inner iterations */
357 inneriter += j_index_end - j_index_start;
359 /* Outer loop uses 41 flops */
362 /* Increment number of outer iterations */
365 /* Update outer/inner flops */
367 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*145);
370 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW4P1_F_c
371 * Electrostatics interaction: Coulomb
372 * VdW interaction: Buckingham
373 * Geometry: Water4-Particle
374 * Calculate force/pot: Force
377 nb_kernel_ElecCoul_VdwBham_GeomW4P1_F_c
378 (t_nblist * gmx_restrict nlist,
379 rvec * gmx_restrict xx,
380 rvec * gmx_restrict ff,
381 t_forcerec * gmx_restrict fr,
382 t_mdatoms * gmx_restrict mdatoms,
383 nb_kernel_data_t * gmx_restrict kernel_data,
384 t_nrnb * gmx_restrict nrnb)
386 int i_shift_offset,i_coord_offset,j_coord_offset;
387 int j_index_start,j_index_end;
388 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
389 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
390 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
391 real *shiftvec,*fshift,*x,*f;
393 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
395 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
397 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
399 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
401 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
402 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
403 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
404 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
405 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
406 real velec,felec,velecsum,facel,crf,krf,krf2;
409 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
418 jindex = nlist->jindex;
420 shiftidx = nlist->shift;
422 shiftvec = fr->shift_vec[0];
423 fshift = fr->fshift[0];
425 charge = mdatoms->chargeA;
426 nvdwtype = fr->ntype;
428 vdwtype = mdatoms->typeA;
430 /* Setup water-specific parameters */
431 inr = nlist->iinr[0];
432 iq1 = facel*charge[inr+1];
433 iq2 = facel*charge[inr+2];
434 iq3 = facel*charge[inr+3];
435 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
440 /* Start outer loop over neighborlists */
441 for(iidx=0; iidx<nri; iidx++)
443 /* Load shift vector for this list */
444 i_shift_offset = DIM*shiftidx[iidx];
445 shX = shiftvec[i_shift_offset+XX];
446 shY = shiftvec[i_shift_offset+YY];
447 shZ = shiftvec[i_shift_offset+ZZ];
449 /* Load limits for loop over neighbors */
450 j_index_start = jindex[iidx];
451 j_index_end = jindex[iidx+1];
453 /* Get outer coordinate index */
455 i_coord_offset = DIM*inr;
457 /* Load i particle coords and add shift vector */
458 ix0 = shX + x[i_coord_offset+DIM*0+XX];
459 iy0 = shY + x[i_coord_offset+DIM*0+YY];
460 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
461 ix1 = shX + x[i_coord_offset+DIM*1+XX];
462 iy1 = shY + x[i_coord_offset+DIM*1+YY];
463 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
464 ix2 = shX + x[i_coord_offset+DIM*2+XX];
465 iy2 = shY + x[i_coord_offset+DIM*2+YY];
466 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
467 ix3 = shX + x[i_coord_offset+DIM*3+XX];
468 iy3 = shY + x[i_coord_offset+DIM*3+YY];
469 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
484 /* Start inner kernel loop */
485 for(jidx=j_index_start; jidx<j_index_end; jidx++)
487 /* Get j neighbor index, and coordinate index */
489 j_coord_offset = DIM*jnr;
491 /* load j atom coordinates */
492 jx0 = x[j_coord_offset+DIM*0+XX];
493 jy0 = x[j_coord_offset+DIM*0+YY];
494 jz0 = x[j_coord_offset+DIM*0+ZZ];
496 /* Calculate displacement vector */
510 /* Calculate squared distance and things based on it */
511 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
512 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
513 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
514 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
516 rinv00 = gmx_invsqrt(rsq00);
517 rinv10 = gmx_invsqrt(rsq10);
518 rinv20 = gmx_invsqrt(rsq20);
519 rinv30 = gmx_invsqrt(rsq30);
521 rinvsq00 = rinv00*rinv00;
522 rinvsq10 = rinv10*rinv10;
523 rinvsq20 = rinv20*rinv20;
524 rinvsq30 = rinv30*rinv30;
526 /* Load parameters for j particles */
528 vdwjidx0 = 3*vdwtype[jnr+0];
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
536 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
537 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
538 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
540 /* BUCKINGHAM DISPERSION/REPULSION */
541 rinvsix = rinvsq00*rinvsq00*rinvsq00;
542 vvdw6 = c6_00*rinvsix;
544 vvdwexp = cexp1_00*exp(-br);
545 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
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 /**************************
563 * CALCULATE INTERACTIONS *
564 **************************/
568 /* COULOMB ELECTROSTATICS */
570 felec = velec*rinvsq10;
574 /* Calculate temporary vectorial force */
579 /* Update vectorial force */
583 f[j_coord_offset+DIM*0+XX] -= tx;
584 f[j_coord_offset+DIM*0+YY] -= ty;
585 f[j_coord_offset+DIM*0+ZZ] -= tz;
587 /**************************
588 * CALCULATE INTERACTIONS *
589 **************************/
593 /* COULOMB ELECTROSTATICS */
595 felec = velec*rinvsq20;
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 /**************************
613 * CALCULATE INTERACTIONS *
614 **************************/
618 /* COULOMB ELECTROSTATICS */
620 felec = velec*rinvsq30;
624 /* Calculate temporary vectorial force */
629 /* Update vectorial force */
633 f[j_coord_offset+DIM*0+XX] -= tx;
634 f[j_coord_offset+DIM*0+YY] -= ty;
635 f[j_coord_offset+DIM*0+ZZ] -= tz;
637 /* Inner loop uses 139 flops */
639 /* End of innermost loop */
642 f[i_coord_offset+DIM*0+XX] += fix0;
643 f[i_coord_offset+DIM*0+YY] += fiy0;
644 f[i_coord_offset+DIM*0+ZZ] += fiz0;
648 f[i_coord_offset+DIM*1+XX] += fix1;
649 f[i_coord_offset+DIM*1+YY] += fiy1;
650 f[i_coord_offset+DIM*1+ZZ] += fiz1;
654 f[i_coord_offset+DIM*2+XX] += fix2;
655 f[i_coord_offset+DIM*2+YY] += fiy2;
656 f[i_coord_offset+DIM*2+ZZ] += fiz2;
660 f[i_coord_offset+DIM*3+XX] += fix3;
661 f[i_coord_offset+DIM*3+YY] += fiy3;
662 f[i_coord_offset+DIM*3+ZZ] += fiz3;
666 fshift[i_shift_offset+XX] += tx;
667 fshift[i_shift_offset+YY] += ty;
668 fshift[i_shift_offset+ZZ] += tz;
670 /* Increment number of inner iterations */
671 inneriter += j_index_end - j_index_start;
673 /* Outer loop uses 39 flops */
676 /* Increment number of outer iterations */
679 /* Update outer/inner flops */
681 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*139);