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#pragma once
23
24#include "config/config.hpp"
25
26#ifdef ESPRESSO_NPT
27
28#include "random.hpp"
29#include "thermostat.hpp"
30
31#include <utils/Vector.hpp>
32
33#include <cstddef>
34
35/** Add velocity-dependent noise and friction for NpT-sims to the particle's
36 * velocity;
37 * @f$ p(t) = p(t) \exp(- \gamma_0 dt / m)
38 * + \sqrt{k_B T (1 - \exp(-2 \gamma_0 dt)}N(0,1) @f$
39 *
40 * @param npt_iso Parameters
41 * @param vel particle velocity
42 * @param mass particle mass
43 * @param p_identity particle identity
44 * @return velocity added noise
45 */
46inline Utils::Vector3d
48 Utils::Vector3d const &vel, double mass,
49 int p_identity) {
50 if (npt_iso.gamma0 > 0.0) {
51 return npt_iso.pref_rescale_0.at(mass) * vel +
52 npt_iso.pref_noise_0.at(mass) *
53 Random::noise_gaussian<RNGSalt::NPTISO_PARTICLE>(
54 npt_iso.rng_counter(), npt_iso.rng_seed(), p_identity);
55 }
56 return npt_iso.pref_rescale_0.at(mass) * vel;
57}
58
59/** Added noise and friction for NpT-sims to \ref NptIsoParameters::p_epsilon;
60 * @f$ p_{\epsilon} = p_{epsilon}(t) \exp(- \gamma_V dt / W)
61 * + \sqrt{k_B T (1 - \exp(-2 \gamma_V dt / W)}N(0,1) @f$
62 *
63 * @param npt_iso Parameters
64 * @param p_epsilon conjugate momentum of volume
65 * @return conjugate momentum of volume added noise
66 */
68 double p_epsilon) {
69 if (npt_iso.gammav > 0.0) {
70 return npt_iso.pref_rescale_V * p_epsilon +
71 npt_iso.pref_noise_V *
72 Random::noise_gaussian<RNGSalt::NPTISO_VOLUME, 1>(
73 npt_iso.rng_counter(), npt_iso.rng_seed(), 0)[0];
74 }
75 return npt_iso.pref_rescale_V * p_epsilon;
76}
77
78#endif // ESPRESSO_NPT
Vector implementation and trait types for boost qvm interoperability.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
double propagate_thermV_nptiso(IsotropicNptThermostat const &npt_iso, double p_epsilon)
Added noise and friction for NpT-sims to NptIsoParameters::p_epsilon; .
Utils::Vector3d propagate_therm0_nptiso(IsotropicNptThermostat const &npt_iso, Utils::Vector3d const &vel, double mass, int p_identity)
Add velocity-dependent noise and friction for NpT-sims to the particle's velocity; .
Random number generation using Philox.
uint64_t rng_counter() const
Get current value of the RNG.
uint32_t rng_seed() const
Thermostat for isotropic NPT dynamics.
std::unordered_map< double, double > pref_noise_0
Particle velocity rescaling noise standard deviation for Orstein-Uhlenbeck equation.
double pref_rescale_V
Volume rescaling at half the time step.
double gamma0
Friction coefficient of the particles .
double gammav
Friction coefficient for the box .
double pref_noise_V
Volume rescaling noise standard deviation for Orstein-Uhlenbeck equation Stores .
std::unordered_map< double, double > pref_rescale_0
Particle velocity rescaling at the time step for Orstein-Uhlenbeck equation.