ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
VerletCriterion.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#include "Particle.hpp"
25#include "config/config.hpp"
27#include "system/System.hpp"
28
29#include <utils/index.hpp>
30#include <utils/math/sqr.hpp>
31
33 GetNonbondedCutoff(System::System const &system) : m_system{system} {}
34 auto operator()(int type_i, int type_j) const {
35 return m_system.nonbonded_ias->get_ia_param(type_i, type_j).max_cut;
36 }
37
38private:
39 System::System const &m_system;
40};
41
42/** Returns true if the particles are to be considered for short range
43 * interactions.
44 */
45template <typename CutoffGetter = GetNonbondedCutoff> class VerletCriterion {
46 const double m_skin;
47 const double m_eff_max_cut2;
48 const double m_eff_coulomb_cut2 = 0.;
49 const double m_eff_dipolar_cut2 = 0.;
50 const double m_collision_cut2 = 0.;
51 double eff_cutoff_sqr(double x) const {
52 if (x == INACTIVE_CUTOFF)
53 return INACTIVE_CUTOFF;
54 return Utils::sqr(x + m_skin);
55 }
56 CutoffGetter get_nonbonded_cutoff;
57
58public:
59 VerletCriterion(System::System const &system, double skin, double max_cut,
60 double coulomb_cut = 0., double dipolar_cut = 0.,
61 double collision_detection_cutoff = 0.)
62 : m_skin(skin), m_eff_max_cut2(eff_cutoff_sqr(max_cut)),
63 m_eff_coulomb_cut2(eff_cutoff_sqr(coulomb_cut)),
64 m_eff_dipolar_cut2(eff_cutoff_sqr(dipolar_cut)),
65 m_collision_cut2(eff_cutoff_sqr(collision_detection_cutoff)),
66 get_nonbonded_cutoff(system) {}
67
68 template <typename Distance>
69 bool operator()(const Particle &p1, const Particle &p2,
70 Distance const &dist) const {
71 auto const &dist2 = dist.dist2;
72 if (dist2 > m_eff_max_cut2)
73 return false;
74
75#ifdef ELECTROSTATICS
76 // Within real space cutoff of electrostatics and both are charged
77 if (dist2 <= m_eff_coulomb_cut2 and p1.q() != 0. and p2.q() != 0.)
78 return true;
79#endif
80
81#ifdef DIPOLES
82 // Within dipolar cutoff and both carry magnetic moments
83 if (dist2 <= m_eff_dipolar_cut2 and p1.dipm() != 0. and p2.dipm() != 0.)
84 return true;
85#endif
86
87#ifdef COLLISION_DETECTION
88 // Collision detection
89 if (dist2 <= m_collision_cut2)
90 return true;
91#endif
92
93 // Within short-range distance (including dpd and the like)
94 auto const ia_cut = get_nonbonded_cutoff(p1.type(), p2.type());
95 return (ia_cut != INACTIVE_CUTOFF) &&
96 (dist2 <= Utils::sqr(ia_cut + m_skin));
97 }
98};
Main system class.
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
Returns true if the particles are to be considered for short range interactions.
bool operator()(const Particle &p1, const Particle &p2, Distance const &dist) const
VerletCriterion(System::System const &system, double skin, double max_cut, double coulomb_cut=0., double dipolar_cut=0., double collision_detection_cutoff=0.)
This file contains the defaults for ESPResSo.
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:28
Various procedures concerning interactions between particles.
constexpr double INACTIVE_CUTOFF
Cutoff for deactivated interactions.
Distance vector and length handed to pair kernels.
auto operator()(int type_i, int type_j) const
GetNonbondedCutoff(System::System const &system)
Struct holding all information for one particle.
Definition Particle.hpp:395
auto const & q() const
Definition Particle.hpp:508
auto const & type() const
Definition Particle.hpp:418
auto const & dipm() const
Definition Particle.hpp:493