36inline double sanitize_cosine(
double cosine) {
57 bool sanitize_cosine =
false) {
59 auto cos_phi = (vec1 * vec2) / std::sqrt(vec1.
norm2() * vec2.
norm2());
60 if (sanitize_cosine) {
61 cos_phi = detail::sanitize_cosine(cos_phi);
79template <
typename ForceFactor>
80std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
82 ForceFactor forceFactor,
bool sanitize_cosine) {
83 auto const d1 = vec1.
norm();
84 auto const d2 = vec2.
norm();
85 auto cos_phi = (vec1 * vec2) / (d1 * d2);
86 if (sanitize_cosine) {
87 cos_phi = detail::sanitize_cosine(cos_phi);
90 auto const fac = forceFactor(cos_phi);
92 auto const v1 = vec1 / d1;
93 auto const v2 = vec2 / d2;
94 auto f_left = (fac / d1) * (v1 * cos_phi - v2);
95 auto f_right = (fac / d2) * (v2 * cos_phi - v1);
96 auto f_mid = -(f_left + f_right);
97 return std::make_tuple(f_mid, f_left, f_right);
Vector implementation and trait types for boost qvm interoperability.
std::tuple< Utils::Vector3d, Utils::Vector3d, Utils::Vector3d > angle_generic_force(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2, ForceFactor forceFactor, bool sanitize_cosine)
Compute a three-body angle interaction force.
double calc_cosine(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2, bool sanitize_cosine=false)
Compute the cosine of the angle between three particles.
This file contains the defaults for ESPResSo.
#define TINY_COS_VALUE
Tiny angle cutoff for cosine calculations.