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_ElecRFCut_VdwBhamSh_GeomW3P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: Buckingham
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwBhamSh_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];
101 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
102 rcutoff = fr->rcoulomb;
103 rcutoff2 = rcutoff*rcutoff;
105 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
111 /* Start outer loop over neighborlists */
112 for(iidx=0; iidx<nri; iidx++)
114 /* Load shift vector for this list */
115 i_shift_offset = DIM*shiftidx[iidx];
116 shX = shiftvec[i_shift_offset+XX];
117 shY = shiftvec[i_shift_offset+YY];
118 shZ = shiftvec[i_shift_offset+ZZ];
120 /* Load limits for loop over neighbors */
121 j_index_start = jindex[iidx];
122 j_index_end = jindex[iidx+1];
124 /* Get outer coordinate index */
126 i_coord_offset = DIM*inr;
128 /* Load i particle coords and add shift vector */
129 ix0 = shX + x[i_coord_offset+DIM*0+XX];
130 iy0 = shY + x[i_coord_offset+DIM*0+YY];
131 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
132 ix1 = shX + x[i_coord_offset+DIM*1+XX];
133 iy1 = shY + x[i_coord_offset+DIM*1+YY];
134 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
135 ix2 = shX + x[i_coord_offset+DIM*2+XX];
136 iy2 = shY + x[i_coord_offset+DIM*2+YY];
137 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
149 /* Reset potential sums */
153 /* Start inner kernel loop */
154 for(jidx=j_index_start; jidx<j_index_end; jidx++)
156 /* Get j neighbor index, and coordinate index */
158 j_coord_offset = DIM*jnr;
160 /* load j atom coordinates */
161 jx0 = x[j_coord_offset+DIM*0+XX];
162 jy0 = x[j_coord_offset+DIM*0+YY];
163 jz0 = x[j_coord_offset+DIM*0+ZZ];
165 /* Calculate displacement vector */
176 /* Calculate squared distance and things based on it */
177 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
178 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
179 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
181 rinv00 = gmx_invsqrt(rsq00);
182 rinv10 = gmx_invsqrt(rsq10);
183 rinv20 = gmx_invsqrt(rsq20);
185 rinvsq00 = rinv00*rinv00;
186 rinvsq10 = rinv10*rinv10;
187 rinvsq20 = rinv20*rinv20;
189 /* Load parameters for j particles */
191 vdwjidx0 = 3*vdwtype[jnr+0];
193 /**************************
194 * CALCULATE INTERACTIONS *
195 **************************/
203 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
204 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
205 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
207 /* REACTION-FIELD ELECTROSTATICS */
208 velec = qq00*(rinv00+krf*rsq00-crf);
209 felec = qq00*(rinv00*rinvsq00-krf2);
211 /* BUCKINGHAM DISPERSION/REPULSION */
212 rinvsix = rinvsq00*rinvsq00*rinvsq00;
213 vvdw6 = c6_00*rinvsix;
215 vvdwexp = cexp1_00*exp(-br);
216 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
217 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
219 /* Update potential sums from outer loop */
225 /* Calculate temporary vectorial force */
230 /* Update vectorial force */
234 f[j_coord_offset+DIM*0+XX] -= tx;
235 f[j_coord_offset+DIM*0+YY] -= ty;
236 f[j_coord_offset+DIM*0+ZZ] -= tz;
240 /**************************
241 * CALCULATE INTERACTIONS *
242 **************************/
249 /* REACTION-FIELD ELECTROSTATICS */
250 velec = qq10*(rinv10+krf*rsq10-crf);
251 felec = qq10*(rinv10*rinvsq10-krf2);
253 /* Update potential sums from outer loop */
258 /* Calculate temporary vectorial force */
263 /* Update vectorial force */
267 f[j_coord_offset+DIM*0+XX] -= tx;
268 f[j_coord_offset+DIM*0+YY] -= ty;
269 f[j_coord_offset+DIM*0+ZZ] -= tz;
273 /**************************
274 * CALCULATE INTERACTIONS *
275 **************************/
282 /* REACTION-FIELD ELECTROSTATICS */
283 velec = qq20*(rinv20+krf*rsq20-crf);
284 felec = qq20*(rinv20*rinvsq20-krf2);
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;
306 /* Inner loop uses 166 flops */
308 /* End of innermost loop */
311 f[i_coord_offset+DIM*0+XX] += fix0;
312 f[i_coord_offset+DIM*0+YY] += fiy0;
313 f[i_coord_offset+DIM*0+ZZ] += fiz0;
317 f[i_coord_offset+DIM*1+XX] += fix1;
318 f[i_coord_offset+DIM*1+YY] += fiy1;
319 f[i_coord_offset+DIM*1+ZZ] += fiz1;
323 f[i_coord_offset+DIM*2+XX] += fix2;
324 f[i_coord_offset+DIM*2+YY] += fiy2;
325 f[i_coord_offset+DIM*2+ZZ] += fiz2;
329 fshift[i_shift_offset+XX] += tx;
330 fshift[i_shift_offset+YY] += ty;
331 fshift[i_shift_offset+ZZ] += tz;
334 /* Update potential energies */
335 kernel_data->energygrp_elec[ggid] += velecsum;
336 kernel_data->energygrp_vdw[ggid] += vvdwsum;
338 /* Increment number of inner iterations */
339 inneriter += j_index_end - j_index_start;
341 /* Outer loop uses 32 flops */
344 /* Increment number of outer iterations */
347 /* Update outer/inner flops */
349 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*166);
352 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
353 * Electrostatics interaction: ReactionField
354 * VdW interaction: Buckingham
355 * Geometry: Water3-Particle
356 * Calculate force/pot: Force
359 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
360 (t_nblist * gmx_restrict nlist,
361 rvec * gmx_restrict xx,
362 rvec * gmx_restrict ff,
363 t_forcerec * gmx_restrict fr,
364 t_mdatoms * gmx_restrict mdatoms,
365 nb_kernel_data_t * gmx_restrict kernel_data,
366 t_nrnb * gmx_restrict nrnb)
368 int i_shift_offset,i_coord_offset,j_coord_offset;
369 int j_index_start,j_index_end;
370 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
371 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
372 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
373 real *shiftvec,*fshift,*x,*f;
375 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
377 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
379 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
381 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
382 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
383 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
384 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
385 real velec,felec,velecsum,facel,crf,krf,krf2;
388 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
397 jindex = nlist->jindex;
399 shiftidx = nlist->shift;
401 shiftvec = fr->shift_vec[0];
402 fshift = fr->fshift[0];
404 charge = mdatoms->chargeA;
408 nvdwtype = fr->ntype;
410 vdwtype = mdatoms->typeA;
412 /* Setup water-specific parameters */
413 inr = nlist->iinr[0];
414 iq0 = facel*charge[inr+0];
415 iq1 = facel*charge[inr+1];
416 iq2 = facel*charge[inr+2];
417 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
419 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
420 rcutoff = fr->rcoulomb;
421 rcutoff2 = rcutoff*rcutoff;
423 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
429 /* Start outer loop over neighborlists */
430 for(iidx=0; iidx<nri; iidx++)
432 /* Load shift vector for this list */
433 i_shift_offset = DIM*shiftidx[iidx];
434 shX = shiftvec[i_shift_offset+XX];
435 shY = shiftvec[i_shift_offset+YY];
436 shZ = shiftvec[i_shift_offset+ZZ];
438 /* Load limits for loop over neighbors */
439 j_index_start = jindex[iidx];
440 j_index_end = jindex[iidx+1];
442 /* Get outer coordinate index */
444 i_coord_offset = DIM*inr;
446 /* Load i particle coords and add shift vector */
447 ix0 = shX + x[i_coord_offset+DIM*0+XX];
448 iy0 = shY + x[i_coord_offset+DIM*0+YY];
449 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
450 ix1 = shX + x[i_coord_offset+DIM*1+XX];
451 iy1 = shY + x[i_coord_offset+DIM*1+YY];
452 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
453 ix2 = shX + x[i_coord_offset+DIM*2+XX];
454 iy2 = shY + x[i_coord_offset+DIM*2+YY];
455 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
467 /* Start inner kernel loop */
468 for(jidx=j_index_start; jidx<j_index_end; jidx++)
470 /* Get j neighbor index, and coordinate index */
472 j_coord_offset = DIM*jnr;
474 /* load j atom coordinates */
475 jx0 = x[j_coord_offset+DIM*0+XX];
476 jy0 = x[j_coord_offset+DIM*0+YY];
477 jz0 = x[j_coord_offset+DIM*0+ZZ];
479 /* Calculate displacement vector */
490 /* Calculate squared distance and things based on it */
491 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
492 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
493 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
495 rinv00 = gmx_invsqrt(rsq00);
496 rinv10 = gmx_invsqrt(rsq10);
497 rinv20 = gmx_invsqrt(rsq20);
499 rinvsq00 = rinv00*rinv00;
500 rinvsq10 = rinv10*rinv10;
501 rinvsq20 = rinv20*rinv20;
503 /* Load parameters for j particles */
505 vdwjidx0 = 3*vdwtype[jnr+0];
507 /**************************
508 * CALCULATE INTERACTIONS *
509 **************************/
517 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
518 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
519 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
521 /* REACTION-FIELD ELECTROSTATICS */
522 felec = qq00*(rinv00*rinvsq00-krf2);
524 /* BUCKINGHAM DISPERSION/REPULSION */
525 rinvsix = rinvsq00*rinvsq00*rinvsq00;
526 vvdw6 = c6_00*rinvsix;
528 vvdwexp = cexp1_00*exp(-br);
529 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
533 /* Calculate temporary vectorial force */
538 /* Update vectorial force */
542 f[j_coord_offset+DIM*0+XX] -= tx;
543 f[j_coord_offset+DIM*0+YY] -= ty;
544 f[j_coord_offset+DIM*0+ZZ] -= tz;
548 /**************************
549 * CALCULATE INTERACTIONS *
550 **************************/
557 /* REACTION-FIELD ELECTROSTATICS */
558 felec = qq10*(rinv10*rinvsq10-krf2);
562 /* Calculate temporary vectorial force */
567 /* Update vectorial force */
571 f[j_coord_offset+DIM*0+XX] -= tx;
572 f[j_coord_offset+DIM*0+YY] -= ty;
573 f[j_coord_offset+DIM*0+ZZ] -= tz;
577 /**************************
578 * CALCULATE INTERACTIONS *
579 **************************/
586 /* REACTION-FIELD ELECTROSTATICS */
587 felec = qq20*(rinv20*rinvsq20-krf2);
591 /* Calculate temporary vectorial force */
596 /* Update vectorial force */
600 f[j_coord_offset+DIM*0+XX] -= tx;
601 f[j_coord_offset+DIM*0+YY] -= ty;
602 f[j_coord_offset+DIM*0+ZZ] -= tz;
606 /* Inner loop uses 117 flops */
608 /* End of innermost loop */
611 f[i_coord_offset+DIM*0+XX] += fix0;
612 f[i_coord_offset+DIM*0+YY] += fiy0;
613 f[i_coord_offset+DIM*0+ZZ] += fiz0;
617 f[i_coord_offset+DIM*1+XX] += fix1;
618 f[i_coord_offset+DIM*1+YY] += fiy1;
619 f[i_coord_offset+DIM*1+ZZ] += fiz1;
623 f[i_coord_offset+DIM*2+XX] += fix2;
624 f[i_coord_offset+DIM*2+YY] += fiy2;
625 f[i_coord_offset+DIM*2+ZZ] += fiz2;
629 fshift[i_shift_offset+XX] += tx;
630 fshift[i_shift_offset+YY] += ty;
631 fshift[i_shift_offset+ZZ] += tz;
633 /* Increment number of inner iterations */
634 inneriter += j_index_end - j_index_start;
636 /* Outer loop uses 30 flops */
639 /* Increment number of outer iterations */
642 /* Update outer/inner flops */
644 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);