1 /* ----------------------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3 
4    Original Version:
5    http://lammps.sandia.gov, Sandia National Laboratories
6    Steve Plimpton, sjplimp@sandia.gov
7 
8    See the README file in the top-level LAMMPS directory.
9 
10    -----------------------------------------------------------------------
11 
12    USER-CUDA Package and associated modifications:
13    https://sourceforge.net/projects/lammpscuda/
14 
15    Christian Trott, christian.trott@tu-ilmenau.de
16    Lars Winterfeld, lars.winterfeld@tu-ilmenau.de
17    Theoretical Physics II, University of Technology Ilmenau, Germany
18 
19    See the README file in the USER-CUDA directory.
20 
21    This software is distributed under the GNU General Public License.
22 ------------------------------------------------------------------------- */
23 
PairLJGromacsCuda_Eval(const F_FLOAT & rsq,const int ij_type,F_FLOAT & factor_lj,int & eflag,ENERGY_FLOAT & evdwl)24 __device__ inline F_FLOAT PairLJGromacsCuda_Eval(const F_FLOAT &rsq, const int ij_type, F_FLOAT &factor_lj, int &eflag, ENERGY_FLOAT &evdwl)
25 {
26   F_FLOAT tlj;
27   const F_FLOAT r2inv = F_F(1.0) / rsq;
28   const F_FLOAT r = _RSQRT_(r2inv);
29   const F_FLOAT r6inv = r2inv * r2inv * r2inv;
30   F_FLOAT	forcelj = r6inv * (_lj1[ij_type] * r6inv - _lj2[ij_type]);
31   const X_FLOAT cut_lj_innersq = (_cut_innersq_global > X_F(0.0) ? _cut_innersq_global : _cut_innersq[ij_type]);
32 
33   if(rsq > cut_lj_innersq) {
34     tlj = r - _SQRT_(cut_lj_innersq);
35     forcelj += r * tlj * tlj * (_ljsw1[ij_type] + _ljsw2[ij_type] * tlj);
36   }
37 
38   if(eflag) {
39     ENERGY_FLOAT evdwl_tmp = r6inv * (_lj3[ij_type] * r6inv - _lj4[ij_type]);
40 
41     if(rsq > cut_lj_innersq) {
42       evdwl_tmp += tlj * tlj * tlj *
43                    (_ljsw3[ij_type] + _ljsw4[ij_type] * tlj) + _ljsw5[ij_type];;
44     }
45 
46     evdwl += evdwl_tmp * factor_lj;
47   }
48 
49   return factor_lj * forcelj * r2inv;
50 }
51