ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
npt_inline.hpp
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
22#ifndef THERMOSTATS_NPT_INLINE_HPP
23#define THERMOSTATS_NPT_INLINE_HPP
24
25#include "config/config.hpp"
26
27#ifdef NPT
28
29#include "random.hpp"
30#include "thermostat.hpp"
31
32#include <utils/Vector.hpp>
33
34#include <cstddef>
35
36/** Add velocity-dependent noise and friction for NpT-sims to the particle's
37 * velocity
38 * @tparam step Which half time step to integrate (1 or 2)
39 * @param npt_iso Parameters
40 * @param vel particle velocity
41 * @param p_identity particle identity
42 * @return noise added to the velocity, already rescaled by
43 * dt/2 (contained in prefactors)
44 */
45template <std::size_t step>
46inline Utils::Vector3d
48 Utils::Vector3d const &vel, int p_identity) {
49 static_assert(step == 1 or step == 2, "NPT only has 2 integration steps");
50 constexpr auto const salt =
52 if (npt_iso.pref_noise_0 > 0.0) {
53 return npt_iso.pref_rescale_0 * vel +
54 npt_iso.pref_noise_0 *
55 Random::noise_uniform<salt>(npt_iso.rng_counter(),
56 npt_iso.rng_seed(), p_identity);
57 }
58 return npt_iso.pref_rescale_0 * vel;
59}
60
61/** Add p_diff-dependent noise and friction for NpT-sims to \ref
62 * NptIsoParameters::p_diff
63 */
65 double p_diff) {
66 if (npt_iso.pref_noise_V > 0.0) {
67 return npt_iso.pref_rescale_V * p_diff +
68 npt_iso.pref_noise_V *
69 Random::noise_uniform<RNGSalt::NPTISOV, 1>(
70 npt_iso.rng_counter(), npt_iso.rng_seed(), 0);
71 }
72 return npt_iso.pref_rescale_V * p_diff;
73}
74
75#endif // NPT
76#endif
Vector implementation and trait types for boost qvm interoperability.
This file contains the defaults for ESPResSo.
Utils::Vector3d friction_therm0_nptiso(IsotropicNptThermostat const &npt_iso, Utils::Vector3d const &vel, int p_identity)
Add velocity-dependent noise and friction for NpT-sims to the particle's velocity.
double friction_thermV_nptiso(IsotropicNptThermostat const &npt_iso, double p_diff)
Add p_diff-dependent noise and friction for NpT-sims to NptIsoParameters::p_diff.
Random number generation using Philox.
@ NPTISO0_HALF_STEP1
@ NPTISO0_HALF_STEP2
uint64_t rng_counter() const
Get current value of the RNG.
uint32_t rng_seed() const
Thermostat for isotropic NPT dynamics.
double pref_rescale_V
Volume rescaling at half the time step.
double pref_rescale_0
Particle velocity rescaling at half the time step.
double pref_noise_0
Particle velocity rescaling noise standard deviation.
double pref_noise_V
Volume rescaling noise standard deviation.