ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
langevin_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#include "Particle.hpp"
27#include "random.hpp"
28#include "rotation.hpp"
29#include "thermostat.hpp"
30
31#include <utils/Vector.hpp>
32#include <utils/matrix.hpp>
33
34/** Langevin thermostat for particle translational velocities.
35 * @param[in] langevin Parameters
36 * @param[in] p Particle
37 * @param[in] time_step Time step
38 * @param[in] kT Thermal energy
39 */
40inline Utils::Vector3d
42 double time_step, double kT) {
43 using namespace Thermostat;
44 // Determine prefactors for the friction and the noise term
45#ifdef THERMOSTAT_PER_PARTICLE
46 auto const gamma = handle_particle_gamma(p.gamma(), langevin.gamma);
47 auto const pref_friction = -gamma;
48 auto const pref_noise = LangevinThermostat::sigma(kT, time_step, gamma);
49#else
50 auto const pref_friction = langevin.pref_friction;
51 auto const pref_noise = langevin.pref_noise;
52#endif // THERMOSTAT_PER_PARTICLE
53
54 auto const friction_op = handle_particle_anisotropy(p, pref_friction);
55 auto const noise_op = handle_particle_anisotropy(p, pref_noise);
56 return friction_op * p.v() +
57 noise_op * Random::noise_uniform<RNGSalt::LANGEVIN>(
58 langevin.rng_counter(), langevin.rng_seed(), p.id());
59}
60
61#ifdef ROTATION
62/** Langevin thermostat for particle angular velocities.
63 * @param[in] langevin Parameters
64 * @param[in] p Particle
65 * @param[in] time_step Time step
66 * @param[in] kT Thermal energy
67 */
68inline Utils::Vector3d
70 Particle const &p, double time_step,
71 double kT) {
72 using namespace Thermostat;
73
74#ifdef THERMOSTAT_PER_PARTICLE
75 auto const gamma =
76 handle_particle_gamma(p.gamma_rot(), langevin.gamma_rotation);
77 auto const pref_friction = gamma;
78 auto const pref_noise = LangevinThermostat::sigma(kT, time_step, gamma);
79#else
80 auto const pref_friction = langevin.gamma_rotation;
81 auto const pref_noise = langevin.pref_noise_rotation;
82#endif // THERMOSTAT_PER_PARTICLE
83
84 auto const noise = Random::noise_uniform<RNGSalt::LANGEVIN_ROT>(
85 langevin.rng_counter(), langevin.rng_seed(), p.id());
86 return -hadamard_product(pref_friction, p.omega()) +
87 hadamard_product(pref_noise, noise);
88}
89#endif // ROTATION
Vector implementation and trait types for boost qvm interoperability.
This file contains the defaults for ESPResSo.
Utils::Vector3d friction_thermo_langevin(LangevinThermostat const &langevin, Particle const &p, double time_step, double kT)
Langevin thermostat for particle translational velocities.
Utils::Vector3d friction_thermo_langevin_rotation(LangevinThermostat const &langevin, Particle const &p, double time_step, double kT)
Langevin thermostat for particle angular velocities.
Matrix implementation and trait types for boost qvm interoperability.
Random number generation using Philox.
This file contains all subroutines required to process rotational motion.
uint64_t rng_counter() const
Get current value of the RNG.
uint32_t rng_seed() const
Thermostat for Langevin dynamics.
GammaType pref_friction
Prefactor for the friction.
static GammaType sigma(double kT, double time_step, GammaType const &gamma)
Calculate the noise prefactor.
GammaType gamma_rotation
Rotational friction coefficient .
GammaType gamma
Translational friction coefficient .
GammaType pref_noise
Prefactor for the translational velocity noise.
GammaType pref_noise_rotation
Prefactor for the angular velocity noise.
Struct holding all information for one particle.
Definition Particle.hpp:393
auto const & gamma() const
Definition Particle.hpp:529
auto const & gamma_rot() const
Definition Particle.hpp:532
auto const & v() const
Definition Particle.hpp:431
auto const & omega() const
Definition Particle.hpp:479
auto const & id() const
Definition Particle.hpp:412