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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW4P1_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: Buckingham
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwBham_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
84 real velec,felec,velecsum,facel,crf,krf,krf2;
87 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
96 jindex = nlist->jindex;
98 shiftidx = nlist->shift;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
103 charge = mdatoms->chargeA;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 iq3 = facel*charge[inr+3];
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];
145 ix3 = shX + x[i_coord_offset+DIM*3+XX];
146 iy3 = shY + x[i_coord_offset+DIM*3+YY];
147 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
162 /* Reset potential sums */
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end; jidx++)
169 /* Get j neighbor index, and coordinate index */
171 j_coord_offset = DIM*jnr;
173 /* load j atom coordinates */
174 jx0 = x[j_coord_offset+DIM*0+XX];
175 jy0 = x[j_coord_offset+DIM*0+YY];
176 jz0 = x[j_coord_offset+DIM*0+ZZ];
178 /* 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;
196 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
198 rinv00 = gmx_invsqrt(rsq00);
199 rinv10 = gmx_invsqrt(rsq10);
200 rinv20 = gmx_invsqrt(rsq20);
201 rinv30 = gmx_invsqrt(rsq30);
203 rinvsq00 = rinv00*rinv00;
204 rinvsq10 = rinv10*rinv10;
205 rinvsq20 = rinv20*rinv20;
206 rinvsq30 = rinv30*rinv30;
208 /* Load parameters for j particles */
210 vdwjidx0 = 3*vdwtype[jnr+0];
212 /**************************
213 * CALCULATE INTERACTIONS *
214 **************************/
218 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
219 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
220 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
222 /* BUCKINGHAM DISPERSION/REPULSION */
223 rinvsix = rinvsq00*rinvsq00*rinvsq00;
224 vvdw6 = c6_00*rinvsix;
226 vvdwexp = cexp1_00*exp(-br);
227 vvdw = vvdwexp - vvdw6*(1.0/6.0);
228 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
230 /* Update potential sums from outer loop */
235 /* Calculate temporary vectorial force */
240 /* Update vectorial force */
244 f[j_coord_offset+DIM*0+XX] -= tx;
245 f[j_coord_offset+DIM*0+YY] -= ty;
246 f[j_coord_offset+DIM*0+ZZ] -= tz;
248 /**************************
249 * CALCULATE INTERACTIONS *
250 **************************/
254 /* COULOMB ELECTROSTATICS */
256 felec = velec*rinvsq10;
258 /* Update potential sums from outer loop */
263 /* Calculate temporary vectorial force */
268 /* Update vectorial force */
272 f[j_coord_offset+DIM*0+XX] -= tx;
273 f[j_coord_offset+DIM*0+YY] -= ty;
274 f[j_coord_offset+DIM*0+ZZ] -= tz;
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
282 /* COULOMB ELECTROSTATICS */
284 felec = velec*rinvsq20;
286 /* Update potential sums from outer loop */
291 /* Calculate temporary vectorial force */
296 /* Update vectorial force */
300 f[j_coord_offset+DIM*0+XX] -= tx;
301 f[j_coord_offset+DIM*0+YY] -= ty;
302 f[j_coord_offset+DIM*0+ZZ] -= tz;
304 /**************************
305 * CALCULATE INTERACTIONS *
306 **************************/
310 /* COULOMB ELECTROSTATICS */
312 felec = velec*rinvsq30;
314 /* Update potential sums from outer loop */
319 /* Calculate temporary vectorial force */
324 /* Update vectorial force */
328 f[j_coord_offset+DIM*0+XX] -= tx;
329 f[j_coord_offset+DIM*0+YY] -= ty;
330 f[j_coord_offset+DIM*0+ZZ] -= tz;
332 /* Inner loop uses 145 flops */
334 /* End of innermost loop */
337 f[i_coord_offset+DIM*0+XX] += fix0;
338 f[i_coord_offset+DIM*0+YY] += fiy0;
339 f[i_coord_offset+DIM*0+ZZ] += fiz0;
343 f[i_coord_offset+DIM*1+XX] += fix1;
344 f[i_coord_offset+DIM*1+YY] += fiy1;
345 f[i_coord_offset+DIM*1+ZZ] += fiz1;
349 f[i_coord_offset+DIM*2+XX] += fix2;
350 f[i_coord_offset+DIM*2+YY] += fiy2;
351 f[i_coord_offset+DIM*2+ZZ] += fiz2;
355 f[i_coord_offset+DIM*3+XX] += fix3;
356 f[i_coord_offset+DIM*3+YY] += fiy3;
357 f[i_coord_offset+DIM*3+ZZ] += fiz3;
361 fshift[i_shift_offset+XX] += tx;
362 fshift[i_shift_offset+YY] += ty;
363 fshift[i_shift_offset+ZZ] += tz;
366 /* Update potential energies */
367 kernel_data->energygrp_elec[ggid] += velecsum;
368 kernel_data->energygrp_vdw[ggid] += vvdwsum;
370 /* Increment number of inner iterations */
371 inneriter += j_index_end - j_index_start;
373 /* Outer loop uses 41 flops */
376 /* Increment number of outer iterations */
379 /* Update outer/inner flops */
381 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*145);
384 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW4P1_F_c
385 * Electrostatics interaction: Coulomb
386 * VdW interaction: Buckingham
387 * Geometry: Water4-Particle
388 * Calculate force/pot: Force
391 nb_kernel_ElecCoul_VdwBham_GeomW4P1_F_c
392 (t_nblist * gmx_restrict nlist,
393 rvec * gmx_restrict xx,
394 rvec * gmx_restrict ff,
395 t_forcerec * gmx_restrict fr,
396 t_mdatoms * gmx_restrict mdatoms,
397 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
398 t_nrnb * gmx_restrict nrnb)
400 int i_shift_offset,i_coord_offset,j_coord_offset;
401 int j_index_start,j_index_end;
402 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
403 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
404 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
405 real *shiftvec,*fshift,*x,*f;
407 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
409 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
411 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
413 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
415 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
416 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
417 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
418 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
419 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
420 real velec,felec,velecsum,facel,crf,krf,krf2;
423 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
432 jindex = nlist->jindex;
434 shiftidx = nlist->shift;
436 shiftvec = fr->shift_vec[0];
437 fshift = fr->fshift[0];
439 charge = mdatoms->chargeA;
440 nvdwtype = fr->ntype;
442 vdwtype = mdatoms->typeA;
444 /* Setup water-specific parameters */
445 inr = nlist->iinr[0];
446 iq1 = facel*charge[inr+1];
447 iq2 = facel*charge[inr+2];
448 iq3 = facel*charge[inr+3];
449 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
454 /* Start outer loop over neighborlists */
455 for(iidx=0; iidx<nri; iidx++)
457 /* Load shift vector for this list */
458 i_shift_offset = DIM*shiftidx[iidx];
459 shX = shiftvec[i_shift_offset+XX];
460 shY = shiftvec[i_shift_offset+YY];
461 shZ = shiftvec[i_shift_offset+ZZ];
463 /* Load limits for loop over neighbors */
464 j_index_start = jindex[iidx];
465 j_index_end = jindex[iidx+1];
467 /* Get outer coordinate index */
469 i_coord_offset = DIM*inr;
471 /* Load i particle coords and add shift vector */
472 ix0 = shX + x[i_coord_offset+DIM*0+XX];
473 iy0 = shY + x[i_coord_offset+DIM*0+YY];
474 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
475 ix1 = shX + x[i_coord_offset+DIM*1+XX];
476 iy1 = shY + x[i_coord_offset+DIM*1+YY];
477 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
478 ix2 = shX + x[i_coord_offset+DIM*2+XX];
479 iy2 = shY + x[i_coord_offset+DIM*2+YY];
480 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
481 ix3 = shX + x[i_coord_offset+DIM*3+XX];
482 iy3 = shY + x[i_coord_offset+DIM*3+YY];
483 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
498 /* Start inner kernel loop */
499 for(jidx=j_index_start; jidx<j_index_end; jidx++)
501 /* Get j neighbor index, and coordinate index */
503 j_coord_offset = DIM*jnr;
505 /* load j atom coordinates */
506 jx0 = x[j_coord_offset+DIM*0+XX];
507 jy0 = x[j_coord_offset+DIM*0+YY];
508 jz0 = x[j_coord_offset+DIM*0+ZZ];
510 /* Calculate displacement vector */
524 /* Calculate squared distance and things based on it */
525 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
526 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
527 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
528 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
530 rinv00 = gmx_invsqrt(rsq00);
531 rinv10 = gmx_invsqrt(rsq10);
532 rinv20 = gmx_invsqrt(rsq20);
533 rinv30 = gmx_invsqrt(rsq30);
535 rinvsq00 = rinv00*rinv00;
536 rinvsq10 = rinv10*rinv10;
537 rinvsq20 = rinv20*rinv20;
538 rinvsq30 = rinv30*rinv30;
540 /* Load parameters for j particles */
542 vdwjidx0 = 3*vdwtype[jnr+0];
544 /**************************
545 * CALCULATE INTERACTIONS *
546 **************************/
550 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
551 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
552 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
554 /* BUCKINGHAM DISPERSION/REPULSION */
555 rinvsix = rinvsq00*rinvsq00*rinvsq00;
556 vvdw6 = c6_00*rinvsix;
558 vvdwexp = cexp1_00*exp(-br);
559 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
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 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
582 /* COULOMB ELECTROSTATICS */
584 felec = velec*rinvsq10;
588 /* Calculate temporary vectorial force */
593 /* Update vectorial force */
597 f[j_coord_offset+DIM*0+XX] -= tx;
598 f[j_coord_offset+DIM*0+YY] -= ty;
599 f[j_coord_offset+DIM*0+ZZ] -= tz;
601 /**************************
602 * CALCULATE INTERACTIONS *
603 **************************/
607 /* COULOMB ELECTROSTATICS */
609 felec = velec*rinvsq20;
613 /* Calculate temporary vectorial force */
618 /* Update vectorial force */
622 f[j_coord_offset+DIM*0+XX] -= tx;
623 f[j_coord_offset+DIM*0+YY] -= ty;
624 f[j_coord_offset+DIM*0+ZZ] -= tz;
626 /**************************
627 * CALCULATE INTERACTIONS *
628 **************************/
632 /* COULOMB ELECTROSTATICS */
634 felec = velec*rinvsq30;
638 /* Calculate temporary vectorial force */
643 /* Update vectorial force */
647 f[j_coord_offset+DIM*0+XX] -= tx;
648 f[j_coord_offset+DIM*0+YY] -= ty;
649 f[j_coord_offset+DIM*0+ZZ] -= tz;
651 /* Inner loop uses 139 flops */
653 /* End of innermost loop */
656 f[i_coord_offset+DIM*0+XX] += fix0;
657 f[i_coord_offset+DIM*0+YY] += fiy0;
658 f[i_coord_offset+DIM*0+ZZ] += fiz0;
662 f[i_coord_offset+DIM*1+XX] += fix1;
663 f[i_coord_offset+DIM*1+YY] += fiy1;
664 f[i_coord_offset+DIM*1+ZZ] += fiz1;
668 f[i_coord_offset+DIM*2+XX] += fix2;
669 f[i_coord_offset+DIM*2+YY] += fiy2;
670 f[i_coord_offset+DIM*2+ZZ] += fiz2;
674 f[i_coord_offset+DIM*3+XX] += fix3;
675 f[i_coord_offset+DIM*3+YY] += fiy3;
676 f[i_coord_offset+DIM*3+ZZ] += fiz3;
680 fshift[i_shift_offset+XX] += tx;
681 fshift[i_shift_offset+YY] += ty;
682 fshift[i_shift_offset+ZZ] += tz;
684 /* Increment number of inner iterations */
685 inneriter += j_index_end - j_index_start;
687 /* Outer loop uses 39 flops */
690 /* Increment number of outer iterations */
693 /* Update outer/inner flops */
695 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*139);