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_ElecRFCut_VdwLJSh_GeomW3P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwLJSh_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;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq0 = facel*charge[inr+0];
111 iq1 = facel*charge[inr+1];
112 iq2 = facel*charge[inr+2];
113 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
115 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
116 rcutoff = fr->rcoulomb;
117 rcutoff2 = rcutoff*rcutoff;
119 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
125 /* Start outer loop over neighborlists */
126 for(iidx=0; iidx<nri; iidx++)
128 /* Load shift vector for this list */
129 i_shift_offset = DIM*shiftidx[iidx];
130 shX = shiftvec[i_shift_offset+XX];
131 shY = shiftvec[i_shift_offset+YY];
132 shZ = shiftvec[i_shift_offset+ZZ];
134 /* Load limits for loop over neighbors */
135 j_index_start = jindex[iidx];
136 j_index_end = jindex[iidx+1];
138 /* Get outer coordinate index */
140 i_coord_offset = DIM*inr;
142 /* Load i particle coords and add shift vector */
143 ix0 = shX + x[i_coord_offset+DIM*0+XX];
144 iy0 = shY + x[i_coord_offset+DIM*0+YY];
145 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
146 ix1 = shX + x[i_coord_offset+DIM*1+XX];
147 iy1 = shY + x[i_coord_offset+DIM*1+YY];
148 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
149 ix2 = shX + x[i_coord_offset+DIM*2+XX];
150 iy2 = shY + x[i_coord_offset+DIM*2+YY];
151 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
163 /* Reset potential sums */
167 /* Start inner kernel loop */
168 for(jidx=j_index_start; jidx<j_index_end; jidx++)
170 /* Get j neighbor index, and coordinate index */
172 j_coord_offset = DIM*jnr;
174 /* load j atom coordinates */
175 jx0 = x[j_coord_offset+DIM*0+XX];
176 jy0 = x[j_coord_offset+DIM*0+YY];
177 jz0 = x[j_coord_offset+DIM*0+ZZ];
179 /* Calculate displacement vector */
190 /* Calculate squared distance and things based on it */
191 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
192 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
193 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
195 rinv00 = gmx_invsqrt(rsq00);
196 rinv10 = gmx_invsqrt(rsq10);
197 rinv20 = gmx_invsqrt(rsq20);
199 rinvsq00 = rinv00*rinv00;
200 rinvsq10 = rinv10*rinv10;
201 rinvsq20 = rinv20*rinv20;
203 /* Load parameters for j particles */
205 vdwjidx0 = 2*vdwtype[jnr+0];
207 /**************************
208 * CALCULATE INTERACTIONS *
209 **************************/
215 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
216 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
218 /* REACTION-FIELD ELECTROSTATICS */
219 velec = qq00*(rinv00+krf*rsq00-crf);
220 felec = qq00*(rinv00*rinvsq00-krf2);
222 /* LENNARD-JONES DISPERSION/REPULSION */
224 rinvsix = rinvsq00*rinvsq00*rinvsq00;
225 vvdw6 = c6_00*rinvsix;
226 vvdw12 = c12_00*rinvsix*rinvsix;
227 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
228 fvdw = (vvdw12-vvdw6)*rinvsq00;
230 /* Update potential sums from outer loop */
236 /* Calculate temporary vectorial force */
241 /* Update vectorial force */
245 f[j_coord_offset+DIM*0+XX] -= tx;
246 f[j_coord_offset+DIM*0+YY] -= ty;
247 f[j_coord_offset+DIM*0+ZZ] -= tz;
251 /**************************
252 * CALCULATE INTERACTIONS *
253 **************************/
260 /* REACTION-FIELD ELECTROSTATICS */
261 velec = qq10*(rinv10+krf*rsq10-crf);
262 felec = qq10*(rinv10*rinvsq10-krf2);
264 /* Update potential sums from outer loop */
269 /* Calculate temporary vectorial force */
274 /* Update vectorial force */
278 f[j_coord_offset+DIM*0+XX] -= tx;
279 f[j_coord_offset+DIM*0+YY] -= ty;
280 f[j_coord_offset+DIM*0+ZZ] -= tz;
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
293 /* REACTION-FIELD ELECTROSTATICS */
294 velec = qq20*(rinv20+krf*rsq20-crf);
295 felec = qq20*(rinv20*rinvsq20-krf2);
297 /* Update potential sums from outer loop */
302 /* Calculate temporary vectorial force */
307 /* Update vectorial force */
311 f[j_coord_offset+DIM*0+XX] -= tx;
312 f[j_coord_offset+DIM*0+YY] -= ty;
313 f[j_coord_offset+DIM*0+ZZ] -= tz;
317 /* Inner loop uses 113 flops */
319 /* End of innermost loop */
322 f[i_coord_offset+DIM*0+XX] += fix0;
323 f[i_coord_offset+DIM*0+YY] += fiy0;
324 f[i_coord_offset+DIM*0+ZZ] += fiz0;
328 f[i_coord_offset+DIM*1+XX] += fix1;
329 f[i_coord_offset+DIM*1+YY] += fiy1;
330 f[i_coord_offset+DIM*1+ZZ] += fiz1;
334 f[i_coord_offset+DIM*2+XX] += fix2;
335 f[i_coord_offset+DIM*2+YY] += fiy2;
336 f[i_coord_offset+DIM*2+ZZ] += fiz2;
340 fshift[i_shift_offset+XX] += tx;
341 fshift[i_shift_offset+YY] += ty;
342 fshift[i_shift_offset+ZZ] += tz;
345 /* Update potential energies */
346 kernel_data->energygrp_elec[ggid] += velecsum;
347 kernel_data->energygrp_vdw[ggid] += vvdwsum;
349 /* Increment number of inner iterations */
350 inneriter += j_index_end - j_index_start;
352 /* Outer loop uses 32 flops */
355 /* Increment number of outer iterations */
358 /* Update outer/inner flops */
360 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*113);
363 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_c
364 * Electrostatics interaction: ReactionField
365 * VdW interaction: LennardJones
366 * Geometry: Water3-Particle
367 * Calculate force/pot: Force
370 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_c
371 (t_nblist * gmx_restrict nlist,
372 rvec * gmx_restrict xx,
373 rvec * gmx_restrict ff,
374 t_forcerec * gmx_restrict fr,
375 t_mdatoms * gmx_restrict mdatoms,
376 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
377 t_nrnb * gmx_restrict nrnb)
379 int i_shift_offset,i_coord_offset,j_coord_offset;
380 int j_index_start,j_index_end;
381 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
382 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
383 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
384 real *shiftvec,*fshift,*x,*f;
386 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
388 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
390 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
392 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
393 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
394 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
395 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
396 real velec,felec,velecsum,facel,crf,krf,krf2;
399 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
408 jindex = nlist->jindex;
410 shiftidx = nlist->shift;
412 shiftvec = fr->shift_vec[0];
413 fshift = fr->fshift[0];
415 charge = mdatoms->chargeA;
419 nvdwtype = fr->ntype;
421 vdwtype = mdatoms->typeA;
423 /* Setup water-specific parameters */
424 inr = nlist->iinr[0];
425 iq0 = facel*charge[inr+0];
426 iq1 = facel*charge[inr+1];
427 iq2 = facel*charge[inr+2];
428 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
430 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
431 rcutoff = fr->rcoulomb;
432 rcutoff2 = rcutoff*rcutoff;
434 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
440 /* Start outer loop over neighborlists */
441 for(iidx=0; iidx<nri; iidx++)
443 /* Load shift vector for this list */
444 i_shift_offset = DIM*shiftidx[iidx];
445 shX = shiftvec[i_shift_offset+XX];
446 shY = shiftvec[i_shift_offset+YY];
447 shZ = shiftvec[i_shift_offset+ZZ];
449 /* Load limits for loop over neighbors */
450 j_index_start = jindex[iidx];
451 j_index_end = jindex[iidx+1];
453 /* Get outer coordinate index */
455 i_coord_offset = DIM*inr;
457 /* Load i particle coords and add shift vector */
458 ix0 = shX + x[i_coord_offset+DIM*0+XX];
459 iy0 = shY + x[i_coord_offset+DIM*0+YY];
460 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
461 ix1 = shX + x[i_coord_offset+DIM*1+XX];
462 iy1 = shY + x[i_coord_offset+DIM*1+YY];
463 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
464 ix2 = shX + x[i_coord_offset+DIM*2+XX];
465 iy2 = shY + x[i_coord_offset+DIM*2+YY];
466 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
478 /* Start inner kernel loop */
479 for(jidx=j_index_start; jidx<j_index_end; jidx++)
481 /* Get j neighbor index, and coordinate index */
483 j_coord_offset = DIM*jnr;
485 /* load j atom coordinates */
486 jx0 = x[j_coord_offset+DIM*0+XX];
487 jy0 = x[j_coord_offset+DIM*0+YY];
488 jz0 = x[j_coord_offset+DIM*0+ZZ];
490 /* Calculate displacement vector */
501 /* Calculate squared distance and things based on it */
502 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
503 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
504 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
506 rinv00 = gmx_invsqrt(rsq00);
507 rinv10 = gmx_invsqrt(rsq10);
508 rinv20 = gmx_invsqrt(rsq20);
510 rinvsq00 = rinv00*rinv00;
511 rinvsq10 = rinv10*rinv10;
512 rinvsq20 = rinv20*rinv20;
514 /* Load parameters for j particles */
516 vdwjidx0 = 2*vdwtype[jnr+0];
518 /**************************
519 * CALCULATE INTERACTIONS *
520 **************************/
526 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
527 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
529 /* REACTION-FIELD ELECTROSTATICS */
530 felec = qq00*(rinv00*rinvsq00-krf2);
532 /* LENNARD-JONES DISPERSION/REPULSION */
534 rinvsix = rinvsq00*rinvsq00*rinvsq00;
535 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
539 /* Calculate temporary vectorial force */
544 /* Update vectorial force */
548 f[j_coord_offset+DIM*0+XX] -= tx;
549 f[j_coord_offset+DIM*0+YY] -= ty;
550 f[j_coord_offset+DIM*0+ZZ] -= tz;
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
563 /* REACTION-FIELD ELECTROSTATICS */
564 felec = qq10*(rinv10*rinvsq10-krf2);
568 /* Calculate temporary vectorial force */
573 /* Update vectorial force */
577 f[j_coord_offset+DIM*0+XX] -= tx;
578 f[j_coord_offset+DIM*0+YY] -= ty;
579 f[j_coord_offset+DIM*0+ZZ] -= tz;
583 /**************************
584 * CALCULATE INTERACTIONS *
585 **************************/
592 /* REACTION-FIELD ELECTROSTATICS */
593 felec = qq20*(rinv20*rinvsq20-krf2);
597 /* Calculate temporary vectorial force */
602 /* Update vectorial force */
606 f[j_coord_offset+DIM*0+XX] -= tx;
607 f[j_coord_offset+DIM*0+YY] -= ty;
608 f[j_coord_offset+DIM*0+ZZ] -= tz;
612 /* Inner loop uses 88 flops */
614 /* End of innermost loop */
617 f[i_coord_offset+DIM*0+XX] += fix0;
618 f[i_coord_offset+DIM*0+YY] += fiy0;
619 f[i_coord_offset+DIM*0+ZZ] += fiz0;
623 f[i_coord_offset+DIM*1+XX] += fix1;
624 f[i_coord_offset+DIM*1+YY] += fiy1;
625 f[i_coord_offset+DIM*1+ZZ] += fiz1;
629 f[i_coord_offset+DIM*2+XX] += fix2;
630 f[i_coord_offset+DIM*2+YY] += fiy2;
631 f[i_coord_offset+DIM*2+ZZ] += fiz2;
635 fshift[i_shift_offset+XX] += tx;
636 fshift[i_shift_offset+YY] += ty;
637 fshift[i_shift_offset+ZZ] += tz;
639 /* Increment number of inner iterations */
640 inneriter += j_index_end - j_index_start;
642 /* Outer loop uses 30 flops */
645 /* Increment number of outer iterations */
648 /* Update outer/inner flops */
650 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*88);