2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * 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_ElecCoul_VdwBham_GeomW4P1_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: Buckingham
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_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;
106 nvdwtype = fr->ntype;
108 vdwtype = mdatoms->typeA;
110 /* Setup water-specific parameters */
111 inr = nlist->iinr[0];
112 iq1 = facel*charge[inr+1];
113 iq2 = facel*charge[inr+2];
114 iq3 = facel*charge[inr+3];
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];
147 ix3 = shX + x[i_coord_offset+DIM*3+XX];
148 iy3 = shY + x[i_coord_offset+DIM*3+YY];
149 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
164 /* Reset potential sums */
168 /* Start inner kernel loop */
169 for(jidx=j_index_start; jidx<j_index_end; jidx++)
171 /* Get j neighbor index, and coordinate index */
173 j_coord_offset = DIM*jnr;
175 /* load j atom coordinates */
176 jx0 = x[j_coord_offset+DIM*0+XX];
177 jy0 = x[j_coord_offset+DIM*0+YY];
178 jz0 = x[j_coord_offset+DIM*0+ZZ];
180 /* Calculate displacement vector */
194 /* Calculate squared distance and things based on it */
195 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
196 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
197 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
198 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
200 rinv00 = gmx_invsqrt(rsq00);
201 rinv10 = gmx_invsqrt(rsq10);
202 rinv20 = gmx_invsqrt(rsq20);
203 rinv30 = gmx_invsqrt(rsq30);
205 rinvsq00 = rinv00*rinv00;
206 rinvsq10 = rinv10*rinv10;
207 rinvsq20 = rinv20*rinv20;
208 rinvsq30 = rinv30*rinv30;
210 /* Load parameters for j particles */
212 vdwjidx0 = 3*vdwtype[jnr+0];
214 /**************************
215 * CALCULATE INTERACTIONS *
216 **************************/
220 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
221 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
222 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
224 /* BUCKINGHAM DISPERSION/REPULSION */
225 rinvsix = rinvsq00*rinvsq00*rinvsq00;
226 vvdw6 = c6_00*rinvsix;
228 vvdwexp = cexp1_00*exp(-br);
229 vvdw = vvdwexp - vvdw6*(1.0/6.0);
230 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
232 /* Update potential sums from outer loop */
237 /* Calculate temporary vectorial force */
242 /* Update vectorial force */
246 f[j_coord_offset+DIM*0+XX] -= tx;
247 f[j_coord_offset+DIM*0+YY] -= ty;
248 f[j_coord_offset+DIM*0+ZZ] -= tz;
250 /**************************
251 * CALCULATE INTERACTIONS *
252 **************************/
256 /* COULOMB ELECTROSTATICS */
258 felec = velec*rinvsq10;
260 /* Update potential sums from outer loop */
265 /* Calculate temporary vectorial force */
270 /* Update vectorial force */
274 f[j_coord_offset+DIM*0+XX] -= tx;
275 f[j_coord_offset+DIM*0+YY] -= ty;
276 f[j_coord_offset+DIM*0+ZZ] -= tz;
278 /**************************
279 * CALCULATE INTERACTIONS *
280 **************************/
284 /* COULOMB ELECTROSTATICS */
286 felec = velec*rinvsq20;
288 /* Update potential sums from outer loop */
293 /* Calculate temporary vectorial force */
298 /* Update vectorial force */
302 f[j_coord_offset+DIM*0+XX] -= tx;
303 f[j_coord_offset+DIM*0+YY] -= ty;
304 f[j_coord_offset+DIM*0+ZZ] -= tz;
306 /**************************
307 * CALCULATE INTERACTIONS *
308 **************************/
312 /* COULOMB ELECTROSTATICS */
314 felec = velec*rinvsq30;
316 /* Update potential sums from outer loop */
321 /* Calculate temporary vectorial force */
326 /* Update vectorial force */
330 f[j_coord_offset+DIM*0+XX] -= tx;
331 f[j_coord_offset+DIM*0+YY] -= ty;
332 f[j_coord_offset+DIM*0+ZZ] -= tz;
334 /* Inner loop uses 145 flops */
336 /* End of innermost loop */
339 f[i_coord_offset+DIM*0+XX] += fix0;
340 f[i_coord_offset+DIM*0+YY] += fiy0;
341 f[i_coord_offset+DIM*0+ZZ] += fiz0;
345 f[i_coord_offset+DIM*1+XX] += fix1;
346 f[i_coord_offset+DIM*1+YY] += fiy1;
347 f[i_coord_offset+DIM*1+ZZ] += fiz1;
351 f[i_coord_offset+DIM*2+XX] += fix2;
352 f[i_coord_offset+DIM*2+YY] += fiy2;
353 f[i_coord_offset+DIM*2+ZZ] += fiz2;
357 f[i_coord_offset+DIM*3+XX] += fix3;
358 f[i_coord_offset+DIM*3+YY] += fiy3;
359 f[i_coord_offset+DIM*3+ZZ] += fiz3;
363 fshift[i_shift_offset+XX] += tx;
364 fshift[i_shift_offset+YY] += ty;
365 fshift[i_shift_offset+ZZ] += tz;
368 /* Update potential energies */
369 kernel_data->energygrp_elec[ggid] += velecsum;
370 kernel_data->energygrp_vdw[ggid] += vvdwsum;
372 /* Increment number of inner iterations */
373 inneriter += j_index_end - j_index_start;
375 /* Outer loop uses 41 flops */
378 /* Increment number of outer iterations */
381 /* Update outer/inner flops */
383 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*145);
386 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW4P1_F_c
387 * Electrostatics interaction: Coulomb
388 * VdW interaction: Buckingham
389 * Geometry: Water4-Particle
390 * Calculate force/pot: Force
393 nb_kernel_ElecCoul_VdwBham_GeomW4P1_F_c
394 (t_nblist * gmx_restrict nlist,
395 rvec * gmx_restrict xx,
396 rvec * gmx_restrict ff,
397 t_forcerec * gmx_restrict fr,
398 t_mdatoms * gmx_restrict mdatoms,
399 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
400 t_nrnb * gmx_restrict nrnb)
402 int i_shift_offset,i_coord_offset,j_coord_offset;
403 int j_index_start,j_index_end;
404 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
405 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
406 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
407 real *shiftvec,*fshift,*x,*f;
409 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
411 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
413 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
415 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
417 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
418 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
419 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
420 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
421 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
422 real velec,felec,velecsum,facel,crf,krf,krf2;
425 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
434 jindex = nlist->jindex;
436 shiftidx = nlist->shift;
438 shiftvec = fr->shift_vec[0];
439 fshift = fr->fshift[0];
441 charge = mdatoms->chargeA;
442 nvdwtype = fr->ntype;
444 vdwtype = mdatoms->typeA;
446 /* Setup water-specific parameters */
447 inr = nlist->iinr[0];
448 iq1 = facel*charge[inr+1];
449 iq2 = facel*charge[inr+2];
450 iq3 = facel*charge[inr+3];
451 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
456 /* Start outer loop over neighborlists */
457 for(iidx=0; iidx<nri; iidx++)
459 /* Load shift vector for this list */
460 i_shift_offset = DIM*shiftidx[iidx];
461 shX = shiftvec[i_shift_offset+XX];
462 shY = shiftvec[i_shift_offset+YY];
463 shZ = shiftvec[i_shift_offset+ZZ];
465 /* Load limits for loop over neighbors */
466 j_index_start = jindex[iidx];
467 j_index_end = jindex[iidx+1];
469 /* Get outer coordinate index */
471 i_coord_offset = DIM*inr;
473 /* Load i particle coords and add shift vector */
474 ix0 = shX + x[i_coord_offset+DIM*0+XX];
475 iy0 = shY + x[i_coord_offset+DIM*0+YY];
476 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
477 ix1 = shX + x[i_coord_offset+DIM*1+XX];
478 iy1 = shY + x[i_coord_offset+DIM*1+YY];
479 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
480 ix2 = shX + x[i_coord_offset+DIM*2+XX];
481 iy2 = shY + x[i_coord_offset+DIM*2+YY];
482 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
483 ix3 = shX + x[i_coord_offset+DIM*3+XX];
484 iy3 = shY + x[i_coord_offset+DIM*3+YY];
485 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
500 /* Start inner kernel loop */
501 for(jidx=j_index_start; jidx<j_index_end; jidx++)
503 /* Get j neighbor index, and coordinate index */
505 j_coord_offset = DIM*jnr;
507 /* load j atom coordinates */
508 jx0 = x[j_coord_offset+DIM*0+XX];
509 jy0 = x[j_coord_offset+DIM*0+YY];
510 jz0 = x[j_coord_offset+DIM*0+ZZ];
512 /* Calculate displacement vector */
526 /* Calculate squared distance and things based on it */
527 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
528 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
529 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
530 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
532 rinv00 = gmx_invsqrt(rsq00);
533 rinv10 = gmx_invsqrt(rsq10);
534 rinv20 = gmx_invsqrt(rsq20);
535 rinv30 = gmx_invsqrt(rsq30);
537 rinvsq00 = rinv00*rinv00;
538 rinvsq10 = rinv10*rinv10;
539 rinvsq20 = rinv20*rinv20;
540 rinvsq30 = rinv30*rinv30;
542 /* Load parameters for j particles */
544 vdwjidx0 = 3*vdwtype[jnr+0];
546 /**************************
547 * CALCULATE INTERACTIONS *
548 **************************/
552 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
553 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
554 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
556 /* BUCKINGHAM DISPERSION/REPULSION */
557 rinvsix = rinvsq00*rinvsq00*rinvsq00;
558 vvdw6 = c6_00*rinvsix;
560 vvdwexp = cexp1_00*exp(-br);
561 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
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 /**************************
579 * CALCULATE INTERACTIONS *
580 **************************/
584 /* COULOMB ELECTROSTATICS */
586 felec = velec*rinvsq10;
590 /* Calculate temporary vectorial force */
595 /* Update vectorial force */
599 f[j_coord_offset+DIM*0+XX] -= tx;
600 f[j_coord_offset+DIM*0+YY] -= ty;
601 f[j_coord_offset+DIM*0+ZZ] -= tz;
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
609 /* COULOMB ELECTROSTATICS */
611 felec = velec*rinvsq20;
615 /* Calculate temporary vectorial force */
620 /* Update vectorial force */
624 f[j_coord_offset+DIM*0+XX] -= tx;
625 f[j_coord_offset+DIM*0+YY] -= ty;
626 f[j_coord_offset+DIM*0+ZZ] -= tz;
628 /**************************
629 * CALCULATE INTERACTIONS *
630 **************************/
634 /* COULOMB ELECTROSTATICS */
636 felec = velec*rinvsq30;
640 /* Calculate temporary vectorial force */
645 /* Update vectorial force */
649 f[j_coord_offset+DIM*0+XX] -= tx;
650 f[j_coord_offset+DIM*0+YY] -= ty;
651 f[j_coord_offset+DIM*0+ZZ] -= tz;
653 /* Inner loop uses 139 flops */
655 /* End of innermost loop */
658 f[i_coord_offset+DIM*0+XX] += fix0;
659 f[i_coord_offset+DIM*0+YY] += fiy0;
660 f[i_coord_offset+DIM*0+ZZ] += fiz0;
664 f[i_coord_offset+DIM*1+XX] += fix1;
665 f[i_coord_offset+DIM*1+YY] += fiy1;
666 f[i_coord_offset+DIM*1+ZZ] += fiz1;
670 f[i_coord_offset+DIM*2+XX] += fix2;
671 f[i_coord_offset+DIM*2+YY] += fiy2;
672 f[i_coord_offset+DIM*2+ZZ] += fiz2;
676 f[i_coord_offset+DIM*3+XX] += fix3;
677 f[i_coord_offset+DIM*3+YY] += fiy3;
678 f[i_coord_offset+DIM*3+ZZ] += fiz3;
682 fshift[i_shift_offset+XX] += tx;
683 fshift[i_shift_offset+YY] += ty;
684 fshift[i_shift_offset+ZZ] += tz;
686 /* Increment number of inner iterations */
687 inneriter += j_index_end - j_index_start;
689 /* Outer loop uses 39 flops */
692 /* Increment number of outer iterations */
695 /* Update outer/inner flops */
697 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*139);