lattice.py 1.58 KB
Newer Older
MischaD's avatar
MischaD committed
1
2
3
4
from lbmweights.utils.mylog import logger
from .exceptions import OrderNotImplementedException


MischaD's avatar
MischaD committed
5
class Lattice:
MischaD's avatar
MischaD committed
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    def __init__(self, dimension=2, order=4, shell_list=[1, 2, 4], seed=None):
        """
        :param dimension:
        :param order:
        :param shell_list:
        :param seed:
        """
        logger.info("Okay")

        self._dimensions = dimension
        self._order = order
        self._shell_list = shell_list
        self._seed = seed

    def __str__(self):
        string = "D{} - Order: {} - Shells: {}".format(
            self._dimensions, self._order, str(self._shell_list)
        )
        if self._seed:
            string += " - Seed: {}".format(self._seed)
        return string

    @classmethod
    def init_by_order(cls, dimension, order, seed=None):
        """
        :param dimension:
        :param order:
        :return:
        """
        shell_list = []
        if dimension == 2:
            if order == 4:
                shell_list = [1, 2, 4]
            elif order == 6:
                shell_list = [1, 2, 4, 8, 9]
            elif order == 8:
                shell_list = [1, 2, 4, 5, 8, 9, 10, 16]

        elif dimension == 3:
            if order == 4:
                shell_list = [1, 2, 4]

        if not shell_list:
            raise OrderNotImplementedException(
                "Cannot initialize by {} for dimension {}. Lower the order or try to come up with the shells yourself.".format(
                    order, dimension
                )
            )
        return cls(dimension=dimension, order=order, shell_list=shell_list, seed=seed)
MischaD's avatar
MischaD committed
55