54 static constexpr int num = 3;
97 double &l_bXc,
double &cosphi,
double &phi) {
120 cosphi = std::round(cosphi);
123 phi = std::acos(cosphi);
125 phi = 2. * std::numbers::pi - phi;
144 double l_v12Xv23, l_v23Xv34;
146 double phi, cos_phi, sin_mphi_over_sin_phi;
150 v12, v23, v34, v12Xv23, l_v12Xv23, v23Xv34, l_v23Xv34, cos_phi, phi);
152 if (angle_is_undefined) {
156 auto const f1 = (v23Xv34 - cos_phi * v12Xv23) / l_v12Xv23;
157 auto const f4 = (v12Xv23 - cos_phi * v23Xv34) / l_v23Xv34;
165 auto const mult_ =
static_cast<double>(
mult);
166 auto const mphi = mult_ * phi -
phase;
167 auto fac = -
bend * mult_;
172 sin_mphi_over_sin_phi = mult_ * std::cos(mphi) / cos_phi;
174 sin_mphi_over_sin_phi = std::sin(mphi) / std::sin(phi);
177 fac *= sin_mphi_over_sin_phi;
180 auto const force1 = fac * v23Xf1;
181 auto const force2 = fac * (v34Xf4 - v12Xf1 - v23Xf1);
182 auto const force3 = fac * (v12Xf1 - v23Xf4 - v34Xf4);
184 return std::make_tuple(force2, force1, force3, -(force1 + force2 + force3));
194inline std::optional<double>
199 double l_v12Xv23, l_v23Xv34;
204 v12, v23, v34, v12Xv23, l_v12Xv23, v23Xv34, l_v23Xv34, cos_phi, phi);
206 if (angle_is_undefined) {
210 auto const mphi =
static_cast<double>(
mult) * phi -
phase;
211 return bend * (1. - std::cos(mphi));
Vector implementation and trait types for boost qvm interoperability.
bool calc_dihedral_angle(Utils::Vector3d const &a, Utils::Vector3d const &b, Utils::Vector3d const &c, Utils::Vector3d &aXb, double &l_aXb, Utils::Vector3d &bXc, double &l_bXc, double &cosphi, double &phi)
Calculates the dihedral angle between particle quadruple p1, p2, p3 and p4.
constexpr auto dihe_tiny_length_value
Tiny length cutoff.
constexpr auto dihe_tiny_sin_value
Tiny angle cutoff for sinus calculations.
__device__ void vector_product(float const *a, float const *b, float *out)
Parameters for four-body angular potential (dihedral-angle potentials).
std::optional< double > energy(Utils::Vector3d const &v12, Utils::Vector3d const &v23, Utils::Vector3d const &v34) const
Compute the four-body dihedral interaction energy.
std::optional< std::tuple< Utils::Vector3d, Utils::Vector3d, Utils::Vector3d, Utils::Vector3d > > forces(Utils::Vector3d const &v12, Utils::Vector3d const &v23, Utils::Vector3d const &v34) const
Compute the four-body dihedral interaction force.
DihedralBond(int mult, double bend, double phase)