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_ElecCoul_VdwBham_GeomW3P1_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: Buckingham
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_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;
103 nvdwtype = fr->ntype;
105 vdwtype = mdatoms->typeA;
107 /* Setup water-specific parameters */
108 inr = nlist->iinr[0];
109 iq0 = facel*charge[inr+0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
117 /* Start outer loop over neighborlists */
118 for(iidx=0; iidx<nri; iidx++)
120 /* Load shift vector for this list */
121 i_shift_offset = DIM*shiftidx[iidx];
122 shX = shiftvec[i_shift_offset+XX];
123 shY = shiftvec[i_shift_offset+YY];
124 shZ = shiftvec[i_shift_offset+ZZ];
126 /* Load limits for loop over neighbors */
127 j_index_start = jindex[iidx];
128 j_index_end = jindex[iidx+1];
130 /* Get outer coordinate index */
132 i_coord_offset = DIM*inr;
134 /* Load i particle coords and add shift vector */
135 ix0 = shX + x[i_coord_offset+DIM*0+XX];
136 iy0 = shY + x[i_coord_offset+DIM*0+YY];
137 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
138 ix1 = shX + x[i_coord_offset+DIM*1+XX];
139 iy1 = shY + x[i_coord_offset+DIM*1+YY];
140 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
141 ix2 = shX + x[i_coord_offset+DIM*2+XX];
142 iy2 = shY + x[i_coord_offset+DIM*2+YY];
143 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
155 /* Reset potential sums */
159 /* Start inner kernel loop */
160 for(jidx=j_index_start; jidx<j_index_end; jidx++)
162 /* Get j neighbor index, and coordinate index */
164 j_coord_offset = DIM*jnr;
166 /* load j atom coordinates */
167 jx0 = x[j_coord_offset+DIM*0+XX];
168 jy0 = x[j_coord_offset+DIM*0+YY];
169 jz0 = x[j_coord_offset+DIM*0+ZZ];
171 /* Calculate displacement vector */
182 /* Calculate squared distance and things based on it */
183 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
184 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
185 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
187 rinv00 = gmx_invsqrt(rsq00);
188 rinv10 = gmx_invsqrt(rsq10);
189 rinv20 = gmx_invsqrt(rsq20);
191 rinvsq00 = rinv00*rinv00;
192 rinvsq10 = rinv10*rinv10;
193 rinvsq20 = rinv20*rinv20;
195 /* Load parameters for j particles */
197 vdwjidx0 = 3*vdwtype[jnr+0];
199 /**************************
200 * CALCULATE INTERACTIONS *
201 **************************/
206 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
207 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
208 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
210 /* COULOMB ELECTROSTATICS */
212 felec = velec*rinvsq00;
214 /* BUCKINGHAM DISPERSION/REPULSION */
215 rinvsix = rinvsq00*rinvsq00*rinvsq00;
216 vvdw6 = c6_00*rinvsix;
218 vvdwexp = cexp1_00*exp(-br);
219 vvdw = vvdwexp - vvdw6*(1.0/6.0);
220 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
222 /* Update potential sums from outer loop */
228 /* Calculate temporary vectorial force */
233 /* Update vectorial force */
237 f[j_coord_offset+DIM*0+XX] -= tx;
238 f[j_coord_offset+DIM*0+YY] -= ty;
239 f[j_coord_offset+DIM*0+ZZ] -= tz;
241 /**************************
242 * CALCULATE INTERACTIONS *
243 **************************/
247 /* COULOMB ELECTROSTATICS */
249 felec = velec*rinvsq10;
251 /* Update potential sums from outer loop */
256 /* Calculate temporary vectorial force */
261 /* Update vectorial force */
265 f[j_coord_offset+DIM*0+XX] -= tx;
266 f[j_coord_offset+DIM*0+YY] -= ty;
267 f[j_coord_offset+DIM*0+ZZ] -= tz;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
275 /* COULOMB ELECTROSTATICS */
277 felec = velec*rinvsq20;
279 /* Update potential sums from outer loop */
284 /* Calculate temporary vectorial force */
289 /* Update vectorial force */
293 f[j_coord_offset+DIM*0+XX] -= tx;
294 f[j_coord_offset+DIM*0+YY] -= ty;
295 f[j_coord_offset+DIM*0+ZZ] -= tz;
297 /* Inner loop uses 123 flops */
299 /* End of innermost loop */
302 f[i_coord_offset+DIM*0+XX] += fix0;
303 f[i_coord_offset+DIM*0+YY] += fiy0;
304 f[i_coord_offset+DIM*0+ZZ] += fiz0;
308 f[i_coord_offset+DIM*1+XX] += fix1;
309 f[i_coord_offset+DIM*1+YY] += fiy1;
310 f[i_coord_offset+DIM*1+ZZ] += fiz1;
314 f[i_coord_offset+DIM*2+XX] += fix2;
315 f[i_coord_offset+DIM*2+YY] += fiy2;
316 f[i_coord_offset+DIM*2+ZZ] += fiz2;
320 fshift[i_shift_offset+XX] += tx;
321 fshift[i_shift_offset+YY] += ty;
322 fshift[i_shift_offset+ZZ] += tz;
325 /* Update potential energies */
326 kernel_data->energygrp_elec[ggid] += velecsum;
327 kernel_data->energygrp_vdw[ggid] += vvdwsum;
329 /* Increment number of inner iterations */
330 inneriter += j_index_end - j_index_start;
332 /* Outer loop uses 32 flops */
335 /* Increment number of outer iterations */
338 /* Update outer/inner flops */
340 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*123);
343 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW3P1_F_c
344 * Electrostatics interaction: Coulomb
345 * VdW interaction: Buckingham
346 * Geometry: Water3-Particle
347 * Calculate force/pot: Force
350 nb_kernel_ElecCoul_VdwBham_GeomW3P1_F_c
351 (t_nblist * gmx_restrict nlist,
352 rvec * gmx_restrict xx,
353 rvec * gmx_restrict ff,
354 t_forcerec * gmx_restrict fr,
355 t_mdatoms * gmx_restrict mdatoms,
356 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
357 t_nrnb * gmx_restrict nrnb)
359 int i_shift_offset,i_coord_offset,j_coord_offset;
360 int j_index_start,j_index_end;
361 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
362 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
363 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
364 real *shiftvec,*fshift,*x,*f;
366 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
368 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
370 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
372 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
373 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
374 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
375 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
376 real velec,felec,velecsum,facel,crf,krf,krf2;
379 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
388 jindex = nlist->jindex;
390 shiftidx = nlist->shift;
392 shiftvec = fr->shift_vec[0];
393 fshift = fr->fshift[0];
395 charge = mdatoms->chargeA;
396 nvdwtype = fr->ntype;
398 vdwtype = mdatoms->typeA;
400 /* Setup water-specific parameters */
401 inr = nlist->iinr[0];
402 iq0 = facel*charge[inr+0];
403 iq1 = facel*charge[inr+1];
404 iq2 = facel*charge[inr+2];
405 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
410 /* Start outer loop over neighborlists */
411 for(iidx=0; iidx<nri; iidx++)
413 /* Load shift vector for this list */
414 i_shift_offset = DIM*shiftidx[iidx];
415 shX = shiftvec[i_shift_offset+XX];
416 shY = shiftvec[i_shift_offset+YY];
417 shZ = shiftvec[i_shift_offset+ZZ];
419 /* Load limits for loop over neighbors */
420 j_index_start = jindex[iidx];
421 j_index_end = jindex[iidx+1];
423 /* Get outer coordinate index */
425 i_coord_offset = DIM*inr;
427 /* Load i particle coords and add shift vector */
428 ix0 = shX + x[i_coord_offset+DIM*0+XX];
429 iy0 = shY + x[i_coord_offset+DIM*0+YY];
430 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
431 ix1 = shX + x[i_coord_offset+DIM*1+XX];
432 iy1 = shY + x[i_coord_offset+DIM*1+YY];
433 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
434 ix2 = shX + x[i_coord_offset+DIM*2+XX];
435 iy2 = shY + x[i_coord_offset+DIM*2+YY];
436 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
448 /* Start inner kernel loop */
449 for(jidx=j_index_start; jidx<j_index_end; jidx++)
451 /* Get j neighbor index, and coordinate index */
453 j_coord_offset = DIM*jnr;
455 /* load j atom coordinates */
456 jx0 = x[j_coord_offset+DIM*0+XX];
457 jy0 = x[j_coord_offset+DIM*0+YY];
458 jz0 = x[j_coord_offset+DIM*0+ZZ];
460 /* Calculate displacement vector */
471 /* Calculate squared distance and things based on it */
472 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
473 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
474 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
476 rinv00 = gmx_invsqrt(rsq00);
477 rinv10 = gmx_invsqrt(rsq10);
478 rinv20 = gmx_invsqrt(rsq20);
480 rinvsq00 = rinv00*rinv00;
481 rinvsq10 = rinv10*rinv10;
482 rinvsq20 = rinv20*rinv20;
484 /* Load parameters for j particles */
486 vdwjidx0 = 3*vdwtype[jnr+0];
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
495 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
496 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
497 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
499 /* COULOMB ELECTROSTATICS */
501 felec = velec*rinvsq00;
503 /* BUCKINGHAM DISPERSION/REPULSION */
504 rinvsix = rinvsq00*rinvsq00*rinvsq00;
505 vvdw6 = c6_00*rinvsix;
507 vvdwexp = cexp1_00*exp(-br);
508 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
512 /* Calculate temporary vectorial force */
517 /* Update vectorial force */
521 f[j_coord_offset+DIM*0+XX] -= tx;
522 f[j_coord_offset+DIM*0+YY] -= ty;
523 f[j_coord_offset+DIM*0+ZZ] -= tz;
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
531 /* COULOMB ELECTROSTATICS */
533 felec = velec*rinvsq10;
537 /* Calculate temporary vectorial force */
542 /* Update vectorial force */
546 f[j_coord_offset+DIM*0+XX] -= tx;
547 f[j_coord_offset+DIM*0+YY] -= ty;
548 f[j_coord_offset+DIM*0+ZZ] -= tz;
550 /**************************
551 * CALCULATE INTERACTIONS *
552 **************************/
556 /* COULOMB ELECTROSTATICS */
558 felec = velec*rinvsq20;
562 /* Calculate temporary vectorial force */
567 /* Update vectorial force */
571 f[j_coord_offset+DIM*0+XX] -= tx;
572 f[j_coord_offset+DIM*0+YY] -= ty;
573 f[j_coord_offset+DIM*0+ZZ] -= tz;
575 /* Inner loop uses 117 flops */
577 /* End of innermost loop */
580 f[i_coord_offset+DIM*0+XX] += fix0;
581 f[i_coord_offset+DIM*0+YY] += fiy0;
582 f[i_coord_offset+DIM*0+ZZ] += fiz0;
586 f[i_coord_offset+DIM*1+XX] += fix1;
587 f[i_coord_offset+DIM*1+YY] += fiy1;
588 f[i_coord_offset+DIM*1+ZZ] += fiz1;
592 f[i_coord_offset+DIM*2+XX] += fix2;
593 f[i_coord_offset+DIM*2+YY] += fiy2;
594 f[i_coord_offset+DIM*2+ZZ] += fiz2;
598 fshift[i_shift_offset+XX] += tx;
599 fshift[i_shift_offset+YY] += ty;
600 fshift[i_shift_offset+ZZ] += tz;
602 /* Increment number of inner iterations */
603 inneriter += j_index_end - j_index_start;
605 /* Outer loop uses 30 flops */
608 /* Increment number of outer iterations */
611 /* Update outer/inner flops */
613 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*117);