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_VdwLJ_GeomW4P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_VdwLJ_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 = 2*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 rinv10 = gmx_invsqrt(rsq10);
185 rinv20 = gmx_invsqrt(rsq20);
186 rinv30 = gmx_invsqrt(rsq30);
188 rinvsq00 = 1.0/rsq00;
189 rinvsq10 = rinv10*rinv10;
190 rinvsq20 = rinv20*rinv20;
191 rinvsq30 = rinv30*rinv30;
193 /* Load parameters for j particles */
195 vdwjidx0 = 2*vdwtype[jnr+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
201 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
202 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
204 /* LENNARD-JONES DISPERSION/REPULSION */
206 rinvsix = rinvsq00*rinvsq00*rinvsq00;
207 vvdw6 = c6_00*rinvsix;
208 vvdw12 = c12_00*rinvsix*rinvsix;
209 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
210 fvdw = (vvdw12-vvdw6)*rinvsq00;
212 /* Update potential sums from outer loop */
217 /* Calculate temporary vectorial force */
222 /* Update vectorial force */
226 f[j_coord_offset+DIM*0+XX] -= tx;
227 f[j_coord_offset+DIM*0+YY] -= ty;
228 f[j_coord_offset+DIM*0+ZZ] -= tz;
230 /**************************
231 * CALCULATE INTERACTIONS *
232 **************************/
236 /* COULOMB ELECTROSTATICS */
238 felec = velec*rinvsq10;
240 /* Update potential sums from outer loop */
245 /* Calculate temporary vectorial force */
250 /* Update vectorial force */
254 f[j_coord_offset+DIM*0+XX] -= tx;
255 f[j_coord_offset+DIM*0+YY] -= ty;
256 f[j_coord_offset+DIM*0+ZZ] -= tz;
258 /**************************
259 * CALCULATE INTERACTIONS *
260 **************************/
264 /* COULOMB ELECTROSTATICS */
266 felec = velec*rinvsq20;
268 /* Update potential sums from outer loop */
273 /* Calculate temporary vectorial force */
278 /* Update vectorial force */
282 f[j_coord_offset+DIM*0+XX] -= tx;
283 f[j_coord_offset+DIM*0+YY] -= ty;
284 f[j_coord_offset+DIM*0+ZZ] -= tz;
286 /**************************
287 * CALCULATE INTERACTIONS *
288 **************************/
292 /* COULOMB ELECTROSTATICS */
294 felec = velec*rinvsq30;
296 /* Update potential sums from outer loop */
301 /* Calculate temporary vectorial force */
306 /* Update vectorial force */
310 f[j_coord_offset+DIM*0+XX] -= tx;
311 f[j_coord_offset+DIM*0+YY] -= ty;
312 f[j_coord_offset+DIM*0+ZZ] -= tz;
314 /* Inner loop uses 116 flops */
316 /* End of innermost loop */
319 f[i_coord_offset+DIM*0+XX] += fix0;
320 f[i_coord_offset+DIM*0+YY] += fiy0;
321 f[i_coord_offset+DIM*0+ZZ] += fiz0;
325 f[i_coord_offset+DIM*1+XX] += fix1;
326 f[i_coord_offset+DIM*1+YY] += fiy1;
327 f[i_coord_offset+DIM*1+ZZ] += fiz1;
331 f[i_coord_offset+DIM*2+XX] += fix2;
332 f[i_coord_offset+DIM*2+YY] += fiy2;
333 f[i_coord_offset+DIM*2+ZZ] += fiz2;
337 f[i_coord_offset+DIM*3+XX] += fix3;
338 f[i_coord_offset+DIM*3+YY] += fiy3;
339 f[i_coord_offset+DIM*3+ZZ] += fiz3;
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;
350 kernel_data->energygrp_vdw[ggid] += vvdwsum;
352 /* Increment number of inner iterations */
353 inneriter += j_index_end - j_index_start;
355 /* Outer loop uses 41 flops */
358 /* Increment number of outer iterations */
361 /* Update outer/inner flops */
363 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*116);
366 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_c
367 * Electrostatics interaction: Coulomb
368 * VdW interaction: LennardJones
369 * Geometry: Water4-Particle
370 * Calculate force/pot: Force
373 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_c
374 (t_nblist * gmx_restrict nlist,
375 rvec * gmx_restrict xx,
376 rvec * gmx_restrict ff,
377 t_forcerec * gmx_restrict fr,
378 t_mdatoms * gmx_restrict mdatoms,
379 nb_kernel_data_t * gmx_restrict kernel_data,
380 t_nrnb * gmx_restrict nrnb)
382 int i_shift_offset,i_coord_offset,j_coord_offset;
383 int j_index_start,j_index_end;
384 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
385 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
386 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
387 real *shiftvec,*fshift,*x,*f;
389 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
391 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
393 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
395 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
397 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
398 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
399 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
400 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
401 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
402 real velec,felec,velecsum,facel,crf,krf,krf2;
405 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
414 jindex = nlist->jindex;
416 shiftidx = nlist->shift;
418 shiftvec = fr->shift_vec[0];
419 fshift = fr->fshift[0];
421 charge = mdatoms->chargeA;
422 nvdwtype = fr->ntype;
424 vdwtype = mdatoms->typeA;
426 /* Setup water-specific parameters */
427 inr = nlist->iinr[0];
428 iq1 = facel*charge[inr+1];
429 iq2 = facel*charge[inr+2];
430 iq3 = facel*charge[inr+3];
431 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
436 /* Start outer loop over neighborlists */
437 for(iidx=0; iidx<nri; iidx++)
439 /* Load shift vector for this list */
440 i_shift_offset = DIM*shiftidx[iidx];
441 shX = shiftvec[i_shift_offset+XX];
442 shY = shiftvec[i_shift_offset+YY];
443 shZ = shiftvec[i_shift_offset+ZZ];
445 /* Load limits for loop over neighbors */
446 j_index_start = jindex[iidx];
447 j_index_end = jindex[iidx+1];
449 /* Get outer coordinate index */
451 i_coord_offset = DIM*inr;
453 /* Load i particle coords and add shift vector */
454 ix0 = shX + x[i_coord_offset+DIM*0+XX];
455 iy0 = shY + x[i_coord_offset+DIM*0+YY];
456 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
457 ix1 = shX + x[i_coord_offset+DIM*1+XX];
458 iy1 = shY + x[i_coord_offset+DIM*1+YY];
459 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
460 ix2 = shX + x[i_coord_offset+DIM*2+XX];
461 iy2 = shY + x[i_coord_offset+DIM*2+YY];
462 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
463 ix3 = shX + x[i_coord_offset+DIM*3+XX];
464 iy3 = shY + x[i_coord_offset+DIM*3+YY];
465 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
480 /* Start inner kernel loop */
481 for(jidx=j_index_start; jidx<j_index_end; jidx++)
483 /* Get j neighbor index, and coordinate index */
485 j_coord_offset = DIM*jnr;
487 /* load j atom coordinates */
488 jx0 = x[j_coord_offset+DIM*0+XX];
489 jy0 = x[j_coord_offset+DIM*0+YY];
490 jz0 = x[j_coord_offset+DIM*0+ZZ];
492 /* Calculate displacement vector */
506 /* Calculate squared distance and things based on it */
507 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
508 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
509 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
510 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
512 rinv10 = gmx_invsqrt(rsq10);
513 rinv20 = gmx_invsqrt(rsq20);
514 rinv30 = gmx_invsqrt(rsq30);
516 rinvsq00 = 1.0/rsq00;
517 rinvsq10 = rinv10*rinv10;
518 rinvsq20 = rinv20*rinv20;
519 rinvsq30 = rinv30*rinv30;
521 /* Load parameters for j particles */
523 vdwjidx0 = 2*vdwtype[jnr+0];
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
529 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
530 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
532 /* LENNARD-JONES DISPERSION/REPULSION */
534 rinvsix = rinvsq00*rinvsq00*rinvsq00;
535 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
539 /* Calculate temporary vectorial force */
544 /* Update vectorial force */
548 f[j_coord_offset+DIM*0+XX] -= tx;
549 f[j_coord_offset+DIM*0+YY] -= ty;
550 f[j_coord_offset+DIM*0+ZZ] -= tz;
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
558 /* COULOMB ELECTROSTATICS */
560 felec = velec*rinvsq10;
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 **************************/
583 /* COULOMB ELECTROSTATICS */
585 felec = velec*rinvsq20;
589 /* Calculate temporary vectorial force */
594 /* Update vectorial force */
598 f[j_coord_offset+DIM*0+XX] -= tx;
599 f[j_coord_offset+DIM*0+YY] -= ty;
600 f[j_coord_offset+DIM*0+ZZ] -= tz;
602 /**************************
603 * CALCULATE INTERACTIONS *
604 **************************/
608 /* COULOMB ELECTROSTATICS */
610 felec = velec*rinvsq30;
614 /* Calculate temporary vectorial force */
619 /* Update vectorial force */
623 f[j_coord_offset+DIM*0+XX] -= tx;
624 f[j_coord_offset+DIM*0+YY] -= ty;
625 f[j_coord_offset+DIM*0+ZZ] -= tz;
627 /* Inner loop uses 108 flops */
629 /* End of innermost loop */
632 f[i_coord_offset+DIM*0+XX] += fix0;
633 f[i_coord_offset+DIM*0+YY] += fiy0;
634 f[i_coord_offset+DIM*0+ZZ] += fiz0;
638 f[i_coord_offset+DIM*1+XX] += fix1;
639 f[i_coord_offset+DIM*1+YY] += fiy1;
640 f[i_coord_offset+DIM*1+ZZ] += fiz1;
644 f[i_coord_offset+DIM*2+XX] += fix2;
645 f[i_coord_offset+DIM*2+YY] += fiy2;
646 f[i_coord_offset+DIM*2+ZZ] += fiz2;
650 f[i_coord_offset+DIM*3+XX] += fix3;
651 f[i_coord_offset+DIM*3+YY] += fiy3;
652 f[i_coord_offset+DIM*3+ZZ] += fiz3;
656 fshift[i_shift_offset+XX] += tx;
657 fshift[i_shift_offset+YY] += ty;
658 fshift[i_shift_offset+ZZ] += tz;
660 /* Increment number of inner iterations */
661 inneriter += j_index_end - j_index_start;
663 /* Outer loop uses 39 flops */
666 /* Increment number of outer iterations */
669 /* Update outer/inner flops */
671 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);