2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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 "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSh_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;
106 nvdwtype = fr->ntype;
108 vdwtype = mdatoms->typeA;
110 /* Setup water-specific parameters */
111 inr = nlist->iinr[0];
112 iq0 = facel*charge[inr+0];
113 iq1 = facel*charge[inr+1];
114 iq2 = facel*charge[inr+2];
115 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
117 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
118 rcutoff = fr->rcoulomb;
119 rcutoff2 = rcutoff*rcutoff;
121 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
127 /* Start outer loop over neighborlists */
128 for(iidx=0; iidx<nri; iidx++)
130 /* Load shift vector for this list */
131 i_shift_offset = DIM*shiftidx[iidx];
132 shX = shiftvec[i_shift_offset+XX];
133 shY = shiftvec[i_shift_offset+YY];
134 shZ = shiftvec[i_shift_offset+ZZ];
136 /* Load limits for loop over neighbors */
137 j_index_start = jindex[iidx];
138 j_index_end = jindex[iidx+1];
140 /* Get outer coordinate index */
142 i_coord_offset = DIM*inr;
144 /* Load i particle coords and add shift vector */
145 ix0 = shX + x[i_coord_offset+DIM*0+XX];
146 iy0 = shY + x[i_coord_offset+DIM*0+YY];
147 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
148 ix1 = shX + x[i_coord_offset+DIM*1+XX];
149 iy1 = shY + x[i_coord_offset+DIM*1+YY];
150 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
151 ix2 = shX + x[i_coord_offset+DIM*2+XX];
152 iy2 = shY + x[i_coord_offset+DIM*2+YY];
153 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
165 /* Reset potential sums */
169 /* Start inner kernel loop */
170 for(jidx=j_index_start; jidx<j_index_end; jidx++)
172 /* Get j neighbor index, and coordinate index */
174 j_coord_offset = DIM*jnr;
176 /* load j atom coordinates */
177 jx0 = x[j_coord_offset+DIM*0+XX];
178 jy0 = x[j_coord_offset+DIM*0+YY];
179 jz0 = x[j_coord_offset+DIM*0+ZZ];
181 /* 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;
197 rinv00 = gmx_invsqrt(rsq00);
198 rinv10 = gmx_invsqrt(rsq10);
199 rinv20 = gmx_invsqrt(rsq20);
201 rinvsq00 = rinv00*rinv00;
202 rinvsq10 = rinv10*rinv10;
203 rinvsq20 = rinv20*rinv20;
205 /* Load parameters for j particles */
207 vdwjidx0 = 2*vdwtype[jnr+0];
209 /**************************
210 * CALCULATE INTERACTIONS *
211 **************************/
217 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
218 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
220 /* REACTION-FIELD ELECTROSTATICS */
221 velec = qq00*(rinv00+krf*rsq00-crf);
222 felec = qq00*(rinv00*rinvsq00-krf2);
224 /* LENNARD-JONES DISPERSION/REPULSION */
226 rinvsix = rinvsq00*rinvsq00*rinvsq00;
227 vvdw6 = c6_00*rinvsix;
228 vvdw12 = c12_00*rinvsix*rinvsix;
229 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
230 fvdw = (vvdw12-vvdw6)*rinvsq00;
232 /* Update potential sums from outer loop */
238 /* Calculate temporary vectorial force */
243 /* Update vectorial force */
247 f[j_coord_offset+DIM*0+XX] -= tx;
248 f[j_coord_offset+DIM*0+YY] -= ty;
249 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
262 /* REACTION-FIELD ELECTROSTATICS */
263 velec = qq10*(rinv10+krf*rsq10-crf);
264 felec = qq10*(rinv10*rinvsq10-krf2);
266 /* Update potential sums from outer loop */
271 /* Calculate temporary vectorial force */
276 /* Update vectorial force */
280 f[j_coord_offset+DIM*0+XX] -= tx;
281 f[j_coord_offset+DIM*0+YY] -= ty;
282 f[j_coord_offset+DIM*0+ZZ] -= tz;
286 /**************************
287 * CALCULATE INTERACTIONS *
288 **************************/
295 /* REACTION-FIELD ELECTROSTATICS */
296 velec = qq20*(rinv20+krf*rsq20-crf);
297 felec = qq20*(rinv20*rinvsq20-krf2);
299 /* Update potential sums from outer loop */
304 /* Calculate temporary vectorial force */
309 /* Update vectorial force */
313 f[j_coord_offset+DIM*0+XX] -= tx;
314 f[j_coord_offset+DIM*0+YY] -= ty;
315 f[j_coord_offset+DIM*0+ZZ] -= tz;
319 /* Inner loop uses 113 flops */
321 /* End of innermost loop */
324 f[i_coord_offset+DIM*0+XX] += fix0;
325 f[i_coord_offset+DIM*0+YY] += fiy0;
326 f[i_coord_offset+DIM*0+ZZ] += fiz0;
330 f[i_coord_offset+DIM*1+XX] += fix1;
331 f[i_coord_offset+DIM*1+YY] += fiy1;
332 f[i_coord_offset+DIM*1+ZZ] += fiz1;
336 f[i_coord_offset+DIM*2+XX] += fix2;
337 f[i_coord_offset+DIM*2+YY] += fiy2;
338 f[i_coord_offset+DIM*2+ZZ] += fiz2;
342 fshift[i_shift_offset+XX] += tx;
343 fshift[i_shift_offset+YY] += ty;
344 fshift[i_shift_offset+ZZ] += tz;
347 /* Update potential energies */
348 kernel_data->energygrp_elec[ggid] += velecsum;
349 kernel_data->energygrp_vdw[ggid] += vvdwsum;
351 /* Increment number of inner iterations */
352 inneriter += j_index_end - j_index_start;
354 /* Outer loop uses 32 flops */
357 /* Increment number of outer iterations */
360 /* Update outer/inner flops */
362 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*113);
365 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_c
366 * Electrostatics interaction: ReactionField
367 * VdW interaction: LennardJones
368 * Geometry: Water3-Particle
369 * Calculate force/pot: Force
372 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_c
373 (t_nblist * gmx_restrict nlist,
374 rvec * gmx_restrict xx,
375 rvec * gmx_restrict ff,
376 t_forcerec * gmx_restrict fr,
377 t_mdatoms * gmx_restrict mdatoms,
378 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
379 t_nrnb * gmx_restrict nrnb)
381 int i_shift_offset,i_coord_offset,j_coord_offset;
382 int j_index_start,j_index_end;
383 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
384 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
385 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
386 real *shiftvec,*fshift,*x,*f;
388 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
390 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
392 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
394 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
395 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
396 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
397 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
398 real velec,felec,velecsum,facel,crf,krf,krf2;
401 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
410 jindex = nlist->jindex;
412 shiftidx = nlist->shift;
414 shiftvec = fr->shift_vec[0];
415 fshift = fr->fshift[0];
417 charge = mdatoms->chargeA;
421 nvdwtype = fr->ntype;
423 vdwtype = mdatoms->typeA;
425 /* Setup water-specific parameters */
426 inr = nlist->iinr[0];
427 iq0 = facel*charge[inr+0];
428 iq1 = facel*charge[inr+1];
429 iq2 = facel*charge[inr+2];
430 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
432 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
433 rcutoff = fr->rcoulomb;
434 rcutoff2 = rcutoff*rcutoff;
436 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
442 /* Start outer loop over neighborlists */
443 for(iidx=0; iidx<nri; iidx++)
445 /* Load shift vector for this list */
446 i_shift_offset = DIM*shiftidx[iidx];
447 shX = shiftvec[i_shift_offset+XX];
448 shY = shiftvec[i_shift_offset+YY];
449 shZ = shiftvec[i_shift_offset+ZZ];
451 /* Load limits for loop over neighbors */
452 j_index_start = jindex[iidx];
453 j_index_end = jindex[iidx+1];
455 /* Get outer coordinate index */
457 i_coord_offset = DIM*inr;
459 /* Load i particle coords and add shift vector */
460 ix0 = shX + x[i_coord_offset+DIM*0+XX];
461 iy0 = shY + x[i_coord_offset+DIM*0+YY];
462 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
463 ix1 = shX + x[i_coord_offset+DIM*1+XX];
464 iy1 = shY + x[i_coord_offset+DIM*1+YY];
465 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
466 ix2 = shX + x[i_coord_offset+DIM*2+XX];
467 iy2 = shY + x[i_coord_offset+DIM*2+YY];
468 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
480 /* Start inner kernel loop */
481 for(jidx=j_index_start; jidx<j_index_end; jidx++)
483 /* Get j neighbor index, and coordinate index */
485 j_coord_offset = DIM*jnr;
487 /* load j atom coordinates */
488 jx0 = x[j_coord_offset+DIM*0+XX];
489 jy0 = x[j_coord_offset+DIM*0+YY];
490 jz0 = x[j_coord_offset+DIM*0+ZZ];
492 /* Calculate displacement vector */
503 /* Calculate squared distance and things based on it */
504 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
505 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
506 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
508 rinv00 = gmx_invsqrt(rsq00);
509 rinv10 = gmx_invsqrt(rsq10);
510 rinv20 = gmx_invsqrt(rsq20);
512 rinvsq00 = rinv00*rinv00;
513 rinvsq10 = rinv10*rinv10;
514 rinvsq20 = rinv20*rinv20;
516 /* Load parameters for j particles */
518 vdwjidx0 = 2*vdwtype[jnr+0];
520 /**************************
521 * CALCULATE INTERACTIONS *
522 **************************/
528 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
529 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
531 /* REACTION-FIELD ELECTROSTATICS */
532 felec = qq00*(rinv00*rinvsq00-krf2);
534 /* LENNARD-JONES DISPERSION/REPULSION */
536 rinvsix = rinvsq00*rinvsq00*rinvsq00;
537 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*0+XX] -= tx;
551 f[j_coord_offset+DIM*0+YY] -= ty;
552 f[j_coord_offset+DIM*0+ZZ] -= tz;
556 /**************************
557 * CALCULATE INTERACTIONS *
558 **************************/
565 /* REACTION-FIELD ELECTROSTATICS */
566 felec = qq10*(rinv10*rinvsq10-krf2);
570 /* Calculate temporary vectorial force */
575 /* Update vectorial force */
579 f[j_coord_offset+DIM*0+XX] -= tx;
580 f[j_coord_offset+DIM*0+YY] -= ty;
581 f[j_coord_offset+DIM*0+ZZ] -= tz;
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
594 /* REACTION-FIELD ELECTROSTATICS */
595 felec = qq20*(rinv20*rinvsq20-krf2);
599 /* Calculate temporary vectorial force */
604 /* Update vectorial force */
608 f[j_coord_offset+DIM*0+XX] -= tx;
609 f[j_coord_offset+DIM*0+YY] -= ty;
610 f[j_coord_offset+DIM*0+ZZ] -= tz;
614 /* Inner loop uses 88 flops */
616 /* End of innermost loop */
619 f[i_coord_offset+DIM*0+XX] += fix0;
620 f[i_coord_offset+DIM*0+YY] += fiy0;
621 f[i_coord_offset+DIM*0+ZZ] += fiz0;
625 f[i_coord_offset+DIM*1+XX] += fix1;
626 f[i_coord_offset+DIM*1+YY] += fiy1;
627 f[i_coord_offset+DIM*1+ZZ] += fiz1;
631 f[i_coord_offset+DIM*2+XX] += fix2;
632 f[i_coord_offset+DIM*2+YY] += fiy2;
633 f[i_coord_offset+DIM*2+ZZ] += fiz2;
637 fshift[i_shift_offset+XX] += tx;
638 fshift[i_shift_offset+YY] += ty;
639 fshift[i_shift_offset+ZZ] += tz;
641 /* Increment number of inner iterations */
642 inneriter += j_index_end - j_index_start;
644 /* Outer loop uses 30 flops */
647 /* Increment number of outer iterations */
650 /* Update outer/inner flops */
652 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*88);