ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
bonded_interaction_data.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include "BoxGeometry.hpp"
25#include "rigid_bond.hpp"
26#include "system/System.hpp"
27#include "thermalized_bond.hpp"
28#include "thermostat.hpp"
29
30#include <algorithm>
31#include <numeric>
32#include <ranges>
33#include <variant>
34
36 auto const max_cut_bonded = std::accumulate(
37 begin(), end(), bonded_inactive_cutoff, [](auto max_cut, auto const &kv) {
38 auto constexpr visitor = [](auto const &bond) { return bond.cutoff(); };
39 return std::max(max_cut, std::visit(visitor, *kv.second));
40 });
41
42 /* Check if there are dihedrals */
43 auto const any_dihedrals = std::ranges::any_of(*this, [](auto const &kv) {
44 return (std::holds_alternative<DihedralBond>(*kv.second) or
45 std::holds_alternative<TabulatedDihedralBond>(*kv.second));
46 });
47
48 /* dihedrals: the central particle is indirectly connected to the fourth
49 * particle via the third particle, so we have to double the cutoff */
51}
52
54 n_thermalized_bonds = 0;
55#ifdef ESPRESSO_BOND_CONSTRAINT
56 n_rigid_bonds = 0;
57#endif
58 for (auto const &bond : std::views::elements<1>(*this)) {
59 if (std::holds_alternative<ThermalizedBond>(*bond)) {
60 ++n_thermalized_bonds;
61 }
62#ifdef ESPRESSO_BOND_CONSTRAINT
63 if (std::holds_alternative<RigidBond>(*bond)) {
64 ++n_rigid_bonds;
65 }
66#endif
67 }
68 if (auto system = m_system.lock()) {
69 system->on_short_range_ia_change();
70 system->on_thermostat_param_change(); // thermalized bonds
71 }
72}
73
75 auto &system = get_system();
76 if (auto bond = std::get_if<ThermalizedBond>(ptr.get())) {
77 bond->set_thermostat_view(system.thermostat);
78 }
79 if (auto bond = std::get_if<IBMVolCons>(ptr.get())) {
80 system.immersed_boundaries->register_softID(*bond);
81 }
82 if (auto bond = std::get_if<IBMTriel>(ptr.get())) {
83 bond->initialize(*system.box_geo, *system.cell_structure);
84 }
85 if (auto bond = std::get_if<IBMTribend>(ptr.get())) {
86 bond->initialize(*system.box_geo, *system.cell_structure);
87 }
88}
89
91 if (auto bond = std::get_if<ThermalizedBond>(ptr.get())) {
92 bond->unset_thermostat_view();
93 n_thermalized_bonds = -1;
94 }
95 if (auto bond = std::get_if<IBMVolCons>(ptr.get())) {
96 bond->unset_volumes_view();
97 }
98#ifdef ESPRESSO_BOND_CONSTRAINT
99 if (std::get_if<RigidBond>(ptr.get())) {
100 n_rigid_bonds = -1;
101 }
102#endif
103}
Data structures for bonded interactions.
virtual void activate_bond(mapped_type const &ptr)
virtual void deactivate_bond(mapped_type const &ptr)
double maximal_cutoff() const
Calculate the maximal cutoff of bonded interactions, required to determine the cell size for communic...
container_type::mapped_type mapped_type
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
constexpr double bonded_inactive_cutoff
Special cutoff value for an inactive bond.
Definition config.hpp:50
Definition of the rigid bond data type for the Rattle algorithm.
Routines to thermalize the center of mass and distance of a particle pair.