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 <boost/optional.hpp>
37
38#include <cmath>
39#include <functional>
40
41/** Parameters for Coulomb bond short-range Potential */
43 /** charge factor */
44 double q1q2;
45
46 double cutoff() const { return 0.; }
47
48 static constexpr int num = 1;
49
50 BondedCoulombSR(double q1q2) { this->q1q2 = q1q2; }
51
52 boost::optional<Utils::Vector3d>
53 force(Utils::Vector3d const &dx,
54 std::function<Utils::Vector3d(double, Utils::Vector3d const &,
55 double)> const &kernel) const;
56 boost::optional<double>
57 energy(Particle const &p1, Particle const &p2, Utils::Vector3d const &dx,
58 std::function<double(Particle const &, Particle const &, double,
59 Utils::Vector3d const &, double)> const &kernel)
60 const;
61
62private:
63 friend boost::serialization::access;
64 template <typename Archive>
65 void serialize(Archive &ar, long int /* version */) {
66 ar & q1q2;
67 }
68};
69
70/** Compute the short-range bonded Coulomb pair force.
71 * @param[in] dx Distance between the particles.
72 * @param[in] kernel Coulomb force kernel.
73 */
74inline boost::optional<Utils::Vector3d> BondedCoulombSR::force(
75 Utils::Vector3d const &dx,
76 std::function<Utils::Vector3d(double, Utils::Vector3d const &,
77 double)> const &kernel) const {
78#ifdef ELECTROSTATICS
79 return kernel(q1q2, dx, dx.norm());
80#else
81 return Utils::Vector3d{};
82#endif
83}
84
85/** Compute the short-range bonded Coulomb pair energy.
86 * @param[in] p1 First particle.
87 * @param[in] p2 Second particle.
88 * @param[in] dx Distance between the particles.
89 * @param[in] kernel Coulomb energy kernel.
90 */
91inline boost::optional<double> BondedCoulombSR::energy(
92 Particle const &p1, Particle const &p2, Utils::Vector3d const &dx,
93 std::function<double(Particle const &, Particle const &, double,
94 Utils::Vector3d const &, double)> const &kernel)
95 const {
96#ifdef ELECTROSTATICS
97 return kernel(p1, p2, q1q2, dx, dx.norm());
98#else
99 return 0.;
100#endif
101}
Vector implementation and trait types for boost qvm interoperability.
__global__ float * force
T norm() const
Definition Vector.hpp:131
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
boost::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.
boost::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:393