OpenMPCD
Morse.hpp
1 #ifndef OPENMPCD_PAIRPOTENTIALS_MORSE_HPP
2 #define OPENMPCD_PAIRPOTENTIALS_MORSE_HPP
3 
4 #include <OpenMPCD/PairPotentials/Base.hpp>
5 
6 namespace OpenMPCD
7 {
8 namespace PairPotentials
9 {
10 
11 /**
12  * Morse Interaction
13  * \f$ \epsilon ( \exp (-2 \ alpha (r - \sigma) ) - 2 \exp (-\alpha(r-\sigma))) - \textrm{shift} \f$
14  *
15  * @tparam T The numeric base type.
16  */
17 template<typename T = FP>
18 class Morse : public Base<T>
19 {
20 public:
21  /**
22  * The constructor.
23  * @param[in] eps depth of the potential well
24  * @param[in] alpha 'width' of the potential well, smaller a, larger well
25  * @param[in] sigma equilibrium bond distance
26  * @param[in] shift The \f$ \textrm{shift} \f$ parameter.
27  */
29  Morse(const T eps, const T alpha, const T sigma, const T shift)
30  : epsilon(eps), alpha(alpha), sigma(sigma), shift(shift)
31  {
32  }
33 
34  /**
35  * Returns the force vector of the interaction for a given position vector.
36  *
37  * This function returns the directional derivative
38  * \f[ - \nabla_R V \left( \vec{R} \right) \f]
39  * where \f$ \vec{R} \f$ is the `R` parameter, \f$ V \f$ is the potential
40  * as given by the `potential` function, and \f$ \nabla_R V \f$ is the
41  * gradient of \f$ V \f$ with respect to \f$ \vec{R} \f$.
42  *
43  * @param[in] R The relative position vector.
44  */
46  Vector3D<T> force(const Vector3D<T>& R) const
47  {
48  const T r = R.getMagnitude();
49  return (-1)*epsilon * ((-2)*alpha*exp( -2*alpha*(r - sigma) ) + 2*alpha*exp( (-1)*alpha*(r-sigma) ))*R.getNormalized();
50  }
51 
52  /**
53  * Returns the potential of the interaction for a given position vector.
54  * @param[in] R The relative position vector.
55  */
57  T potential(const Vector3D<T>& R) const
58  {
59  const T r = R.getMagnitude();
60  return epsilon*
61  (exp( -2*alpha*(r - sigma) )
62  - 2 * exp( (-1)*alpha*(r-sigma)))
63  - shift;
64  }
65 
66 private:
67  const T epsilon;
68  const T alpha;
69  const T sigma;
70  const T shift;
71 }; //class Morse
72 
73 } //namespace PairPotentials
74 } //namespace OpenMPCD
75 #endif //OPENMPCD_PAIRPOTENTIALS_MORSE_HPP
OpenMPCD::PairPotentials::Morse
Morse Interaction .
Definition: Morse.hpp:18
OpenMPCD::Vector3D
3-dimensional vector.
Definition: Vector3D.hpp:38
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::PairPotentials::Morse::Morse
OPENMPCD_CUDA_HOST_AND_DEVICE Morse(const T eps, const T alpha, const T sigma, const T shift)
The constructor.
Definition: Morse.hpp:29
OpenMPCD::Vector3D::getNormalized
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getNormalized() const
Returns this vector, but normalized.
Definition: Vector3D.hpp:264
OpenMPCD::PairPotentials::Base
Abstract base class for pair potentials.
Definition: PairPotentials/Base.hpp:24
OpenMPCD::PairPotentials::Morse::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: Morse.hpp:46
OpenMPCD::Vector3D::getMagnitude
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitude() const
Returns the magnitude of this vector.
Definition: Vector3D.hpp:227
OpenMPCD::PairPotentials::Morse::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: Morse.hpp:57