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-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 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(Particle const &p1, Particle const &p2, Utils::Vector3d const &dx,
57 std::function<double(Particle const &, Particle const &, double,
58 Utils::Vector3d const &, double)> const &kernel)
59 const;
60};
61
62/** Compute the short-range bonded Coulomb pair force.
63 * @param[in] dx Distance between the particles.
64 * @param[in] kernel Coulomb force kernel.
65 */
66inline std::optional<Utils::Vector3d> BondedCoulombSR::force(
67 Utils::Vector3d const &dx,
68 std::function<Utils::Vector3d(double, Utils::Vector3d const &,
69 double)> const &kernel) const {
70#ifdef ELECTROSTATICS
71 return kernel(q1q2, dx, dx.norm());
72#else
73 return Utils::Vector3d{};
74#endif
75}
76
77/** Compute the short-range bonded Coulomb pair energy.
78 * @param[in] p1 First particle.
79 * @param[in] p2 Second particle.
80 * @param[in] dx Distance between the particles.
81 * @param[in] kernel Coulomb energy kernel.
82 */
83inline std::optional<double> BondedCoulombSR::energy(
84 Particle const &p1, Particle const &p2, Utils::Vector3d const &dx,
85 std::function<double(Particle const &, Particle const &, double,
86 Utils::Vector3d const &, double)> const &kernel)
87 const {
88#ifdef ELECTROSTATICS
89 return kernel(p1, p2, q1q2, dx, dx.norm());
90#else
91 return 0.;
92#endif
93}
Vector implementation and trait types for boost qvm interoperability.
T norm() const
Definition Vector.hpp:138
This file contains the defaults for ESPResSo.
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(Particle const &p1, Particle const &p2, Utils::Vector3d const &dx, std::function< double(Particle const &, Particle 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.
Struct holding all information for one particle.
Definition Particle.hpp:395