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_VdwNone_GeomW4P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: None
37 * Geometry: Water4-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwNone_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
59 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
61 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
65 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
66 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
75 jindex = nlist->jindex;
77 shiftidx = nlist->shift;
79 shiftvec = fr->shift_vec[0];
80 fshift = fr->fshift[0];
82 charge = mdatoms->chargeA;
87 /* Setup water-specific parameters */
89 iq1 = facel*charge[inr+1];
90 iq2 = facel*charge[inr+2];
91 iq3 = facel*charge[inr+3];
96 /* Start outer loop over neighborlists */
97 for(iidx=0; iidx<nri; iidx++)
99 /* Load shift vector for this list */
100 i_shift_offset = DIM*shiftidx[iidx];
101 shX = shiftvec[i_shift_offset+XX];
102 shY = shiftvec[i_shift_offset+YY];
103 shZ = shiftvec[i_shift_offset+ZZ];
105 /* Load limits for loop over neighbors */
106 j_index_start = jindex[iidx];
107 j_index_end = jindex[iidx+1];
109 /* Get outer coordinate index */
111 i_coord_offset = DIM*inr;
113 /* Load i particle coords and add shift vector */
114 ix1 = shX + x[i_coord_offset+DIM*1+XX];
115 iy1 = shY + x[i_coord_offset+DIM*1+YY];
116 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
117 ix2 = shX + x[i_coord_offset+DIM*2+XX];
118 iy2 = shY + x[i_coord_offset+DIM*2+YY];
119 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
120 ix3 = shX + x[i_coord_offset+DIM*3+XX];
121 iy3 = shY + x[i_coord_offset+DIM*3+YY];
122 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
134 /* Reset potential sums */
137 /* Start inner kernel loop */
138 for(jidx=j_index_start; jidx<j_index_end; jidx++)
140 /* Get j neighbor index, and coordinate index */
142 j_coord_offset = DIM*jnr;
144 /* load j atom coordinates */
145 jx0 = x[j_coord_offset+DIM*0+XX];
146 jy0 = x[j_coord_offset+DIM*0+YY];
147 jz0 = x[j_coord_offset+DIM*0+ZZ];
149 /* Calculate displacement vector */
160 /* Calculate squared distance and things based on it */
161 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
162 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
163 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
165 rinv10 = gmx_invsqrt(rsq10);
166 rinv20 = gmx_invsqrt(rsq20);
167 rinv30 = gmx_invsqrt(rsq30);
169 rinvsq10 = rinv10*rinv10;
170 rinvsq20 = rinv20*rinv20;
171 rinvsq30 = rinv30*rinv30;
173 /* Load parameters for j particles */
176 /**************************
177 * CALCULATE INTERACTIONS *
178 **************************/
182 /* REACTION-FIELD ELECTROSTATICS */
183 velec = qq10*(rinv10+krf*rsq10-crf);
184 felec = qq10*(rinv10*rinvsq10-krf2);
186 /* Update potential sums from outer loop */
191 /* Calculate temporary vectorial force */
196 /* Update vectorial force */
200 f[j_coord_offset+DIM*0+XX] -= tx;
201 f[j_coord_offset+DIM*0+YY] -= ty;
202 f[j_coord_offset+DIM*0+ZZ] -= tz;
204 /**************************
205 * CALCULATE INTERACTIONS *
206 **************************/
210 /* REACTION-FIELD ELECTROSTATICS */
211 velec = qq20*(rinv20+krf*rsq20-crf);
212 felec = qq20*(rinv20*rinvsq20-krf2);
214 /* Update potential sums from outer loop */
219 /* Calculate temporary vectorial force */
224 /* Update vectorial force */
228 f[j_coord_offset+DIM*0+XX] -= tx;
229 f[j_coord_offset+DIM*0+YY] -= ty;
230 f[j_coord_offset+DIM*0+ZZ] -= tz;
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
238 /* REACTION-FIELD ELECTROSTATICS */
239 velec = qq30*(rinv30+krf*rsq30-crf);
240 felec = qq30*(rinv30*rinvsq30-krf2);
242 /* Update potential sums from outer loop */
247 /* Calculate temporary vectorial force */
252 /* Update vectorial force */
256 f[j_coord_offset+DIM*0+XX] -= tx;
257 f[j_coord_offset+DIM*0+YY] -= ty;
258 f[j_coord_offset+DIM*0+ZZ] -= tz;
260 /* Inner loop uses 96 flops */
262 /* End of innermost loop */
265 f[i_coord_offset+DIM*1+XX] += fix1;
266 f[i_coord_offset+DIM*1+YY] += fiy1;
267 f[i_coord_offset+DIM*1+ZZ] += fiz1;
271 f[i_coord_offset+DIM*2+XX] += fix2;
272 f[i_coord_offset+DIM*2+YY] += fiy2;
273 f[i_coord_offset+DIM*2+ZZ] += fiz2;
277 f[i_coord_offset+DIM*3+XX] += fix3;
278 f[i_coord_offset+DIM*3+YY] += fiy3;
279 f[i_coord_offset+DIM*3+ZZ] += fiz3;
283 fshift[i_shift_offset+XX] += tx;
284 fshift[i_shift_offset+YY] += ty;
285 fshift[i_shift_offset+ZZ] += tz;
288 /* Update potential energies */
289 kernel_data->energygrp_elec[ggid] += velecsum;
291 /* Increment number of inner iterations */
292 inneriter += j_index_end - j_index_start;
294 /* Outer loop uses 31 flops */
297 /* Increment number of outer iterations */
300 /* Update outer/inner flops */
302 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*96);
305 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4P1_F_c
306 * Electrostatics interaction: ReactionField
307 * VdW interaction: None
308 * Geometry: Water4-Particle
309 * Calculate force/pot: Force
312 nb_kernel_ElecRF_VdwNone_GeomW4P1_F_c
313 (t_nblist * gmx_restrict nlist,
314 rvec * gmx_restrict xx,
315 rvec * gmx_restrict ff,
316 t_forcerec * gmx_restrict fr,
317 t_mdatoms * gmx_restrict mdatoms,
318 nb_kernel_data_t * gmx_restrict kernel_data,
319 t_nrnb * gmx_restrict nrnb)
321 int i_shift_offset,i_coord_offset,j_coord_offset;
322 int j_index_start,j_index_end;
323 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
324 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
325 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
326 real *shiftvec,*fshift,*x,*f;
328 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
330 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
332 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
334 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
335 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
336 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
337 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
338 real velec,felec,velecsum,facel,crf,krf,krf2;
346 jindex = nlist->jindex;
348 shiftidx = nlist->shift;
350 shiftvec = fr->shift_vec[0];
351 fshift = fr->fshift[0];
353 charge = mdatoms->chargeA;
358 /* Setup water-specific parameters */
359 inr = nlist->iinr[0];
360 iq1 = facel*charge[inr+1];
361 iq2 = facel*charge[inr+2];
362 iq3 = facel*charge[inr+3];
367 /* Start outer loop over neighborlists */
368 for(iidx=0; iidx<nri; iidx++)
370 /* Load shift vector for this list */
371 i_shift_offset = DIM*shiftidx[iidx];
372 shX = shiftvec[i_shift_offset+XX];
373 shY = shiftvec[i_shift_offset+YY];
374 shZ = shiftvec[i_shift_offset+ZZ];
376 /* Load limits for loop over neighbors */
377 j_index_start = jindex[iidx];
378 j_index_end = jindex[iidx+1];
380 /* Get outer coordinate index */
382 i_coord_offset = DIM*inr;
384 /* Load i particle coords and add shift vector */
385 ix1 = shX + x[i_coord_offset+DIM*1+XX];
386 iy1 = shY + x[i_coord_offset+DIM*1+YY];
387 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
388 ix2 = shX + x[i_coord_offset+DIM*2+XX];
389 iy2 = shY + x[i_coord_offset+DIM*2+YY];
390 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
391 ix3 = shX + x[i_coord_offset+DIM*3+XX];
392 iy3 = shY + x[i_coord_offset+DIM*3+YY];
393 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
405 /* Start inner kernel loop */
406 for(jidx=j_index_start; jidx<j_index_end; jidx++)
408 /* Get j neighbor index, and coordinate index */
410 j_coord_offset = DIM*jnr;
412 /* load j atom coordinates */
413 jx0 = x[j_coord_offset+DIM*0+XX];
414 jy0 = x[j_coord_offset+DIM*0+YY];
415 jz0 = x[j_coord_offset+DIM*0+ZZ];
417 /* Calculate displacement vector */
428 /* Calculate squared distance and things based on it */
429 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
430 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
431 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
433 rinv10 = gmx_invsqrt(rsq10);
434 rinv20 = gmx_invsqrt(rsq20);
435 rinv30 = gmx_invsqrt(rsq30);
437 rinvsq10 = rinv10*rinv10;
438 rinvsq20 = rinv20*rinv20;
439 rinvsq30 = rinv30*rinv30;
441 /* Load parameters for j particles */
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
450 /* REACTION-FIELD ELECTROSTATICS */
451 felec = qq10*(rinv10*rinvsq10-krf2);
455 /* Calculate temporary vectorial force */
460 /* Update vectorial force */
464 f[j_coord_offset+DIM*0+XX] -= tx;
465 f[j_coord_offset+DIM*0+YY] -= ty;
466 f[j_coord_offset+DIM*0+ZZ] -= tz;
468 /**************************
469 * CALCULATE INTERACTIONS *
470 **************************/
474 /* REACTION-FIELD ELECTROSTATICS */
475 felec = qq20*(rinv20*rinvsq20-krf2);
479 /* Calculate temporary vectorial force */
484 /* Update vectorial force */
488 f[j_coord_offset+DIM*0+XX] -= tx;
489 f[j_coord_offset+DIM*0+YY] -= ty;
490 f[j_coord_offset+DIM*0+ZZ] -= tz;
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
498 /* REACTION-FIELD ELECTROSTATICS */
499 felec = qq30*(rinv30*rinvsq30-krf2);
503 /* Calculate temporary vectorial force */
508 /* Update vectorial force */
512 f[j_coord_offset+DIM*0+XX] -= tx;
513 f[j_coord_offset+DIM*0+YY] -= ty;
514 f[j_coord_offset+DIM*0+ZZ] -= tz;
516 /* Inner loop uses 81 flops */
518 /* End of innermost loop */
521 f[i_coord_offset+DIM*1+XX] += fix1;
522 f[i_coord_offset+DIM*1+YY] += fiy1;
523 f[i_coord_offset+DIM*1+ZZ] += fiz1;
527 f[i_coord_offset+DIM*2+XX] += fix2;
528 f[i_coord_offset+DIM*2+YY] += fiy2;
529 f[i_coord_offset+DIM*2+ZZ] += fiz2;
533 f[i_coord_offset+DIM*3+XX] += fix3;
534 f[i_coord_offset+DIM*3+YY] += fiy3;
535 f[i_coord_offset+DIM*3+ZZ] += fiz3;
539 fshift[i_shift_offset+XX] += tx;
540 fshift[i_shift_offset+YY] += ty;
541 fshift[i_shift_offset+ZZ] += tz;
543 /* Increment number of inner iterations */
544 inneriter += j_index_end - j_index_start;
546 /* Outer loop uses 30 flops */
549 /* Increment number of outer iterations */
552 /* Update outer/inner flops */
554 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*81);