From 314115186f79749bda8bfc3280cb37dfa03fea48 Mon Sep 17 00:00:00 2001 From: Pascal Hebbeker Date: Thu, 15 Nov 2018 15:45:11 +0100 Subject: [PATCH 1/5] use Maxwell-Boltzmann velocity distribution in reaction ensemble --- src/core/reaction_ensemble.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/reaction_ensemble.cpp b/src/core/reaction_ensemble.cpp index 79bb7bbf701..ecab247e950 100644 --- a/src/core/reaction_ensemble.cpp +++ b/src/core/reaction_ensemble.cpp @@ -717,9 +717,9 @@ int ReactionAlgorithm::create_particle(int desired_type) { // for components double vel[3]; // we use mass=1 for all particles, think about adapting this - vel[0] = std::pow(2 * PI * temperature, -3.0 / 2.0) * gaussian_random(); - vel[1] = std::pow(2 * PI * temperature, -3.0 / 2.0) * gaussian_random(); - vel[2] = std::pow(2 * PI * temperature, -3.0 / 2.0) * gaussian_random(); + vel[0] = std::sqrt(temperature) * gaussian_random(); + vel[1] = std::sqrt(temperature) * gaussian_random(); + vel[2] = std::sqrt(temperature) * gaussian_random(); #ifdef ELECTROSTATICS double charge = charges_of_types[desired_type]; #endif From 2f933fef6e929f7973f10e685ff899f8461b6a70 Mon Sep 17 00:00:00 2001 From: Pascal Hebbeker Date: Mon, 26 Nov 2018 14:41:11 +0100 Subject: [PATCH 2/5] note the missing mass dependency of RE in the doc --- src/python/espressomd/reaction_ensemble.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python/espressomd/reaction_ensemble.pyx b/src/python/espressomd/reaction_ensemble.pyx index 627e88b313a..3d30154e7de 100644 --- a/src/python/espressomd/reaction_ensemble.pyx +++ b/src/python/espressomd/reaction_ensemble.pyx @@ -16,6 +16,9 @@ cdef class ReactionAlgorithm(object): reaction algorithm by setting the standard pressure, temperature, and the exclusion radius. + Note: When setting the velocities of the particles according the the + Maxwell distribution the mass of all particles is assumed to equal 1. + Parameters ---------- From a28b747f62c54785acabb0f127a1e25e6c416d91 Mon Sep 17 00:00:00 2001 From: Pascal Hebbeker Date: Mon, 26 Nov 2018 18:18:10 +0100 Subject: [PATCH 3/5] set particle velocities in the RE MC move Draw a random velocity according to the Maxwell-Boltzmann distribution. Fixes #1770 --- src/core/reaction_ensemble.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/reaction_ensemble.cpp b/src/core/reaction_ensemble.cpp index ecab247e950..01874ab1e76 100644 --- a/src/core/reaction_ensemble.cpp +++ b/src/core/reaction_ensemble.cpp @@ -831,6 +831,12 @@ bool ReactionAlgorithm::do_global_mc_move_for_particles_of_type( p_id = p_id_s_changed_particles[i]; // change particle position new_pos = get_random_position_in_box(); + double vel[3]; + // we use mass=1 for all particles, think about adapting this + vel[0] = std::sqrt(temperature) * gaussian_random(); + vel[1] = std::sqrt(temperature) * gaussian_random(); + vel[2] = std::sqrt(temperature) * gaussian_random(); + set_particle_v(p_id, vel); // new_pos=get_random_position_in_box_enhanced_proposal_of_small_radii(); // //enhanced proposal of small radii place_particle(p_id, new_pos.data()); From 670a4df64d872d7b1e992388b6f17bf4fce44f9b Mon Sep 17 00:00:00 2001 From: Pascal Hebbeker Date: Tue, 27 Nov 2018 16:14:43 +0100 Subject: [PATCH 4/5] account for the particle mass in the RE MC move --- src/core/reaction_ensemble.cpp | 8 ++++---- src/python/espressomd/reaction_ensemble.pyx | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/reaction_ensemble.cpp b/src/core/reaction_ensemble.cpp index 01874ab1e76..7ce6711f3da 100644 --- a/src/core/reaction_ensemble.cpp +++ b/src/core/reaction_ensemble.cpp @@ -832,10 +832,10 @@ bool ReactionAlgorithm::do_global_mc_move_for_particles_of_type( // change particle position new_pos = get_random_position_in_box(); double vel[3]; - // we use mass=1 for all particles, think about adapting this - vel[0] = std::sqrt(temperature) * gaussian_random(); - vel[1] = std::sqrt(temperature) * gaussian_random(); - vel[2] = std::sqrt(temperature) * gaussian_random(); + auto const &p = get_particle_data(p_id); + vel[0] = std::sqrt(temperature / p.p.mass) * gaussian_random(); + vel[1] = std::sqrt(temperature / p.p.mass) * gaussian_random(); + vel[2] = std::sqrt(temperature / p.p.mass) * gaussian_random(); set_particle_v(p_id, vel); // new_pos=get_random_position_in_box_enhanced_proposal_of_small_radii(); // //enhanced proposal of small radii diff --git a/src/python/espressomd/reaction_ensemble.pyx b/src/python/espressomd/reaction_ensemble.pyx index 3d30154e7de..dbe44529cfe 100644 --- a/src/python/espressomd/reaction_ensemble.pyx +++ b/src/python/espressomd/reaction_ensemble.pyx @@ -16,8 +16,9 @@ cdef class ReactionAlgorithm(object): reaction algorithm by setting the standard pressure, temperature, and the exclusion radius. - Note: When setting the velocities of the particles according the the - Maxwell distribution the mass of all particles is assumed to equal 1. + Note: When creating particles the velocities the new particles are set + according the Maxwell distribution. In this step the mass of the new particle + is assumed to equal 1. Parameters From 33bf7840b69b5cfafea5567b436b243ac24d3e47 Mon Sep 17 00:00:00 2001 From: Pascal Hebbeker Date: Fri, 30 Nov 2018 11:30:17 +0100 Subject: [PATCH 5/5] fix spelling of the documentation --- src/python/espressomd/reaction_ensemble.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/espressomd/reaction_ensemble.pyx b/src/python/espressomd/reaction_ensemble.pyx index dbe44529cfe..0bfcd655275 100644 --- a/src/python/espressomd/reaction_ensemble.pyx +++ b/src/python/espressomd/reaction_ensemble.pyx @@ -16,9 +16,9 @@ cdef class ReactionAlgorithm(object): reaction algorithm by setting the standard pressure, temperature, and the exclusion radius. - Note: When creating particles the velocities the new particles are set - according the Maxwell distribution. In this step the mass of the new particle - is assumed to equal 1. + Note: When creating particles the velocities of the new particles are set + according the Maxwell-Boltzmann distribution. In this step the mass of the + new particle is assumed to equal 1. Parameters