Skip to content

Commit

Permalink
Merge pull request #2377 from thepith/maxwell_re
Browse files Browse the repository at this point in the history
use correct Maxwell-Boltzmann velocity distribution in reaction ensemble
  • Loading branch information
RudolfWeeber authored Nov 30, 2018
2 parents 2b6579a + 1146eca commit c9410e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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();
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];
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 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
----------
Expand Down

0 comments on commit c9410e8

Please sign in to comment.