def test_should_always_accept_favorable_move(self): current_energy = 0. trial_energy = -1. bias = 0. result = mc.metropolis(current_energy, trial_energy, bias) self.assertEqual(result, True)
def test_should_not_accept_unfavorable_move_with_random_greater_than_metropolis_weight(self): current_energy = 0. trial_energy = 1. bias = 0. with mock.patch('meld.system.montecarlo.random.random') as mock_random: mock_random.return_value = 0.37 # slightly more than exp(-1) result = mc.metropolis(current_energy, trial_energy, bias) self.assertEqual(result, False)
def test_should_not_accept_unfavorable_move_with_random_greater_than_metropolis_weight( self): current_energy = 0. trial_energy = 1. bias = 0. with mock.patch("meld.system.montecarlo.random.random") as mock_random: mock_random.return_value = 0.37 # slightly more than exp(-1) result = mc.metropolis(current_energy, trial_energy, bias) self.assertEqual(result, False)
def test_should_accept_unfavorable_move_with_random_less_than_metropolis_weight( self): current_energy = 0. trial_energy = 1. bias = 0. with mock.patch('meld.system.montecarlo.random.random') as mock_random: mock_random.return_value = 0.35 # slightly less than exp(-1) result = mc.metropolis(current_energy, trial_energy, bias) self.assertEqual(result, True)
def test_should_accept_unfavorable_move_with_random_less_than_metropolis_weight( self ): current_energy = 0. trial_energy = 1. bias = 0. with mock.patch("meld.system.montecarlo.random.random") as mock_random: mock_random.return_value = 0.35 # slightly less than exp(-1) result = mc.metropolis(current_energy, trial_energy, bias) self.assertEqual(result, True)