Exemple #1
0
 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)
     seeds  = np.random.rand(N_seeds,3) * np.broadcast_to(size,(N_seeds,3))
     Voronoi  = Geom.from_Voronoi_tessellation( grid,size,seeds,                 np.arange(N_seeds)+5,periodic)
     Laguerre = Geom.from_Laguerre_tessellation(grid,size,seeds,np.ones(N_seeds),np.arange(N_seeds)+5,periodic)
     assert geom_equal(Laguerre,Voronoi)
Exemple #2
0
 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)
     seeds  = np.random.rand(N_seeds,3) * np.broadcast_to(size,(N_seeds,3))
     weights= np.full((N_seeds),-np.inf)
     ms     = np.random.randint(N_seeds)
     weights[ms] = np.random.random()
     Laguerre = Geom.from_Laguerre_tessellation(grid,size,seeds,weights,periodic=np.random.random()>0.5)
     assert np.all(Laguerre.material == ms)
Exemple #3
0
 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)
     seeds  = np.random.rand(N_seeds,3) * np.broadcast_to(size,(N_seeds,3))
     weights= np.full((N_seeds),-np.inf)
     ms     = np.random.randint(1, N_seeds+1)
     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)
Exemple #4
0
 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])))
     material = np.zeros(grid)
     material[:,grid[1]//2:,:] = 1
     if   approach == 'Laguerre':
         geom = Geom.from_Laguerre_tessellation(grid,size,seeds,np.ones(2),periodic=np.random.random()>0.5)
     elif approach == 'Voronoi':
         geom = Geom.from_Voronoi_tessellation(grid,size,seeds,            periodic=np.random.random()>0.5)
     assert np.all(geom.material == material)