ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
thermostat.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 \ref thermostat.hpp.
23 */
24
25#include <config/config.hpp>
26
29#include "communication.hpp"
30#include "errorhandling.hpp"
32#include "npt.hpp"
33#include "system/System.hpp"
34#include "thermostat.hpp"
35
36#include <ranges>
37#include <variant>
38
40 if (thermalized_bond) {
41 thermalized_bond->recalc_prefactors(time_step, *(get_system().bonded_ias));
42 }
43 if (langevin) {
44 langevin->recalc_prefactors(kT, time_step);
45 }
46 if (brownian) {
47 brownian->recalc_prefactors(kT);
48 }
49#ifdef ESPRESSO_DPD
50 if (dpd) {
51 get_system().nonbonded_ias->dpd_init(kT, time_step);
52 }
53#endif
54#ifdef ESPRESSO_NPT
55 if (npt_iso) {
56 npt_iso->recalc_prefactors(kT, get_system().nptiso->piston,
57 get_system().nptiso->mass_list, time_step);
58 }
59#endif
60}
61
63 if (thermo_switch & THERMO_LANGEVIN) {
64 langevin->rng_increment();
65 }
66 if (thermo_switch & THERMO_BROWNIAN) {
67 brownian->rng_increment();
68 }
69#ifdef ESPRESSO_NPT
70 if (thermo_switch & THERMO_NPT_ISO) {
71 npt_iso->rng_increment();
72 }
73#endif
74#ifdef ESPRESSO_DPD
75 if (thermo_switch & THERMO_DPD) {
76 dpd->rng_increment();
77 }
78#endif
79#ifdef ESPRESSO_STOKESIAN_DYNAMICS
80 if (thermo_switch & THERMO_SD) {
81 stokesian->rng_increment();
82 }
83#endif
84 if (thermo_switch & THERMO_BOND) {
85 thermalized_bond->rng_increment();
86 }
87}
88
90 if (lb) {
91 if (get_system().lb.is_solver_set() and ::comm_cart.rank() == 0 and
92 lb->gamma > 0.) {
94 << "Recalculating forces, so the LB coupling forces are not "
95 "included in the particle force the first time step. This "
96 "only matters if it happens frequently during sampling.";
97 }
98 lb->couple_to_md = false;
99 }
100}
101
103 double time_step, BondedInteractionsMap &bonded_ias) {
104 for (auto &handle : std::views::elements<1>(bonded_ias)) {
105 if (auto *bond = std::get_if<ThermalizedBond>(handle.get())) {
106 bond->recalc_prefactors(time_step);
107 }
108 }
109}
@ THERMO_SD
@ THERMO_BROWNIAN
@ THERMO_BOND
@ THERMO_LANGEVIN
@ THERMO_DPD
@ THERMO_NPT_ISO
Data structures for bonded interactions.
container for bonded interactions.
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
void philox_counter_increment()
Increment RNG counters.
void recalc_prefactors(double time_step)
Initialize constants of all thermostats.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeWarningMsg()
Various procedures concerning interactions between particles.
Exports for the NpT code.
void recalc_prefactors(double time_step, BondedInteractionsMap &bonded_ias)
Routines to thermalize the center of mass and distance of a particle pair.