Commit 43601b92 authored by MischaD's avatar MischaD
Browse files

Create Lattice by order

parent 4ba6aeeb
import click
import re
from lbmweights.lattice import Lattice
@click.group()
def main():
pass
@main.command()
@click.option('--dimension', type=int, default=2, help='Dimension of the lattice, default 2')
@click.option('--order', type=int, default=4, help='Order of isotropy, default is 4')
@click.option('--shells', type=str, default="1,2,4", help='String of velocity shell size. Squared length of the shell')
@click.option('--seed', type=int, help='Random number to be used as seed')
def lbmweights(dimension, order, shells, seed):
shell_list = [int(x) for x in re.findall(u"\d+", shells)]
l = Lattice(dimension=dimension, order=order, shell_list=shell_list, seed=seed)
print(l)
l = Lattice.init_by_order(dimension=2, order=6)
print(l)
if __name__ == "__main__":
main()
from lbmweights.utils.mylog import logger
from .exceptions import OrderNotImplementedException
class Lattice:
def __init__(self):
pass
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)
def __call__(self, *args, **kwargs):
print("okaychamp")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment