48 bool sanitize_cosine =
false) {
50 auto cos_phi = (vec1 * vec2) / std::sqrt(vec1.
norm2() * vec2.
norm2());
51 if (sanitize_cosine) {
70template <
typename ForceFactor>
71std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
73 ForceFactor forceFactor,
bool sanitize_cosine) {
74 auto const d1 = vec1.
norm();
75 auto const d2 = vec2.
norm();
76 auto cos_phi = (vec1 * vec2) / (d1 * d2);
77 if (sanitize_cosine) {
81 auto const fac = forceFactor(cos_phi);
83 auto const v1 = vec1 / d1;
84 auto const v2 = vec2 / d2;
85 auto f_left = (fac / d1) * (v1 * cos_phi - v2);
86 auto f_right = (fac / d2) * (v2 * cos_phi - v1);
87 auto f_mid = -(f_left + f_right);
88 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.