2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_c
35 * Electrostatics interaction: Coulomb
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
79 jindex = nlist->jindex;
81 shiftidx = nlist->shift;
83 shiftvec = fr->shift_vec[0];
84 fshift = fr->fshift[0];
86 charge = mdatoms->chargeA;
89 vdwtype = mdatoms->typeA;
91 /* Setup water-specific parameters */
93 iq0 = facel*charge[inr+0];
94 iq1 = facel*charge[inr+1];
95 iq2 = facel*charge[inr+2];
96 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
101 /* Start outer loop over neighborlists */
102 for(iidx=0; iidx<nri; iidx++)
104 /* Load shift vector for this list */
105 i_shift_offset = DIM*shiftidx[iidx];
106 shX = shiftvec[i_shift_offset+XX];
107 shY = shiftvec[i_shift_offset+YY];
108 shZ = shiftvec[i_shift_offset+ZZ];
110 /* Load limits for loop over neighbors */
111 j_index_start = jindex[iidx];
112 j_index_end = jindex[iidx+1];
114 /* Get outer coordinate index */
116 i_coord_offset = DIM*inr;
118 /* Load i particle coords and add shift vector */
119 ix0 = shX + x[i_coord_offset+DIM*0+XX];
120 iy0 = shY + x[i_coord_offset+DIM*0+YY];
121 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
122 ix1 = shX + x[i_coord_offset+DIM*1+XX];
123 iy1 = shY + x[i_coord_offset+DIM*1+YY];
124 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
125 ix2 = shX + x[i_coord_offset+DIM*2+XX];
126 iy2 = shY + x[i_coord_offset+DIM*2+YY];
127 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
139 /* Reset potential sums */
143 /* Start inner kernel loop */
144 for(jidx=j_index_start; jidx<j_index_end; jidx++)
146 /* Get j neighbor index, and coordinate index */
148 j_coord_offset = DIM*jnr;
150 /* load j atom coordinates */
151 jx0 = x[j_coord_offset+DIM*0+XX];
152 jy0 = x[j_coord_offset+DIM*0+YY];
153 jz0 = x[j_coord_offset+DIM*0+ZZ];
155 /* Calculate displacement vector */
166 /* Calculate squared distance and things based on it */
167 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
168 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
169 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
171 rinv00 = gmx_invsqrt(rsq00);
172 rinv10 = gmx_invsqrt(rsq10);
173 rinv20 = gmx_invsqrt(rsq20);
175 rinvsq00 = rinv00*rinv00;
176 rinvsq10 = rinv10*rinv10;
177 rinvsq20 = rinv20*rinv20;
179 /* Load parameters for j particles */
181 vdwjidx0 = 2*vdwtype[jnr+0];
183 /**************************
184 * CALCULATE INTERACTIONS *
185 **************************/
188 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
189 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
191 /* COULOMB ELECTROSTATICS */
193 felec = velec*rinvsq00;
195 /* LENNARD-JONES DISPERSION/REPULSION */
197 rinvsix = rinvsq00*rinvsq00*rinvsq00;
198 vvdw6 = c6_00*rinvsix;
199 vvdw12 = c12_00*rinvsix*rinvsix;
200 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
201 fvdw = (vvdw12-vvdw6)*rinvsq00;
203 /* Update potential sums from outer loop */
209 /* Calculate temporary vectorial force */
214 /* Update vectorial force */
218 f[j_coord_offset+DIM*0+XX] -= tx;
219 f[j_coord_offset+DIM*0+YY] -= ty;
220 f[j_coord_offset+DIM*0+ZZ] -= tz;
222 /**************************
223 * CALCULATE INTERACTIONS *
224 **************************/
228 /* COULOMB ELECTROSTATICS */
230 felec = velec*rinvsq10;
232 /* Update potential sums from outer loop */
237 /* Calculate temporary vectorial force */
242 /* Update vectorial force */
246 f[j_coord_offset+DIM*0+XX] -= tx;
247 f[j_coord_offset+DIM*0+YY] -= ty;
248 f[j_coord_offset+DIM*0+ZZ] -= tz;
250 /**************************
251 * CALCULATE INTERACTIONS *
252 **************************/
256 /* COULOMB ELECTROSTATICS */
258 felec = velec*rinvsq20;
260 /* Update potential sums from outer loop */
265 /* Calculate temporary vectorial force */
270 /* Update vectorial force */
274 f[j_coord_offset+DIM*0+XX] -= tx;
275 f[j_coord_offset+DIM*0+YY] -= ty;
276 f[j_coord_offset+DIM*0+ZZ] -= tz;
278 /* Inner loop uses 96 flops */
280 /* End of innermost loop */
283 f[i_coord_offset+DIM*0+XX] += fix0;
284 f[i_coord_offset+DIM*0+YY] += fiy0;
285 f[i_coord_offset+DIM*0+ZZ] += fiz0;
289 f[i_coord_offset+DIM*1+XX] += fix1;
290 f[i_coord_offset+DIM*1+YY] += fiy1;
291 f[i_coord_offset+DIM*1+ZZ] += fiz1;
295 f[i_coord_offset+DIM*2+XX] += fix2;
296 f[i_coord_offset+DIM*2+YY] += fiy2;
297 f[i_coord_offset+DIM*2+ZZ] += fiz2;
301 fshift[i_shift_offset+XX] += tx;
302 fshift[i_shift_offset+YY] += ty;
303 fshift[i_shift_offset+ZZ] += tz;
306 /* Update potential energies */
307 kernel_data->energygrp_elec[ggid] += velecsum;
308 kernel_data->energygrp_vdw[ggid] += vvdwsum;
310 /* Increment number of inner iterations */
311 inneriter += j_index_end - j_index_start;
313 /* Outer loop uses 32 flops */
316 /* Increment number of outer iterations */
319 /* Update outer/inner flops */
321 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*96);
324 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_c
325 * Electrostatics interaction: Coulomb
326 * VdW interaction: LennardJones
327 * Geometry: Water3-Particle
328 * Calculate force/pot: Force
331 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_c
332 (t_nblist * gmx_restrict nlist,
333 rvec * gmx_restrict xx,
334 rvec * gmx_restrict ff,
335 t_forcerec * gmx_restrict fr,
336 t_mdatoms * gmx_restrict mdatoms,
337 nb_kernel_data_t * gmx_restrict kernel_data,
338 t_nrnb * gmx_restrict nrnb)
340 int i_shift_offset,i_coord_offset,j_coord_offset;
341 int j_index_start,j_index_end;
342 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
343 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
344 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
345 real *shiftvec,*fshift,*x,*f;
347 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
349 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
351 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
353 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
354 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
355 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
356 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
357 real velec,felec,velecsum,facel,crf,krf,krf2;
360 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
369 jindex = nlist->jindex;
371 shiftidx = nlist->shift;
373 shiftvec = fr->shift_vec[0];
374 fshift = fr->fshift[0];
376 charge = mdatoms->chargeA;
377 nvdwtype = fr->ntype;
379 vdwtype = mdatoms->typeA;
381 /* Setup water-specific parameters */
382 inr = nlist->iinr[0];
383 iq0 = facel*charge[inr+0];
384 iq1 = facel*charge[inr+1];
385 iq2 = facel*charge[inr+2];
386 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
391 /* Start outer loop over neighborlists */
392 for(iidx=0; iidx<nri; iidx++)
394 /* Load shift vector for this list */
395 i_shift_offset = DIM*shiftidx[iidx];
396 shX = shiftvec[i_shift_offset+XX];
397 shY = shiftvec[i_shift_offset+YY];
398 shZ = shiftvec[i_shift_offset+ZZ];
400 /* Load limits for loop over neighbors */
401 j_index_start = jindex[iidx];
402 j_index_end = jindex[iidx+1];
404 /* Get outer coordinate index */
406 i_coord_offset = DIM*inr;
408 /* Load i particle coords and add shift vector */
409 ix0 = shX + x[i_coord_offset+DIM*0+XX];
410 iy0 = shY + x[i_coord_offset+DIM*0+YY];
411 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
412 ix1 = shX + x[i_coord_offset+DIM*1+XX];
413 iy1 = shY + x[i_coord_offset+DIM*1+YY];
414 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
415 ix2 = shX + x[i_coord_offset+DIM*2+XX];
416 iy2 = shY + x[i_coord_offset+DIM*2+YY];
417 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
429 /* Start inner kernel loop */
430 for(jidx=j_index_start; jidx<j_index_end; jidx++)
432 /* Get j neighbor index, and coordinate index */
434 j_coord_offset = DIM*jnr;
436 /* load j atom coordinates */
437 jx0 = x[j_coord_offset+DIM*0+XX];
438 jy0 = x[j_coord_offset+DIM*0+YY];
439 jz0 = x[j_coord_offset+DIM*0+ZZ];
441 /* Calculate displacement vector */
452 /* Calculate squared distance and things based on it */
453 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
454 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
455 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
457 rinv00 = gmx_invsqrt(rsq00);
458 rinv10 = gmx_invsqrt(rsq10);
459 rinv20 = gmx_invsqrt(rsq20);
461 rinvsq00 = rinv00*rinv00;
462 rinvsq10 = rinv10*rinv10;
463 rinvsq20 = rinv20*rinv20;
465 /* Load parameters for j particles */
467 vdwjidx0 = 2*vdwtype[jnr+0];
469 /**************************
470 * CALCULATE INTERACTIONS *
471 **************************/
474 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
475 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
477 /* COULOMB ELECTROSTATICS */
479 felec = velec*rinvsq00;
481 /* LENNARD-JONES DISPERSION/REPULSION */
483 rinvsix = rinvsq00*rinvsq00*rinvsq00;
484 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
488 /* Calculate temporary vectorial force */
493 /* Update vectorial force */
497 f[j_coord_offset+DIM*0+XX] -= tx;
498 f[j_coord_offset+DIM*0+YY] -= ty;
499 f[j_coord_offset+DIM*0+ZZ] -= tz;
501 /**************************
502 * CALCULATE INTERACTIONS *
503 **************************/
507 /* COULOMB ELECTROSTATICS */
509 felec = velec*rinvsq10;
513 /* Calculate temporary vectorial force */
518 /* Update vectorial force */
522 f[j_coord_offset+DIM*0+XX] -= tx;
523 f[j_coord_offset+DIM*0+YY] -= ty;
524 f[j_coord_offset+DIM*0+ZZ] -= tz;
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
532 /* COULOMB ELECTROSTATICS */
534 felec = velec*rinvsq20;
538 /* Calculate temporary vectorial force */
543 /* Update vectorial force */
547 f[j_coord_offset+DIM*0+XX] -= tx;
548 f[j_coord_offset+DIM*0+YY] -= ty;
549 f[j_coord_offset+DIM*0+ZZ] -= tz;
551 /* Inner loop uses 88 flops */
553 /* End of innermost loop */
556 f[i_coord_offset+DIM*0+XX] += fix0;
557 f[i_coord_offset+DIM*0+YY] += fiy0;
558 f[i_coord_offset+DIM*0+ZZ] += fiz0;
562 f[i_coord_offset+DIM*1+XX] += fix1;
563 f[i_coord_offset+DIM*1+YY] += fiy1;
564 f[i_coord_offset+DIM*1+ZZ] += fiz1;
568 f[i_coord_offset+DIM*2+XX] += fix2;
569 f[i_coord_offset+DIM*2+YY] += fiy2;
570 f[i_coord_offset+DIM*2+ZZ] += fiz2;
574 fshift[i_shift_offset+XX] += tx;
575 fshift[i_shift_offset+YY] += ty;
576 fshift[i_shift_offset+ZZ] += tz;
578 /* Increment number of inner iterations */
579 inneriter += j_index_end - j_index_start;
581 /* Outer loop uses 30 flops */
584 /* Increment number of outer iterations */
587 /* Update outer/inner flops */
589 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*88);