From e334674a06bc5c8667264634f1d4efaf31c15ecb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 29 Mar 2020 20:28:54 +0200 Subject: [PATCH] test bycristal tessellation --- python/tests/test_Geom.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/python/tests/test_Geom.py b/python/tests/test_Geom.py index c098603c6..f988179fa 100644 --- a/python/tests/test_Geom.py +++ b/python/tests/test_Geom.py @@ -99,7 +99,7 @@ class TestGeom: assert geom_equal(modified,Geom.from_file(reference)) @pytest.mark.parametrize('periodic',[(True),(False)]) - def test_tessellation(self,periodic): + def test_tessellation_approaches(self,periodic): grid = np.random.randint(10,20,3) size = np.random.random(3) + 1.0 N_seeds= np.random.randint(10,30) @@ -108,7 +108,7 @@ class TestGeom: Laguerre = Geom.from_Laguerre_tessellation(grid,size,seeds,np.ones(N_seeds),periodic) assert geom_equal(Laguerre,Voronoi) - def test_Laguerre(self): + def test_Laguerre_weights(self): grid = np.random.randint(10,20,3) size = np.random.random(3) + 1.0 N_seeds= np.random.randint(10,30) @@ -118,3 +118,16 @@ class TestGeom: weights[ms-1] = np.random.random() Laguerre = Geom.from_Laguerre_tessellation(grid,size,seeds,weights,np.random.random()>0.5) assert np.all(Laguerre.microstructure == ms) + + @pytest.mark.parametrize('approach',[('Laguerre'),('Voronoi')]) + def test_tessellate_bicrystal(self,approach): + grid = np.random.randint(5,10,3)*2 + size = grid.astype(np.float) + seeds = np.vstack((size*np.array([0.5,0.25,0.5]),size*np.array([0.5,0.75,0.5]))) + microstructure = np.ones(grid) + microstructure[:,grid[1]//2:,:] = 2 + if approach == 'Laguerre': + geom = Geom.from_Laguerre_tessellation(grid,size,seeds,np.ones(2),np.random.random()>0.5) + elif approach == 'Voronoi': + geom = Geom.from_Voronoi_tessellation(grid,size,seeds, np.random.random()>0.5) + assert np.all(geom.microstructure == microstructure)