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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/math/vec.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwBham_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
105 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 /* Setup water-specific parameters */
114 inr = nlist->iinr[0];
115 iq1 = facel*charge[inr+1];
116 iq2 = facel*charge[inr+2];
117 iq3 = facel*charge[inr+3];
118 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
123 /* Start outer loop over neighborlists */
124 for(iidx=0; iidx<nri; iidx++)
126 /* Load shift vector for this list */
127 i_shift_offset = DIM*shiftidx[iidx];
128 shX = shiftvec[i_shift_offset+XX];
129 shY = shiftvec[i_shift_offset+YY];
130 shZ = shiftvec[i_shift_offset+ZZ];
132 /* Load limits for loop over neighbors */
133 j_index_start = jindex[iidx];
134 j_index_end = jindex[iidx+1];
136 /* Get outer coordinate index */
138 i_coord_offset = DIM*inr;
140 /* Load i particle coords and add shift vector */
141 ix0 = shX + x[i_coord_offset+DIM*0+XX];
142 iy0 = shY + x[i_coord_offset+DIM*0+YY];
143 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
144 ix1 = shX + x[i_coord_offset+DIM*1+XX];
145 iy1 = shY + x[i_coord_offset+DIM*1+YY];
146 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
147 ix2 = shX + x[i_coord_offset+DIM*2+XX];
148 iy2 = shY + x[i_coord_offset+DIM*2+YY];
149 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
150 ix3 = shX + x[i_coord_offset+DIM*3+XX];
151 iy3 = shY + x[i_coord_offset+DIM*3+YY];
152 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
167 /* Reset potential sums */
171 /* Start inner kernel loop */
172 for(jidx=j_index_start; jidx<j_index_end; jidx++)
174 /* Get j neighbor index, and coordinate index */
176 j_coord_offset = DIM*jnr;
178 /* load j atom coordinates */
179 jx0 = x[j_coord_offset+DIM*0+XX];
180 jy0 = x[j_coord_offset+DIM*0+YY];
181 jz0 = x[j_coord_offset+DIM*0+ZZ];
183 /* Calculate displacement vector */
197 /* Calculate squared distance and things based on it */
198 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
199 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
200 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
201 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
203 rinv00 = gmx_invsqrt(rsq00);
204 rinv10 = gmx_invsqrt(rsq10);
205 rinv20 = gmx_invsqrt(rsq20);
206 rinv30 = gmx_invsqrt(rsq30);
208 rinvsq00 = rinv00*rinv00;
209 rinvsq10 = rinv10*rinv10;
210 rinvsq20 = rinv20*rinv20;
211 rinvsq30 = rinv30*rinv30;
213 /* Load parameters for j particles */
215 vdwjidx0 = 3*vdwtype[jnr+0];
217 /**************************
218 * CALCULATE INTERACTIONS *
219 **************************/
223 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
224 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
225 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
227 /* BUCKINGHAM DISPERSION/REPULSION */
228 rinvsix = rinvsq00*rinvsq00*rinvsq00;
229 vvdw6 = c6_00*rinvsix;
231 vvdwexp = cexp1_00*exp(-br);
232 vvdw = vvdwexp - vvdw6*(1.0/6.0);
233 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
235 /* Update potential sums from outer loop */
240 /* Calculate temporary vectorial force */
245 /* Update vectorial force */
249 f[j_coord_offset+DIM*0+XX] -= tx;
250 f[j_coord_offset+DIM*0+YY] -= ty;
251 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
259 /* REACTION-FIELD ELECTROSTATICS */
260 velec = qq10*(rinv10+krf*rsq10-crf);
261 felec = qq10*(rinv10*rinvsq10-krf2);
263 /* Update potential sums from outer loop */
268 /* Calculate temporary vectorial force */
273 /* Update vectorial force */
277 f[j_coord_offset+DIM*0+XX] -= tx;
278 f[j_coord_offset+DIM*0+YY] -= ty;
279 f[j_coord_offset+DIM*0+ZZ] -= tz;
281 /**************************
282 * CALCULATE INTERACTIONS *
283 **************************/
287 /* REACTION-FIELD ELECTROSTATICS */
288 velec = qq20*(rinv20+krf*rsq20-crf);
289 felec = qq20*(rinv20*rinvsq20-krf2);
291 /* Update potential sums from outer loop */
296 /* Calculate temporary vectorial force */
301 /* Update vectorial force */
305 f[j_coord_offset+DIM*0+XX] -= tx;
306 f[j_coord_offset+DIM*0+YY] -= ty;
307 f[j_coord_offset+DIM*0+ZZ] -= tz;
309 /**************************
310 * CALCULATE INTERACTIONS *
311 **************************/
315 /* REACTION-FIELD ELECTROSTATICS */
316 velec = qq30*(rinv30+krf*rsq30-crf);
317 felec = qq30*(rinv30*rinvsq30-krf2);
319 /* Update potential sums from outer loop */
324 /* Calculate temporary vectorial force */
329 /* Update vectorial force */
333 f[j_coord_offset+DIM*0+XX] -= tx;
334 f[j_coord_offset+DIM*0+YY] -= ty;
335 f[j_coord_offset+DIM*0+ZZ] -= tz;
337 /* Inner loop uses 157 flops */
339 /* End of innermost loop */
342 f[i_coord_offset+DIM*0+XX] += fix0;
343 f[i_coord_offset+DIM*0+YY] += fiy0;
344 f[i_coord_offset+DIM*0+ZZ] += fiz0;
348 f[i_coord_offset+DIM*1+XX] += fix1;
349 f[i_coord_offset+DIM*1+YY] += fiy1;
350 f[i_coord_offset+DIM*1+ZZ] += fiz1;
354 f[i_coord_offset+DIM*2+XX] += fix2;
355 f[i_coord_offset+DIM*2+YY] += fiy2;
356 f[i_coord_offset+DIM*2+ZZ] += fiz2;
360 f[i_coord_offset+DIM*3+XX] += fix3;
361 f[i_coord_offset+DIM*3+YY] += fiy3;
362 f[i_coord_offset+DIM*3+ZZ] += fiz3;
366 fshift[i_shift_offset+XX] += tx;
367 fshift[i_shift_offset+YY] += ty;
368 fshift[i_shift_offset+ZZ] += tz;
371 /* Update potential energies */
372 kernel_data->energygrp_elec[ggid] += velecsum;
373 kernel_data->energygrp_vdw[ggid] += vvdwsum;
375 /* Increment number of inner iterations */
376 inneriter += j_index_end - j_index_start;
378 /* Outer loop uses 41 flops */
381 /* Increment number of outer iterations */
384 /* Update outer/inner flops */
386 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*157);
389 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwBham_GeomW4P1_F_c
390 * Electrostatics interaction: ReactionField
391 * VdW interaction: Buckingham
392 * Geometry: Water4-Particle
393 * Calculate force/pot: Force
396 nb_kernel_ElecRF_VdwBham_GeomW4P1_F_c
397 (t_nblist * gmx_restrict nlist,
398 rvec * gmx_restrict xx,
399 rvec * gmx_restrict ff,
400 t_forcerec * gmx_restrict fr,
401 t_mdatoms * gmx_restrict mdatoms,
402 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
403 t_nrnb * gmx_restrict nrnb)
405 int i_shift_offset,i_coord_offset,j_coord_offset;
406 int j_index_start,j_index_end;
407 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
408 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
409 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
410 real *shiftvec,*fshift,*x,*f;
412 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
414 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
416 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
418 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
420 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
421 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
422 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
423 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
424 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
425 real velec,felec,velecsum,facel,crf,krf,krf2;
428 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
437 jindex = nlist->jindex;
439 shiftidx = nlist->shift;
441 shiftvec = fr->shift_vec[0];
442 fshift = fr->fshift[0];
444 charge = mdatoms->chargeA;
448 nvdwtype = fr->ntype;
450 vdwtype = mdatoms->typeA;
452 /* Setup water-specific parameters */
453 inr = nlist->iinr[0];
454 iq1 = facel*charge[inr+1];
455 iq2 = facel*charge[inr+2];
456 iq3 = facel*charge[inr+3];
457 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
462 /* Start outer loop over neighborlists */
463 for(iidx=0; iidx<nri; iidx++)
465 /* Load shift vector for this list */
466 i_shift_offset = DIM*shiftidx[iidx];
467 shX = shiftvec[i_shift_offset+XX];
468 shY = shiftvec[i_shift_offset+YY];
469 shZ = shiftvec[i_shift_offset+ZZ];
471 /* Load limits for loop over neighbors */
472 j_index_start = jindex[iidx];
473 j_index_end = jindex[iidx+1];
475 /* Get outer coordinate index */
477 i_coord_offset = DIM*inr;
479 /* Load i particle coords and add shift vector */
480 ix0 = shX + x[i_coord_offset+DIM*0+XX];
481 iy0 = shY + x[i_coord_offset+DIM*0+YY];
482 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
483 ix1 = shX + x[i_coord_offset+DIM*1+XX];
484 iy1 = shY + x[i_coord_offset+DIM*1+YY];
485 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
486 ix2 = shX + x[i_coord_offset+DIM*2+XX];
487 iy2 = shY + x[i_coord_offset+DIM*2+YY];
488 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
489 ix3 = shX + x[i_coord_offset+DIM*3+XX];
490 iy3 = shY + x[i_coord_offset+DIM*3+YY];
491 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
506 /* Start inner kernel loop */
507 for(jidx=j_index_start; jidx<j_index_end; jidx++)
509 /* Get j neighbor index, and coordinate index */
511 j_coord_offset = DIM*jnr;
513 /* load j atom coordinates */
514 jx0 = x[j_coord_offset+DIM*0+XX];
515 jy0 = x[j_coord_offset+DIM*0+YY];
516 jz0 = x[j_coord_offset+DIM*0+ZZ];
518 /* Calculate displacement vector */
532 /* Calculate squared distance and things based on it */
533 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
534 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
535 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
536 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
538 rinv00 = gmx_invsqrt(rsq00);
539 rinv10 = gmx_invsqrt(rsq10);
540 rinv20 = gmx_invsqrt(rsq20);
541 rinv30 = gmx_invsqrt(rsq30);
543 rinvsq00 = rinv00*rinv00;
544 rinvsq10 = rinv10*rinv10;
545 rinvsq20 = rinv20*rinv20;
546 rinvsq30 = rinv30*rinv30;
548 /* Load parameters for j particles */
550 vdwjidx0 = 3*vdwtype[jnr+0];
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
558 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
559 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
560 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
562 /* BUCKINGHAM DISPERSION/REPULSION */
563 rinvsix = rinvsq00*rinvsq00*rinvsq00;
564 vvdw6 = c6_00*rinvsix;
566 vvdwexp = cexp1_00*exp(-br);
567 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
571 /* Calculate temporary vectorial force */
576 /* Update vectorial force */
580 f[j_coord_offset+DIM*0+XX] -= tx;
581 f[j_coord_offset+DIM*0+YY] -= ty;
582 f[j_coord_offset+DIM*0+ZZ] -= tz;
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
590 /* REACTION-FIELD ELECTROSTATICS */
591 felec = qq10*(rinv10*rinvsq10-krf2);
595 /* Calculate temporary vectorial force */
600 /* Update vectorial force */
604 f[j_coord_offset+DIM*0+XX] -= tx;
605 f[j_coord_offset+DIM*0+YY] -= ty;
606 f[j_coord_offset+DIM*0+ZZ] -= tz;
608 /**************************
609 * CALCULATE INTERACTIONS *
610 **************************/
614 /* REACTION-FIELD ELECTROSTATICS */
615 felec = qq20*(rinv20*rinvsq20-krf2);
619 /* Calculate temporary vectorial force */
624 /* Update vectorial force */
628 f[j_coord_offset+DIM*0+XX] -= tx;
629 f[j_coord_offset+DIM*0+YY] -= ty;
630 f[j_coord_offset+DIM*0+ZZ] -= tz;
632 /**************************
633 * CALCULATE INTERACTIONS *
634 **************************/
638 /* REACTION-FIELD ELECTROSTATICS */
639 felec = qq30*(rinv30*rinvsq30-krf2);
643 /* Calculate temporary vectorial force */
648 /* Update vectorial force */
652 f[j_coord_offset+DIM*0+XX] -= tx;
653 f[j_coord_offset+DIM*0+YY] -= ty;
654 f[j_coord_offset+DIM*0+ZZ] -= tz;
656 /* Inner loop uses 139 flops */
658 /* End of innermost loop */
661 f[i_coord_offset+DIM*0+XX] += fix0;
662 f[i_coord_offset+DIM*0+YY] += fiy0;
663 f[i_coord_offset+DIM*0+ZZ] += fiz0;
667 f[i_coord_offset+DIM*1+XX] += fix1;
668 f[i_coord_offset+DIM*1+YY] += fiy1;
669 f[i_coord_offset+DIM*1+ZZ] += fiz1;
673 f[i_coord_offset+DIM*2+XX] += fix2;
674 f[i_coord_offset+DIM*2+YY] += fiy2;
675 f[i_coord_offset+DIM*2+ZZ] += fiz2;
679 f[i_coord_offset+DIM*3+XX] += fix3;
680 f[i_coord_offset+DIM*3+YY] += fiy3;
681 f[i_coord_offset+DIM*3+ZZ] += fiz3;
685 fshift[i_shift_offset+XX] += tx;
686 fshift[i_shift_offset+YY] += ty;
687 fshift[i_shift_offset+ZZ] += tz;
689 /* Increment number of inner iterations */
690 inneriter += j_index_end - j_index_start;
692 /* Outer loop uses 39 flops */
695 /* Increment number of outer iterations */
698 /* Update outer/inner flops */
700 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*139);