1 # -*- coding: iso-8859-1 -*-
4 from hoomd_script
import *
9 class bond_table_tests (unittest
.TestCase
):
12 self
.polymer1
= dict(bond_len
=1.2, type=['A']*6 + ['B']*7 + ['A']*6, bond
="linear", count
=100);
13 self
.polymer2
= dict(bond_len
=1.2, type=['B']*4, bond
="linear", count
=10)
14 self
.polymers
= [self
.polymer1
, self
.polymer2
]
15 self
.box
= data
.boxdim(L
=35);
16 self
.separation
=dict(A
=0.35, B
=0.35)
17 init
.create_random_polymers(box
=self
.box
, polymers
=self
.polymers
, separation
=self
.separation
);
19 sorter
.set_params(grid
=8)
21 # basic test of creation
23 btable
= bond
.table(width
=1000);
24 btable
.bond_coeff
.set('polymer', rmin
=0.0, rmax
=1.0, func
=lambda r
, rmin
, rmax
: (r
, 2*r
), coeff
=dict());
25 btable
.update_coeffs();
27 # test missing coefficients
28 def test_set_missing_coeff(self
):
29 btable
= bond
.table(width
=1000);
30 btable
.bond_coeff
.set('polymer', rmin
=0.0, rmax
=1.0);
31 self
.assertRaises(RuntimeError, btable
.update_coeffs
);
33 # test more missing coefficients
34 def test_missing_all(self
):
35 btable
= bond
.table(width
=1000);
36 self
.assertRaises(RuntimeError, btable
.update_coeffs
);
39 # Add tests to check for runtime errors
45 if __name__
== '__main__':
46 unittest
.main(argv
= ['test.py', '-v'])