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_ElecRF_VdwLJ_GeomW4P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwLJ_GeomW4P1_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 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
65 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
66 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
67 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
68 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
69 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
70 real velec,felec,velecsum,facel,crf,krf,krf2;
73 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
82 jindex = nlist->jindex;
84 shiftidx = nlist->shift;
86 shiftvec = fr->shift_vec[0];
87 fshift = fr->fshift[0];
89 charge = mdatoms->chargeA;
95 vdwtype = mdatoms->typeA;
97 /* Setup water-specific parameters */
99 iq1 = facel*charge[inr+1];
100 iq2 = facel*charge[inr+2];
101 iq3 = facel*charge[inr+3];
102 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
107 /* Start outer loop over neighborlists */
108 for(iidx=0; iidx<nri; iidx++)
110 /* Load shift vector for this list */
111 i_shift_offset = DIM*shiftidx[iidx];
112 shX = shiftvec[i_shift_offset+XX];
113 shY = shiftvec[i_shift_offset+YY];
114 shZ = shiftvec[i_shift_offset+ZZ];
116 /* Load limits for loop over neighbors */
117 j_index_start = jindex[iidx];
118 j_index_end = jindex[iidx+1];
120 /* Get outer coordinate index */
122 i_coord_offset = DIM*inr;
124 /* Load i particle coords and add shift vector */
125 ix0 = shX + x[i_coord_offset+DIM*0+XX];
126 iy0 = shY + x[i_coord_offset+DIM*0+YY];
127 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
128 ix1 = shX + x[i_coord_offset+DIM*1+XX];
129 iy1 = shY + x[i_coord_offset+DIM*1+YY];
130 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
131 ix2 = shX + x[i_coord_offset+DIM*2+XX];
132 iy2 = shY + x[i_coord_offset+DIM*2+YY];
133 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
134 ix3 = shX + x[i_coord_offset+DIM*3+XX];
135 iy3 = shY + x[i_coord_offset+DIM*3+YY];
136 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
151 /* Reset potential sums */
155 /* Start inner kernel loop */
156 for(jidx=j_index_start; jidx<j_index_end; jidx++)
158 /* Get j neighbor index, and coordinate index */
160 j_coord_offset = DIM*jnr;
162 /* load j atom coordinates */
163 jx0 = x[j_coord_offset+DIM*0+XX];
164 jy0 = x[j_coord_offset+DIM*0+YY];
165 jz0 = x[j_coord_offset+DIM*0+ZZ];
167 /* Calculate displacement vector */
181 /* Calculate squared distance and things based on it */
182 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
183 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
184 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
185 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
187 rinv10 = gmx_invsqrt(rsq10);
188 rinv20 = gmx_invsqrt(rsq20);
189 rinv30 = gmx_invsqrt(rsq30);
191 rinvsq00 = 1.0/rsq00;
192 rinvsq10 = rinv10*rinv10;
193 rinvsq20 = rinv20*rinv20;
194 rinvsq30 = rinv30*rinv30;
196 /* Load parameters for j particles */
198 vdwjidx0 = 2*vdwtype[jnr+0];
200 /**************************
201 * CALCULATE INTERACTIONS *
202 **************************/
204 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
205 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
207 /* LENNARD-JONES DISPERSION/REPULSION */
209 rinvsix = rinvsq00*rinvsq00*rinvsq00;
210 vvdw6 = c6_00*rinvsix;
211 vvdw12 = c12_00*rinvsix*rinvsix;
212 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
213 fvdw = (vvdw12-vvdw6)*rinvsq00;
215 /* Update potential sums from outer loop */
220 /* Calculate temporary vectorial force */
225 /* Update vectorial force */
229 f[j_coord_offset+DIM*0+XX] -= tx;
230 f[j_coord_offset+DIM*0+YY] -= ty;
231 f[j_coord_offset+DIM*0+ZZ] -= tz;
233 /**************************
234 * CALCULATE INTERACTIONS *
235 **************************/
239 /* REACTION-FIELD ELECTROSTATICS */
240 velec = qq10*(rinv10+krf*rsq10-crf);
241 felec = qq10*(rinv10*rinvsq10-krf2);
243 /* Update potential sums from outer loop */
248 /* Calculate temporary vectorial force */
253 /* Update vectorial force */
257 f[j_coord_offset+DIM*0+XX] -= tx;
258 f[j_coord_offset+DIM*0+YY] -= ty;
259 f[j_coord_offset+DIM*0+ZZ] -= tz;
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
267 /* REACTION-FIELD ELECTROSTATICS */
268 velec = qq20*(rinv20+krf*rsq20-crf);
269 felec = qq20*(rinv20*rinvsq20-krf2);
271 /* Update potential sums from outer loop */
276 /* Calculate temporary vectorial force */
281 /* Update vectorial force */
285 f[j_coord_offset+DIM*0+XX] -= tx;
286 f[j_coord_offset+DIM*0+YY] -= ty;
287 f[j_coord_offset+DIM*0+ZZ] -= tz;
289 /**************************
290 * CALCULATE INTERACTIONS *
291 **************************/
295 /* REACTION-FIELD ELECTROSTATICS */
296 velec = qq30*(rinv30+krf*rsq30-crf);
297 felec = qq30*(rinv30*rinvsq30-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;
317 /* Inner loop uses 128 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 f[i_coord_offset+DIM*3+XX] += fix3;
341 f[i_coord_offset+DIM*3+YY] += fiy3;
342 f[i_coord_offset+DIM*3+ZZ] += fiz3;
346 fshift[i_shift_offset+XX] += tx;
347 fshift[i_shift_offset+YY] += ty;
348 fshift[i_shift_offset+ZZ] += tz;
351 /* Update potential energies */
352 kernel_data->energygrp_elec[ggid] += velecsum;
353 kernel_data->energygrp_vdw[ggid] += vvdwsum;
355 /* Increment number of inner iterations */
356 inneriter += j_index_end - j_index_start;
358 /* Outer loop uses 41 flops */
361 /* Increment number of outer iterations */
364 /* Update outer/inner flops */
366 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*128);
369 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
370 * Electrostatics interaction: ReactionField
371 * VdW interaction: LennardJones
372 * Geometry: Water4-Particle
373 * Calculate force/pot: Force
376 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
377 (t_nblist * gmx_restrict nlist,
378 rvec * gmx_restrict xx,
379 rvec * gmx_restrict ff,
380 t_forcerec * gmx_restrict fr,
381 t_mdatoms * gmx_restrict mdatoms,
382 nb_kernel_data_t * gmx_restrict kernel_data,
383 t_nrnb * gmx_restrict nrnb)
385 int i_shift_offset,i_coord_offset,j_coord_offset;
386 int j_index_start,j_index_end;
387 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
388 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
389 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
390 real *shiftvec,*fshift,*x,*f;
392 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
394 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
396 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
398 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
400 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
401 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
402 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
403 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
404 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
405 real velec,felec,velecsum,facel,crf,krf,krf2;
408 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
417 jindex = nlist->jindex;
419 shiftidx = nlist->shift;
421 shiftvec = fr->shift_vec[0];
422 fshift = fr->fshift[0];
424 charge = mdatoms->chargeA;
428 nvdwtype = fr->ntype;
430 vdwtype = mdatoms->typeA;
432 /* Setup water-specific parameters */
433 inr = nlist->iinr[0];
434 iq1 = facel*charge[inr+1];
435 iq2 = facel*charge[inr+2];
436 iq3 = facel*charge[inr+3];
437 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
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];
469 ix3 = shX + x[i_coord_offset+DIM*3+XX];
470 iy3 = shY + x[i_coord_offset+DIM*3+YY];
471 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
486 /* Start inner kernel loop */
487 for(jidx=j_index_start; jidx<j_index_end; jidx++)
489 /* Get j neighbor index, and coordinate index */
491 j_coord_offset = DIM*jnr;
493 /* load j atom coordinates */
494 jx0 = x[j_coord_offset+DIM*0+XX];
495 jy0 = x[j_coord_offset+DIM*0+YY];
496 jz0 = x[j_coord_offset+DIM*0+ZZ];
498 /* Calculate displacement vector */
512 /* Calculate squared distance and things based on it */
513 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
514 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
515 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
516 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
518 rinv10 = gmx_invsqrt(rsq10);
519 rinv20 = gmx_invsqrt(rsq20);
520 rinv30 = gmx_invsqrt(rsq30);
522 rinvsq00 = 1.0/rsq00;
523 rinvsq10 = rinv10*rinv10;
524 rinvsq20 = rinv20*rinv20;
525 rinvsq30 = rinv30*rinv30;
527 /* Load parameters for j particles */
529 vdwjidx0 = 2*vdwtype[jnr+0];
531 /**************************
532 * CALCULATE INTERACTIONS *
533 **************************/
535 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
536 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
538 /* LENNARD-JONES DISPERSION/REPULSION */
540 rinvsix = rinvsq00*rinvsq00*rinvsq00;
541 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
545 /* Calculate temporary vectorial force */
550 /* Update vectorial force */
554 f[j_coord_offset+DIM*0+XX] -= tx;
555 f[j_coord_offset+DIM*0+YY] -= ty;
556 f[j_coord_offset+DIM*0+ZZ] -= tz;
558 /**************************
559 * CALCULATE INTERACTIONS *
560 **************************/
564 /* REACTION-FIELD ELECTROSTATICS */
565 felec = qq10*(rinv10*rinvsq10-krf2);
569 /* Calculate temporary vectorial force */
574 /* Update vectorial force */
578 f[j_coord_offset+DIM*0+XX] -= tx;
579 f[j_coord_offset+DIM*0+YY] -= ty;
580 f[j_coord_offset+DIM*0+ZZ] -= tz;
582 /**************************
583 * CALCULATE INTERACTIONS *
584 **************************/
588 /* REACTION-FIELD ELECTROSTATICS */
589 felec = qq20*(rinv20*rinvsq20-krf2);
593 /* Calculate temporary vectorial force */
598 /* Update vectorial force */
602 f[j_coord_offset+DIM*0+XX] -= tx;
603 f[j_coord_offset+DIM*0+YY] -= ty;
604 f[j_coord_offset+DIM*0+ZZ] -= tz;
606 /**************************
607 * CALCULATE INTERACTIONS *
608 **************************/
612 /* REACTION-FIELD ELECTROSTATICS */
613 felec = qq30*(rinv30*rinvsq30-krf2);
617 /* Calculate temporary vectorial force */
622 /* Update vectorial force */
626 f[j_coord_offset+DIM*0+XX] -= tx;
627 f[j_coord_offset+DIM*0+YY] -= ty;
628 f[j_coord_offset+DIM*0+ZZ] -= tz;
630 /* Inner loop uses 108 flops */
632 /* End of innermost loop */
635 f[i_coord_offset+DIM*0+XX] += fix0;
636 f[i_coord_offset+DIM*0+YY] += fiy0;
637 f[i_coord_offset+DIM*0+ZZ] += fiz0;
641 f[i_coord_offset+DIM*1+XX] += fix1;
642 f[i_coord_offset+DIM*1+YY] += fiy1;
643 f[i_coord_offset+DIM*1+ZZ] += fiz1;
647 f[i_coord_offset+DIM*2+XX] += fix2;
648 f[i_coord_offset+DIM*2+YY] += fiy2;
649 f[i_coord_offset+DIM*2+ZZ] += fiz2;
653 f[i_coord_offset+DIM*3+XX] += fix3;
654 f[i_coord_offset+DIM*3+YY] += fiy3;
655 f[i_coord_offset+DIM*3+ZZ] += fiz3;
659 fshift[i_shift_offset+XX] += tx;
660 fshift[i_shift_offset+YY] += ty;
661 fshift[i_shift_offset+ZZ] += tz;
663 /* Increment number of inner iterations */
664 inneriter += j_index_end - j_index_start;
666 /* Outer loop uses 39 flops */
669 /* Increment number of outer iterations */
672 /* Update outer/inner flops */
674 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);