1 # -*- coding: iso-8859-1 -*-
4 from hoomd_script
import *
9 class pair_table_tests (unittest
.TestCase
):
12 init
.create_random(N
=100, phi_p
=0.05);
14 sorter
.set_params(grid
=8)
16 # basic test of creation
18 table
= pair
.table(width
=1000);
19 table
.pair_coeff
.set('A', 'A', rmin
=0.0, rmax
=1.0, func
=lambda r
, rmin
, rmax
: (r
, 2*r
), coeff
=dict());
20 table
.update_coeffs();
22 # test missing coefficients
23 def test_set_missing_epsilon(self
):
24 table
= pair
.table(width
=1000);
25 table
.pair_coeff
.set('A', 'A', rmin
=0.0, rmax
=1.0);
26 self
.assertRaises(RuntimeError, table
.update_coeffs
);
28 # test missing coefficients
29 def test_missing_AA(self
):
30 table
= pair
.table(width
=1000);
31 self
.assertRaises(RuntimeError, table
.update_coeffs
);
33 # test nlist subscribe
34 def test_nlist_subscribe(self
):
35 table
= pair
.table(width
=1000);
36 table
.pair_coeff
.set('A', 'A', rmin
=0.0, rmax
=1.0, func
=lambda r
, rmin
, rmax
: (r
, 2*r
), coeff
=dict());
37 table
.update_coeffs();
38 globals.neighbor_list
.update_rcut();
39 self
.assertAlmostEqual(1.0, globals.neighbor_list
.r_cut
);
41 table
.pair_coeff
.set('A', 'A', rmax
= 2.5)
42 globals.neighbor_list
.update_rcut();
43 self
.assertAlmostEqual(2.5, globals.neighbor_list
.r_cut
);
49 if __name__
== '__main__':
50 unittest
.main(argv
= ['test.py', '-v'])