Fix potential problem in Messenger related to MPI window
[hoomd-blue.git] / test / hoomd_script / test_pair_lj.py
blob55435d0961d172904fc8245e3740be7bd6b4b9b4
1 # -*- coding: iso-8859-1 -*-
2 # Maintainer: joaander
4 from hoomd_script import *
5 import unittest
6 import os
8 # pair.lj
9 class pair_lj_tests (unittest.TestCase):
10 def setUp(self):
11 print
12 init.create_random(N=100, phi_p=0.05);
14 sorter.set_params(grid=8)
16 # basic test of creation
17 def test(self):
18 lj = pair.lj(r_cut=3.0);
19 lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0, alpha=1.0, r_cut=2.5, r_on=2.0);
20 lj.update_coeffs();
22 # test missing coefficients
23 def test_set_missing_epsilon(self):
24 lj = pair.lj(r_cut=3.0);
25 lj.pair_coeff.set('A', 'A', sigma=1.0, alpha=1.0);
26 self.assertRaises(RuntimeError, lj.update_coeffs);
28 # test missing coefficients
29 def test_missing_AA(self):
30 lj = pair.lj(r_cut=3.0);
31 self.assertRaises(RuntimeError, lj.update_coeffs);
33 # test set params
34 def test_set_params(self):
35 lj = pair.lj(r_cut=3.0);
36 lj.set_params(mode="no_shift");
37 lj.set_params(mode="shift");
38 lj.set_params(mode="xplor");
39 self.assertRaises(RuntimeError, lj.set_params, mode="blah");
41 # test default coefficients
42 def test_default_coeff(self):
43 lj = pair.lj(r_cut=3.0);
44 # (alpha, r_cut, and r_on are default)
45 lj.pair_coeff.set('A', 'A', sigma=1.0, epsilon=1.0)
46 lj.update_coeffs()
48 # test max rcut
49 def test_max_rcut(self):
50 lj = pair.lj(r_cut=2.5);
51 lj.pair_coeff.set('A', 'A', simga=1.0, epsilon=1.0)
52 self.assertAlmostEqual(2.5, lj.get_max_rcut());
53 lj.pair_coeff.set('A', 'A', r_cut = 2.0)
54 self.assertAlmostEqual(2.0, lj.get_max_rcut());
56 # test nlist subscribe
57 def test_nlist_subscribe(self):
58 lj = pair.lj(r_cut=2.5);
59 lj.pair_coeff.set('A', 'A', simga=1.0, epsilon=1.0)
60 globals.neighbor_list.update_rcut();
61 self.assertAlmostEqual(2.5, globals.neighbor_list.r_cut);
63 lj.pair_coeff.set('A', 'A', r_cut = 2.0)
64 globals.neighbor_list.update_rcut();
65 self.assertAlmostEqual(2.0, globals.neighbor_list.r_cut);
67 # test coeff list
68 def test_coeff_list(self):
69 lj = pair.lj(r_cut=3.0);
70 lj.pair_coeff.set(['A', 'B'], ['A', 'C'], epsilon=1.0, sigma=1.0, alpha=1.0, r_cut=2.5, r_on=2.0);
71 lj.update_coeffs();
73 def tearDown(self):
74 init.reset();
77 if __name__ == '__main__':
78 unittest.main(argv = ['test.py', '-v'])