mcpele
1.0.0
The Monte Carlo Python Energy Landscape Explorer
|
00001 #include "mcpele/take_step_probabilities.h" 00002 00003 namespace mcpele { 00004 00005 TakeStepProbabilities::TakeStepProbabilities(const size_t seed) 00006 : m_generator(seed) 00007 {} 00008 00009 void TakeStepProbabilities::add_step(std::shared_ptr<TakeStep> step_input, const double weight_input) 00010 { 00011 m_steps.push_back(step_input); 00012 m_weights.push_back(weight_input); 00013 m_steps.swap(m_steps); 00014 m_weights.swap(m_weights); 00015 m_distribution = std::discrete_distribution<size_t>(m_weights.begin(), m_weights.end()); 00016 } 00017 00018 void TakeStepProbabilities::displace(pele::Array<double>& coords, MC* mc) 00019 { 00020 if (m_steps.size() == 0) { 00021 throw std::runtime_error("TakeStepProbabilities::displace: no step specified"); 00022 } 00023 m_current_index = m_distribution(m_generator); 00024 m_steps.at(m_current_index)->displace(coords, mc); 00025 } 00026 00027 void TakeStepProbabilities::report(pele::Array<double>& old_coords, const double old_energy, pele::Array<double>& new_coords, const double new_energy, const bool success, MC* mc) 00028 { 00029 m_steps.at(m_current_index)->report(old_coords, old_energy, new_coords, new_energy, success, mc); 00030 } 00031 00032 } // namespace mcpele