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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_VF_c
49 * Electrostatics interaction: GeneralizedBorn
50 * VdW interaction: LennardJones
51 * Geometry: Particle-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecGB_VdwLJ_GeomP1P1_VF_c
56 (t_nblist
* gmx_restrict nlist
,
57 rvec
* gmx_restrict xx
,
58 rvec
* gmx_restrict ff
,
59 t_forcerec
* gmx_restrict fr
,
60 t_mdatoms
* gmx_restrict mdatoms
,
61 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
62 t_nrnb
* gmx_restrict nrnb
)
64 int i_shift_offset
,i_coord_offset
,j_coord_offset
;
65 int j_index_start
,j_index_end
;
66 int nri
,inr
,ggid
,iidx
,jidx
,jnr
,outeriter
,inneriter
;
67 real shX
,shY
,shZ
,tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
;
68 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
69 real
*shiftvec
,*fshift
,*x
,*f
;
71 real ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
73 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
74 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
75 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
78 real vgb
,fgb
,vgbsum
,dvdasum
,gbscale
,gbtabscale
,isaprod
,gbqqfactor
,gbinvepsdiff
,dvdaj
,gbeps
,dvdatmp
;
79 real
*invsqrta
,*dvda
,*gbtab
;
81 real rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,br
,vvdwexp
,sh_vdw_invrcut6
;
85 real rt
,vfeps
,vftabscale
,Y
,F
,Geps
,Heps2
,Fp
,VV
,FF
;
93 jindex
= nlist
->jindex
;
95 shiftidx
= nlist
->shift
;
97 shiftvec
= fr
->shift_vec
[0];
98 fshift
= fr
->fshift
[0];
100 charge
= mdatoms
->chargeA
;
101 nvdwtype
= fr
->ntype
;
103 vdwtype
= mdatoms
->typeA
;
105 invsqrta
= fr
->invsqrta
;
107 gbtabscale
= fr
->gbtab
.scale
;
108 gbtab
= fr
->gbtab
.data
;
109 gbinvepsdiff
= (1.0/fr
->epsilon_r
) - (1.0/fr
->gb_epsilon_solvent
);
114 /* Start outer loop over neighborlists */
115 for(iidx
=0; iidx
<nri
; iidx
++)
117 /* Load shift vector for this list */
118 i_shift_offset
= DIM
*shiftidx
[iidx
];
119 shX
= shiftvec
[i_shift_offset
+XX
];
120 shY
= shiftvec
[i_shift_offset
+YY
];
121 shZ
= shiftvec
[i_shift_offset
+ZZ
];
123 /* Load limits for loop over neighbors */
124 j_index_start
= jindex
[iidx
];
125 j_index_end
= jindex
[iidx
+1];
127 /* Get outer coordinate index */
129 i_coord_offset
= DIM
*inr
;
131 /* Load i particle coords and add shift vector */
132 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
133 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
134 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
140 /* Load parameters for i particles */
141 iq0
= facel
*charge
[inr
+0];
142 isai0
= invsqrta
[inr
+0];
143 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
145 /* Reset potential sums */
151 /* Start inner kernel loop */
152 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
154 /* Get j neighbor index, and coordinate index */
156 j_coord_offset
= DIM
*jnr
;
158 /* load j atom coordinates */
159 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
160 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
161 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
163 /* Calculate displacement vector */
168 /* Calculate squared distance and things based on it */
169 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
171 rinv00
= gmx_invsqrt(rsq00
);
173 rinvsq00
= rinv00
*rinv00
;
175 /* Load parameters for j particles */
177 isaj0
= invsqrta
[jnr
+0];
178 vdwjidx0
= 2*vdwtype
[jnr
+0];
180 /**************************
181 * CALCULATE INTERACTIONS *
182 **************************/
187 c6_00
= vdwparam
[vdwioffset0
+vdwjidx0
];
188 c12_00
= vdwparam
[vdwioffset0
+vdwjidx0
+1];
190 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
191 isaprod
= isai0
*isaj0
;
192 gbqqfactor
= isaprod
*(-qq00
)*gbinvepsdiff
;
193 gbscale
= isaprod
*gbtabscale
;
196 /* Calculate generalized born table index - this is a separate table from the normal one,
197 * but we use the same procedure by multiplying r with scale and truncating to integer.
206 Geps
= gbeps
*gbtab
[gbitab
+2];
207 Heps2
= gbeps
*gbeps
*gbtab
[gbitab
+3];
212 FF
= Fp
+Geps
+2.0*Heps2
;
213 fgb
= gbqqfactor
*FF
*gbscale
;
214 dvdatmp
= -0.5*(vgb
+fgb
*r00
);
215 dvdasum
= dvdasum
+ dvdatmp
;
216 dvda
[jnr
] = dvdaj
+dvdatmp
*isaj0
*isaj0
;
218 felec
= (velec
*rinv00
-fgb
)*rinv00
;
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 */
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 /* Inner loop uses 71 flops */
250 /* End of innermost loop */
253 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
254 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
255 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
259 fshift
[i_shift_offset
+XX
] += tx
;
260 fshift
[i_shift_offset
+YY
] += ty
;
261 fshift
[i_shift_offset
+ZZ
] += tz
;
264 /* Update potential energies */
265 kernel_data
->energygrp_elec
[ggid
] += velecsum
;
266 kernel_data
->energygrp_polarization
[ggid
] += vgbsum
;
267 kernel_data
->energygrp_vdw
[ggid
] += vvdwsum
;
268 dvda
[inr
] = dvda
[inr
] + dvdasum
*isai0
*isai0
;
270 /* Increment number of inner iterations */
271 inneriter
+= j_index_end
- j_index_start
;
273 /* Outer loop uses 16 flops */
276 /* Increment number of outer iterations */
279 /* Update outer/inner flops */
281 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_VF
,outeriter
*16 + inneriter
*71);
284 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
285 * Electrostatics interaction: GeneralizedBorn
286 * VdW interaction: LennardJones
287 * Geometry: Particle-Particle
288 * Calculate force/pot: Force
291 nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_c
292 (t_nblist
* gmx_restrict nlist
,
293 rvec
* gmx_restrict xx
,
294 rvec
* gmx_restrict ff
,
295 t_forcerec
* gmx_restrict fr
,
296 t_mdatoms
* gmx_restrict mdatoms
,
297 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
298 t_nrnb
* gmx_restrict nrnb
)
300 int i_shift_offset
,i_coord_offset
,j_coord_offset
;
301 int j_index_start
,j_index_end
;
302 int nri
,inr
,ggid
,iidx
,jidx
,jnr
,outeriter
,inneriter
;
303 real shX
,shY
,shZ
,tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
;
304 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
305 real
*shiftvec
,*fshift
,*x
,*f
;
307 real ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
309 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
310 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
311 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
314 real vgb
,fgb
,vgbsum
,dvdasum
,gbscale
,gbtabscale
,isaprod
,gbqqfactor
,gbinvepsdiff
,dvdaj
,gbeps
,dvdatmp
;
315 real
*invsqrta
,*dvda
,*gbtab
;
317 real rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,br
,vvdwexp
,sh_vdw_invrcut6
;
321 real rt
,vfeps
,vftabscale
,Y
,F
,Geps
,Heps2
,Fp
,VV
,FF
;
329 jindex
= nlist
->jindex
;
331 shiftidx
= nlist
->shift
;
333 shiftvec
= fr
->shift_vec
[0];
334 fshift
= fr
->fshift
[0];
336 charge
= mdatoms
->chargeA
;
337 nvdwtype
= fr
->ntype
;
339 vdwtype
= mdatoms
->typeA
;
341 invsqrta
= fr
->invsqrta
;
343 gbtabscale
= fr
->gbtab
.scale
;
344 gbtab
= fr
->gbtab
.data
;
345 gbinvepsdiff
= (1.0/fr
->epsilon_r
) - (1.0/fr
->gb_epsilon_solvent
);
350 /* Start outer loop over neighborlists */
351 for(iidx
=0; iidx
<nri
; iidx
++)
353 /* Load shift vector for this list */
354 i_shift_offset
= DIM
*shiftidx
[iidx
];
355 shX
= shiftvec
[i_shift_offset
+XX
];
356 shY
= shiftvec
[i_shift_offset
+YY
];
357 shZ
= shiftvec
[i_shift_offset
+ZZ
];
359 /* Load limits for loop over neighbors */
360 j_index_start
= jindex
[iidx
];
361 j_index_end
= jindex
[iidx
+1];
363 /* Get outer coordinate index */
365 i_coord_offset
= DIM
*inr
;
367 /* Load i particle coords and add shift vector */
368 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
369 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
370 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
376 /* Load parameters for i particles */
377 iq0
= facel
*charge
[inr
+0];
378 isai0
= invsqrta
[inr
+0];
379 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
383 /* Start inner kernel loop */
384 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
386 /* Get j neighbor index, and coordinate index */
388 j_coord_offset
= DIM
*jnr
;
390 /* load j atom coordinates */
391 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
392 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
393 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
395 /* Calculate displacement vector */
400 /* Calculate squared distance and things based on it */
401 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
403 rinv00
= gmx_invsqrt(rsq00
);
405 rinvsq00
= rinv00
*rinv00
;
407 /* Load parameters for j particles */
409 isaj0
= invsqrta
[jnr
+0];
410 vdwjidx0
= 2*vdwtype
[jnr
+0];
412 /**************************
413 * CALCULATE INTERACTIONS *
414 **************************/
419 c6_00
= vdwparam
[vdwioffset0
+vdwjidx0
];
420 c12_00
= vdwparam
[vdwioffset0
+vdwjidx0
+1];
422 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
423 isaprod
= isai0
*isaj0
;
424 gbqqfactor
= isaprod
*(-qq00
)*gbinvepsdiff
;
425 gbscale
= isaprod
*gbtabscale
;
428 /* Calculate generalized born table index - this is a separate table from the normal one,
429 * but we use the same procedure by multiplying r with scale and truncating to integer.
438 Geps
= gbeps
*gbtab
[gbitab
+2];
439 Heps2
= gbeps
*gbeps
*gbtab
[gbitab
+3];
444 FF
= Fp
+Geps
+2.0*Heps2
;
445 fgb
= gbqqfactor
*FF
*gbscale
;
446 dvdatmp
= -0.5*(vgb
+fgb
*r00
);
447 dvdasum
= dvdasum
+ dvdatmp
;
448 dvda
[jnr
] = dvdaj
+dvdatmp
*isaj0
*isaj0
;
450 felec
= (velec
*rinv00
-fgb
)*rinv00
;
452 /* LENNARD-JONES DISPERSION/REPULSION */
454 rinvsix
= rinvsq00
*rinvsq00
*rinvsq00
;
455 fvdw
= (c12_00
*rinvsix
-c6_00
)*rinvsix
*rinvsq00
;
459 /* Calculate temporary vectorial force */
464 /* Update vectorial force */
468 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
469 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
470 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
472 /* Inner loop uses 64 flops */
474 /* End of innermost loop */
477 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
478 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
479 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
483 fshift
[i_shift_offset
+XX
] += tx
;
484 fshift
[i_shift_offset
+YY
] += ty
;
485 fshift
[i_shift_offset
+ZZ
] += tz
;
487 dvda
[inr
] = dvda
[inr
] + dvdasum
*isai0
*isai0
;
489 /* Increment number of inner iterations */
490 inneriter
+= j_index_end
- j_index_start
;
492 /* Outer loop uses 13 flops */
495 /* Increment number of outer iterations */
498 /* Update outer/inner flops */
500 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_F
,outeriter
*13 + inneriter
*64);