Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)