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

use correct Maxwell-Boltzmann velocity distribution in reaction ensemble #2377

Merged
merged 7 commits into from
Nov 30, 2018
12 changes: 9 additions & 3 deletions src/core/reaction_ensemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
thepith marked this conversation as resolved.
Show resolved Hide resolved
vel[1] = std::sqrt(temperature) * gaussian_random();
vel[2] = std::sqrt(temperature) * gaussian_random();
#ifdef ELECTROSTATICS
double charge = charges_of_types[desired_type];
#endif
Expand Down Expand Up @@ -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];
thepith marked this conversation as resolved.
Show resolved Hide resolved
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
place_particle(p_id, new_pos.data());
Expand Down
4 changes: 4 additions & 0 deletions src/python/espressomd/reaction_ensemble.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ 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
thepith marked this conversation as resolved.
Show resolved Hide resolved
according the Maxwell distribution. In this step the mass of the new particle
thepith marked this conversation as resolved.
Show resolved Hide resolved
is assumed to equal 1.


Parameters
----------
Expand Down