2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW3P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwBham_GeomW3P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real velec,felec,velecsum,facel,crf,krf,krf2;
86 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
95 jindex = nlist->jindex;
97 shiftidx = nlist->shift;
99 shiftvec = fr->shift_vec[0];
100 fshift = fr->fshift[0];
102 charge = mdatoms->chargeA;
106 nvdwtype = fr->ntype;
108 vdwtype = mdatoms->typeA;
110 /* Setup water-specific parameters */
111 inr = nlist->iinr[0];
112 iq0 = facel*charge[inr+0];
113 iq1 = facel*charge[inr+1];
114 iq2 = facel*charge[inr+2];
115 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
120 /* Start outer loop over neighborlists */
121 for(iidx=0; iidx<nri; iidx++)
123 /* Load shift vector for this list */
124 i_shift_offset = DIM*shiftidx[iidx];
125 shX = shiftvec[i_shift_offset+XX];
126 shY = shiftvec[i_shift_offset+YY];
127 shZ = shiftvec[i_shift_offset+ZZ];
129 /* Load limits for loop over neighbors */
130 j_index_start = jindex[iidx];
131 j_index_end = jindex[iidx+1];
133 /* Get outer coordinate index */
135 i_coord_offset = DIM*inr;
137 /* Load i particle coords and add shift vector */
138 ix0 = shX + x[i_coord_offset+DIM*0+XX];
139 iy0 = shY + x[i_coord_offset+DIM*0+YY];
140 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
141 ix1 = shX + x[i_coord_offset+DIM*1+XX];
142 iy1 = shY + x[i_coord_offset+DIM*1+YY];
143 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
144 ix2 = shX + x[i_coord_offset+DIM*2+XX];
145 iy2 = shY + x[i_coord_offset+DIM*2+YY];
146 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
158 /* Reset potential sums */
162 /* Start inner kernel loop */
163 for(jidx=j_index_start; jidx<j_index_end; jidx++)
165 /* Get j neighbor index, and coordinate index */
167 j_coord_offset = DIM*jnr;
169 /* load j atom coordinates */
170 jx0 = x[j_coord_offset+DIM*0+XX];
171 jy0 = x[j_coord_offset+DIM*0+YY];
172 jz0 = x[j_coord_offset+DIM*0+ZZ];
174 /* Calculate displacement vector */
185 /* Calculate squared distance and things based on it */
186 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
187 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
188 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
190 rinv00 = gmx_invsqrt(rsq00);
191 rinv10 = gmx_invsqrt(rsq10);
192 rinv20 = gmx_invsqrt(rsq20);
194 rinvsq00 = rinv00*rinv00;
195 rinvsq10 = rinv10*rinv10;
196 rinvsq20 = rinv20*rinv20;
198 /* Load parameters for j particles */
200 vdwjidx0 = 3*vdwtype[jnr+0];
202 /**************************
203 * CALCULATE INTERACTIONS *
204 **************************/
209 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
210 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
211 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
213 /* REACTION-FIELD ELECTROSTATICS */
214 velec = qq00*(rinv00+krf*rsq00-crf);
215 felec = qq00*(rinv00*rinvsq00-krf2);
217 /* BUCKINGHAM DISPERSION/REPULSION */
218 rinvsix = rinvsq00*rinvsq00*rinvsq00;
219 vvdw6 = c6_00*rinvsix;
221 vvdwexp = cexp1_00*exp(-br);
222 vvdw = vvdwexp - vvdw6*(1.0/6.0);
223 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
225 /* Update potential sums from outer loop */
231 /* Calculate temporary vectorial force */
236 /* Update vectorial force */
240 f[j_coord_offset+DIM*0+XX] -= tx;
241 f[j_coord_offset+DIM*0+YY] -= ty;
242 f[j_coord_offset+DIM*0+ZZ] -= tz;
244 /**************************
245 * CALCULATE INTERACTIONS *
246 **************************/
250 /* REACTION-FIELD ELECTROSTATICS */
251 velec = qq10*(rinv10+krf*rsq10-crf);
252 felec = qq10*(rinv10*rinvsq10-krf2);
254 /* Update potential sums from outer loop */
259 /* Calculate temporary vectorial force */
264 /* Update vectorial force */
268 f[j_coord_offset+DIM*0+XX] -= tx;
269 f[j_coord_offset+DIM*0+YY] -= ty;
270 f[j_coord_offset+DIM*0+ZZ] -= tz;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
278 /* REACTION-FIELD ELECTROSTATICS */
279 velec = qq20*(rinv20+krf*rsq20-crf);
280 felec = qq20*(rinv20*rinvsq20-krf2);
282 /* Update potential sums from outer loop */
287 /* Calculate temporary vectorial force */
292 /* Update vectorial force */
296 f[j_coord_offset+DIM*0+XX] -= tx;
297 f[j_coord_offset+DIM*0+YY] -= ty;
298 f[j_coord_offset+DIM*0+ZZ] -= tz;
300 /* Inner loop uses 135 flops */
302 /* End of innermost loop */
305 f[i_coord_offset+DIM*0+XX] += fix0;
306 f[i_coord_offset+DIM*0+YY] += fiy0;
307 f[i_coord_offset+DIM*0+ZZ] += fiz0;
311 f[i_coord_offset+DIM*1+XX] += fix1;
312 f[i_coord_offset+DIM*1+YY] += fiy1;
313 f[i_coord_offset+DIM*1+ZZ] += fiz1;
317 f[i_coord_offset+DIM*2+XX] += fix2;
318 f[i_coord_offset+DIM*2+YY] += fiy2;
319 f[i_coord_offset+DIM*2+ZZ] += fiz2;
323 fshift[i_shift_offset+XX] += tx;
324 fshift[i_shift_offset+YY] += ty;
325 fshift[i_shift_offset+ZZ] += tz;
328 /* Update potential energies */
329 kernel_data->energygrp_elec[ggid] += velecsum;
330 kernel_data->energygrp_vdw[ggid] += vvdwsum;
332 /* Increment number of inner iterations */
333 inneriter += j_index_end - j_index_start;
335 /* Outer loop uses 32 flops */
338 /* Increment number of outer iterations */
341 /* Update outer/inner flops */
343 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*135);
346 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW3P1_F_c
347 * Electrostatics interaction: ReactionField
348 * VdW interaction: Buckingham
349 * Geometry: Water3-Particle
350 * Calculate force/pot: Force
353 nb_kernel_ElecRF_VdwBham_GeomW3P1_F_c
354 (t_nblist * gmx_restrict nlist,
355 rvec * gmx_restrict xx,
356 rvec * gmx_restrict ff,
357 t_forcerec * gmx_restrict fr,
358 t_mdatoms * gmx_restrict mdatoms,
359 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
360 t_nrnb * gmx_restrict nrnb)
362 int i_shift_offset,i_coord_offset,j_coord_offset;
363 int j_index_start,j_index_end;
364 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
365 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
366 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
367 real *shiftvec,*fshift,*x,*f;
369 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
371 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
373 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
375 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
376 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
377 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
378 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
379 real velec,felec,velecsum,facel,crf,krf,krf2;
382 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
391 jindex = nlist->jindex;
393 shiftidx = nlist->shift;
395 shiftvec = fr->shift_vec[0];
396 fshift = fr->fshift[0];
398 charge = mdatoms->chargeA;
402 nvdwtype = fr->ntype;
404 vdwtype = mdatoms->typeA;
406 /* Setup water-specific parameters */
407 inr = nlist->iinr[0];
408 iq0 = facel*charge[inr+0];
409 iq1 = facel*charge[inr+1];
410 iq2 = facel*charge[inr+2];
411 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
416 /* Start outer loop over neighborlists */
417 for(iidx=0; iidx<nri; iidx++)
419 /* Load shift vector for this list */
420 i_shift_offset = DIM*shiftidx[iidx];
421 shX = shiftvec[i_shift_offset+XX];
422 shY = shiftvec[i_shift_offset+YY];
423 shZ = shiftvec[i_shift_offset+ZZ];
425 /* Load limits for loop over neighbors */
426 j_index_start = jindex[iidx];
427 j_index_end = jindex[iidx+1];
429 /* Get outer coordinate index */
431 i_coord_offset = DIM*inr;
433 /* Load i particle coords and add shift vector */
434 ix0 = shX + x[i_coord_offset+DIM*0+XX];
435 iy0 = shY + x[i_coord_offset+DIM*0+YY];
436 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
437 ix1 = shX + x[i_coord_offset+DIM*1+XX];
438 iy1 = shY + x[i_coord_offset+DIM*1+YY];
439 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
440 ix2 = shX + x[i_coord_offset+DIM*2+XX];
441 iy2 = shY + x[i_coord_offset+DIM*2+YY];
442 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
454 /* Start inner kernel loop */
455 for(jidx=j_index_start; jidx<j_index_end; jidx++)
457 /* Get j neighbor index, and coordinate index */
459 j_coord_offset = DIM*jnr;
461 /* load j atom coordinates */
462 jx0 = x[j_coord_offset+DIM*0+XX];
463 jy0 = x[j_coord_offset+DIM*0+YY];
464 jz0 = x[j_coord_offset+DIM*0+ZZ];
466 /* Calculate displacement vector */
477 /* Calculate squared distance and things based on it */
478 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
479 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
480 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
482 rinv00 = gmx_invsqrt(rsq00);
483 rinv10 = gmx_invsqrt(rsq10);
484 rinv20 = gmx_invsqrt(rsq20);
486 rinvsq00 = rinv00*rinv00;
487 rinvsq10 = rinv10*rinv10;
488 rinvsq20 = rinv20*rinv20;
490 /* Load parameters for j particles */
492 vdwjidx0 = 3*vdwtype[jnr+0];
494 /**************************
495 * CALCULATE INTERACTIONS *
496 **************************/
501 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
502 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
503 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
505 /* REACTION-FIELD ELECTROSTATICS */
506 felec = qq00*(rinv00*rinvsq00-krf2);
508 /* BUCKINGHAM DISPERSION/REPULSION */
509 rinvsix = rinvsq00*rinvsq00*rinvsq00;
510 vvdw6 = c6_00*rinvsix;
512 vvdwexp = cexp1_00*exp(-br);
513 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
517 /* Calculate temporary vectorial force */
522 /* Update vectorial force */
526 f[j_coord_offset+DIM*0+XX] -= tx;
527 f[j_coord_offset+DIM*0+YY] -= ty;
528 f[j_coord_offset+DIM*0+ZZ] -= tz;
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
536 /* REACTION-FIELD ELECTROSTATICS */
537 felec = qq10*(rinv10*rinvsq10-krf2);
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*0+XX] -= tx;
551 f[j_coord_offset+DIM*0+YY] -= ty;
552 f[j_coord_offset+DIM*0+ZZ] -= tz;
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
560 /* REACTION-FIELD ELECTROSTATICS */
561 felec = qq20*(rinv20*rinvsq20-krf2);
565 /* Calculate temporary vectorial force */
570 /* Update vectorial force */
574 f[j_coord_offset+DIM*0+XX] -= tx;
575 f[j_coord_offset+DIM*0+YY] -= ty;
576 f[j_coord_offset+DIM*0+ZZ] -= tz;
578 /* Inner loop uses 117 flops */
580 /* End of innermost loop */
583 f[i_coord_offset+DIM*0+XX] += fix0;
584 f[i_coord_offset+DIM*0+YY] += fiy0;
585 f[i_coord_offset+DIM*0+ZZ] += fiz0;
589 f[i_coord_offset+DIM*1+XX] += fix1;
590 f[i_coord_offset+DIM*1+YY] += fiy1;
591 f[i_coord_offset+DIM*1+ZZ] += fiz1;
595 f[i_coord_offset+DIM*2+XX] += fix2;
596 f[i_coord_offset+DIM*2+YY] += fiy2;
597 f[i_coord_offset+DIM*2+ZZ] += fiz2;
601 fshift[i_shift_offset+XX] += tx;
602 fshift[i_shift_offset+YY] += ty;
603 fshift[i_shift_offset+ZZ] += tz;
605 /* Increment number of inner iterations */
606 inneriter += j_index_end - j_index_start;
608 /* Outer loop uses 30 flops */
611 /* Increment number of outer iterations */
614 /* Update outer/inner flops */
616 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);