Commit 293a613a authored by MischaD's avatar MischaD
Browse files

Added Testcases

parent 64db569b
......@@ -111,6 +111,7 @@ class Lattice:
return velocities
@timer
def calculate_valid_interval(self):
if not self._weight_polynomials:
raise UninitializedAttributeException("Weight Polynomials not give. Calculate them first!")
......@@ -131,7 +132,7 @@ class Lattice:
continue
# positive weights
if i == 0:
cur_interval = sp.Union(cur_interval, sp.Interval(-oo, roots[i]))
cur_interval = sp.Union(cur_interval, sp.Interval(-oo, roots[i+1]))
elif i == (len(roots) - 1):
cur_interval = sp.Union(cur_interval, sp.Interval(roots[i], oo))
else:
......@@ -140,6 +141,7 @@ class Lattice:
self._interval = interval
return interval
@timer
def calculate_weights(self):
logger.debug("Entering Calculate Weights")
logger.info(str(self))
......
import unittest
from lbmweights.lattice import Lattice
class TestAnalyzeTensorDimensions(unittest.TestCase):
def setUp(self):
self.lattice2 = Lattice(dimension=2, order=2, shell_list=[1,2,4])
self.lattice4 = Lattice(dimension=2, order=4, shell_list=[1,2,4])
self.lattice6 = Lattice(dimension=2, order=6, shell_list=[1,2,4])
self.lattice8 = Lattice(dimension=2, order=8, shell_list=[1,2,4])
def test_analyze_tensor_dimensions(self):
self.lattice2.calculate_weights()
self.assertTrue(self.lattice2._possible_tensors == [[[2]]])
self.lattice4.calculate_weights()
self.assertTrue(self.lattice4._possible_tensors == [[[2]], [[4], [2,2]]])
self.lattice6.calculate_weights()
self.assertTrue(self.lattice6._possible_tensors == [[[2]], [[4], [2, 2]], [[6], [4,2],[2,2,2]]])
self.lattice8.calculate_weights()
self.assertTrue(self.lattice8._possible_tensors == [[[2]], [[4], [2, 2]], [[6], [4,2],[2,2,2]], [[8],[6,2],[4,4],[4,2,2],[2,2,2,2]]])
if __name__ == "__main__":
unittest.main()
import unittest
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)
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)
if __name__ == '__main__':
logger.disabled = True
unittest.main()
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