Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unite BROWNIAN_PER_PARTICLE and LANGEVIN_PER_PARTICLE #4057

Merged
merged 7 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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 All @@ -1498,7 +1498,7 @@ charge) to a particle (Drude core) that mimics an electron cloud which can be
elongated to create a dynamically inducible dipole. The energetic minimum of
the Drude charge can be obtained self-consistently, which requires several
iterations of the system's electrostatics and is usually considered
computational expensive. However, with thermalized cold Drude oscillators, the
computationally expensive. However, with thermalized cold Drude oscillators, the
distance between Drude charge and core is coupled to a thermostat so that it
fluctuates around the SCF solution. This thermostat is kept at a low
temperature compared to the global temperature to minimize the heat flow into
Expand All @@ -1515,8 +1515,8 @@ 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
temperature and friction coefficient of the Drude complex to zero, which allows
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.

As the Drude charge should not alter the *charge* or *mass* of the Drude
Expand Down
7 changes: 2 additions & 5 deletions doc/sphinx/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,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 temperature and friction coefficient
per particle.

- ``BROWNIAN_PER_PARTICLE`` Allows to choose the Brownian temperature and 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/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ the anisotropic diffusion of anisotropic colloids (rods, etc.).

Using the Langevin thermostat, it is possible to set a temperature and 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.

.. _Brownian thermostat:
Expand Down Expand Up @@ -532,7 +532,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
temperature and the 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
13 changes: 3 additions & 10 deletions 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 Expand Up @@ -61,13 +61,11 @@
# PARAMETERS

# PHYSICS
temperature_snake = 0.0
gamma_snake_head = 1.0
gamma_snake_bead = 15.0

temperature_bubbles = 10000.0
temp_l = temperature_bubbles
temp_r = temperature_bubbles
temp_l = 10000.0
temp_r = temp_l
temp_max = 1e5
gamma_bubbles = 0.5

Expand Down Expand Up @@ -180,7 +178,6 @@
type=snake_head_type,
fix=[False, False, True],
mass=snake_head_mass,
temp=temperature_snake,
gamma=gamma_snake_head)
else:
system.part.add(
Expand All @@ -192,7 +189,6 @@
type=snake_bead_type,
fix=[False, False, True],
mass=snake_bead_mass,
temp=temperature_snake,
gamma=gamma_snake_bead)

# NB INTER
Expand Down Expand Up @@ -262,7 +258,6 @@
type=bubble_type,
fix=[False, False, True],
mass=bubble_mass,
temp=temperature_bubbles,
gamma=gamma_bubbles)
testid = len(system.part) - 1
n += 1
Expand Down Expand Up @@ -453,10 +448,8 @@ def T_to_g(temp):
Nl = len(pl)
Nr = len(pr)
for p in pl:
p.temp = temp_l
p.gamma = T_to_g(temp_l)
for p in pr:
p.temp = temp_r
p.gamma = T_to_g(temp_r)

w = visualizer.specs['window_size']
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -215,7 +215,7 @@ def combination_rule_sigma(rule, sig1, sig2):
system.part.add(
id=rid, type=types["BMIM_COM"], pos=pos_com,
mass=masses["BMIM_COM"], rinertia=[646.284, 585.158, 61.126],
temp=0, gamma=0, rotation=[1, 1, 1])
gamma=0, rotation=[1, 1, 1])
cation_com_ids.append(rid)
com_id = rid
rid += 1
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
10 changes: 4 additions & 6 deletions src/core/Particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ struct ParticleProperties {
static constexpr bool is_virtual = false;
#endif /* VIRTUAL_SITES */

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
double T = -1.;
#ifdef THERMOSTAT_PER_PARTICLE
#ifndef PARTICLE_ANISOTROPY
double gamma = -1.;
#else
Expand All @@ -161,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 @@ -220,13 +219,12 @@ struct ParticleProperties {
#endif
#endif /* VIRTUAL_SITES */

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
ar &T;
#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
20 changes: 6 additions & 14 deletions src/core/particle_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ using UpdatePropertyMessage = boost::variant
&Prop::vs_relative>
#endif
#endif
#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
, UpdateProperty<double, &Prop::T>
#ifdef THERMOSTAT_PER_PARTICLE
#ifndef PARTICLE_ANISOTROPY
, UpdateProperty<double, &Prop::gamma>
#else
Expand All @@ -135,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 @@ -871,11 +870,7 @@ void set_particle_torque_lab(int part, const Utils::Vector3d &torque_lab) {
}
#endif

#if defined(LANGEVIN_PER_PARTICLE) || defined(BROWNIAN_PER_PARTICLE)
void set_particle_temperature(int part, double T) {
mpi_update_particle_property<double, &ParticleProperties::T>(part, T);
}

#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 @@ -900,7 +895,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 @@ -1249,7 +1244,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 @@ -1268,10 +1263,7 @@ void pointer_to_gamma_rot(Particle const *p, double const *&res) {
}
#endif // ROTATION

void pointer_to_temperature(Particle const *p, double const *&res) {
res = &(p->p.T);
}
#endif // LANGEVIN_PER_PARTICLE || BROWNIAN_PER_PARTICLE
#endif // THERMOSTAT_PER_PARTICLE

#ifdef ENGINE
void pointer_to_swimming(Particle const *p,
Expand Down
15 changes: 4 additions & 11 deletions src/core/particle_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,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)
/** Call only on the master node: set particle temperature.
* @param part the particle.
* @param T its new temperature.
*/
void set_particle_temperature(int part, double T);

#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 @@ -271,7 +265,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 @@ -396,13 +390,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);
void pointer_to_temperature(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
Loading