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 "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
84 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
93 jindex = nlist->jindex;
95 shiftidx = nlist->shift;
97 shiftvec = fr->shift_vec[0];
98 fshift = fr->fshift[0];
100 charge = mdatoms->chargeA;
101 nvdwtype = fr->ntype;
103 vdwtype = mdatoms->typeA;
105 /* Setup water-specific parameters */
106 inr = nlist->iinr[0];
107 iq0 = facel*charge[inr+0];
108 iq1 = facel*charge[inr+1];
109 iq2 = facel*charge[inr+2];
110 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
115 /* Start outer loop over neighborlists */
116 for(iidx=0; iidx<nri; iidx++)
118 /* Load shift vector for this list */
119 i_shift_offset = DIM*shiftidx[iidx];
120 shX = shiftvec[i_shift_offset+XX];
121 shY = shiftvec[i_shift_offset+YY];
122 shZ = shiftvec[i_shift_offset+ZZ];
124 /* Load limits for loop over neighbors */
125 j_index_start = jindex[iidx];
126 j_index_end = jindex[iidx+1];
128 /* Get outer coordinate index */
130 i_coord_offset = DIM*inr;
132 /* Load i particle coords and add shift vector */
133 ix0 = shX + x[i_coord_offset+DIM*0+XX];
134 iy0 = shY + x[i_coord_offset+DIM*0+YY];
135 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
136 ix1 = shX + x[i_coord_offset+DIM*1+XX];
137 iy1 = shY + x[i_coord_offset+DIM*1+YY];
138 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
139 ix2 = shX + x[i_coord_offset+DIM*2+XX];
140 iy2 = shY + x[i_coord_offset+DIM*2+YY];
141 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
153 /* Reset potential sums */
157 /* Start inner kernel loop */
158 for(jidx=j_index_start; jidx<j_index_end; jidx++)
160 /* Get j neighbor index, and coordinate index */
162 j_coord_offset = DIM*jnr;
164 /* load j atom coordinates */
165 jx0 = x[j_coord_offset+DIM*0+XX];
166 jy0 = x[j_coord_offset+DIM*0+YY];
167 jz0 = x[j_coord_offset+DIM*0+ZZ];
169 /* Calculate displacement vector */
180 /* Calculate squared distance and things based on it */
181 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
182 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
183 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
185 rinv00 = gmx_invsqrt(rsq00);
186 rinv10 = gmx_invsqrt(rsq10);
187 rinv20 = gmx_invsqrt(rsq20);
189 rinvsq00 = rinv00*rinv00;
190 rinvsq10 = rinv10*rinv10;
191 rinvsq20 = rinv20*rinv20;
193 /* Load parameters for j particles */
195 vdwjidx0 = 2*vdwtype[jnr+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
202 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
203 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
205 /* COULOMB ELECTROSTATICS */
207 felec = velec*rinvsq00;
209 /* LENNARD-JONES DISPERSION/REPULSION */
211 rinvsix = rinvsq00*rinvsq00*rinvsq00;
212 vvdw6 = c6_00*rinvsix;
213 vvdw12 = c12_00*rinvsix*rinvsix;
214 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
215 fvdw = (vvdw12-vvdw6)*rinvsq00;
217 /* Update potential sums from outer loop */
223 /* Calculate temporary vectorial force */
228 /* Update vectorial force */
232 f[j_coord_offset+DIM*0+XX] -= tx;
233 f[j_coord_offset+DIM*0+YY] -= ty;
234 f[j_coord_offset+DIM*0+ZZ] -= tz;
236 /**************************
237 * CALCULATE INTERACTIONS *
238 **************************/
242 /* COULOMB ELECTROSTATICS */
244 felec = velec*rinvsq10;
246 /* Update potential sums from outer loop */
251 /* Calculate temporary vectorial force */
256 /* Update vectorial force */
260 f[j_coord_offset+DIM*0+XX] -= tx;
261 f[j_coord_offset+DIM*0+YY] -= ty;
262 f[j_coord_offset+DIM*0+ZZ] -= tz;
264 /**************************
265 * CALCULATE INTERACTIONS *
266 **************************/
270 /* COULOMB ELECTROSTATICS */
272 felec = velec*rinvsq20;
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*0+XX] -= tx;
289 f[j_coord_offset+DIM*0+YY] -= ty;
290 f[j_coord_offset+DIM*0+ZZ] -= tz;
292 /* Inner loop uses 96 flops */
294 /* End of innermost loop */
297 f[i_coord_offset+DIM*0+XX] += fix0;
298 f[i_coord_offset+DIM*0+YY] += fiy0;
299 f[i_coord_offset+DIM*0+ZZ] += fiz0;
303 f[i_coord_offset+DIM*1+XX] += fix1;
304 f[i_coord_offset+DIM*1+YY] += fiy1;
305 f[i_coord_offset+DIM*1+ZZ] += fiz1;
309 f[i_coord_offset+DIM*2+XX] += fix2;
310 f[i_coord_offset+DIM*2+YY] += fiy2;
311 f[i_coord_offset+DIM*2+ZZ] += fiz2;
315 fshift[i_shift_offset+XX] += tx;
316 fshift[i_shift_offset+YY] += ty;
317 fshift[i_shift_offset+ZZ] += tz;
320 /* Update potential energies */
321 kernel_data->energygrp_elec[ggid] += velecsum;
322 kernel_data->energygrp_vdw[ggid] += vvdwsum;
324 /* Increment number of inner iterations */
325 inneriter += j_index_end - j_index_start;
327 /* Outer loop uses 32 flops */
330 /* Increment number of outer iterations */
333 /* Update outer/inner flops */
335 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*96);
338 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_c
339 * Electrostatics interaction: Coulomb
340 * VdW interaction: LennardJones
341 * Geometry: Water3-Particle
342 * Calculate force/pot: Force
345 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_c
346 (t_nblist * gmx_restrict nlist,
347 rvec * gmx_restrict xx,
348 rvec * gmx_restrict ff,
349 t_forcerec * gmx_restrict fr,
350 t_mdatoms * gmx_restrict mdatoms,
351 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
352 t_nrnb * gmx_restrict nrnb)
354 int i_shift_offset,i_coord_offset,j_coord_offset;
355 int j_index_start,j_index_end;
356 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
357 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
358 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
359 real *shiftvec,*fshift,*x,*f;
361 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
363 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
365 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
367 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
368 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
369 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
370 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
371 real velec,felec,velecsum,facel,crf,krf,krf2;
374 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
383 jindex = nlist->jindex;
385 shiftidx = nlist->shift;
387 shiftvec = fr->shift_vec[0];
388 fshift = fr->fshift[0];
390 charge = mdatoms->chargeA;
391 nvdwtype = fr->ntype;
393 vdwtype = mdatoms->typeA;
395 /* Setup water-specific parameters */
396 inr = nlist->iinr[0];
397 iq0 = facel*charge[inr+0];
398 iq1 = facel*charge[inr+1];
399 iq2 = facel*charge[inr+2];
400 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
405 /* Start outer loop over neighborlists */
406 for(iidx=0; iidx<nri; iidx++)
408 /* Load shift vector for this list */
409 i_shift_offset = DIM*shiftidx[iidx];
410 shX = shiftvec[i_shift_offset+XX];
411 shY = shiftvec[i_shift_offset+YY];
412 shZ = shiftvec[i_shift_offset+ZZ];
414 /* Load limits for loop over neighbors */
415 j_index_start = jindex[iidx];
416 j_index_end = jindex[iidx+1];
418 /* Get outer coordinate index */
420 i_coord_offset = DIM*inr;
422 /* Load i particle coords and add shift vector */
423 ix0 = shX + x[i_coord_offset+DIM*0+XX];
424 iy0 = shY + x[i_coord_offset+DIM*0+YY];
425 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
426 ix1 = shX + x[i_coord_offset+DIM*1+XX];
427 iy1 = shY + x[i_coord_offset+DIM*1+YY];
428 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
429 ix2 = shX + x[i_coord_offset+DIM*2+XX];
430 iy2 = shY + x[i_coord_offset+DIM*2+YY];
431 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
443 /* Start inner kernel loop */
444 for(jidx=j_index_start; jidx<j_index_end; jidx++)
446 /* Get j neighbor index, and coordinate index */
448 j_coord_offset = DIM*jnr;
450 /* load j atom coordinates */
451 jx0 = x[j_coord_offset+DIM*0+XX];
452 jy0 = x[j_coord_offset+DIM*0+YY];
453 jz0 = x[j_coord_offset+DIM*0+ZZ];
455 /* Calculate displacement vector */
466 /* Calculate squared distance and things based on it */
467 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
468 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
469 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
471 rinv00 = gmx_invsqrt(rsq00);
472 rinv10 = gmx_invsqrt(rsq10);
473 rinv20 = gmx_invsqrt(rsq20);
475 rinvsq00 = rinv00*rinv00;
476 rinvsq10 = rinv10*rinv10;
477 rinvsq20 = rinv20*rinv20;
479 /* Load parameters for j particles */
481 vdwjidx0 = 2*vdwtype[jnr+0];
483 /**************************
484 * CALCULATE INTERACTIONS *
485 **************************/
488 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
489 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
491 /* COULOMB ELECTROSTATICS */
493 felec = velec*rinvsq00;
495 /* LENNARD-JONES DISPERSION/REPULSION */
497 rinvsix = rinvsq00*rinvsq00*rinvsq00;
498 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
502 /* Calculate temporary vectorial force */
507 /* Update vectorial force */
511 f[j_coord_offset+DIM*0+XX] -= tx;
512 f[j_coord_offset+DIM*0+YY] -= ty;
513 f[j_coord_offset+DIM*0+ZZ] -= tz;
515 /**************************
516 * CALCULATE INTERACTIONS *
517 **************************/
521 /* COULOMB ELECTROSTATICS */
523 felec = velec*rinvsq10;
527 /* Calculate temporary vectorial force */
532 /* Update vectorial force */
536 f[j_coord_offset+DIM*0+XX] -= tx;
537 f[j_coord_offset+DIM*0+YY] -= ty;
538 f[j_coord_offset+DIM*0+ZZ] -= tz;
540 /**************************
541 * CALCULATE INTERACTIONS *
542 **************************/
546 /* COULOMB ELECTROSTATICS */
548 felec = velec*rinvsq20;
552 /* Calculate temporary vectorial force */
557 /* Update vectorial force */
561 f[j_coord_offset+DIM*0+XX] -= tx;
562 f[j_coord_offset+DIM*0+YY] -= ty;
563 f[j_coord_offset+DIM*0+ZZ] -= tz;
565 /* Inner loop uses 88 flops */
567 /* End of innermost loop */
570 f[i_coord_offset+DIM*0+XX] += fix0;
571 f[i_coord_offset+DIM*0+YY] += fiy0;
572 f[i_coord_offset+DIM*0+ZZ] += fiz0;
576 f[i_coord_offset+DIM*1+XX] += fix1;
577 f[i_coord_offset+DIM*1+YY] += fiy1;
578 f[i_coord_offset+DIM*1+ZZ] += fiz1;
582 f[i_coord_offset+DIM*2+XX] += fix2;
583 f[i_coord_offset+DIM*2+YY] += fiy2;
584 f[i_coord_offset+DIM*2+ZZ] += fiz2;
588 fshift[i_shift_offset+XX] += tx;
589 fshift[i_shift_offset+YY] += ty;
590 fshift[i_shift_offset+ZZ] += tz;
592 /* Increment number of inner iterations */
593 inneriter += j_index_end - j_index_start;
595 /* Outer loop uses 30 flops */
598 /* Increment number of outer iterations */
601 /* Update outer/inner flops */
603 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*88);