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 "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwBhamSh_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];
117 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
118 rcutoff = fr->rcoulomb;
119 rcutoff2 = rcutoff*rcutoff;
121 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
127 /* Start outer loop over neighborlists */
128 for(iidx=0; iidx<nri; iidx++)
130 /* Load shift vector for this list */
131 i_shift_offset = DIM*shiftidx[iidx];
132 shX = shiftvec[i_shift_offset+XX];
133 shY = shiftvec[i_shift_offset+YY];
134 shZ = shiftvec[i_shift_offset+ZZ];
136 /* Load limits for loop over neighbors */
137 j_index_start = jindex[iidx];
138 j_index_end = jindex[iidx+1];
140 /* Get outer coordinate index */
142 i_coord_offset = DIM*inr;
144 /* Load i particle coords and add shift vector */
145 ix0 = shX + x[i_coord_offset+DIM*0+XX];
146 iy0 = shY + x[i_coord_offset+DIM*0+YY];
147 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
148 ix1 = shX + x[i_coord_offset+DIM*1+XX];
149 iy1 = shY + x[i_coord_offset+DIM*1+YY];
150 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
151 ix2 = shX + x[i_coord_offset+DIM*2+XX];
152 iy2 = shY + x[i_coord_offset+DIM*2+YY];
153 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
165 /* Reset potential sums */
169 /* Start inner kernel loop */
170 for(jidx=j_index_start; jidx<j_index_end; jidx++)
172 /* Get j neighbor index, and coordinate index */
174 j_coord_offset = DIM*jnr;
176 /* load j atom coordinates */
177 jx0 = x[j_coord_offset+DIM*0+XX];
178 jy0 = x[j_coord_offset+DIM*0+YY];
179 jz0 = x[j_coord_offset+DIM*0+ZZ];
181 /* Calculate displacement vector */
192 /* Calculate squared distance and things based on it */
193 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
194 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
195 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
197 rinv00 = gmx_invsqrt(rsq00);
198 rinv10 = gmx_invsqrt(rsq10);
199 rinv20 = gmx_invsqrt(rsq20);
201 rinvsq00 = rinv00*rinv00;
202 rinvsq10 = rinv10*rinv10;
203 rinvsq20 = rinv20*rinv20;
205 /* Load parameters for j particles */
207 vdwjidx0 = 3*vdwtype[jnr+0];
209 /**************************
210 * CALCULATE INTERACTIONS *
211 **************************/
219 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
220 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
221 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
223 /* REACTION-FIELD ELECTROSTATICS */
224 velec = qq00*(rinv00+krf*rsq00-crf);
225 felec = qq00*(rinv00*rinvsq00-krf2);
227 /* BUCKINGHAM DISPERSION/REPULSION */
228 rinvsix = rinvsq00*rinvsq00*rinvsq00;
229 vvdw6 = c6_00*rinvsix;
231 vvdwexp = cexp1_00*exp(-br);
232 vvdw = (vvdwexp-cexp1_00*exp(-cexp2_00*rvdw)) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
233 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
235 /* Update potential sums from outer loop */
241 /* Calculate temporary vectorial force */
246 /* Update vectorial force */
250 f[j_coord_offset+DIM*0+XX] -= tx;
251 f[j_coord_offset+DIM*0+YY] -= ty;
252 f[j_coord_offset+DIM*0+ZZ] -= tz;
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
265 /* REACTION-FIELD ELECTROSTATICS */
266 velec = qq10*(rinv10+krf*rsq10-crf);
267 felec = qq10*(rinv10*rinvsq10-krf2);
269 /* Update potential sums from outer loop */
274 /* Calculate temporary vectorial force */
279 /* Update vectorial force */
283 f[j_coord_offset+DIM*0+XX] -= tx;
284 f[j_coord_offset+DIM*0+YY] -= ty;
285 f[j_coord_offset+DIM*0+ZZ] -= tz;
289 /**************************
290 * CALCULATE INTERACTIONS *
291 **************************/
298 /* REACTION-FIELD ELECTROSTATICS */
299 velec = qq20*(rinv20+krf*rsq20-crf);
300 felec = qq20*(rinv20*rinvsq20-krf2);
302 /* Update potential sums from outer loop */
307 /* Calculate temporary vectorial force */
312 /* Update vectorial force */
316 f[j_coord_offset+DIM*0+XX] -= tx;
317 f[j_coord_offset+DIM*0+YY] -= ty;
318 f[j_coord_offset+DIM*0+ZZ] -= tz;
322 /* Inner loop uses 166 flops */
324 /* End of innermost loop */
327 f[i_coord_offset+DIM*0+XX] += fix0;
328 f[i_coord_offset+DIM*0+YY] += fiy0;
329 f[i_coord_offset+DIM*0+ZZ] += fiz0;
333 f[i_coord_offset+DIM*1+XX] += fix1;
334 f[i_coord_offset+DIM*1+YY] += fiy1;
335 f[i_coord_offset+DIM*1+ZZ] += fiz1;
339 f[i_coord_offset+DIM*2+XX] += fix2;
340 f[i_coord_offset+DIM*2+YY] += fiy2;
341 f[i_coord_offset+DIM*2+ZZ] += fiz2;
345 fshift[i_shift_offset+XX] += tx;
346 fshift[i_shift_offset+YY] += ty;
347 fshift[i_shift_offset+ZZ] += tz;
350 /* Update potential energies */
351 kernel_data->energygrp_elec[ggid] += velecsum;
352 kernel_data->energygrp_vdw[ggid] += vvdwsum;
354 /* Increment number of inner iterations */
355 inneriter += j_index_end - j_index_start;
357 /* Outer loop uses 32 flops */
360 /* Increment number of outer iterations */
363 /* Update outer/inner flops */
365 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*166);
368 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
369 * Electrostatics interaction: ReactionField
370 * VdW interaction: Buckingham
371 * Geometry: Water3-Particle
372 * Calculate force/pot: Force
375 nb_kernel_ElecRFCut_VdwBhamSh_GeomW3P1_F_c
376 (t_nblist * gmx_restrict nlist,
377 rvec * gmx_restrict xx,
378 rvec * gmx_restrict ff,
379 t_forcerec * gmx_restrict fr,
380 t_mdatoms * gmx_restrict mdatoms,
381 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
382 t_nrnb * gmx_restrict nrnb)
384 int i_shift_offset,i_coord_offset,j_coord_offset;
385 int j_index_start,j_index_end;
386 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
387 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
388 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
389 real *shiftvec,*fshift,*x,*f;
391 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
393 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
395 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
397 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
398 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
399 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
400 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
401 real velec,felec,velecsum,facel,crf,krf,krf2;
404 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
413 jindex = nlist->jindex;
415 shiftidx = nlist->shift;
417 shiftvec = fr->shift_vec[0];
418 fshift = fr->fshift[0];
420 charge = mdatoms->chargeA;
424 nvdwtype = fr->ntype;
426 vdwtype = mdatoms->typeA;
428 /* Setup water-specific parameters */
429 inr = nlist->iinr[0];
430 iq0 = facel*charge[inr+0];
431 iq1 = facel*charge[inr+1];
432 iq2 = facel*charge[inr+2];
433 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
435 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
436 rcutoff = fr->rcoulomb;
437 rcutoff2 = rcutoff*rcutoff;
439 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
445 /* Start outer loop over neighborlists */
446 for(iidx=0; iidx<nri; iidx++)
448 /* Load shift vector for this list */
449 i_shift_offset = DIM*shiftidx[iidx];
450 shX = shiftvec[i_shift_offset+XX];
451 shY = shiftvec[i_shift_offset+YY];
452 shZ = shiftvec[i_shift_offset+ZZ];
454 /* Load limits for loop over neighbors */
455 j_index_start = jindex[iidx];
456 j_index_end = jindex[iidx+1];
458 /* Get outer coordinate index */
460 i_coord_offset = DIM*inr;
462 /* Load i particle coords and add shift vector */
463 ix0 = shX + x[i_coord_offset+DIM*0+XX];
464 iy0 = shY + x[i_coord_offset+DIM*0+YY];
465 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
466 ix1 = shX + x[i_coord_offset+DIM*1+XX];
467 iy1 = shY + x[i_coord_offset+DIM*1+YY];
468 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
469 ix2 = shX + x[i_coord_offset+DIM*2+XX];
470 iy2 = shY + x[i_coord_offset+DIM*2+YY];
471 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
483 /* Start inner kernel loop */
484 for(jidx=j_index_start; jidx<j_index_end; jidx++)
486 /* Get j neighbor index, and coordinate index */
488 j_coord_offset = DIM*jnr;
490 /* load j atom coordinates */
491 jx0 = x[j_coord_offset+DIM*0+XX];
492 jy0 = x[j_coord_offset+DIM*0+YY];
493 jz0 = x[j_coord_offset+DIM*0+ZZ];
495 /* Calculate displacement vector */
506 /* Calculate squared distance and things based on it */
507 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
508 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
509 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
511 rinv00 = gmx_invsqrt(rsq00);
512 rinv10 = gmx_invsqrt(rsq10);
513 rinv20 = gmx_invsqrt(rsq20);
515 rinvsq00 = rinv00*rinv00;
516 rinvsq10 = rinv10*rinv10;
517 rinvsq20 = rinv20*rinv20;
519 /* Load parameters for j particles */
521 vdwjidx0 = 3*vdwtype[jnr+0];
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
533 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
534 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
535 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
537 /* REACTION-FIELD ELECTROSTATICS */
538 felec = qq00*(rinv00*rinvsq00-krf2);
540 /* BUCKINGHAM DISPERSION/REPULSION */
541 rinvsix = rinvsq00*rinvsq00*rinvsq00;
542 vvdw6 = c6_00*rinvsix;
544 vvdwexp = cexp1_00*exp(-br);
545 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
549 /* Calculate temporary vectorial force */
554 /* Update vectorial force */
558 f[j_coord_offset+DIM*0+XX] -= tx;
559 f[j_coord_offset+DIM*0+YY] -= ty;
560 f[j_coord_offset+DIM*0+ZZ] -= tz;
564 /**************************
565 * CALCULATE INTERACTIONS *
566 **************************/
573 /* REACTION-FIELD ELECTROSTATICS */
574 felec = qq10*(rinv10*rinvsq10-krf2);
578 /* Calculate temporary vectorial force */
583 /* Update vectorial force */
587 f[j_coord_offset+DIM*0+XX] -= tx;
588 f[j_coord_offset+DIM*0+YY] -= ty;
589 f[j_coord_offset+DIM*0+ZZ] -= tz;
593 /**************************
594 * CALCULATE INTERACTIONS *
595 **************************/
602 /* REACTION-FIELD ELECTROSTATICS */
603 felec = qq20*(rinv20*rinvsq20-krf2);
607 /* Calculate temporary vectorial force */
612 /* Update vectorial force */
616 f[j_coord_offset+DIM*0+XX] -= tx;
617 f[j_coord_offset+DIM*0+YY] -= ty;
618 f[j_coord_offset+DIM*0+ZZ] -= tz;
622 /* Inner loop uses 117 flops */
624 /* End of innermost loop */
627 f[i_coord_offset+DIM*0+XX] += fix0;
628 f[i_coord_offset+DIM*0+YY] += fiy0;
629 f[i_coord_offset+DIM*0+ZZ] += fiz0;
633 f[i_coord_offset+DIM*1+XX] += fix1;
634 f[i_coord_offset+DIM*1+YY] += fiy1;
635 f[i_coord_offset+DIM*1+ZZ] += fiz1;
639 f[i_coord_offset+DIM*2+XX] += fix2;
640 f[i_coord_offset+DIM*2+YY] += fiy2;
641 f[i_coord_offset+DIM*2+ZZ] += fiz2;
645 fshift[i_shift_offset+XX] += tx;
646 fshift[i_shift_offset+YY] += ty;
647 fshift[i_shift_offset+ZZ] += tz;
649 /* Increment number of inner iterations */
650 inneriter += j_index_end - j_index_start;
652 /* Outer loop uses 30 flops */
655 /* Increment number of outer iterations */
658 /* Update outer/inner flops */
660 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);