OpenMPCD
ImplementationDetails/NormalMode.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Implements functionality in the `OpenMPCD::NormalMode` namespace.
4  */
5 
6 #ifndef OPENMPCD_IMPLEMENTATIONDETAILS_NORMALMODE_HPP
7 #define OPENMPCD_IMPLEMENTATIONDETAILS_NORMALMODE_HPP
8 
11 
12 #include <boost/math/constants/constants.hpp>
13 #include <boost/static_assert.hpp>
14 #include <boost/type_traits/is_floating_point.hpp>
15 
16 namespace OpenMPCD
17 {
18 namespace NormalMode
19 {
20 
21 template<typename T>
23  const unsigned int i, const Vector3D<T>* const vectors,
24  const std::size_t N, const T shift)
25 {
26  BOOST_STATIC_ASSERT(boost::is_floating_point<T>::value);
27  //non-floating-point `T` is probably a mistake
28 
32 
33  Vector3D<T> ret(0, 0, 0);
34 
35  const T pi = boost::math::constants::pi<T>();
36  const T argPart = T(i) * pi / T(N);
37  for(std::size_t n = 1; n <= N; ++n)
38  ret += vectors[n - 1] * cos(argPart * (n + shift));
39 
40  return ret / T(N);
41 }
42 
43 } //namespace NormalMode
44 } //namespace OpenMPCD
45 
46 #endif //OPENMPCD_IMPLEMENTATIONDETAILS_NORMALMODE_HPP
OpenMPCD::NormalMode::computeNormalCoordinate
const Vector3D< T > computeNormalCoordinate(const unsigned int i, const Vector3D< T > *const vectors, const std::size_t N, const T shift)
Calculates a normal coordinate.
Definition: ImplementationDetails/NormalMode.hpp:22
Exceptions.hpp
OpenMPCD::Utility::MathematicalFunctions::cos
OPENMPCD_CUDA_HOST_AND_DEVICE T cos(const T x)
Returns the cosine of the argument.
OpenMPCD::Vector3D
3-dimensional vector.
Definition: Vector3D.hpp:38
OpenMPCD::Utility::MathematicalConstants::pi
OPENMPCD_CUDA_HOST_AND_DEVICE T pi()
Returns the value of .
Definition: MathematicalConstants.hpp:29
OPENMPCD_DEBUG_ASSERT.hpp
OPENMPCD_DEBUG_ASSERT_EXCEPTIONTYPE
#define OPENMPCD_DEBUG_ASSERT_EXCEPTIONTYPE(assertion, ExceptionType)
Definition: OPENMPCD_DEBUG_ASSERT.hpp:76
OpenMPCD::NULLPointerException
NULL-pointer exception.
Definition: Exceptions.hpp:96
OpenMPCD::InvalidArgumentException
Invalid argument exception.
Definition: Exceptions.hpp:128