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

core: thermostat: Removed heat_up/cool_down mechanism for Langevin ty… #3341

Merged
merged 2 commits into from
Dec 3, 2019
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
10 changes: 0 additions & 10 deletions src/core/bonded_interactions/thermalized_bond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ int thermalized_bond_set_params(int bond_type, double temp_com,
return ES_OK;
}

void thermalized_bond_heat_up() {
double pref_scale = sqrt(3);
thermalized_bond_update_params(pref_scale);
}

void thermalized_bond_cool_down() {
double pref_scale = 1.0 / sqrt(3);
thermalized_bond_update_params(pref_scale);
}

void thermalized_bond_init() {

for (auto &bonded_ia_param : bonded_ia_params) {
Expand Down
4 changes: 0 additions & 4 deletions src/core/bonded_interactions/thermalized_bond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ bool thermalized_bond_is_seed_required();
uint64_t thermalized_bond_get_rng_state();
void thermalized_bond_set_rng_state(uint64_t counter);

/* Setup */
void thermalized_bond_heat_up();
void thermalized_bond_cool_down();
void thermalized_bond_update_params(double pref_scale);
void thermalized_bond_init();

Expand All @@ -72,7 +69,6 @@ void thermalized_bond_init();
2. Salt (decorrelates different counter)
3. Particle ID, Partner ID
*/

inline Utils::Vector3d v_noise(int particle_id, int partner_id) {

using rng_type = r123::Philox4x64;
Expand Down
10 changes: 0 additions & 10 deletions src/core/dpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@ void dpd_set_rng_state(const uint64_t counter) {

uint64_t dpd_get_rng_state() { return dpd_rng_counter->value(); }

void dpd_heat_up() {
double pref_scale = sqrt(3);
dpd_update_params(pref_scale);
}

void dpd_cool_down() {
double pref_scale = 1.0 / sqrt(3);
dpd_update_params(pref_scale);
}

int dpd_set_params(int part_type_a, int part_type_b, double gamma, double r_c,
int wf, double tgamma, double tr_c, int twf) {
IA_parameters &ia_params = *get_ia_param_safe(part_type_a, part_type_b);
Expand Down
2 changes: 0 additions & 2 deletions src/core/dpd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ struct DPDParameters {
double pref = 0.0;
};

void dpd_heat_up();
void dpd_cool_down();
int dpd_set_params(int part_type_a, int part_type_b, double gamma, double r_c,
int wf, double tgamma, double tr_c, int twf);
void dpd_init();
Expand Down
4 changes: 0 additions & 4 deletions src/core/integrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ void integrate_vv(int n_steps, int reuse_forces) {
*/
if (reuse_forces == -1 || (recalc_forces && reuse_forces != 1)) {
ESPRESSO_PROFILER_MARK_BEGIN("Initial Force Calculation");
thermo_heat_up();

lb_lbcoupling_deactivate();

#ifdef VIRTUAL_SITES
Expand All @@ -197,8 +195,6 @@ void integrate_vv(int n_steps, int reuse_forces) {
#endif
}

thermo_cool_down();

ESPRESSO_PROFILER_MARK_END("Initial Force Calculation");
}

Expand Down
41 changes: 0 additions & 41 deletions src/core/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,44 +161,3 @@ void thermo_init() {
thermo_init_npt_isotropic();
#endif
}

void langevin_heat_up() {
langevin_pref2_buffer = langevin_pref2;
langevin_pref2 *= sqrt(3);

langevin_pref2_rotation_buffer = langevin_pref2_rotation;
langevin_pref2_rotation *= sqrt(3);
}

void thermo_heat_up() {
if (thermo_switch & THERMO_LANGEVIN) {
langevin_heat_up();
}
#ifdef DPD
if (thermo_switch & THERMO_DPD) {
dpd_heat_up();
}
#endif
if (n_thermalized_bonds) {
thermalized_bond_heat_up();
}
}

void langevin_cool_down() {
langevin_pref2 = langevin_pref2_buffer;
langevin_pref2_rotation = langevin_pref2_rotation_buffer;
}

void thermo_cool_down() {
if (thermo_switch & THERMO_LANGEVIN) {
langevin_cool_down();
}
#ifdef DPD
if (thermo_switch & THERMO_DPD) {
dpd_cool_down();
}
#endif
if (n_thermalized_bonds) {
thermalized_bond_cool_down();
}
}
12 changes: 0 additions & 12 deletions src/core/thermostat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ uint64_t langevin_get_rng_state();
start of integration */
void thermo_init();

/** very nasty: if we recalculate force when leaving/reentering the integrator,
a(t) and a((t-dt)+dt) are NOT equal in the vv algorithm. The random numbers
are drawn twice, resulting in a different variance of the random force.
This is corrected by additional heat when restarting the integrator here.
Currently only works for the Langevin thermostat, although probably also
others are affected.
*/
void thermo_heat_up();

/** pendant to \ref thermo_heat_up */
void thermo_cool_down();

#ifdef NPT
/** add velocity-dependent noise and friction for NpT-sims to the particle's
velocity
Expand Down
25 changes: 21 additions & 4 deletions testsuite/python/langevin_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,16 @@ def test_03__friction_rot(self):
np.copy(system.part[0].omega_body),
o0 * np.exp(-gamma_r_i / rinertia * system.time), atol=5E-4)

def test_04__global_langevin(self):
"""Test for global Langevin parameters."""
def check_global_langevin(self, recalc_forces, loops):
"""Test velocity distribution for global Langevin parameters.

Parameters
----------
recalc_forces : :obj:`bool`
True if the forces should be recalculated after every step.
loops : :obj:`int`
Number of sampling loops
"""
N = 200
system = self.system
system.part.clear()
Expand All @@ -208,11 +216,10 @@ def test_04__global_langevin(self):
system.integrator.run(20)

# Sampling
loops = 150
v_stored = np.zeros((N * loops, 3))
omega_stored = np.zeros((N * loops, 3))
for i in range(loops):
system.integrator.run(1)
system.integrator.run(1, recalc_forces=recalc_forces)
v_stored[i * N:(i + 1) * N, :] = system.part[:].v
if espressomd.has_features("ROTATION"):
omega_stored[i * N:(i + 1) * N, :] = system.part[:].omega_body
Expand All @@ -226,6 +233,16 @@ def test_04__global_langevin(self):
self.check_velocity_distribution(
omega_stored, v_minmax, bins, error_tol, kT)

def test_global_langevin(self):
"""Test velocity distribution for global Langevin parameters."""
self.check_global_langevin(False, loops=150)

def test_global_langevin_initial_forces(self):
"""Test velocity distribution for global Langevin parameters,
when using the initial force calculation.
"""
self.check_global_langevin(True, loops=170)

@utx.skipIfMissingFeatures("LANGEVIN_PER_PARTICLE")
def test_05__langevin_per_particle(self):
"""Test for Langevin particle. Covers all combinations of
Expand Down