48 std::shared_ptr<TabulatedPotential>
pot;
58 TabulatedBond(
double min,
double max, std::vector<double>
const &energy,
59 std::vector<double>
const &force) {
60 pot = std::make_shared<TabulatedPotential>(min, max, force, energy);
68 static constexpr int num = 1;
71 std::vector<double>
const &
energy,
72 std::vector<double>
const &
force)
74 this->
pot->minval = min;
75 this->
pot->maxval = max;
86 static constexpr int num = 2;
89 std::vector<double>
const &force)
91 this->
pot->minval = 0.;
95 std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
104 static constexpr int num = 3;
107 std::vector<double>
const &
energy,
108 std::vector<double>
const &force)
110 this->
pot->minval = 0.;
131inline std::optional<Utils::Vector3d>
133 auto const dist = dx.
norm();
135 if (dist < pot->
cutoff()) {
136 auto const fac =
pot->force(dist) / dist;
150inline std::optional<double>
152 auto const dist = dx.
norm();
154 if (dist < pot->
cutoff()) {
155 return pot->energy(dist);
165inline std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
169 auto forceFactor = [
this](
double const cos_phi) {
170 auto const sin_phi = sqrt(1 -
Utils::sqr(cos_phi));
172 auto const phi = acos(-cos_phi);
174 auto const phi = acos(cos_phi);
176 auto const tab_pot =
pot;
177 auto const gradient = tab_pot->force(phi);
178 return -gradient / sin_phi;
193 auto const cos_phi =
calc_cosine(vec1, vec2,
true);
196 auto const phi = acos(-cos_phi);
198 auto const phi = acos(cos_phi);
200 return pot->energy(phi);
219 double l_v12Xv23, l_v23Xv34;
225 v12, v23, v34, v12Xv23, l_v12Xv23, v23Xv34, l_v23Xv34, cos_phi, phi);
227 if (angle_is_undefined) {
231 auto const f1 = (v23Xv34 - cos_phi * v12Xv23) / l_v12Xv23;
232 auto const f4 = (v12Xv23 - cos_phi * v23Xv34) / l_v23Xv34;
240 auto const fac =
pot->force(phi);
243 auto const force1 = fac * v23Xf1;
244 auto const force2 = fac * (v34Xf4 - v12Xf1 - v23Xf1);
245 auto const force3 = fac * (v12Xf1 - v23Xf4 - v34Xf4);
247 return std::make_tuple(force2, force1, force3, -(force2 + force1 + force3));
257inline std::optional<double>
263 double l_v12Xv23, l_v23Xv34;
267 v12, v23, v34, v12Xv23, l_v12Xv23, v23Xv34, l_v23Xv34, cos_phi, phi);
269 if (angle_is_undefined) {
273 return pot->energy(phi);
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.
This file contains the defaults for ESPResSo.
#define ROUND_ERROR_PREC
Precision for capture of round off errors.
Routines to calculate the dihedral energy or/and force for a particle quadruple.
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.
__device__ void vector_product(float const *a, float const *b, float *out)
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Parameters for 3-body tabulated potential.
TabulatedAngleBond(double min, double max, std::vector< double > const &energy, std::vector< double > const &force)
double energy(Utils::Vector3d const &vec1, Utils::Vector3d const &vec2) const
Compute 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.
Base class for n-body tabulated potential (n=2,3,4).
std::shared_ptr< TabulatedPotential > pot
TabulatedBond(double min, double max, std::vector< double > const &energy, std::vector< double > const &force)
Set the parameters of a bonded tabulated potential.
Parameters for 4-body tabulated potential.
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.
TabulatedDihedralBond(double min, double max, std::vector< double > const &energy, std::vector< double > const &force)
std::optional< double > energy(Utils::Vector3d const &v12, Utils::Vector3d const &v23, Utils::Vector3d const &v34) const
Compute the four-body dihedral interaction energy.
Parameters for 2-body tabulated potential.
std::optional< Utils::Vector3d > force(Utils::Vector3d const &dx) const
Compute a tabulated bond length force.
std::optional< double > energy(Utils::Vector3d const &dx) const
Compute a tabulated bond length energy.
TabulatedDistanceBond(double min, double max, std::vector< double > const &energy, std::vector< double > const &force)