find_h#

Find the high of the two-phase zone in an invasion image

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def _find_trapped_pores(inv_seq, indices, indptr, outlets):  # pragma: no cover

The arguments and their defaults for this function are:

import inspect
inspect.signature(ps.metrics.find_h)
<Signature (saturation, position=None, srange=[0.01, 0.99])>

Start by performing a basic invasion simulation:

np.random.seed(1)
im = ps.generators.blobs(shape=[150, 150], porosity=0.6, blobiness=1)
inlets = np.zeros_like(im)
inlets[0, :] = True
inv = ps.simulations.drainage(im=im, inlets=inlets, voxel_size=1, g=0)

fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(inv.im_satn/im, interpolation='none', origin='lower')
ax[0].axis(False)
ax[0].set_title('Saturation map')
ax[1].imshow((inv.im_satn < 0.6)*(inv.im_satn > 0)/im, interpolation='none', origin='lower')
ax[1].axis(False)
ax[1].set_title('Fluid distribution at saturation = 0.6');
../../../_images/5f06266f19844881b166c732f3c9995eb951254f6a74938f716420b864313a01.png

Next we need to find to convert the fluid configuration image into a saturation profile:

s = ps.metrics.satn_profile(satn=inv.im_satn, s=0.6)
plt.plot(s.position, s.saturation, 'b-o')
plt.xlabel("distance from injection face")
plt.ylabel("non-wetting phase saturation");
../../../_images/1b423233919e714f3fdfab04871c49f543308701796174814a6ac183511666af.png

Finally, we can determine the height of the two phase zone:

h = ps.metrics.find_h(s.saturation, s.position)
print(h)
[13:56:11] WARNING  The requested saturation range was adjusted to (0.01, 0.9768292682926829) to     _funcs.py:1244
                    accomodate data                                                                                
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Results of find_h generated at Tue Jun  6 13:56:11 2023
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
valid                     False
zmax                      4.5
zmin                      114.5
smax                      0.9768292682926829
smin                      0.01
h                         110.0
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

srange#

The object that is returned by find_h is like a dataclass, meaning it is an object with data as attributes, which can be inspected by printing it. Note that the valid attribute is False. This is because by default the function finds the distance between s_nwp=0.99 and s_nwp=0.01, however as can be seen in the above printout the maximun saturation in the image was 0.9768, so the profile did not span the requested range. This can be specified:

h = ps.metrics.find_h(s.saturation, s.position, srange=[0.01, 0.95])
print(h)
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Results of find_h generated at Tue Jun  6 13:56:11 2023
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
valid                     True
zmax                      24.5
zmin                      114.5
smax                      0.95
smin                      0.01
h                         90.0
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――