Skip to content

Commit b33496f

Browse files
committed
Merge pull request #520 from PMEAL/Removing_template
removed the template_sphere
2 parents 3ae8ecf + 70bb32d commit b33496f

File tree

4 files changed

+59
-59
lines changed

4 files changed

+59
-59
lines changed

OpenPNM/Network/__Cubic__.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -448,46 +448,3 @@ def domain_area(self, face):
448448
def subdivide(self, pores=[], shape=[], labels=[]):
449449
topo.subdivide(network=self, pores=pores, shape=shape, labels=labels)
450450
subdivide.__doc__ = topo.subdivide.__doc__
451-
452-
def template_sphere_shell(outer_radius=None, inner_radius=0):
453-
r"""
454-
This method generates an image array of a sphere shell for a cubic network.
455-
456-
Parameters
457-
----------
458-
outer_radius : array_like
459-
Number of the nodes in the outer radius of the shell
460-
461-
inner_radius : float
462-
Number of the nodes in the inner radius of the shell
463-
464-
"""
465-
466-
if outer_radius is None:
467-
raise Exception('No outer radius has been sent!')
468-
if inner_radius is None:
469-
raise Exception('Number of nodes in the inner radius cannot be '
470-
'None!')
471-
rmax = np.array(outer_radius, ndmin=1)
472-
rmin = np.array(inner_radius, ndmin=1)
473-
s_rmax = np.size(rmax)
474-
s_rmin = np.size(rmin)
475-
if not ((s_rmax in [1, 3]) and (s_rmin in [1, 3])):
476-
raise Exception('In this method, each radius can be scalar or '
477-
'array with components along all xyz directions.')
478-
s_u_rmax = np.size(np.unique(rmax))
479-
s_u_rmin = np.size(np.unique(rmin))
480-
if not ((s_u_rmax == 1) and (s_u_rmin == 1)):
481-
raise Exception('In this method, all components of radius should '
482-
'be unique values along all xyz directions.')
483-
pnum = 2 * np.ones(3) * rmax - 1
484-
Rx, Ry, Rz = np.array(pnum, dtype=np.int32)
485-
x, y, z = np.indices((Rx, Ry, Rz))
486-
x = x - (Rx - 1)/2
487-
y = y - (Ry - 1)/2
488-
z = z - (Rz - 1)/2
489-
img = x ** 2 + y ** 2 + z ** 2 < np.unique(rmax) ** 2
490-
if not np.all(rmin == 0):
491-
img_min = x ** 2 + y ** 2 + z ** 2 > np.unique(rmin) ** 2
492-
img = img * img_min
493-
return (img)

OpenPNM/Utilities/__topology__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,3 +679,46 @@ def merge_pores(self, network, pores, labels=['merged']):
679679
Pnew = network.Ps[-1]
680680
self.connect_pores(network, pores1=Pnew, pores2=Pn, labels=labels)
681681
self.trim(network=network, pores=pores)
682+
683+
def template_sphere_shell(outer_radius=None, inner_radius=0):
684+
r"""
685+
This method generates an image array of a sphere shell for a cubic network.
686+
687+
Parameters
688+
----------
689+
outer_radius : array_like
690+
Number of the nodes in the outer radius of the shell
691+
692+
inner_radius : float
693+
Number of the nodes in the inner radius of the shell
694+
695+
"""
696+
697+
if outer_radius is None:
698+
raise Exception('No outer radius has been sent!')
699+
if inner_radius is None:
700+
raise Exception('Number of nodes in the inner radius cannot be '
701+
'None!')
702+
rmax = _np.array(outer_radius, ndmin=1)
703+
rmin = _np.array(inner_radius, ndmin=1)
704+
s_rmax = _np.size(rmax)
705+
s_rmin = _np.size(rmin)
706+
if not ((s_rmax in [1, 3]) and (s_rmin in [1, 3])):
707+
raise Exception('In this method, each radius can be scalar or '
708+
'array with components along all xyz directions.')
709+
s_u_rmax = _np.size(_np.unique(rmax))
710+
s_u_rmin = _np.size(_np.unique(rmin))
711+
if not ((s_u_rmax == 1) and (s_u_rmin == 1)):
712+
raise Exception('In this method, all components of radius should '
713+
'be unique values along all xyz directions.')
714+
pnum = 2 * _np.ones(3) * rmax - 1
715+
Rx, Ry, Rz = _np.array(pnum, dtype=_np.int32)
716+
x, y, z = _np.indices((Rx, Ry, Rz))
717+
x = x - (Rx - 1)/2
718+
y = y - (Ry - 1)/2
719+
z = z - (Rz - 1)/2
720+
img = x ** 2 + y ** 2 + z ** 2 < _np.unique(rmax) ** 2
721+
if not _np.all(rmin == 0):
722+
img_min = x ** 2 + y ** 2 + z ** 2 > _np.unique(rmin) ** 2
723+
img = img * img_min
724+
return (img)

test/unit/Network/CubicTest.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,3 @@ def test_domain_length(self):
148148
L = self.net.domain_length(face_1=self.net.pores('top'),
149149
face_2=self.net.pores('bottom'))
150150
assert sp.allclose(L, 4, rtol=1e-02)
151-
152-
def test_template_sphere_shell(self):
153-
from OpenPNM.Utilities import topology
154-
spacing = sp.array([0.5])
155-
r_o = [5, 5, 5]
156-
r_in = [2, 2, 2]
157-
img = OpenPNM.Network.Cubic.template_sphere_shell(outer_radius=r_o,
158-
inner_radius=r_in)
159-
pn_sphere = OpenPNM.Network.Cubic(template=img, spacing=spacing)
160-
assert pn_sphere.Np == 452
161-
img2 = OpenPNM.Network.Cubic.template_sphere_shell(outer_radius=r_o)
162-
pn_sphere = OpenPNM.Network.Cubic(template=img2, spacing=spacing)
163-
L1 = sp.amax(topology.find_pores_distance(network=pn_sphere,
164-
pores1=pn_sphere.Ps,
165-
pores2=pn_sphere.Ps))
166-
assert L1 < sp.sqrt(3) * 8 * 0.5

test/unit/Utilities/TopologyTest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,19 @@ def test_merge_pores(self):
3333
topo.merge_pores(network=net, pores=P, labels=['merged'])
3434
assert net.Np == 95
3535
assert net.Nt == 222
36+
37+
def test_template_sphere_shell(self):
38+
from OpenPNM.Utilities import topology
39+
spacing = sp.array([0.5])
40+
r_o = [5, 5, 5]
41+
r_in = [2, 2, 2]
42+
img = topology.template_sphere_shell(outer_radius=r_o,
43+
inner_radius=r_in)
44+
pn_sphere = OpenPNM.Network.Cubic(template=img, spacing=spacing)
45+
assert pn_sphere.Np == 452
46+
img2 = topology.template_sphere_shell(outer_radius=r_o)
47+
pn_sphere = OpenPNM.Network.Cubic(template=img2, spacing=spacing)
48+
L1 = sp.amax(topology.find_pores_distance(network=pn_sphere,
49+
pores1=pn_sphere.Ps,
50+
pores2=pn_sphere.Ps))
51+
assert L1 < sp.sqrt(3) * 8 * 0.5

0 commit comments

Comments
 (0)