Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing in pore scale models #2889

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions openpnm/models/geometry/pore_surface_area/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def sphere(
R = network[pore_diameter] / 2
value = 4 * _np.pi * R**2
Tca = network[throat_cross_sectional_area]
_np.subtract.at(value, network.conns.T.flatten(), _np.repeat(Tca, repeats=2))
_np.subtract.at(value, network.conns[:, 0], Tca)
_np.subtract.at(value, network.conns[:, 1], Tca)
value = _np.clip(value, 1e-12, _np.inf)
return value


Expand Down Expand Up @@ -69,7 +71,9 @@ def circle(
"""
value = _np.pi * network[pore_diameter]
Tca = network[throat_cross_sectional_area]
_np.subtract.at(value, network.conns.T.flatten(), _np.repeat(Tca, repeats=2))
_np.subtract.at(value, network.conns[:, 0], Tca)
_np.subtract.at(value, network.conns[:, 1], Tca)
value = _np.clip(value, 1e-12, _np.inf)
return value


Expand All @@ -95,7 +99,9 @@ def cube(
D = network[pore_diameter]
value = 6.0 * D**2
Tca = network[throat_cross_sectional_area]
_np.subtract.at(value, network.conns.T.flatten(), _np.repeat(Tca, repeats=2))
_np.subtract.at(value, network.conns[:, 0], Tca)
_np.subtract.at(value, network.conns[:, 1], Tca)
value = _np.clip(value, 1e-12, _np.inf)
return value


Expand All @@ -121,5 +127,7 @@ def square(
D = network[pore_diameter]
value = 4.0 * D
Tca = network[throat_cross_sectional_area]
_np.subtract.at(value, network.conns.T.flatten(), _np.repeat(Tca, repeats=2))
_np.subtract.at(value, network.conns[:, 0], Tca)
_np.subtract.at(value, network.conns[:, 1], Tca)
value = _np.clip(value, 1e-12, _np.inf)
return value
18 changes: 9 additions & 9 deletions tests/unit/models/geometry/PoreSurfaceAreaTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def test_sphere(self):

def test_circle(self):
self.net2D.add_model(propname='pore.surface_area',
model=mods.circle,
regen_mode='normal')
model=mods.circle,
regen_mode='normal')
a = np.array([2.74159265, 2.84159265, 2.94159265])
b = np.unique(self.net2D['pore.surface_area'])
assert_allclose(a, b)
Expand All @@ -39,8 +39,8 @@ def test_cube(self):

def test_square(self):
self.net2D.add_model(propname='pore.surface_area',
model=mods.square,
regen_mode='normal')
model=mods.square,
regen_mode='normal')
a = np.array([3.6, 3.7, 3.8])
b = np.unique(self.net2D['pore.surface_area'])
assert_allclose(a, b)
Expand All @@ -54,16 +54,16 @@ def test_circle_multi_geom(self):
net['throat.cross_sectional_area'][[0, 1, 2]] = 0.3
net['pore.right'] = ~net['pore.left']
net.add_model(propname='pore.surface_area',
model=mods.circle,
domain='left',
regen_mode='normal')
model=mods.circle,
domain='left',
regen_mode='normal')
net.add_model(propname='pore.surface_area',
model=mods.circle,
domain='right',
regen_mode='normal')
a = np.array([2.84159265, 2.74159265, 2.74159265])
a = np.array([2.84159265, 2.54159265, 2.54159265])
b = net['pore.surface_area@left']
c = np.array([2.74159265, 2.74159265, 2.74159265, 2.94159265,
c = np.array([2.74159265, 2.94159265, 2.94159265, 2.94159265,
2.94159265, 2.94159265, 3.04159265])
d = net['pore.surface_area@right']
assert_allclose(a, b)
Expand Down
Loading