1 #ifndef OPENMPCD_PAIRPOTENTIALS_LENNARDJONES_HPP
2 #define OPENMPCD_PAIRPOTENTIALS_LENNARDJONES_HPP
4 #include <OpenMPCD/PairPotentials/Base.hpp>
8 namespace PairPotentials
25 template<
typename T = FP>
38 LennardJones(
const T r_offset,
const T r_cut,
const T sigma,
const T epsilon)
39 : r_offset(r_offset), r_cut(r_cut), sigma(sigma), epsilon(epsilon)
63 const T oneOverRMinusROffset = 1.0 / (Rv - r_offset);
64 const T ratio = sigma * oneOverRMinusROffset;
65 const T ratio6 =
pow(ratio, 6);
66 const T ratio12 = ratio6 * ratio6;
67 return 24 * epsilon * (2 * ratio12 - ratio6) * oneOverRMinusROffset*R.
getNormalized();
85 return 4*epsilon*(
pow(sigma/(Rv-r_offset ), 12) -
pow(sigma/(Rv-r_offset),6));
98 #endif //OPENMPCD_PAIRPOTENTIALS_LENNARDJONES_HPP
OPENMPCD_CUDA_HOST_AND_DEVICE boost::enable_if< boost::is_integral< B >, double >::type pow(const B base, const double exponent)
The power function.
#define OPENMPCD_CUDA_HOST_AND_DEVICE
Denotes a function to be callable both from the Host and from a CUDA Device.
OPENMPCD_CUDA_HOST_AND_DEVICE LennardJones(const T r_offset, const T r_cut, const T sigma, const T epsilon)
The constructor.
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getNormalized() const
Returns this vector, but normalized.
OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D< T > force(const Vector3D< T > &R) const
Returns the force vector of the interaction for a given position vector.
Abstract base class for pair potentials.
Lennard-Jones Interaction.
OPENMPCD_CUDA_HOST_AND_DEVICE T potential(const Vector3D< T > &R) const
Returns the potential of the interaction for a given position vector.
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitude() const
Returns the magnitude of this vector.