OpenMPCD
FENE.hpp
1 #ifndef OPENMPCD_PAIRPOTENTIALS_FENE_HPP
2 #define OPENMPCD_PAIRPOTENTIALS_FENE_HPP
3 
4 #include <OpenMPCD/PairPotentials/Base.hpp>
5 
6 namespace OpenMPCD
7 {
8 namespace PairPotentials
9 {
10 
11 /**
12  * FENE Interaction
13  * \f$ -0.5 K R^2 \log (1 - (\frac{r - l_0}{R})^2)\f$
14  *
15  * @tparam T The numeric base type.
16  */
17 template<typename T = FP>
18 class FENE : public Base<T>
19 {
20 public:
21  /**
22  * The constructor.
23  * @param[in] K Strength of FENE Interaction
24  * @param[in] l_0 Mean Bond length
25  * @param[in] R Maximum FENE elongation
26  */
28  FENE(const T K, const T l_0, const T R)
29  : K(K), l0(l_0), R(R)
30  {
31  }
32 
33  /**
34  * Returns the force vector of the interaction for a given position vector.
35  *
36  * This function returns the directional derivative
37  * \f[ - \nabla_R V \left( \vec{R} \right) \f]
38  * where \f$ \vec{R} \f$ is the `Rvec` parameter, \f$ V \f$ is the potential
39  * as given by the `potential` function, and \f$ \nabla_R V \f$ is the
40  * gradient of \f$ V \f$ with respect to \f$ \vec{R} \f$.
41  *
42  * @param[in] Rvec The relative position vector.
43  */
45  Vector3D<T> force(const Vector3D<T>& Rvec) const
46  {
47  const T abs_r = Rvec.getMagnitude();
48  return
49  - Rvec.getNormalized() *
50  (
51  (K*(abs_r - l0))
52  /
53  ( 1 - ( (abs_r - l0) * ( abs_r - l0 ) ) / ( R * R ) )
54  );
55  }
56 
57  /**
58  * Returns the potential of the interaction for a given position vector.
59  * @param[in] Rvec The relative position vector.
60  */
62  T potential(const Vector3D<T>& Rvec) const
63  {
64  T tmp = ((Rvec.getMagnitude() - l0) / R);
65  tmp *= tmp;
66  return -0.5*K*R*R*log( 1 - tmp );
67  }
68 
69  /**
70  * Returns the \f$ K \f$ parameter.
71  */
73  T getK() const
74  {
75  return K;
76  }
77 
78  /**
79  * Returns the \f$ R \f$ parameter.
80  */
82  T getR() const
83  {
84  return R;
85  }
86 
87  /**
88  * Returns the \f$ l_0 \f$ parameter.
89  */
91  T get_l_0() const
92  {
93  return l0;
94  }
95 
96 private:
97  const T K;
98  const T l0;
99  const T R;
100 }; //class FENE
101 
102 } //namespace PairPotentials
103 } //namespace OpenMPCD
104 #endif //OPENMPCD_PAIRPOTENTIALS_FENE_HPP
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::FENE::FENE
OPENMPCD_CUDA_HOST_AND_DEVICE FENE(const T K, const T l_0, const T R)
The constructor.
Definition: FENE.hpp:28
OpenMPCD::PairPotentials::FENE::getK
OPENMPCD_CUDA_HOST_AND_DEVICE T getK() const
Returns the parameter.
Definition: FENE.hpp:73
OpenMPCD::Vector3D::getNormalized
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getNormalized() const
Returns this vector, but normalized.
Definition: Vector3D.hpp:264
OpenMPCD::PairPotentials::FENE
FENE Interaction .
Definition: FENE.hpp:18
OpenMPCD::PairPotentials::FENE::force
OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D< T > force(const Vector3D< T > &Rvec) const
Returns the force vector of the interaction for a given position vector.
Definition: FENE.hpp:45
OpenMPCD::PairPotentials::FENE::potential
OPENMPCD_CUDA_HOST_AND_DEVICE T potential(const Vector3D< T > &Rvec) const
Returns the potential of the interaction for a given position vector.
Definition: FENE.hpp:62
OpenMPCD::PairPotentials::Base
Abstract base class for pair potentials.
Definition: PairPotentials/Base.hpp:24
OpenMPCD::PairPotentials::FENE::get_l_0
OPENMPCD_CUDA_HOST_AND_DEVICE T get_l_0() const
Returns the parameter.
Definition: FENE.hpp:91
OpenMPCD::Vector3D::getMagnitude
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitude() const
Returns the magnitude of this vector.
Definition: Vector3D.hpp:227
OpenMPCD::PairPotentials::FENE::getR
OPENMPCD_CUDA_HOST_AND_DEVICE T getR() const
Returns the parameter.
Definition: FENE.hpp:82