def test_distance_center(): shape = sp.array([7, 5, 9]) spacing = sp.array([2, 1, 0.5]) pn = OpenPNM.Network.Cubic(shape=shape, spacing=spacing) sx, sy, sz = spacing center_coord = sp.around(topology.find_centroid(pn['pore.coords']), 7) cx, cy, cz = center_coord coords = pn['pore.coords'] x, y, z = coords.T coords = sp.concatenate((coords, center_coord.reshape((1, 3)))) pn['pore.center'] = False mask1 = (x <= (cx + sx / 2)) * (y <= (cy + sy / 2)) * (z <= (cz + sz / 2)) mask2 = (x >= (cx - sx / 2)) * (y >= (cy - sy / 2)) * (z >= (cz - sz / 2)) center_pores_mask = pn.Ps[mask1 * mask2] pn['pore.center'][center_pores_mask] = True center = pn.Ps[pn['pore.center']] L1 = sp.amax( topology.find_pores_distance(network=pn, pores1=center, pores2=pn.Ps)) L2 = sp.amax( topology.find_pores_distance(network=pn, pores1=pn.Ps, pores2=pn.Ps)) l1 = ((shape[0] - 1) * sx)**2 l2 = ((shape[1] - 1) * sy)**2 l3 = ((shape[2] - 1) * sz)**2 L3 = sp.sqrt(l1 + l2 + l3) assert sp.around(L1 * 2, 7) == sp.around(L2, 7) assert sp.around(L2, 7) == sp.around(L3, 7)
def test_distance_center(): shape = sp.array([7, 5, 9]) spacing = sp.array([2, 1, 0.5]) pn = OpenPNM.Network.Cubic(shape=shape, spacing=spacing) sx, sy, sz = spacing center_coord = sp.around(topology.find_centroid(pn['pore.coords']), 7) cx, cy, cz = center_coord coords = pn['pore.coords'] x, y, z = coords.T coords = sp.concatenate((coords, center_coord.reshape((1, 3)))) pn['pore.center'] = False mask1 = (x <= (cx + sx/2)) * (y <= (cy + sy/2)) * (z <= (cz + sz/2)) mask2 = (x >= (cx - sx/2)) * (y >= (cy - sy/2)) * (z >= (cz - sz/2)) center_pores_mask = pn.Ps[mask1 * mask2] pn['pore.center'][center_pores_mask] = True center = pn.Ps[pn['pore.center']] L1 = sp.amax(topology.find_pores_distance(network=pn, pores1=center, pores2=pn.Ps)) L2 = sp.amax(topology.find_pores_distance(network=pn, pores1=pn.Ps, pores2=pn.Ps)) l1 = ((shape[0] - 1) * sx) ** 2 l2 = ((shape[1] - 1) * sy) ** 2 l3 = ((shape[2] - 1) * sz) ** 2 L3 = sp.sqrt(l1 + l2 + l3) assert sp.around(L1 * 2, 7) == sp.around(L2, 7) assert sp.around(L2, 7) == sp.around(L3, 7)
def test_template_sphere_shell(self): from OpenPNM.Utilities import topology spacing = sp.array([0.5]) r_o = [5, 5, 5] r_in = [2, 2, 2] img = topology.template_sphere_shell(outer_radius=r_o, inner_radius=r_in) pn_sphere = OpenPNM.Network.Cubic(template=img, spacing=spacing) assert pn_sphere.Np == 452 img2 = topology.template_sphere_shell(outer_radius=r_o) pn_sphere = OpenPNM.Network.Cubic(template=img2, spacing=spacing) L1 = sp.amax(topology.find_pores_distance(network=pn_sphere, pores1=pn_sphere.Ps, pores2=pn_sphere.Ps)) assert L1 < sp.sqrt(3) * 8 * 0.5
def test_template_sphere_shell(self): from OpenPNM.Utilities import topology spacing = sp.array([0.5]) r_o = [5, 5, 5] r_in = [2, 2, 2] img = topology.template_sphere_shell(outer_radius=r_o, inner_radius=r_in) pn_sphere = OpenPNM.Network.Cubic(template=img, spacing=spacing) assert pn_sphere.Np == 452 img2 = topology.template_sphere_shell(outer_radius=r_o) pn_sphere = OpenPNM.Network.Cubic(template=img2, spacing=spacing) L1 = sp.amax( topology.find_pores_distance(network=pn_sphere, pores1=pn_sphere.Ps, pores2=pn_sphere.Ps)) assert L1 < sp.sqrt(3) * 8 * 0.5
def test_template_sphere_shell(self): from OpenPNM.Network import tools spacing = sp.array([0.5]) r_o = 5 r_in = 2 img = tools.template_sphere_shell(outer_radius=r_o, inner_radius=r_in) pn_sphere = OpenPNM.Network.Cubic(template=img, spacing=spacing) assert pn_sphere.Np == 452 img1 = tools.template_disc_ring(outer_radius=r_o, inner_radius=r_in) pn_disc = OpenPNM.Network.Cubic(template=img1, spacing=spacing) assert pn_disc.Np == 56 img2 = tools.template_sphere_shell(outer_radius=r_o) pn_sphere = OpenPNM.Network.Cubic(template=img2, spacing=spacing) L1 = sp.amax(topology.find_pores_distance(network=pn_sphere, pores1=pn_sphere.Ps, pores2=pn_sphere.Ps)) L2 = ((8 * 0.5) ** 2 + (4 * 0.5) ** 2 + (4 * 0.5) ** 2) ** 0.5 + 1e-15 assert L1 < L2