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_ElecRF_VdwNone_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: None
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwNone_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 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
77 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
79 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
80 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
81 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
82 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
83 real velec,felec,velecsum,facel,crf,krf,krf2;
91 jindex = nlist->jindex;
93 shiftidx = nlist->shift;
95 shiftvec = fr->shift_vec[0];
96 fshift = fr->fshift[0];
98 charge = mdatoms->chargeA;
103 /* Setup water-specific parameters */
104 inr = nlist->iinr[0];
105 iq1 = facel*charge[inr+1];
106 iq2 = facel*charge[inr+2];
107 iq3 = facel*charge[inr+3];
112 /* Start outer loop over neighborlists */
113 for(iidx=0; iidx<nri; iidx++)
115 /* Load shift vector for this list */
116 i_shift_offset = DIM*shiftidx[iidx];
117 shX = shiftvec[i_shift_offset+XX];
118 shY = shiftvec[i_shift_offset+YY];
119 shZ = shiftvec[i_shift_offset+ZZ];
121 /* Load limits for loop over neighbors */
122 j_index_start = jindex[iidx];
123 j_index_end = jindex[iidx+1];
125 /* Get outer coordinate index */
127 i_coord_offset = DIM*inr;
129 /* Load i particle coords and add shift vector */
130 ix1 = shX + x[i_coord_offset+DIM*1+XX];
131 iy1 = shY + x[i_coord_offset+DIM*1+YY];
132 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
133 ix2 = shX + x[i_coord_offset+DIM*2+XX];
134 iy2 = shY + x[i_coord_offset+DIM*2+YY];
135 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
136 ix3 = shX + x[i_coord_offset+DIM*3+XX];
137 iy3 = shY + x[i_coord_offset+DIM*3+YY];
138 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
150 /* Reset potential sums */
153 /* Start inner kernel loop */
154 for(jidx=j_index_start; jidx<j_index_end; jidx++)
156 /* Get j neighbor index, and coordinate index */
158 j_coord_offset = DIM*jnr;
160 /* load j atom coordinates */
161 jx0 = x[j_coord_offset+DIM*0+XX];
162 jy0 = x[j_coord_offset+DIM*0+YY];
163 jz0 = x[j_coord_offset+DIM*0+ZZ];
165 /* Calculate displacement vector */
176 /* Calculate squared distance and things based on it */
177 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
178 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
179 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
181 rinv10 = gmx_invsqrt(rsq10);
182 rinv20 = gmx_invsqrt(rsq20);
183 rinv30 = gmx_invsqrt(rsq30);
185 rinvsq10 = rinv10*rinv10;
186 rinvsq20 = rinv20*rinv20;
187 rinvsq30 = rinv30*rinv30;
189 /* Load parameters for j particles */
192 /**************************
193 * CALCULATE INTERACTIONS *
194 **************************/
198 /* REACTION-FIELD ELECTROSTATICS */
199 velec = qq10*(rinv10+krf*rsq10-crf);
200 felec = qq10*(rinv10*rinvsq10-krf2);
202 /* Update potential sums from outer loop */
207 /* Calculate temporary vectorial force */
212 /* Update vectorial force */
216 f[j_coord_offset+DIM*0+XX] -= tx;
217 f[j_coord_offset+DIM*0+YY] -= ty;
218 f[j_coord_offset+DIM*0+ZZ] -= tz;
220 /**************************
221 * CALCULATE INTERACTIONS *
222 **************************/
226 /* REACTION-FIELD ELECTROSTATICS */
227 velec = qq20*(rinv20+krf*rsq20-crf);
228 felec = qq20*(rinv20*rinvsq20-krf2);
230 /* Update potential sums from outer loop */
235 /* Calculate temporary vectorial force */
240 /* Update vectorial force */
244 f[j_coord_offset+DIM*0+XX] -= tx;
245 f[j_coord_offset+DIM*0+YY] -= ty;
246 f[j_coord_offset+DIM*0+ZZ] -= tz;
248 /**************************
249 * CALCULATE INTERACTIONS *
250 **************************/
254 /* REACTION-FIELD ELECTROSTATICS */
255 velec = qq30*(rinv30+krf*rsq30-crf);
256 felec = qq30*(rinv30*rinvsq30-krf2);
258 /* Update potential sums from outer loop */
263 /* Calculate temporary vectorial force */
268 /* Update vectorial force */
272 f[j_coord_offset+DIM*0+XX] -= tx;
273 f[j_coord_offset+DIM*0+YY] -= ty;
274 f[j_coord_offset+DIM*0+ZZ] -= tz;
276 /* Inner loop uses 96 flops */
278 /* End of innermost loop */
281 f[i_coord_offset+DIM*1+XX] += fix1;
282 f[i_coord_offset+DIM*1+YY] += fiy1;
283 f[i_coord_offset+DIM*1+ZZ] += fiz1;
287 f[i_coord_offset+DIM*2+XX] += fix2;
288 f[i_coord_offset+DIM*2+YY] += fiy2;
289 f[i_coord_offset+DIM*2+ZZ] += fiz2;
293 f[i_coord_offset+DIM*3+XX] += fix3;
294 f[i_coord_offset+DIM*3+YY] += fiy3;
295 f[i_coord_offset+DIM*3+ZZ] += fiz3;
299 fshift[i_shift_offset+XX] += tx;
300 fshift[i_shift_offset+YY] += ty;
301 fshift[i_shift_offset+ZZ] += tz;
304 /* Update potential energies */
305 kernel_data->energygrp_elec[ggid] += velecsum;
307 /* Increment number of inner iterations */
308 inneriter += j_index_end - j_index_start;
310 /* Outer loop uses 31 flops */
313 /* Increment number of outer iterations */
316 /* Update outer/inner flops */
318 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*31 + inneriter*96);
321 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4P1_F_c
322 * Electrostatics interaction: ReactionField
323 * VdW interaction: None
324 * Geometry: Water4-Particle
325 * Calculate force/pot: Force
328 nb_kernel_ElecRF_VdwNone_GeomW4P1_F_c
329 (t_nblist * gmx_restrict nlist,
330 rvec * gmx_restrict xx,
331 rvec * gmx_restrict ff,
332 t_forcerec * gmx_restrict fr,
333 t_mdatoms * gmx_restrict mdatoms,
334 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
335 t_nrnb * gmx_restrict nrnb)
337 int i_shift_offset,i_coord_offset,j_coord_offset;
338 int j_index_start,j_index_end;
339 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
340 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
341 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
342 real *shiftvec,*fshift,*x,*f;
344 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
346 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
348 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
350 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
351 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
352 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
353 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
354 real velec,felec,velecsum,facel,crf,krf,krf2;
362 jindex = nlist->jindex;
364 shiftidx = nlist->shift;
366 shiftvec = fr->shift_vec[0];
367 fshift = fr->fshift[0];
369 charge = mdatoms->chargeA;
374 /* Setup water-specific parameters */
375 inr = nlist->iinr[0];
376 iq1 = facel*charge[inr+1];
377 iq2 = facel*charge[inr+2];
378 iq3 = facel*charge[inr+3];
383 /* Start outer loop over neighborlists */
384 for(iidx=0; iidx<nri; iidx++)
386 /* Load shift vector for this list */
387 i_shift_offset = DIM*shiftidx[iidx];
388 shX = shiftvec[i_shift_offset+XX];
389 shY = shiftvec[i_shift_offset+YY];
390 shZ = shiftvec[i_shift_offset+ZZ];
392 /* Load limits for loop over neighbors */
393 j_index_start = jindex[iidx];
394 j_index_end = jindex[iidx+1];
396 /* Get outer coordinate index */
398 i_coord_offset = DIM*inr;
400 /* Load i particle coords and add shift vector */
401 ix1 = shX + x[i_coord_offset+DIM*1+XX];
402 iy1 = shY + x[i_coord_offset+DIM*1+YY];
403 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
404 ix2 = shX + x[i_coord_offset+DIM*2+XX];
405 iy2 = shY + x[i_coord_offset+DIM*2+YY];
406 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
407 ix3 = shX + x[i_coord_offset+DIM*3+XX];
408 iy3 = shY + x[i_coord_offset+DIM*3+YY];
409 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
421 /* Start inner kernel loop */
422 for(jidx=j_index_start; jidx<j_index_end; jidx++)
424 /* Get j neighbor index, and coordinate index */
426 j_coord_offset = DIM*jnr;
428 /* load j atom coordinates */
429 jx0 = x[j_coord_offset+DIM*0+XX];
430 jy0 = x[j_coord_offset+DIM*0+YY];
431 jz0 = x[j_coord_offset+DIM*0+ZZ];
433 /* Calculate displacement vector */
444 /* Calculate squared distance and things based on it */
445 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
446 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
447 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
449 rinv10 = gmx_invsqrt(rsq10);
450 rinv20 = gmx_invsqrt(rsq20);
451 rinv30 = gmx_invsqrt(rsq30);
453 rinvsq10 = rinv10*rinv10;
454 rinvsq20 = rinv20*rinv20;
455 rinvsq30 = rinv30*rinv30;
457 /* Load parameters for j particles */
460 /**************************
461 * CALCULATE INTERACTIONS *
462 **************************/
466 /* REACTION-FIELD ELECTROSTATICS */
467 felec = qq10*(rinv10*rinvsq10-krf2);
471 /* Calculate temporary vectorial force */
476 /* Update vectorial force */
480 f[j_coord_offset+DIM*0+XX] -= tx;
481 f[j_coord_offset+DIM*0+YY] -= ty;
482 f[j_coord_offset+DIM*0+ZZ] -= tz;
484 /**************************
485 * CALCULATE INTERACTIONS *
486 **************************/
490 /* REACTION-FIELD ELECTROSTATICS */
491 felec = qq20*(rinv20*rinvsq20-krf2);
495 /* Calculate temporary vectorial force */
500 /* Update vectorial force */
504 f[j_coord_offset+DIM*0+XX] -= tx;
505 f[j_coord_offset+DIM*0+YY] -= ty;
506 f[j_coord_offset+DIM*0+ZZ] -= tz;
508 /**************************
509 * CALCULATE INTERACTIONS *
510 **************************/
514 /* REACTION-FIELD ELECTROSTATICS */
515 felec = qq30*(rinv30*rinvsq30-krf2);
519 /* Calculate temporary vectorial force */
524 /* Update vectorial force */
528 f[j_coord_offset+DIM*0+XX] -= tx;
529 f[j_coord_offset+DIM*0+YY] -= ty;
530 f[j_coord_offset+DIM*0+ZZ] -= tz;
532 /* Inner loop uses 81 flops */
534 /* End of innermost loop */
537 f[i_coord_offset+DIM*1+XX] += fix1;
538 f[i_coord_offset+DIM*1+YY] += fiy1;
539 f[i_coord_offset+DIM*1+ZZ] += fiz1;
543 f[i_coord_offset+DIM*2+XX] += fix2;
544 f[i_coord_offset+DIM*2+YY] += fiy2;
545 f[i_coord_offset+DIM*2+ZZ] += fiz2;
549 f[i_coord_offset+DIM*3+XX] += fix3;
550 f[i_coord_offset+DIM*3+YY] += fiy3;
551 f[i_coord_offset+DIM*3+ZZ] += fiz3;
555 fshift[i_shift_offset+XX] += tx;
556 fshift[i_shift_offset+YY] += ty;
557 fshift[i_shift_offset+ZZ] += tz;
559 /* Increment number of inner iterations */
560 inneriter += j_index_end - j_index_start;
562 /* Outer loop uses 30 flops */
565 /* Increment number of outer iterations */
568 /* Update outer/inner flops */
570 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*30 + inneriter*81);