0-offset for geom

This commit is contained in:
Martin Diehl 2020-10-10 09:57:18 +02:00
parent ffabeacbcb
commit 86d91baf90
3 changed files with 8 additions and 10 deletions

@ -1 +1 @@
Subproject commit e30d554c1b78d5767bac9f2e2e5037947477b474
Subproject commit 4b75ce7adaf901c8c371fb54424df1352c53dfb0

View File

@ -256,7 +256,7 @@ class Geom:
else:
material_ = material_.reshape(grid)
return Geom(material = material_+1 if material is None else material[material_],
return Geom(material = material_ if material is None else material[material_],
size = size,
comments = util.execution_stamp('Geom','from_Laguerre_tessellation'),
)
@ -286,7 +286,7 @@ class Geom:
KDTree = spatial.cKDTree(seeds,boxsize=size) if periodic else spatial.cKDTree(seeds)
devNull,material_ = KDTree.query(coords)
return Geom(material = (material_+1 if material is None else material[material_]).reshape(grid),
return Geom(material = (material_ if material is None else material[material_]).reshape(grid),
size = size,
comments = util.execution_stamp('Geom','from_Voronoi_tessellation'),
)
@ -335,7 +335,7 @@ class Geom:
@staticmethod
def from_minimal_surface(grid,size,surface,threshold=0.0,periods=1,materials=(1,2)):
def from_minimal_surface(grid,size,surface,threshold=0.0,periods=1,materials=(0,1)):
"""
Generate geometry from definition of triply periodic minimal surface.

View File

@ -1,5 +1,3 @@
import os
import pytest
import numpy as np
@ -305,8 +303,8 @@ class TestGeom:
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()
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)
@ -316,8 +314,8 @@ class TestGeom:
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.ones(grid)
material[:,grid[1]//2:,:] = 2
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':