Exemplo n.º 1
0
 def test_is_initialised_fails_with_no_lattice(self):
     simulation = Simulation()
     simulation.atoms = 'foo'
     simulation.number_of_jumps = 'bar'
     simulation.lattice = None
     with self.assertRaises(AttributeError):
         simulation.is_initialised()
Exemplo n.º 2
0
 def test_run_without_equilibration_steps(self):
     simulation = Simulation()
     simulation.is_initialised = Mock(return_value=(True, None))
     simulation.atoms = 'a'
     simulation.lattice = Mock(spec=Lattice)
     simulation.lattice.jump = Mock()
     simulation.number_of_jumps = 10
     simulation.run()
     self.assertEqual(simulation.lattice.jump.call_count, 10)
Exemplo n.º 3
0
    def test_run_for_time(self):
        simulation = Simulation()
        simulation.is_initialised = Mock(return_value=(True, None))
        simulation.atoms = 'a'
        simulation.lattice = Mock(spec=Lattice)
        simulation.lattice.time = 0.0

        def fake_jump_method():
            simulation.lattice.time += 1.0

        simulation.lattice.jump = fake_jump_method
        simulation.run(for_time=10.0)
        self.assertEqual(simulation.lattice.time, 10.0)
        self.assertEqual(simulation.number_of_jumps, 10)
Exemplo n.º 4
0
 def test_run_raises_error_if_not_initialised(self):
     simulation = Simulation()
     simulation.is_initialised = Mock(side_effect=AttributeError('test'))
     with self.assertRaises(AttributeError) as context:
         simulation.run()