Skip to content

Commit

Permalink
core: Introduce THERMOSTAT_PER_PARTICLE feature
Browse files Browse the repository at this point in the history
This replaces BROWNIAN_PER_PARTICLE and LANGEVIN_PER_PARTICLE.
  • Loading branch information
jngrad committed Dec 17, 2020
1 parent c2aa543 commit 9faf3db
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 74 deletions.
4 changes: 2 additions & 2 deletions doc/sphinx/advanced_methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ Particle polarizability with thermalized cold Drude oscillators

.. note::

Requires features ``THOLE``, ``P3M``, ``LANGEVIN_PER_PARTICLE``.
Requires features ``THOLE``, ``P3M``, ``THERMOSTAT_PER_PARTICLE``.

.. note::

Expand Down Expand Up @@ -1515,7 +1515,7 @@ In |es|, the basic ingredients to simulate such a system are split into three bo

The system-wide thermostat has to be applied to the centre of mass and not to
the core particle directly. Therefore, the particles have to be excluded from
global thermostatting. With ``LANGEVIN_PER_PARTICLE`` enabled, we set the
global thermostatting. With ``THERMOSTAT_PER_PARTICLE`` enabled, we set the
friction coefficient of the Drude complex to zero, which allows
to still use a global Langevin thermostat for non-polarizable particles.

Expand Down
7 changes: 2 additions & 5 deletions doc/sphinx/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,8 @@ General features
additional degrees of freedom, which for example means that the
kinetic energy changes at constant temperature is twice as large.
- ``LANGEVIN_PER_PARTICLE`` Allows to choose the Langevin friction coefficient
per particle.
- ``BROWNIAN_PER_PARTICLE`` Allows to choose the Brownian friction coefficient
per particle.
- ``THERMOSTAT_PER_PARTICLE`` Allows setting a per-particle friction
coefficient for the Langevin and Brownian thermostats.
- ``ROTATIONAL_INERTIA``
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/inter_non-bonded.rst
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ To use the script, compile espresso with the following features:

#define EXTERNAL_FORCES
#define MASS
#define LANGEVIN_PER_PARTICLE
#define THERMOSTAT_PER_PARTICLE
#define ROTATION
#define ROTATIONAL_INERTIA
#define ELECTROSTATICS
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinx/system_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ the anisotropic diffusion of anisotropic colloids (rods, etc.).

Using the Langevin thermostat, it is possible to set a
friction coefficient for every particle individually via the feature
``LANGEVIN_PER_PARTICLE``. Consult the reference of the ``part`` command
``THERMOSTAT_PER_PARTICLE``. Consult the reference of the ``part`` command
(chapter :ref:`Setting up particles`) for information on how to achieve this.

.. _LB thermostat:
Expand Down Expand Up @@ -426,7 +426,7 @@ Best explained in an example::
where ``gamma`` (hereinafter :math:`\gamma`) is a viscous friction coefficient.
In terms of the Python interface and setup, the Brownian thermostat is very
similar to the :ref:`Langevin thermostat`. The feature
``BROWNIAN_PER_PARTICLE`` is used to control the per-particle
``THERMOSTAT_PER_PARTICLE`` is used to control the per-particle
friction coefficient setup. The major differences are
its internal integrator implementation and other temporal constraints.
The integrator is still a symplectic Velocity Verlet-like one.
Expand Down
3 changes: 1 addition & 2 deletions maintainer/configs/maxset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

#define BOND_CONSTRAINT
#define COLLISION_DETECTION
#define LANGEVIN_PER_PARTICLE
#define BROWNIAN_PER_PARTICLE
#define THERMOSTAT_PER_PARTICLE

#define NPT

Expand Down
3 changes: 1 addition & 2 deletions maintainer/configs/no_rotation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
// Geometry, equation of motion, thermostat/barostat
#define MASS
#define EXTERNAL_FORCES
#define LANGEVIN_PER_PARTICLE
#define BROWNIAN_PER_PARTICLE
#define THERMOSTAT_PER_PARTICLE
#define BOND_CONSTRAINT
#define NPT
#define DPD
Expand Down
2 changes: 1 addition & 1 deletion samples/chamber_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from espressomd.visualization_opengl import openGLLive, KeyboardButtonEvent, KeyboardFireEvent

required_features = ["LENNARD_JONES", "WCA", "MASS",
"EXTERNAL_FORCES", "LANGEVIN_PER_PARTICLE"]
"EXTERNAL_FORCES", "THERMOSTAT_PER_PARTICLE"]
espressomd.assert_features(required_features)

print("""THE CHAMBER GAME
Expand Down
2 changes: 1 addition & 1 deletion samples/drude_bmimpf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import espressomd
required_features = ["LENNARD_JONES", "P3M", "MASS", "ROTATION",
"ROTATIONAL_INERTIA", "VIRTUAL_SITES_RELATIVE",
"THOLE", "LANGEVIN_PER_PARTICLE"]
"THOLE", "THERMOSTAT_PER_PARTICLE"]
espressomd.assert_features(required_features)

import espressomd.observables
Expand Down
3 changes: 1 addition & 2 deletions src/config/features.def
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ EXTERNAL_FORCES
MASS
EXCLUSIONS
BOND_CONSTRAINT
LANGEVIN_PER_PARTICLE
BROWNIAN_PER_PARTICLE
THERMOSTAT_PER_PARTICLE
COLLISION_DETECTION
NPT
ENGINE implies ROTATION, EXTERNAL_FORCES
Expand Down
3 changes: 1 addition & 2 deletions src/config/myconfig-default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
#define MASS
#define PARTICLE_ANISOTROPY
#define EXTERNAL_FORCES
#define LANGEVIN_PER_PARTICLE
#define BROWNIAN_PER_PARTICLE
#define THERMOSTAT_PER_PARTICLE
#define BOND_CONSTRAINT
#define NPT
#define DPD
Expand Down
8 changes: 4 additions & 4 deletions src/core/Particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ struct ParticleProperties {
static constexpr bool is_virtual = false;
#endif /* VIRTUAL_SITES */

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
#ifdef THERMOSTAT_PER_PARTICLE
#ifndef PARTICLE_ANISOTROPY
double gamma = -1.;
#else
Expand All @@ -160,7 +160,7 @@ struct ParticleProperties {
Utils::Vector3d gamma_rot = {-1., -1., -1.};
#endif // ROTATIONAL_INERTIA
#endif // ROTATION
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

#ifdef EXTERNAL_FORCES
/** flag whether to fix a particle in space.
Expand Down Expand Up @@ -219,12 +219,12 @@ struct ParticleProperties {
#endif
#endif /* VIRTUAL_SITES */

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
#ifdef THERMOSTAT_PER_PARTICLE
ar γ
#ifdef ROTATION
ar &gamma_rot;
#endif
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE
#ifdef EXTERNAL_FORCES
ar &ext_flag;
ar &ext_force;
Expand Down
13 changes: 6 additions & 7 deletions src/core/particle_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ using UpdatePropertyMessage = boost::variant
&Prop::vs_relative>
#endif
#endif
#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
#ifdef THERMOSTAT_PER_PARTICLE
#ifndef PARTICLE_ANISOTROPY
, UpdateProperty<double, &Prop::gamma>
#else
Expand All @@ -134,7 +134,7 @@ using UpdatePropertyMessage = boost::variant
, UpdateProperty<Utils::Vector3d, &Prop::gamma_rot>
#endif // PARTICLE_ANISOTROPY
#endif // ROTATION
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE
#ifdef EXTERNAL_FORCES
, UpdateProperty<uint8_t, &Prop::ext_flag>
, UpdateProperty<Utils::Vector3d, &Prop::ext_force>
Expand Down Expand Up @@ -865,8 +865,7 @@ void set_particle_torque_lab(int part, const Utils::Vector3d &torque_lab) {
}
#endif

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)

#ifdef THERMOSTAT_PER_PARTICLE
#ifndef PARTICLE_ANISOTROPY
void set_particle_gamma(int part, double gamma) {
mpi_update_particle_property<double, &ParticleProperties::gamma>(part, gamma);
Expand All @@ -891,7 +890,7 @@ void set_particle_gamma_rot(int part, Utils::Vector3d gamma_rot) {
}
#endif // PARTICLE_ANISOTROPY
#endif // ROTATION
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

#ifdef EXTERNAL_FORCES
#ifdef ROTATION
Expand Down Expand Up @@ -1241,7 +1240,7 @@ void pointer_to_fix(Particle const *p, const uint8_t *&res) {
}
#endif

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
#ifdef THERMOSTAT_PER_PARTICLE
void pointer_to_gamma(Particle const *p, double const *&res) {
#ifndef PARTICLE_ANISOTROPY
res = &(p->p.gamma);
Expand All @@ -1260,7 +1259,7 @@ void pointer_to_gamma_rot(Particle const *p, double const *&res) {
}
#endif // ROTATION

#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

#ifdef ENGINE
void pointer_to_swimming(Particle const *p,
Expand Down
8 changes: 4 additions & 4 deletions src/core/particle_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void set_particle_vs_relative(int part, int vs_relative_to, double vs_distance,
Utils::Quaternion<double> const &rel_ori);
#endif

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
#ifdef THERMOSTAT_PER_PARTICLE
/** Call only on the master node: set particle frictional coefficient.
* @param part the particle.
* @param gamma its new frictional coefficient.
Expand All @@ -259,7 +259,7 @@ void set_particle_gamma_rot(int part, double gamma);
void set_particle_gamma_rot(int part, Utils::Vector3d gamma_rot);
#endif
#endif
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

#ifdef EXTERNAL_FORCES
#ifdef ROTATION
Expand Down Expand Up @@ -385,12 +385,12 @@ void pointer_to_ext_torque(Particle const *p, double const *&res2);
void pointer_to_fix(Particle const *p, const uint8_t *&res);
#endif

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
#ifdef THERMOSTAT_PER_PARTICLE
void pointer_to_gamma(Particle const *p, double const *&res);
#ifdef ROTATION
void pointer_to_gamma_rot(Particle const *p, double const *&res);
#endif
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

#ifdef ENGINE
void pointer_to_swimming(Particle const *p,
Expand Down
16 changes: 8 additions & 8 deletions src/core/thermostats/brownian_inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ inline Utils::Vector3d bd_drag(Thermostat::GammaType const &brownian_gamma,
// The friction tensor Z from the Eq. (14.31) of Schlick2010:
Thermostat::GammaType gamma;

#ifdef BROWNIAN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
if (p.p.gamma >= Thermostat::GammaType{}) {
gamma = p.p.gamma;
} else
Expand Down Expand Up @@ -106,7 +106,7 @@ inline Utils::Vector3d bd_drag_vel(Thermostat::GammaType const &brownian_gamma,
// The friction tensor Z from the eq. (14.31) of Schlick2010:
Thermostat::GammaType gamma;

#ifdef BROWNIAN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
if (p.p.gamma >= Thermostat::GammaType{}) {
gamma = p.p.gamma;
} else
Expand Down Expand Up @@ -172,7 +172,7 @@ inline Utils::Vector3d bd_random_walk(BrownianThermostat const &brownian,
return {};

Thermostat::GammaType sigma_pos = brownian.sigma_pos;
#ifdef BROWNIAN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
// override default if particle-specific gamma
if (p.p.gamma >= Thermostat::GammaType{}) {
if (temperature > 0.0) {
Expand All @@ -181,7 +181,7 @@ inline Utils::Vector3d bd_random_walk(BrownianThermostat const &brownian,
sigma_pos = Thermostat::GammaType{};
}
}
#endif // BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

// Eq. (14.37) is factored by the Gaussian noise (12.22) with its squared
// magnitude defined in the second eq. (14.38), Schlick2010.
Expand Down Expand Up @@ -280,7 +280,7 @@ bd_drag_rot(Thermostat::GammaType const &brownian_gamma_rotation, Particle &p,
double dt) {
Thermostat::GammaType gamma;

#ifdef BROWNIAN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
if (p.p.gamma_rot >= Thermostat::GammaType{}) {
gamma = p.p.gamma_rot;
} else
Expand Down Expand Up @@ -322,7 +322,7 @@ bd_drag_vel_rot(Thermostat::GammaType const &brownian_gamma_rotation,
Particle const &p) {
Thermostat::GammaType gamma;

#ifdef BROWNIAN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
if (p.p.gamma_rot >= Thermostat::GammaType{}) {
gamma = p.p.gamma_rot;
} else
Expand Down Expand Up @@ -359,7 +359,7 @@ bd_random_walk_rot(BrownianThermostat const &brownian, Particle const &p,
double dt) {

Thermostat::GammaType sigma_pos = brownian.sigma_pos_rotation;
#ifdef BROWNIAN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
// override default if particle-specific gamma
if (p.p.gamma_rot >= Thermostat::GammaType{}) {
if (temperature > 0.) {
Expand All @@ -368,7 +368,7 @@ bd_random_walk_rot(BrownianThermostat const &brownian, Particle const &p,
sigma_pos = {}; // just an indication of the infinity
}
}
#endif // BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

Utils::Vector3d dphi = {};
auto const noise = Random::noise_gaussian<RNGSalt::BROWNIAN_ROT_INC>(
Expand Down
12 changes: 6 additions & 6 deletions src/core/thermostats/langevin_inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/** Langevin thermostat for particle translational velocities.
* Collects the particle velocity (different for ENGINE, PARTICLE_ANISOTROPY).
* Collects the langevin parameters kT, gamma (different for
* LANGEVIN_PER_PARTICLE). Applies the noise and friction term.
* THERMOSTAT_PER_PARTICLE). Applies the noise and friction term.
* @param[in] langevin Parameters
* @param[in] p %Particle
* @param[in] time_step Time step
Expand All @@ -50,15 +50,15 @@ friction_thermo_langevin(LangevinThermostat const &langevin, Particle const &p,
// Determine prefactors for the friction and the noise term
Thermostat::GammaType pref_friction = langevin.pref_friction;
Thermostat::GammaType pref_noise = langevin.pref_noise;
#ifdef LANGEVIN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
// override default if particle-specific gamma
if (p.p.gamma >= Thermostat::GammaType{}) {
auto const gamma =
p.p.gamma >= Thermostat::GammaType{} ? p.p.gamma : langevin.gamma;
pref_friction = -gamma;
pref_noise = LangevinThermostat::sigma(temperature, time_step, gamma);
}
#endif // LANGEVIN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

// Get effective velocity in the thermostatting
#ifdef ENGINE
Expand Down Expand Up @@ -94,7 +94,7 @@ friction_thermo_langevin(LangevinThermostat const &langevin, Particle const &p,
/** Langevin thermostat for particle angular velocities.
* Collects the particle velocity (different for PARTICLE_ANISOTROPY).
* Collects the langevin parameters kT, gamma_rot (different for
* LANGEVIN_PER_PARTICLE). Applies the noise and friction term.
* THERMOSTAT_PER_PARTICLE). Applies the noise and friction term.
* @param[in] langevin Parameters
* @param[in] p %Particle
* @param[in] time_step Time step
Expand All @@ -106,7 +106,7 @@ friction_thermo_langevin_rotation(LangevinThermostat const &langevin,
auto pref_friction = -langevin.gamma_rotation;
auto pref_noise = langevin.pref_noise_rotation;

#ifdef LANGEVIN_PER_PARTICLE
#ifdef THERMOSTAT_PER_PARTICLE
// override default if particle-specific gamma
if (p.p.gamma_rot >= Thermostat::GammaType{}) {
auto const gamma = p.p.gamma_rot >= Thermostat::GammaType{}
Expand All @@ -115,7 +115,7 @@ friction_thermo_langevin_rotation(LangevinThermostat const &langevin,
pref_friction = -gamma;
pref_noise = LangevinThermostat::sigma(temperature, time_step, gamma);
}
#endif // LANGEVIN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

auto const noise = Random::noise_uniform<RNGSalt::LANGEVIN_ROT>(
langevin.rng_counter(), langevin.rng_seed(), p.p.identity);
Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/particle_data.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ cdef extern from "particle_data.hpp":
void set_particle_virtual(int part, int isVirtual)
void pointer_to_virtual(const particle * P, const bint * & res)

IF LANGEVIN_PER_PARTICLE or BROWNIAN_PER_PARTICLE:
IF THERMOSTAT_PER_PARTICLE:
IF PARTICLE_ANISOTROPY:
void set_particle_gamma(int part, Vector3d gamma)
ELSE:
Expand Down
Loading

0 comments on commit 9faf3db

Please sign in to comment.