Adjust extract porenetwork script - disconnected pores already include isolated pores
Bug report
What happened / Problem description: Since the updating script extract_pore_network_with_porespy.py for the new openpnm version 3, isolated pores and pores in disconnected clusters are removed to avoid singularity. However, @mathis mentioned that isolated pores can't be removed anymore as they were already removed before by the pores in disconnected clusters.
Checking with the extraction script based on a OpenPNM version 2.X, "trim_pores" was used (see OpenPNM version 2.8), which is equivilant to "disconnected_pores" in OpenPNM version 3.X.
What you expected to happen: No error, when removing isolated pores or pores from disconnected clusters and no removed pores, which should not be.
How to reproduce it (as minimally and precisely as possible):
Minimal Python example
A porenetwork is created and boundary throats are deleted such that it leaves a network with isolated pores at the corners (see plot).
It can be seen from the output, that isolated pores and pores in disconnected clusters are the same in this case. Hence, disconnected_pores
also contains isolated_pores
. After trimming the network with disconnected_pores
, trimming with isolated_pores
does not work any more/is unnecessary.
import openpnm as op
import numpy as np
import matplotlib.pyplot as plt
import math
def plot_network_with_op(network):
print('\n------------------------------------------')
print('Plot network with openPNM visualization (using matplotlib)')
opMplStyle = True
if opMplStyle:
op.visualization.set_mpl_style()
fig = plt.figure(figsize=[20, 15])
ax = fig.add_subplot(111)
legend_labels = ['throat', 'pore']
ax = op.visualization.plot_connections(network, ax=ax, label = legend_labels[0])
ax = op.visualization.plot_coordinates(network, ax=ax, label = legend_labels[1])
plt.legend()
plt.show()
def calc_throat_center_coords(network):
pore_coords = network["pore.coords"]
throats = network["throat.conns"]
throat_centers = np.mean(pore_coords[throats], axis=1)
return throat_centers
def remove_boundary_throats(network):
eps = 1e-6
throat_centers = calc_throat_center_coords(network)
box_min = np.min(network['pore.coords'][:], axis=0)
box_max = np.max(network['pore.coords'][:], axis=0)
eps_array_2D = np.array([eps, eps, 0.0])
boundaryThroats = np.any((throat_centers < box_min + eps_array_2D) | (throat_centers > box_max - eps_array_2D), axis=1) #bool vector with True for throats at boundary
op.topotools.trim(network=network, throats=boundaryThroats)
N_x = 5
N_y = N_x
porenetwork = op.network.Cubic(shape=[N_x,N_y ])
# delete throats at boundary to create isolated pores in corners
remove_boundary_throats(porenetwork)
plot_network_with_op(porenetwork)
health = op.utils.check_network_health(porenetwork)
print("Pores in disconnected clusters: ", health["disconnected_pores"])
print("Isolated pores: ", health["isolated_pores"])
op.topotools.trim(network=porenetwork, pores=health["isolated_pores"])
op.topotools.trim(network=porenetwork, pores=health["disconnected_pores"])
Sugdestion:
Just use disconnected_pores
to trim porenetwork as this is equivalent to the old script based on OpenPNM 2.X and it also contains the isolated_pores
Environment:
- Dune version:
- DuMux version:
- Others: