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_VdwLJ_GeomW4P1_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
105 charge = mdatoms->chargeA;
106 nvdwtype = fr->ntype;
108 vdwtype = mdatoms->typeA;
110 /* Setup water-specific parameters */
111 inr = nlist->iinr[0];
112 iq1 = facel*charge[inr+1];
113 iq2 = facel*charge[inr+2];
114 iq3 = facel*charge[inr+3];
115 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
120 /* Start outer loop over neighborlists */
121 for(iidx=0; iidx<nri; iidx++)
123 /* Load shift vector for this list */
124 i_shift_offset = DIM*shiftidx[iidx];
125 shX = shiftvec[i_shift_offset+XX];
126 shY = shiftvec[i_shift_offset+YY];
127 shZ = shiftvec[i_shift_offset+ZZ];
129 /* Load limits for loop over neighbors */
130 j_index_start = jindex[iidx];
131 j_index_end = jindex[iidx+1];
133 /* Get outer coordinate index */
135 i_coord_offset = DIM*inr;
137 /* Load i particle coords and add shift vector */
138 ix0 = shX + x[i_coord_offset+DIM*0+XX];
139 iy0 = shY + x[i_coord_offset+DIM*0+YY];
140 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
141 ix1 = shX + x[i_coord_offset+DIM*1+XX];
142 iy1 = shY + x[i_coord_offset+DIM*1+YY];
143 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
144 ix2 = shX + x[i_coord_offset+DIM*2+XX];
145 iy2 = shY + x[i_coord_offset+DIM*2+YY];
146 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
147 ix3 = shX + x[i_coord_offset+DIM*3+XX];
148 iy3 = shY + x[i_coord_offset+DIM*3+YY];
149 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
164 /* Reset potential sums */
168 /* Start inner kernel loop */
169 for(jidx=j_index_start; jidx<j_index_end; jidx++)
171 /* Get j neighbor index, and coordinate index */
173 j_coord_offset = DIM*jnr;
175 /* load j atom coordinates */
176 jx0 = x[j_coord_offset+DIM*0+XX];
177 jy0 = x[j_coord_offset+DIM*0+YY];
178 jz0 = x[j_coord_offset+DIM*0+ZZ];
180 /* Calculate displacement vector */
194 /* Calculate squared distance and things based on it */
195 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
196 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
197 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
198 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
200 rinv10 = gmx_invsqrt(rsq10);
201 rinv20 = gmx_invsqrt(rsq20);
202 rinv30 = gmx_invsqrt(rsq30);
204 rinvsq00 = 1.0/rsq00;
205 rinvsq10 = rinv10*rinv10;
206 rinvsq20 = rinv20*rinv20;
207 rinvsq30 = rinv30*rinv30;
209 /* Load parameters for j particles */
211 vdwjidx0 = 2*vdwtype[jnr+0];
213 /**************************
214 * CALCULATE INTERACTIONS *
215 **************************/
217 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
218 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
220 /* LENNARD-JONES DISPERSION/REPULSION */
222 rinvsix = rinvsq00*rinvsq00*rinvsq00;
223 vvdw6 = c6_00*rinvsix;
224 vvdw12 = c12_00*rinvsix*rinvsix;
225 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
226 fvdw = (vvdw12-vvdw6)*rinvsq00;
228 /* Update potential sums from outer loop */
233 /* Calculate temporary vectorial force */
238 /* Update vectorial force */
242 f[j_coord_offset+DIM*0+XX] -= tx;
243 f[j_coord_offset+DIM*0+YY] -= ty;
244 f[j_coord_offset+DIM*0+ZZ] -= tz;
246 /**************************
247 * CALCULATE INTERACTIONS *
248 **************************/
252 /* COULOMB ELECTROSTATICS */
254 felec = velec*rinvsq10;
256 /* Update potential sums from outer loop */
261 /* Calculate temporary vectorial force */
266 /* Update vectorial force */
270 f[j_coord_offset+DIM*0+XX] -= tx;
271 f[j_coord_offset+DIM*0+YY] -= ty;
272 f[j_coord_offset+DIM*0+ZZ] -= tz;
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
280 /* COULOMB ELECTROSTATICS */
282 felec = velec*rinvsq20;
284 /* Update potential sums from outer loop */
289 /* Calculate temporary vectorial force */
294 /* Update vectorial force */
298 f[j_coord_offset+DIM*0+XX] -= tx;
299 f[j_coord_offset+DIM*0+YY] -= ty;
300 f[j_coord_offset+DIM*0+ZZ] -= tz;
302 /**************************
303 * CALCULATE INTERACTIONS *
304 **************************/
308 /* COULOMB ELECTROSTATICS */
310 felec = velec*rinvsq30;
312 /* Update potential sums from outer loop */
317 /* Calculate temporary vectorial force */
322 /* Update vectorial force */
326 f[j_coord_offset+DIM*0+XX] -= tx;
327 f[j_coord_offset+DIM*0+YY] -= ty;
328 f[j_coord_offset+DIM*0+ZZ] -= tz;
330 /* Inner loop uses 116 flops */
332 /* End of innermost loop */
335 f[i_coord_offset+DIM*0+XX] += fix0;
336 f[i_coord_offset+DIM*0+YY] += fiy0;
337 f[i_coord_offset+DIM*0+ZZ] += fiz0;
341 f[i_coord_offset+DIM*1+XX] += fix1;
342 f[i_coord_offset+DIM*1+YY] += fiy1;
343 f[i_coord_offset+DIM*1+ZZ] += fiz1;
347 f[i_coord_offset+DIM*2+XX] += fix2;
348 f[i_coord_offset+DIM*2+YY] += fiy2;
349 f[i_coord_offset+DIM*2+ZZ] += fiz2;
353 f[i_coord_offset+DIM*3+XX] += fix3;
354 f[i_coord_offset+DIM*3+YY] += fiy3;
355 f[i_coord_offset+DIM*3+ZZ] += fiz3;
359 fshift[i_shift_offset+XX] += tx;
360 fshift[i_shift_offset+YY] += ty;
361 fshift[i_shift_offset+ZZ] += tz;
364 /* Update potential energies */
365 kernel_data->energygrp_elec[ggid] += velecsum;
366 kernel_data->energygrp_vdw[ggid] += vvdwsum;
368 /* Increment number of inner iterations */
369 inneriter += j_index_end - j_index_start;
371 /* Outer loop uses 41 flops */
374 /* Increment number of outer iterations */
377 /* Update outer/inner flops */
379 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*116);
382 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_c
383 * Electrostatics interaction: Coulomb
384 * VdW interaction: LennardJones
385 * Geometry: Water4-Particle
386 * Calculate force/pot: Force
389 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_c
390 (t_nblist * gmx_restrict nlist,
391 rvec * gmx_restrict xx,
392 rvec * gmx_restrict ff,
393 t_forcerec * gmx_restrict fr,
394 t_mdatoms * gmx_restrict mdatoms,
395 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
396 t_nrnb * gmx_restrict nrnb)
398 int i_shift_offset,i_coord_offset,j_coord_offset;
399 int j_index_start,j_index_end;
400 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
401 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
402 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
403 real *shiftvec,*fshift,*x,*f;
405 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
407 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
409 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
411 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
413 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
414 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
415 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
416 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
417 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
418 real velec,felec,velecsum,facel,crf,krf,krf2;
421 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
430 jindex = nlist->jindex;
432 shiftidx = nlist->shift;
434 shiftvec = fr->shift_vec[0];
435 fshift = fr->fshift[0];
437 charge = mdatoms->chargeA;
438 nvdwtype = fr->ntype;
440 vdwtype = mdatoms->typeA;
442 /* Setup water-specific parameters */
443 inr = nlist->iinr[0];
444 iq1 = facel*charge[inr+1];
445 iq2 = facel*charge[inr+2];
446 iq3 = facel*charge[inr+3];
447 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
452 /* Start outer loop over neighborlists */
453 for(iidx=0; iidx<nri; iidx++)
455 /* Load shift vector for this list */
456 i_shift_offset = DIM*shiftidx[iidx];
457 shX = shiftvec[i_shift_offset+XX];
458 shY = shiftvec[i_shift_offset+YY];
459 shZ = shiftvec[i_shift_offset+ZZ];
461 /* Load limits for loop over neighbors */
462 j_index_start = jindex[iidx];
463 j_index_end = jindex[iidx+1];
465 /* Get outer coordinate index */
467 i_coord_offset = DIM*inr;
469 /* Load i particle coords and add shift vector */
470 ix0 = shX + x[i_coord_offset+DIM*0+XX];
471 iy0 = shY + x[i_coord_offset+DIM*0+YY];
472 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
473 ix1 = shX + x[i_coord_offset+DIM*1+XX];
474 iy1 = shY + x[i_coord_offset+DIM*1+YY];
475 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
476 ix2 = shX + x[i_coord_offset+DIM*2+XX];
477 iy2 = shY + x[i_coord_offset+DIM*2+YY];
478 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
479 ix3 = shX + x[i_coord_offset+DIM*3+XX];
480 iy3 = shY + x[i_coord_offset+DIM*3+YY];
481 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
496 /* Start inner kernel loop */
497 for(jidx=j_index_start; jidx<j_index_end; jidx++)
499 /* Get j neighbor index, and coordinate index */
501 j_coord_offset = DIM*jnr;
503 /* load j atom coordinates */
504 jx0 = x[j_coord_offset+DIM*0+XX];
505 jy0 = x[j_coord_offset+DIM*0+YY];
506 jz0 = x[j_coord_offset+DIM*0+ZZ];
508 /* Calculate displacement vector */
522 /* Calculate squared distance and things based on it */
523 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
524 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
525 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
526 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
528 rinv10 = gmx_invsqrt(rsq10);
529 rinv20 = gmx_invsqrt(rsq20);
530 rinv30 = gmx_invsqrt(rsq30);
532 rinvsq00 = 1.0/rsq00;
533 rinvsq10 = rinv10*rinv10;
534 rinvsq20 = rinv20*rinv20;
535 rinvsq30 = rinv30*rinv30;
537 /* Load parameters for j particles */
539 vdwjidx0 = 2*vdwtype[jnr+0];
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
545 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
546 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
548 /* LENNARD-JONES DISPERSION/REPULSION */
550 rinvsix = rinvsq00*rinvsq00*rinvsq00;
551 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
555 /* Calculate temporary vectorial force */
560 /* Update vectorial force */
564 f[j_coord_offset+DIM*0+XX] -= tx;
565 f[j_coord_offset+DIM*0+YY] -= ty;
566 f[j_coord_offset+DIM*0+ZZ] -= tz;
568 /**************************
569 * CALCULATE INTERACTIONS *
570 **************************/
574 /* COULOMB ELECTROSTATICS */
576 felec = velec*rinvsq10;
580 /* Calculate temporary vectorial force */
585 /* Update vectorial force */
589 f[j_coord_offset+DIM*0+XX] -= tx;
590 f[j_coord_offset+DIM*0+YY] -= ty;
591 f[j_coord_offset+DIM*0+ZZ] -= tz;
593 /**************************
594 * CALCULATE INTERACTIONS *
595 **************************/
599 /* COULOMB ELECTROSTATICS */
601 felec = velec*rinvsq20;
605 /* Calculate temporary vectorial force */
610 /* Update vectorial force */
614 f[j_coord_offset+DIM*0+XX] -= tx;
615 f[j_coord_offset+DIM*0+YY] -= ty;
616 f[j_coord_offset+DIM*0+ZZ] -= tz;
618 /**************************
619 * CALCULATE INTERACTIONS *
620 **************************/
624 /* COULOMB ELECTROSTATICS */
626 felec = velec*rinvsq30;
630 /* Calculate temporary vectorial force */
635 /* Update vectorial force */
639 f[j_coord_offset+DIM*0+XX] -= tx;
640 f[j_coord_offset+DIM*0+YY] -= ty;
641 f[j_coord_offset+DIM*0+ZZ] -= tz;
643 /* Inner loop uses 108 flops */
645 /* End of innermost loop */
648 f[i_coord_offset+DIM*0+XX] += fix0;
649 f[i_coord_offset+DIM*0+YY] += fiy0;
650 f[i_coord_offset+DIM*0+ZZ] += fiz0;
654 f[i_coord_offset+DIM*1+XX] += fix1;
655 f[i_coord_offset+DIM*1+YY] += fiy1;
656 f[i_coord_offset+DIM*1+ZZ] += fiz1;
660 f[i_coord_offset+DIM*2+XX] += fix2;
661 f[i_coord_offset+DIM*2+YY] += fiy2;
662 f[i_coord_offset+DIM*2+ZZ] += fiz2;
666 f[i_coord_offset+DIM*3+XX] += fix3;
667 f[i_coord_offset+DIM*3+YY] += fiy3;
668 f[i_coord_offset+DIM*3+ZZ] += fiz3;
672 fshift[i_shift_offset+XX] += tx;
673 fshift[i_shift_offset+YY] += ty;
674 fshift[i_shift_offset+ZZ] += tz;
676 /* Increment number of inner iterations */
677 inneriter += j_index_end - j_index_start;
679 /* Outer loop uses 39 flops */
682 /* Increment number of outer iterations */
685 /* Update outer/inner flops */
687 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);