ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
bonded_coulomb_sr.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2026 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 short-range part of the bonded Coulomb potential
26 * between particle pairs. Can be used to subtract certain intramolecular
27 * interactions in combination with Thole damping.
28 */
29
30#include "config/config.hpp"
31
32#include "Particle.hpp"
33
34#include <utils/Vector.hpp>
35
36#include <cmath>
37#include <functional>
38#include <optional>
39
40/** Parameters for Coulomb bond short-range Potential */
42 /** charge factor */
43 double q1q2;
44
45 double cutoff() const { return 0.; }
46
47 static constexpr int num = 1;
48
49 BondedCoulombSR(double q1q2) { this->q1q2 = q1q2; }
50
51 std::optional<Utils::Vector3d>
52 force(Utils::Vector3d const &dx,
53 std::function<Utils::Vector3d(double, Utils::Vector3d const &,
54 double)> const &kernel) const;
55 std::optional<double>
56 energy(Utils::Vector3d const &pos1, Utils::Vector3d const &pos2,
57 Utils::Vector3d const &dx,
58 std::function<double(Utils::Vector3d const &, Utils::Vector3d const &,
59 double, Utils::Vector3d const &, double)> const
60 &kernel) const;
61};
62
63/** Compute the short-range bonded Coulomb pair force.
64 * @param[in] dx Distance between the particles.
65 * @param[in] kernel Coulomb force kernel.
66 */
67inline std::optional<Utils::Vector3d> BondedCoulombSR::force(
68 Utils::Vector3d const &dx,
69 std::function<Utils::Vector3d(double, Utils::Vector3d const &,
70 double)> const &kernel) const {
71#ifdef ESPRESSO_ELECTROSTATICS
72 return kernel(q1q2, dx, dx.norm());
73#else
74 return Utils::Vector3d{};
75#endif
76}
77
78/** Compute the short-range bonded Coulomb pair energy.
79 * @param[in] pos1 The position of first particle.
80 * @param[in] pos2 The position of second particle.
81 * @param[in] dx Distance between the particles.
82 * @param[in] kernel Coulomb energy kernel.
83 */
84inline std::optional<double> BondedCoulombSR::energy(
85 Utils::Vector3d const &pos1, Utils::Vector3d const &pos2,
86 Utils::Vector3d const &dx,
87 std::function<double(Utils::Vector3d const &, Utils::Vector3d const &,
88 double, Utils::Vector3d const &, double)> const
89 &kernel) const {
90#ifdef ESPRESSO_ELECTROSTATICS
91 return kernel(pos1, pos2, q1q2, dx, dx.norm());
92#else
93 return 0.;
94#endif
95}
Vector implementation and trait types for boost qvm interoperability.
T norm() const
Definition Vector.hpp:159
Parameters for Coulomb bond short-range Potential.
double q1q2
charge factor
BondedCoulombSR(double q1q2)
static constexpr int num
double cutoff() const
std::optional< double > energy(Utils::Vector3d const &pos1, Utils::Vector3d const &pos2, Utils::Vector3d const &dx, std::function< double(Utils::Vector3d const &, Utils::Vector3d const &, double, Utils::Vector3d const &, double)> const &kernel) const
Compute the short-range bonded Coulomb pair energy.
std::optional< Utils::Vector3d > force(Utils::Vector3d const &dx, std::function< Utils::Vector3d(double, Utils::Vector3d const &, double)> const &kernel) const
Compute the short-range bonded Coulomb pair force.