OpenMPCD
PairPotentials/Base.hpp
1 #ifndef OPENMPCD_PAIRPOTENTIALS_BASE_HPP
2 #define OPENMPCD_PAIRPOTENTIALS_BASE_HPP
3 
5 #include <OpenMPCD/Types.hpp>
6 #include <OpenMPCD/Vector3D.hpp>
7 
8 namespace OpenMPCD
9 {
10 
11 /**
12  * Namespace hosting various pair potentials, i.e. potentials depending on the
13  * distance between pairs of particles.
14  */
15 namespace PairPotentials
16 {
17 
18 /**
19  * Abstract base class for pair potentials.
20  *
21  * @tparam T The numeric base type.
22  */
23 template<typename T = FP>
24 class Base
25 {
26 public:
27  /**
28  * The destructor.
29  */
31  virtual ~Base()
32  {
33  }
34 
35  /**
36  * Returns the force vector of the interaction for a given position vector.
37  *
38  * This function returns the directional derivative
39  * \f[ - \nabla_R V \left( \vec{R} \right) \f]
40  * where \f$ \vec{R} \f$ is the `Rvec` parameter, \f$ V \f$ is the potential
41  * as given by the `potential` function, and \f$ \nabla_R V \f$ is the
42  * gradient of \f$ V \f$ with respect to \f$ \vec{R} \f$.
43  *
44  * @param[in] Rvec The relative position vector.
45  */
47  virtual Vector3D<T> force(const Vector3D<T>& Rvec) const = 0;
48 
49  /**
50  * Returns the potential of the interaction for a given position vector.
51  * @param[in] Rvec The relative position vector.
52  */
54  virtual T potential(const Vector3D<T>& Rvec) const = 0;
55 
56  /**
57  * Returns the force exerted on the particle at `r1` due to the particle at
58  * `r2`.
59  *
60  * @param[in] r1 The position of the first particle.
61  * @param[in] r2 The position of the second particle.
62  */
64  const Vector3D<T>
65  forceOnR1DueToR2(const Vector3D<T>& r1, const Vector3D<T>& r2) const
66  {
67  return force(r1 - r2);
68  }
69 
70 }; //class Base
71 
72 } //namespace PairPotentials
73 } //namespace OpenMPCD
74 #endif //OPENMPCD_PAIRPOTENTIALS_BASE_HPP
OpenMPCD::PairPotentials::Base::forceOnR1DueToR2
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D< T > forceOnR1DueToR2(const Vector3D< T > &r1, const Vector3D< T > &r2) const
Returns the force exerted on the particle at r1 due to the particle at r2.
Definition: PairPotentials/Base.hpp:65
OpenMPCD::Vector3D
3-dimensional vector.
Definition: Vector3D.hpp:38
OpenMPCD::PairPotentials::Base::~Base
virtual OPENMPCD_CUDA_HOST_AND_DEVICE ~Base()
The destructor.
Definition: PairPotentials/Base.hpp:31
OpenMPCD::PairPotentials::Base::potential
virtual OPENMPCD_CUDA_HOST_AND_DEVICE T potential(const Vector3D< T > &Rvec) const =0
Returns the potential of the interaction for a given position vector.
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
Vector3D.hpp
Types.hpp
Macros.hpp
OpenMPCD::PairPotentials::Base::force
virtual OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D< T > force(const Vector3D< T > &Rvec) const =0
Returns the force vector of the interaction for a given position vector.
OpenMPCD::PairPotentials::Base
Abstract base class for pair potentials.
Definition: PairPotentials/Base.hpp:24