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_VdwLJSh_GeomW3P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRFCut_VdwLJSh_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 = 2*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 = 2*vdwtype[jnr+0];
193 /**************************
194 * CALCULATE INTERACTIONS *
195 **************************/
201 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
202 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
204 /* REACTION-FIELD ELECTROSTATICS */
205 velec = qq00*(rinv00+krf*rsq00-crf);
206 felec = qq00*(rinv00*rinvsq00-krf2);
208 /* LENNARD-JONES DISPERSION/REPULSION */
210 rinvsix = rinvsq00*rinvsq00*rinvsq00;
211 vvdw6 = c6_00*rinvsix;
212 vvdw12 = c12_00*rinvsix*rinvsix;
213 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
214 fvdw = (vvdw12-vvdw6)*rinvsq00;
216 /* Update potential sums from outer loop */
222 /* Calculate temporary vectorial force */
227 /* Update vectorial force */
231 f[j_coord_offset+DIM*0+XX] -= tx;
232 f[j_coord_offset+DIM*0+YY] -= ty;
233 f[j_coord_offset+DIM*0+ZZ] -= tz;
237 /**************************
238 * CALCULATE INTERACTIONS *
239 **************************/
246 /* REACTION-FIELD ELECTROSTATICS */
247 velec = qq10*(rinv10+krf*rsq10-crf);
248 felec = qq10*(rinv10*rinvsq10-krf2);
250 /* Update potential sums from outer loop */
255 /* Calculate temporary vectorial force */
260 /* Update vectorial force */
264 f[j_coord_offset+DIM*0+XX] -= tx;
265 f[j_coord_offset+DIM*0+YY] -= ty;
266 f[j_coord_offset+DIM*0+ZZ] -= tz;
270 /**************************
271 * CALCULATE INTERACTIONS *
272 **************************/
279 /* REACTION-FIELD ELECTROSTATICS */
280 velec = qq20*(rinv20+krf*rsq20-crf);
281 felec = qq20*(rinv20*rinvsq20-krf2);
283 /* Update potential sums from outer loop */
288 /* Calculate temporary vectorial force */
293 /* Update vectorial force */
297 f[j_coord_offset+DIM*0+XX] -= tx;
298 f[j_coord_offset+DIM*0+YY] -= ty;
299 f[j_coord_offset+DIM*0+ZZ] -= tz;
303 /* Inner loop uses 113 flops */
305 /* End of innermost loop */
308 f[i_coord_offset+DIM*0+XX] += fix0;
309 f[i_coord_offset+DIM*0+YY] += fiy0;
310 f[i_coord_offset+DIM*0+ZZ] += fiz0;
314 f[i_coord_offset+DIM*1+XX] += fix1;
315 f[i_coord_offset+DIM*1+YY] += fiy1;
316 f[i_coord_offset+DIM*1+ZZ] += fiz1;
320 f[i_coord_offset+DIM*2+XX] += fix2;
321 f[i_coord_offset+DIM*2+YY] += fiy2;
322 f[i_coord_offset+DIM*2+ZZ] += fiz2;
326 fshift[i_shift_offset+XX] += tx;
327 fshift[i_shift_offset+YY] += ty;
328 fshift[i_shift_offset+ZZ] += tz;
331 /* Update potential energies */
332 kernel_data->energygrp_elec[ggid] += velecsum;
333 kernel_data->energygrp_vdw[ggid] += vvdwsum;
335 /* Increment number of inner iterations */
336 inneriter += j_index_end - j_index_start;
338 /* Outer loop uses 32 flops */
341 /* Increment number of outer iterations */
344 /* Update outer/inner flops */
346 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*113);
349 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_c
350 * Electrostatics interaction: ReactionField
351 * VdW interaction: LennardJones
352 * Geometry: Water3-Particle
353 * Calculate force/pot: Force
356 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_c
357 (t_nblist * gmx_restrict nlist,
358 rvec * gmx_restrict xx,
359 rvec * gmx_restrict ff,
360 t_forcerec * gmx_restrict fr,
361 t_mdatoms * gmx_restrict mdatoms,
362 nb_kernel_data_t * gmx_restrict kernel_data,
363 t_nrnb * gmx_restrict nrnb)
365 int i_shift_offset,i_coord_offset,j_coord_offset;
366 int j_index_start,j_index_end;
367 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
368 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
369 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
370 real *shiftvec,*fshift,*x,*f;
372 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
374 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
376 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
378 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
379 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
380 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
381 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
382 real velec,felec,velecsum,facel,crf,krf,krf2;
385 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
394 jindex = nlist->jindex;
396 shiftidx = nlist->shift;
398 shiftvec = fr->shift_vec[0];
399 fshift = fr->fshift[0];
401 charge = mdatoms->chargeA;
405 nvdwtype = fr->ntype;
407 vdwtype = mdatoms->typeA;
409 /* Setup water-specific parameters */
410 inr = nlist->iinr[0];
411 iq0 = facel*charge[inr+0];
412 iq1 = facel*charge[inr+1];
413 iq2 = facel*charge[inr+2];
414 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
416 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
417 rcutoff = fr->rcoulomb;
418 rcutoff2 = rcutoff*rcutoff;
420 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
426 /* Start outer loop over neighborlists */
427 for(iidx=0; iidx<nri; iidx++)
429 /* Load shift vector for this list */
430 i_shift_offset = DIM*shiftidx[iidx];
431 shX = shiftvec[i_shift_offset+XX];
432 shY = shiftvec[i_shift_offset+YY];
433 shZ = shiftvec[i_shift_offset+ZZ];
435 /* Load limits for loop over neighbors */
436 j_index_start = jindex[iidx];
437 j_index_end = jindex[iidx+1];
439 /* Get outer coordinate index */
441 i_coord_offset = DIM*inr;
443 /* Load i particle coords and add shift vector */
444 ix0 = shX + x[i_coord_offset+DIM*0+XX];
445 iy0 = shY + x[i_coord_offset+DIM*0+YY];
446 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
447 ix1 = shX + x[i_coord_offset+DIM*1+XX];
448 iy1 = shY + x[i_coord_offset+DIM*1+YY];
449 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
450 ix2 = shX + x[i_coord_offset+DIM*2+XX];
451 iy2 = shY + x[i_coord_offset+DIM*2+YY];
452 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
464 /* Start inner kernel loop */
465 for(jidx=j_index_start; jidx<j_index_end; jidx++)
467 /* Get j neighbor index, and coordinate index */
469 j_coord_offset = DIM*jnr;
471 /* load j atom coordinates */
472 jx0 = x[j_coord_offset+DIM*0+XX];
473 jy0 = x[j_coord_offset+DIM*0+YY];
474 jz0 = x[j_coord_offset+DIM*0+ZZ];
476 /* Calculate displacement vector */
487 /* Calculate squared distance and things based on it */
488 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
489 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
490 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
492 rinv00 = gmx_invsqrt(rsq00);
493 rinv10 = gmx_invsqrt(rsq10);
494 rinv20 = gmx_invsqrt(rsq20);
496 rinvsq00 = rinv00*rinv00;
497 rinvsq10 = rinv10*rinv10;
498 rinvsq20 = rinv20*rinv20;
500 /* Load parameters for j particles */
502 vdwjidx0 = 2*vdwtype[jnr+0];
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
512 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
513 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
515 /* REACTION-FIELD ELECTROSTATICS */
516 felec = qq00*(rinv00*rinvsq00-krf2);
518 /* LENNARD-JONES DISPERSION/REPULSION */
520 rinvsix = rinvsq00*rinvsq00*rinvsq00;
521 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
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;
540 /**************************
541 * CALCULATE INTERACTIONS *
542 **************************/
549 /* REACTION-FIELD ELECTROSTATICS */
550 felec = qq10*(rinv10*rinvsq10-krf2);
554 /* Calculate temporary vectorial force */
559 /* Update vectorial force */
563 f[j_coord_offset+DIM*0+XX] -= tx;
564 f[j_coord_offset+DIM*0+YY] -= ty;
565 f[j_coord_offset+DIM*0+ZZ] -= tz;
569 /**************************
570 * CALCULATE INTERACTIONS *
571 **************************/
578 /* REACTION-FIELD ELECTROSTATICS */
579 felec = qq20*(rinv20*rinvsq20-krf2);
583 /* Calculate temporary vectorial force */
588 /* Update vectorial force */
592 f[j_coord_offset+DIM*0+XX] -= tx;
593 f[j_coord_offset+DIM*0+YY] -= ty;
594 f[j_coord_offset+DIM*0+ZZ] -= tz;
598 /* Inner loop uses 88 flops */
600 /* End of innermost loop */
603 f[i_coord_offset+DIM*0+XX] += fix0;
604 f[i_coord_offset+DIM*0+YY] += fiy0;
605 f[i_coord_offset+DIM*0+ZZ] += fiz0;
609 f[i_coord_offset+DIM*1+XX] += fix1;
610 f[i_coord_offset+DIM*1+YY] += fiy1;
611 f[i_coord_offset+DIM*1+ZZ] += fiz1;
615 f[i_coord_offset+DIM*2+XX] += fix2;
616 f[i_coord_offset+DIM*2+YY] += fiy2;
617 f[i_coord_offset+DIM*2+ZZ] += fiz2;
621 fshift[i_shift_offset+XX] += tx;
622 fshift[i_shift_offset+YY] += ty;
623 fshift[i_shift_offset+ZZ] += tz;
625 /* Increment number of inner iterations */
626 inneriter += j_index_end - j_index_start;
628 /* Outer loop uses 30 flops */
631 /* Increment number of outer iterations */
634 /* Update outer/inner flops */
636 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*88);