Skip to content

Commit

Permalink
changing api for rev_tau func
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Sep 18, 2023
1 parent 74709af commit ef1bfb4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions porespy/beta/_gdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
settings.loglevel = 50


def rev_tortuosity(im, maxsize=100):
def rev_tortuosity(im, block_size_lim=[10, 100]):
r"""
Compute data for a representative element volume plot based on tortuosity
Expand All @@ -29,52 +29,55 @@ def rev_tortuosity(im, maxsize=100):
im : ndarray
A boolean image of the porous media with `True` values indicating the phase
of interest.
maxsize : int
The maximum size of blocks to analyze. Placing an upper limit on the
size of the blocks can avoid time consuming computations.
block_size_lim : list of ints
The upper and lower bounds of the block sizes to use. The defaults are
10 to 100 voxels. Placing an upper limit on the size of the blocks can
avoid time consuming computations, while placing a lower limit can avoid
computing values for meaninglessly small blocks.
Returns
-------
df : pandas DataFrame
A DataFrame with the tortuosity and volume for each block, along with
other useful data like the porosity.
df : DataFrame
A `pandas` DataFrame with the tortuosity and volume for each block, along
with other useful data like the porosity.
"""
a = np.ceil(min(im.shape)/maxsize).astype(int)
block_size = min(im.shape) // np.arange(a, 1000) # Generate WAY more than needed
block_size = block_size[block_size >= 10] # Trim to 10 and higher
mn, mx = block_size_lim
a = np.ceil(min(im.shape)/mx).astype(int)
block_size = min(im.shape) // np.arange(a, 9999) # Generate WAY more than needed
block_size = block_size[block_size >= mn] # Trim to given min block size
tau = []
for s in tqdm(block_size):
tau.append(chunks_to_dataframe(im, block_size=s))
df = pd.concat(tau)
del df['Diffusive Conductance']
del df['Throat Number']
df = df[df.Tortuosity > 1]
df = df[df.Tortuosity < np.inf] # inf values mean block did not percolate
return df


@dask.delayed
def calc_g(image, axis):
r'''Calculates diffusive conductance of an image.
r"""
Calculates diffusive conductance of an image.
Parameters
----------
image : np.ndarray
The binary image to analyze with ``True`` indicating phase of interest.
axis : int
0 for x-axis, 1 for y-axis, 2 for z-axis.
result: int
result : int
0 for diffusive conductance, 1 for both diffusive conductance
and results object from Porespy.
'''
"""
try:
# if tortuosity_fd fails, throat is closed off from whichever axis was specified
solver = op.solvers.PyamgRugeStubenSolver(tol=1e-5)
results = simulations.tortuosity_fd(im=image, axis=axis, solver=solver)

except Exception:
# a is diffusive conductance, b is tortuosity
a, b = (0, -1)
a, b = (0, np.inf)

return (a, b)

Expand Down Expand Up @@ -155,7 +158,6 @@ def tortuosity_gdd(im, scale_factor=3, block_size=None, use_dask=True):
----------
im : np.ndarray
The binary image to analyze with ``True`` indicating phase of interest
chunk_shape : list
Contains the number of chunks to be made in the x,y,z directions.
Expand Down

0 comments on commit ef1bfb4

Please sign in to comment.