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 */
20#include "rigid_bond.hpp"
21#include "system/System.hpp"
22#include "thermalized_bond.hpp"
23
24#include <boost/range/numeric.hpp>
25#include <boost/variant.hpp>
26
27#include <utils/constants.hpp>
28
29#include <algorithm>
30#include <cstddef>
31#include <vector>
32
34
35/** Visitor to get the bond cutoff from the bond parameter variant */
36class BondCutoff : public boost::static_visitor<double> {
37public:
38 template <typename T> double operator()(T const &bond) const {
39 return bond.cutoff();
40 }
41};
42
44 auto const max_cut_bonded = boost::accumulate(
46 [](auto max_cut, auto const &kv) {
47 return std::max(max_cut,
48 boost::apply_visitor(BondCutoff(), *kv.second));
49 });
50
51 /* Check if there are dihedrals */
52 auto const any_dihedrals = std::any_of(
53 bonded_ia_params.begin(), bonded_ia_params.end(), [](auto const &kv) {
54 return (boost::get<DihedralBond>(&(*kv.second)) ||
55 boost::get<TabulatedDihedralBond>(&(*kv.second)));
56 });
57
58 /* dihedrals: the central particle is indirectly connected to the fourth
59 * particle via the third particle, so we have to double the cutoff */
60 return (any_dihedrals) ? 2 * max_cut_bonded : max_cut_bonded;
61}
62
63void BondedInteractionsMap::on_ia_change() {
64 n_thermalized_bonds = 0;
65#ifdef BOND_CONSTRAINT
66 n_rigid_bonds = 0;
67#endif
68 for (auto &kv : *this) {
69 if (boost::get<ThermalizedBond>(&(*kv.second)) != nullptr) {
70 ++n_thermalized_bonds;
71 }
72#ifdef BOND_CONSTRAINT
73 if (boost::get<RigidBond>(&(*kv.second)) != nullptr) {
74 ++n_rigid_bonds;
75 }
76#endif
77 }
79 auto &system = System::get_system();
80 system.on_short_range_ia_change();
81 system.on_thermostat_param_change(); // thermalized bonds
82 }
83}
double maximal_cutoff_bonded()
Calculate the maximal cutoff of bonded interactions, required to determine the cell size for communic...
BondedInteractionsMap bonded_ia_params
Field containing the parameters of the bonded ia types.
Data structures for bonded interactions.
static constexpr double BONDED_INACTIVE_CUTOFF
Visitor to get the bond cutoff from the bond parameter variant.
double operator()(T const &bond) const
System & get_system()
bool is_system_set()
Definition of the rigid bond data type for the Rattle algorithm.
Routines to thermalize the center of mass and distance of a particle pair.