def _get_domain_area(self, inlets=None, outlets=None): logger.warning('Attempting to estimate inlet area...will be low') network = self.project.network # Abort if network is not 3D if np.sum(np.ptp(network['pore.coords'], axis=0) == 0) > 0: raise Exception('The network is not 3D, specify area manually') if inlets is None: inlets = self._get_inlets() if outlets is None: outlets = self._get_outlets() inlets = network['pore.coords'][inlets] outlets = network['pore.coords'][outlets] if not iscoplanar(inlets): logger.error('Detected inlet pores are not coplanar') if not iscoplanar(outlets): logger.error('Detected outlet pores are not coplanar') Nin = np.ptp(inlets, axis=0) > 0 if Nin.all(): logger.warning('Detected inlets are not oriented along a ' + 'principle axis') Nout = np.ptp(outlets, axis=0) > 0 if Nout.all(): logger.warning('Detected outlets are not oriented along a ' + 'principle axis') hull_in = ConvexHull(points=inlets[:, Nin]) hull_out = ConvexHull(points=outlets[:, Nout]) if hull_in.volume != hull_out.volume: logger.error('Inlet and outlet faces are different area') area = hull_in.volume # In 2D volume=area, area=perimeter return area
def test_iscoplanar(self): # Generate planar points with several parallel vectors at start coords = [[0, 0, 0], [0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 2]] assert topotools.iscoplanar(coords) # NON-planar points, also with parallel vectors coords = [[0, 0, 0], [0, 0, 0], [0, 0, 1], [0, 0, 2], [1, 1, 2]] assert ~topotools.iscoplanar(coords) # Planar points, none parallel coords = [[0, 0, 0], [0, 1, 2], [0, 2, 1], [0, 3, 2], [0, 2, 3]] assert topotools.iscoplanar(coords) # Non-planar points, none parallel coords = [[0, 0, 0], [0, 1, 2], [0, 2, 1], [0, 3, 3], [1, 1, 2]] assert ~topotools.iscoplanar(coords)
def _get_domain_length(self, inlets=None, outlets=None): logger.warning('Attempting to estimate domain length... ' + 'could be low if boundary pores were not added') network = self.project.network if inlets is None: inlets = self._get_inlets() if outlets is None: outlets = self._get_outlets() inlets = network['pore.coords'][inlets] outlets = network['pore.coords'][outlets] if not iscoplanar(inlets): logger.error('Detected inlet pores are not coplanar') if not iscoplanar(outlets): logger.error('Detected inlet pores are not coplanar') tree = cKDTree(data=inlets) Ls = np.unique(np.around(tree.query(x=outlets)[0], decimals=5)) if np.size(Ls) != 1: logger.error('A unique value of length could not be found') length = Ls[0] return length
def _get_domain_length(self, inlets=None, outlets=None): logger.warning('Attempting to estimate domain length... ' + 'could be low if boundary pores were not added') network = self.project.network if inlets is None: inlets = self._get_inlets() if outlets is None: outlets = self._get_outlets() inlets = network['pore.coords'][inlets] outlets = network['pore.coords'][outlets] if not iscoplanar(inlets): logger.error('Detected inlet pores are not coplanar') if not iscoplanar(outlets): logger.error('Detected inlet pores are not coplanar') tree = cKDTree(data=inlets) Ls = np.unique(np.float64(tree.query(x=outlets)[0])) if not np.allclose(Ls, Ls[0]): logger.error('A unique value of length could not be found') length = Ls[0] return length