OpenMPCD
GEMn.hpp
1 #ifndef OPENMPCD_PAIRPOTENTIALS_GEMN_HPP
2 #define OPENMPCD_PAIRPOTENTIALS_GEMN_HPP
3 
4 #include <OpenMPCD/PairPotentials/Base.hpp>
5 
6 namespace OpenMPCD
7 {
8 namespace PairPotentials
9 {
10 
11 /**
12  * GEM-n Interaction
13  * \f$ \epsilon \exp ( - (\frac{r}{\sigma})^n ) \f$
14  * An extension of the Gaussian Core Model,
15  * see Stillinger, F. H. Phase Transition in the gaussian core system J.Chem.Phys. 65, 3968-3947 (1976)
16  * and Nikoubashman, A. Non-Equilibrium Computer Experiments of Soft Matter Systems TU Wien, PhD Thesis (2012)
17  *
18  * @tparam T The numeric base type.
19  */
20 template<typename T = FP>
21 class GEMn : public Base<T>
22 {
23 public:
24  /**
25  * The constructor.
26  * @param[in] eps Depth of the potential well.
27  * @param[in] sigma Width of the gaussian core.
28  * @param[in] n Exponent of \f$ r \f$.
29  */
31  GEMn(const T eps, const T sigma, const int n)
32  : epsilon(eps), sigma(sigma), n(n)
33  {
34  }
35 
36  /**
37  * Returns the force vector of the interaction for a given position vector.
38  *
39  * This function returns the directional derivative
40  * \f[ - \nabla_R V \left( \vec{R} \right) \f]
41  * where \f$ \vec{R} \f$ is the `R` parameter, \f$ V \f$ is the potential
42  * as given by the `potential` function, and \f$ \nabla_R V \f$ is the
43  * gradient of \f$ V \f$ with respect to \f$ \vec{R} \f$.
44  *
45  * @param[in] R The relative position vector.
46  */
48  Vector3D<T> force(const Vector3D<T>& R) const
49  {
50  const T abs_r = R.getMagnitude();
51  const T rOverSigma = pow( (abs_r/sigma), double(n));
52  return (( n * epsilon * rOverSigma * exp((-1) * rOverSigma)) / (abs_r)) * R.getNormalized();
53  }
54 
55  /**
56  * Returns the potential of the interaction for a given position vector.
57  * @param[in] R The relative position vector.
58  */
60  T potential(const Vector3D<T>& R) const
61  {
62  return epsilon*exp((-1) * pow( (R.getMagnitude()/sigma), double(n)) );
63  }
64 
65 private:
66  const T epsilon;
67  const T sigma;
68  const int n;
69 }; //class GEMn
70 
71 } //namespace PairPotentials
72 } //namespace OpenMPCD
73 #endif //OPENMPCD_PAIRPOTENTIALS_GEMN_HPP
OpenMPCD::PairPotentials::GEMn
GEM-n Interaction An extension of the Gaussian Core Model, see Stillinger, F.
Definition: GEMn.hpp:21
OpenMPCD::Vector3D
3-dimensional vector.
Definition: Vector3D.hpp:38
OpenMPCD::CUDA::DeviceCode::pow
OPENMPCD_CUDA_HOST_AND_DEVICE boost::enable_if< boost::is_integral< B >, double >::type pow(const B base, const double exponent)
The power function.
Definition: Utilities.hpp:50
OPENMPCD_CUDA_HOST_AND_DEVICE
#define OPENMPCD_CUDA_HOST_AND_DEVICE
Denotes a function to be callable both from the Host and from a CUDA Device.
Definition: Macros.hpp:15
OpenMPCD::Vector3D::getNormalized
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getNormalized() const
Returns this vector, but normalized.
Definition: Vector3D.hpp:264
OpenMPCD::PairPotentials::GEMn::force
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.
Definition: GEMn.hpp:48
OpenMPCD::PairPotentials::GEMn::GEMn
OPENMPCD_CUDA_HOST_AND_DEVICE GEMn(const T eps, const T sigma, const int n)
The constructor.
Definition: GEMn.hpp:31
OpenMPCD::PairPotentials::GEMn::potential
OPENMPCD_CUDA_HOST_AND_DEVICE T potential(const Vector3D< T > &R) const
Returns the potential of the interaction for a given position vector.
Definition: GEMn.hpp:60
OpenMPCD::PairPotentials::Base
Abstract base class for pair potentials.
Definition: PairPotentials/Base.hpp:24
OpenMPCD::Vector3D::getMagnitude
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitude() const
Returns the magnitude of this vector.
Definition: Vector3D.hpp:227