test_lattice.py 2.04 KB
Newer Older
MischaD's avatar
MischaD committed
1
import unittest
MischaD's avatar
MischaD committed
2
import sympy as sp
MischaD's avatar
MischaD committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from lbmweights import Lattice
from lbmweights.utils.mylog import logger


class TestQ9(unittest.TestCase):
    def setUp(self):
        self.seed = 20
        self.lattice = Lattice(dimension=2, order=4, shell_list=[1, 2, 4], seed=self.seed)

    def testOutput(self):
        weights = self.lattice.calculate_weights()
        self.assertEqual(len(weights), 4)


class TestV17(unittest.TestCase):
    def setUp(self):
        self.seed = 44
        self.lattice = Lattice(dimension=2, order=6, shell_list=[1,2,4,8,9], seed=self.seed)

    def testOutput(self):
        weights = self.lattice.calculate_weights()
        self.assertEqual(len(weights), 6)


class Test3D(unittest.TestCase):
    def setUp(self):
        self.seed = 20
        self.lattice = Lattice(dimension=3, order=6, shell_list=[1,2,3,4,12,16], seed=self.seed)

    def testOutput(self):
        weights = self.lattice.calculate_weights()
        self.assertEqual(len(weights), 7)


MischaD's avatar
MischaD committed
37
38
39
40
41
42
43
44
class TestV37(unittest.TestCase):
    def setUp(self):
        self.seed = 20
        self.lattice = Lattice(dimension=2, order=8, shell_list=[1,2,4,5,8,9,10,16], seed=self.seed)

    def testOutput(self):
        weights = self.lattice.calculate_weights()
        self.assertEqual(len(weights), 9)
MischaD's avatar
MischaD committed
45
46
47
        interval = self.lattice._interval
        self.assertAlmostEqual(sp.N(interval.inf), 0.6979533, places=6)
        self.assertAlmostEqual(sp.N(interval.sup), 0.8704738, places=6)
MischaD's avatar
MischaD committed
48
49


MischaD's avatar
MischaD committed
50
51
52
53
54
55
56
57
58
class TestReducibleShell(unittest.TestCase):
    def setUp(self):
        self.seed = 20
        # 25 can be shell 05 or shell 34
        self.lattice = Lattice(dimension=2, order=10, shell_list=[1,2,4,5,8,9,10,13,16,25], seed=44)

    def testOutput(self):
        weights = self.lattice.calculate_weights()
        self.assertEqual(len(weights), 12)
MischaD's avatar
MischaD committed
59
60
61
        interval = self.lattice._interval
        self.assertAlmostEqual(sp.N(interval.inf), 0.7592510, places=6)
        self.assertAlmostEqual(sp.N(interval.sup), 0.9054850, places=6)
MischaD's avatar
MischaD committed
62
63
64
65
66


if __name__ == '__main__':
    logger.disabled = True
    unittest.main()