ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
nonbonded_interaction_data.cpp
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/** \file
22 * Implementation of nonbonded_interaction_data.hpp
23 */
24
25#include <config/config.hpp>
26
28
30#include "system/System.hpp"
31
32#include <algorithm>
33#include <cassert>
34#include <cstddef>
35#include <memory>
36#include <utility>
37#include <vector>
38
39// Set mask bit and fold cutoff into max_cut if the potential's max_cutoff()
40// exceeds the current maximum. The "active" criterion matches each kernel's
41// own guard: a kernel can only contribute when its max_cutoff() > 0 (since
42// dist >= 0 and inactive_cutoff = -1).
43[[maybe_unused]] static void consider(double &max_cut_current, unsigned &mask,
44 PairPotential p, double sub_cutoff) {
45 if (sub_cutoff > 0.) {
46 mask |= pair_potential_bit(p);
49 }
50 }
51}
52
53static std::pair<double, unsigned>
57 auto mask = 0u;
58
59#ifdef ESPRESSO_LENNARD_JONES
61 data.lj.max_cutoff());
62#endif
63
64#ifdef ESPRESSO_WCA
66#endif
67
68#ifdef ESPRESSO_DPD
70#endif
71
72#ifdef ESPRESSO_LENNARD_JONES_GENERIC
74 data.ljgen.max_cutoff());
75#endif
76
77#ifdef ESPRESSO_SMOOTH_STEP
79 data.smooth_step.max_cutoff());
80#endif
81
82#ifdef ESPRESSO_HERTZIAN
84 data.hertzian.max_cutoff());
85#endif
86
87#ifdef ESPRESSO_GAUSSIAN
89 data.gaussian.max_cutoff());
90#endif
91
92#ifdef ESPRESSO_BMHTF_NACL
94 data.bmhtf.max_cutoff());
95#endif
96
97#ifdef ESPRESSO_MORSE
99 data.morse.max_cutoff());
100#endif
101
102#ifdef ESPRESSO_BUCKINGHAM
104 data.buckingham.max_cutoff());
105#endif
106
107#ifdef ESPRESSO_SOFT_SPHERE
109 data.soft_sphere.max_cutoff());
110#endif
111
112#ifdef ESPRESSO_HAT
114#endif
115
116#ifdef ESPRESSO_LJCOS
118 data.ljcos.max_cutoff());
119#endif
120
121#ifdef ESPRESSO_LJCOS2
123 data.ljcos2.max_cutoff());
124#endif
125
126#ifdef ESPRESSO_GAY_BERNE
128 data.gay_berne.max_cutoff());
129#endif
130
131#ifdef ESPRESSO_TABULATED
133#endif
134
135#ifdef ESPRESSO_THOLE
136 // If THOLE is active, use p3m cutoff
137 if (data.thole.scaling_coeff != 0.)
138 max_cut_current = std::max(max_cut_current, system.coulomb.cutoff());
139#endif
140
141 return {max_cut_current, mask};
142}
143
145 auto const &system = get_system();
146 for (auto &data : m_nonbonded_ia_params) {
147 auto const [mc, mask] = recalc_maximal_cutoff(*data, system);
148 data->max_cut = mc;
149 data->active_pair_mask = mask;
150 }
151}
152
155 for (auto &data : m_nonbonded_ia_params) {
156 max_cut_nonbonded = std::max(max_cut_nonbonded, data->max_cut);
157 }
158 return max_cut_nonbonded;
159}
160
162 get_system().on_non_bonded_ia_change();
163}
void recalc_maximal_cutoffs()
Recalculate cutoff of each interaction struct.
void on_non_bonded_ia_change() const
Notify system that non-bonded interactions changed.
double maximal_cutoff() const
Get maximal cutoff.
Main system class.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
constexpr double inactive_cutoff
Special cutoff value for an inactive interaction.
Definition config.hpp:53
static void consider(double &max_cut_current, unsigned &mask, PairPotential p, double sub_cutoff)
static std::pair< double, unsigned > recalc_maximal_cutoff(IA_parameters const &data, System::System const &system)
Various procedures concerning interactions between particles.
PairPotential
Bit positions in IA_parameters::active_pair_mask.
constexpr unsigned pair_potential_bit(PairPotential p)
Bitmask for a pair potential.
Parameters for non-bonded interactions.
Gaussian_Parameters gaussian
GayBerne_Parameters gay_berne
SoftSphere_Parameters soft_sphere
SmoothStep_Parameters smooth_step
Hertzian_Parameters hertzian
Buckingham_Parameters buckingham