ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
angle_cossquare.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24/** \file
25 * Routines to calculate the angle energy or/and and force
26 * for a particle triple using the potential described in
27 * @ref bondedIA_angle_cossquare.
28 */
29
30#include "angle_common.hpp"
31
32#include <utils/Vector.hpp>
33#include <utils/math/sqr.hpp>
34
35#include <cmath>
36#include <tuple>
37
38/** Parameters for three-body angular potential (cossquare). */
40 /** bending constant */
41 double bend;
42 /** equilibrium angle (default is 180 degrees) */
43 double phi0;
44 /** cosine of @p phi0 (internal parameter) */
45 double cos_phi0;
46
47 double cutoff() const { return 0.; }
48
49 static constexpr int num = 2;
50
51 AngleCossquareBond(double bend, double phi0) {
52 this->bend = bend;
53 this->phi0 = phi0;
54 this->cos_phi0 = cos(phi0);
55 }
56
57 std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
58 forces(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2) const;
59 double energy(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2) const;
60};
61
62/** Compute the three-body angle interaction force.
63 * @param[in] vec1 Vector from central particle to left particle.
64 * @param[in] vec2 Vector from central particle to right particle.
65 * @return Forces on the second, first and third particles, in that order.
66 */
67inline std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
69 Utils::Vector3d const &vec2) const {
70
71 auto forceFactor = [this](double const cos_phi) {
72 return bend * (cos_phi - cos_phi0);
73 };
74
75 return angle_generic_force(vec1, vec2, forceFactor, false);
76}
77
78/** Computes the three-body angle interaction energy.
79 * @param[in] vec1 Vector from central particle to left particle.
80 * @param[in] vec2 Vector from central particle to right particle.
81 */
83 Utils::Vector3d const &vec2) const {
84 auto const cos_phi = calc_cosine(vec1, vec2, true);
85 return 0.5 * bend * Utils::sqr(cos_phi - cos_phi0);
86}
Vector implementation and trait types for boost qvm interoperability.
Common code for functions calculating angle forces.
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.
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:28
Parameters for three-body angular potential (cossquare).
double cos_phi0
cosine of phi0 (internal parameter)
double phi0
equilibrium angle (default is 180 degrees)
AngleCossquareBond(double bend, double phi0)
double bend
bending constant
double cutoff() const
double energy(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2) const
Computes the three-body angle interaction energy.
std::tuple< Utils::Vector3d, Utils::Vector3d, Utils::Vector3d > forces(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2) const
Compute the three-body angle interaction force.
static constexpr int num