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-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/** \file
22 * Implementation of \ref thermostat.hpp.
23 */
24
25#include "config/config.hpp"
26
29#include "communication.hpp"
30#include "dpd.hpp"
31#include "errorhandling.hpp"
32#include "npt.hpp"
33#include "system/System.hpp"
34#include "thermostat.hpp"
35
36#include <variant>
37
38#include <ranges>
39
41 if (thermalized_bond) {
42 thermalized_bond->recalc_prefactors(time_step, *(get_system().bonded_ias));
43 }
44 if (langevin) {
45 langevin->recalc_prefactors(kT, time_step);
46 }
47 if (brownian) {
48 brownian->recalc_prefactors(kT);
49 }
50#ifdef ESPRESSO_DPD
51 if (dpd) {
52 dpd_init(kT, time_step);
53 }
54#endif
55#ifdef ESPRESSO_NPT
56 if (npt_iso) {
57 npt_iso->recalc_prefactors(kT, get_system().nptiso->piston,
58 get_system().nptiso->mass_list, time_step);
59 }
60#endif
61}
62
64 if (thermo_switch & THERMO_LANGEVIN) {
65 langevin->rng_increment();
66 }
67 if (thermo_switch & THERMO_BROWNIAN) {
68 brownian->rng_increment();
69 }
70#ifdef ESPRESSO_NPT
71 if (thermo_switch & THERMO_NPT_ISO) {
72 npt_iso->rng_increment();
73 }
74#endif
75#ifdef ESPRESSO_DPD
76 if (thermo_switch & THERMO_DPD) {
77 dpd->rng_increment();
78 }
79#endif
80#ifdef ESPRESSO_STOKESIAN_DYNAMICS
81 if (thermo_switch & THERMO_SD) {
82 stokesian->rng_increment();
83 }
84#endif
85 if (thermo_switch & THERMO_BOND) {
86 thermalized_bond->rng_increment();
87 }
88}
89
91 if (lb) {
92 if (get_system().lb.is_solver_set() and ::comm_cart.rank() == 0 and
93 lb->gamma > 0.) {
95 << "Recalculating forces, so the LB coupling forces are not "
96 "included in the particle force the first time step. This "
97 "only matters if it happens frequently during sampling.";
98 }
99 lb->couple_to_md = false;
100 }
101}
102
104 double time_step, BondedInteractionsMap &bonded_ias) {
105 for (auto &handle : std::views::elements<1>(bonded_ias)) {
106 if (auto *bond = std::get_if<ThermalizedBond>(handle.get())) {
107 bond->recalc_prefactors(time_step);
108 }
109 }
110}
@ THERMO_SD
@ THERMO_BROWNIAN
@ THERMO_BOND
@ THERMO_LANGEVIN
@ THERMO_DPD
@ THERMO_NPT_ISO
Data structures for bonded interactions.
container for bonded interactions.
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.
void dpd_init(double kT, double time_step)
Definition dpd.cpp:64
Routines to use DPD as thermostat or pair force .
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeWarningMsg()
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.