2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW3P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRF_VdwBham_GeomW3P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
84 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
93 jindex = nlist->jindex;
95 shiftidx = nlist->shift;
97 shiftvec = fr->shift_vec[0];
98 fshift = fr->fshift[0];
100 charge = mdatoms->chargeA;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq0 = facel*charge[inr+0];
111 iq1 = facel*charge[inr+1];
112 iq2 = facel*charge[inr+2];
113 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
118 /* Start outer loop over neighborlists */
119 for(iidx=0; iidx<nri; iidx++)
121 /* Load shift vector for this list */
122 i_shift_offset = DIM*shiftidx[iidx];
123 shX = shiftvec[i_shift_offset+XX];
124 shY = shiftvec[i_shift_offset+YY];
125 shZ = shiftvec[i_shift_offset+ZZ];
127 /* Load limits for loop over neighbors */
128 j_index_start = jindex[iidx];
129 j_index_end = jindex[iidx+1];
131 /* Get outer coordinate index */
133 i_coord_offset = DIM*inr;
135 /* Load i particle coords and add shift vector */
136 ix0 = shX + x[i_coord_offset+DIM*0+XX];
137 iy0 = shY + x[i_coord_offset+DIM*0+YY];
138 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
139 ix1 = shX + x[i_coord_offset+DIM*1+XX];
140 iy1 = shY + x[i_coord_offset+DIM*1+YY];
141 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
142 ix2 = shX + x[i_coord_offset+DIM*2+XX];
143 iy2 = shY + x[i_coord_offset+DIM*2+YY];
144 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
156 /* Reset potential sums */
160 /* Start inner kernel loop */
161 for(jidx=j_index_start; jidx<j_index_end; jidx++)
163 /* Get j neighbor index, and coordinate index */
165 j_coord_offset = DIM*jnr;
167 /* load j atom coordinates */
168 jx0 = x[j_coord_offset+DIM*0+XX];
169 jy0 = x[j_coord_offset+DIM*0+YY];
170 jz0 = x[j_coord_offset+DIM*0+ZZ];
172 /* Calculate displacement vector */
183 /* Calculate squared distance and things based on it */
184 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
185 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
186 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
188 rinv00 = gmx_invsqrt(rsq00);
189 rinv10 = gmx_invsqrt(rsq10);
190 rinv20 = gmx_invsqrt(rsq20);
192 rinvsq00 = rinv00*rinv00;
193 rinvsq10 = rinv10*rinv10;
194 rinvsq20 = rinv20*rinv20;
196 /* Load parameters for j particles */
198 vdwjidx0 = 3*vdwtype[jnr+0];
200 /**************************
201 * CALCULATE INTERACTIONS *
202 **************************/
207 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
208 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
209 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
211 /* REACTION-FIELD ELECTROSTATICS */
212 velec = qq00*(rinv00+krf*rsq00-crf);
213 felec = qq00*(rinv00*rinvsq00-krf2);
215 /* BUCKINGHAM DISPERSION/REPULSION */
216 rinvsix = rinvsq00*rinvsq00*rinvsq00;
217 vvdw6 = c6_00*rinvsix;
219 vvdwexp = cexp1_00*exp(-br);
220 vvdw = vvdwexp - vvdw6*(1.0/6.0);
221 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
223 /* Update potential sums from outer loop */
229 /* Calculate temporary vectorial force */
234 /* Update vectorial force */
238 f[j_coord_offset+DIM*0+XX] -= tx;
239 f[j_coord_offset+DIM*0+YY] -= ty;
240 f[j_coord_offset+DIM*0+ZZ] -= tz;
242 /**************************
243 * CALCULATE INTERACTIONS *
244 **************************/
248 /* REACTION-FIELD ELECTROSTATICS */
249 velec = qq10*(rinv10+krf*rsq10-crf);
250 felec = qq10*(rinv10*rinvsq10-krf2);
252 /* Update potential sums from outer loop */
257 /* Calculate temporary vectorial force */
262 /* Update vectorial force */
266 f[j_coord_offset+DIM*0+XX] -= tx;
267 f[j_coord_offset+DIM*0+YY] -= ty;
268 f[j_coord_offset+DIM*0+ZZ] -= tz;
270 /**************************
271 * CALCULATE INTERACTIONS *
272 **************************/
276 /* REACTION-FIELD ELECTROSTATICS */
277 velec = qq20*(rinv20+krf*rsq20-crf);
278 felec = qq20*(rinv20*rinvsq20-krf2);
280 /* Update potential sums from outer loop */
285 /* Calculate temporary vectorial force */
290 /* Update vectorial force */
294 f[j_coord_offset+DIM*0+XX] -= tx;
295 f[j_coord_offset+DIM*0+YY] -= ty;
296 f[j_coord_offset+DIM*0+ZZ] -= tz;
298 /* Inner loop uses 135 flops */
300 /* End of innermost loop */
303 f[i_coord_offset+DIM*0+XX] += fix0;
304 f[i_coord_offset+DIM*0+YY] += fiy0;
305 f[i_coord_offset+DIM*0+ZZ] += fiz0;
309 f[i_coord_offset+DIM*1+XX] += fix1;
310 f[i_coord_offset+DIM*1+YY] += fiy1;
311 f[i_coord_offset+DIM*1+ZZ] += fiz1;
315 f[i_coord_offset+DIM*2+XX] += fix2;
316 f[i_coord_offset+DIM*2+YY] += fiy2;
317 f[i_coord_offset+DIM*2+ZZ] += fiz2;
321 fshift[i_shift_offset+XX] += tx;
322 fshift[i_shift_offset+YY] += ty;
323 fshift[i_shift_offset+ZZ] += tz;
326 /* Update potential energies */
327 kernel_data->energygrp_elec[ggid] += velecsum;
328 kernel_data->energygrp_vdw[ggid] += vvdwsum;
330 /* Increment number of inner iterations */
331 inneriter += j_index_end - j_index_start;
333 /* Outer loop uses 32 flops */
336 /* Increment number of outer iterations */
339 /* Update outer/inner flops */
341 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*135);
344 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW3P1_F_c
345 * Electrostatics interaction: ReactionField
346 * VdW interaction: Buckingham
347 * Geometry: Water3-Particle
348 * Calculate force/pot: Force
351 nb_kernel_ElecRF_VdwBham_GeomW3P1_F_c
352 (t_nblist * gmx_restrict nlist,
353 rvec * gmx_restrict xx,
354 rvec * gmx_restrict ff,
355 t_forcerec * gmx_restrict fr,
356 t_mdatoms * gmx_restrict mdatoms,
357 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
358 t_nrnb * gmx_restrict nrnb)
360 int i_shift_offset,i_coord_offset,j_coord_offset;
361 int j_index_start,j_index_end;
362 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
363 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
364 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
365 real *shiftvec,*fshift,*x,*f;
367 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
369 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
371 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
373 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
374 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
375 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
376 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
377 real velec,felec,velecsum,facel,crf,krf,krf2;
380 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
389 jindex = nlist->jindex;
391 shiftidx = nlist->shift;
393 shiftvec = fr->shift_vec[0];
394 fshift = fr->fshift[0];
396 charge = mdatoms->chargeA;
400 nvdwtype = fr->ntype;
402 vdwtype = mdatoms->typeA;
404 /* Setup water-specific parameters */
405 inr = nlist->iinr[0];
406 iq0 = facel*charge[inr+0];
407 iq1 = facel*charge[inr+1];
408 iq2 = facel*charge[inr+2];
409 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
414 /* Start outer loop over neighborlists */
415 for(iidx=0; iidx<nri; iidx++)
417 /* Load shift vector for this list */
418 i_shift_offset = DIM*shiftidx[iidx];
419 shX = shiftvec[i_shift_offset+XX];
420 shY = shiftvec[i_shift_offset+YY];
421 shZ = shiftvec[i_shift_offset+ZZ];
423 /* Load limits for loop over neighbors */
424 j_index_start = jindex[iidx];
425 j_index_end = jindex[iidx+1];
427 /* Get outer coordinate index */
429 i_coord_offset = DIM*inr;
431 /* Load i particle coords and add shift vector */
432 ix0 = shX + x[i_coord_offset+DIM*0+XX];
433 iy0 = shY + x[i_coord_offset+DIM*0+YY];
434 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
435 ix1 = shX + x[i_coord_offset+DIM*1+XX];
436 iy1 = shY + x[i_coord_offset+DIM*1+YY];
437 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
438 ix2 = shX + x[i_coord_offset+DIM*2+XX];
439 iy2 = shY + x[i_coord_offset+DIM*2+YY];
440 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
452 /* Start inner kernel loop */
453 for(jidx=j_index_start; jidx<j_index_end; jidx++)
455 /* Get j neighbor index, and coordinate index */
457 j_coord_offset = DIM*jnr;
459 /* load j atom coordinates */
460 jx0 = x[j_coord_offset+DIM*0+XX];
461 jy0 = x[j_coord_offset+DIM*0+YY];
462 jz0 = x[j_coord_offset+DIM*0+ZZ];
464 /* Calculate displacement vector */
475 /* Calculate squared distance and things based on it */
476 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
477 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
478 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
480 rinv00 = gmx_invsqrt(rsq00);
481 rinv10 = gmx_invsqrt(rsq10);
482 rinv20 = gmx_invsqrt(rsq20);
484 rinvsq00 = rinv00*rinv00;
485 rinvsq10 = rinv10*rinv10;
486 rinvsq20 = rinv20*rinv20;
488 /* Load parameters for j particles */
490 vdwjidx0 = 3*vdwtype[jnr+0];
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
499 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
500 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
501 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
503 /* REACTION-FIELD ELECTROSTATICS */
504 felec = qq00*(rinv00*rinvsq00-krf2);
506 /* BUCKINGHAM DISPERSION/REPULSION */
507 rinvsix = rinvsq00*rinvsq00*rinvsq00;
508 vvdw6 = c6_00*rinvsix;
510 vvdwexp = cexp1_00*exp(-br);
511 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
515 /* Calculate temporary vectorial force */
520 /* Update vectorial force */
524 f[j_coord_offset+DIM*0+XX] -= tx;
525 f[j_coord_offset+DIM*0+YY] -= ty;
526 f[j_coord_offset+DIM*0+ZZ] -= tz;
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
534 /* REACTION-FIELD ELECTROSTATICS */
535 felec = qq10*(rinv10*rinvsq10-krf2);
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 /* REACTION-FIELD ELECTROSTATICS */
559 felec = qq20*(rinv20*rinvsq20-krf2);
563 /* Calculate temporary vectorial force */
568 /* Update vectorial force */
572 f[j_coord_offset+DIM*0+XX] -= tx;
573 f[j_coord_offset+DIM*0+YY] -= ty;
574 f[j_coord_offset+DIM*0+ZZ] -= tz;
576 /* Inner loop uses 117 flops */
578 /* End of innermost loop */
581 f[i_coord_offset+DIM*0+XX] += fix0;
582 f[i_coord_offset+DIM*0+YY] += fiy0;
583 f[i_coord_offset+DIM*0+ZZ] += fiz0;
587 f[i_coord_offset+DIM*1+XX] += fix1;
588 f[i_coord_offset+DIM*1+YY] += fiy1;
589 f[i_coord_offset+DIM*1+ZZ] += fiz1;
593 f[i_coord_offset+DIM*2+XX] += fix2;
594 f[i_coord_offset+DIM*2+YY] += fiy2;
595 f[i_coord_offset+DIM*2+ZZ] += fiz2;
599 fshift[i_shift_offset+XX] += tx;
600 fshift[i_shift_offset+YY] += ty;
601 fshift[i_shift_offset+ZZ] += tz;
603 /* Increment number of inner iterations */
604 inneriter += j_index_end - j_index_start;
606 /* Outer loop uses 30 flops */
609 /* Increment number of outer iterations */
612 /* Update outer/inner flops */
614 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);