def run(self, phase=None, throats=None): logger.warning('This algorithm can take some time...') conduit_lengths = sp.sum(misc.conduit_lengths(network=self._net, mode='centroid'), axis=1) graph = self._net.create_adjacency_matrix(data=conduit_lengths, sprsfmt='csr') if phase is not None: self._phase = phase if 'throat.occupancy' in self._phase.props(): temp = conduit_lengths*(self._phase['throat.occupancy'] == 1) graph = self._net.create_adjacency_matrix(data=temp, sprsfmt='csr', prop='temp') path = spgr.shortest_path(csgraph=graph, method='D', directed=False) Px = sp.array(self._net['pore.coords'][:, 0], ndmin=2) Py = sp.array(self._net['pore.coords'][:, 1], ndmin=2) Pz = sp.array(self._net['pore.coords'][:, 2], ndmin=2) Cx = sp.square(Px.T - Px) Cy = sp.square(Py.T - Py) Cz = sp.square(Pz.T - Pz) Ds = sp.sqrt(Cx + Cy + Cz) temp = path / Ds temp[sp.isnan(temp)] = 0 temp[sp.isinf(temp)] = 0 return temp
def bulk_diffusion(physics, phase, network, pore_molar_density='pore.molar_density', pore_diffusivity='pore.diffusivity', pore_area='pore.area', pore_diameter='pore.diameter', throat_area='throat.area', throat_length='throat.length', throat_diameter='throat.diameter', shape_factor='throat.shape_factor', calc_pore_len=False, **kwargs): r""" Calculate the diffusive conductance of conduits in network, where a conduit is ( 1/2 pore - full throat - 1/2 pore ) based on the areas Parameters ---------- network : OpenPNM Network Object phase : OpenPNM Phase Object The phase of interest Notes ----- (1) This function requires that all the necessary phase properties already be calculated. (2) This function calculates the specified property for the *entire* network then extracts the values for the appropriate throats at the end. """ # Get Nt-by-2 list of pores connected to each throat Ps = network['throat.conns'] # Get properties in every pore in the network parea = network[pore_area] pdia = network[pore_diameter] # Get the properties of every throat tdia = network[throat_diameter] tarea = _sp.pi * (tdia / 2)**2 tlen = network[throat_length] # Interpolate pore phase property values to throats cp = phase[pore_molar_density] ct = phase.interpolate_data(data=cp) DABp = phase[pore_diffusivity] DABt = phase.interpolate_data(data=DABp) if calc_pore_len: lengths = misc.conduit_lengths(network, mode='centroid') plen1 = lengths[:, 0] plen2 = lengths[:, 2] else: plen1 = (0.5 * pdia[Ps[:, 0]]) plen2 = (0.5 * pdia[Ps[:, 1]]) # Remove any non-positive lengths plen1[plen1 <= 0] = 1e-12 plen2[plen2 <= 0] = 1e-12 # Find g for half of pore 1 gp1 = ct * DABt * parea[Ps[:, 0]] / plen1 gp1[_sp.isnan(gp1)] = _sp.inf gp1[~(gp1 > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf # Find g for half of pore 2 gp2 = ct * DABt * parea[Ps[:, 1]] / plen2 gp2[_sp.isnan(gp2)] = _sp.inf gp2[~(gp2 > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf # Find g for full throat, remove any non-positive lengths tlen[tlen <= 0] = 1e-12 # Get shape factor try: sf = network[shape_factor] except: sf = _sp.ones(network.num_throats()) sf[_sp.isnan(sf)] = 1.0 gt = (1 / sf) * ct * DABt * tarea / tlen # Set 0 conductance pores (boundaries) to inf gt[~(gt > 0)] = _sp.inf value = (1 / gt + 1 / gp1 + 1 / gp2)**(-1) value = value[phase.throats(physics.name)] return value
def hagen_poiseuille(physics, phase, network, pore_diameter='pore.diameter', pore_viscosity='pore.viscosity', throat_length='throat.length', throat_diameter='throat.diameter', calc_pore_len=True, shape_factor='throat.shape_factor', **kwargs): r""" Calculates the hydraulic conductivity of throat assuming cylindrical geometry using the Hagen-Poiseuille model Parameters ---------- network : OpenPNM Network Object phase : OpenPNM Phase Object Notes ----- (1) This function requires that all the necessary phase properties already be calculated. (2) This function calculates the specified property for the *entire* network then extracts the values for the appropriate throats at the end. """ # Get Nt-by-2 list of pores connected to each throat Ps = network['throat.conns'] # Get properties in every pore in the network mup = phase[pore_viscosity] mut = phase.interpolate_data(mup) pdia = network[pore_diameter] if calc_pore_len: lengths = misc.conduit_lengths(network, mode='centroid') plen1 = lengths[:, 0] plen2 = lengths[:, 2] else: plen1 = (0.5*pdia[Ps[:, 0]]) plen2 = (0.5*pdia[Ps[:, 1]]) # Remove any non-positive lengths plen1[plen1 <= 0] = 1e-12 plen2[plen2 <= 0] = 1e-12 # Find g for half of pore 1 gp1 = _sp.pi*(pdia[Ps[:, 0]])**4/(128*plen1*mut) gp1[_sp.isnan(gp1)] = _sp.inf gp1[~(gp1 > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf # Find g for half of pore 2 gp2 = _sp.pi*(pdia[Ps[:, 1]])**4/(128*plen2*mut) gp2[_sp.isnan(gp2)] = _sp.inf gp2[~(gp2 > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf # Find g for full throat tdia = network[throat_diameter] tlen = network[throat_length] # Remove any non-positive lengths tlen[tlen <= 0] = 1e-12 # Get shape factor try: sf = network[shape_factor] except: sf = _sp.ones(network.num_throats()) sf[_sp.isnan(sf)] = 1.0 gt = (1/sf)*_sp.pi*(tdia)**4/(128*tlen*mut) gt[~(gt > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf value = (1/gt + 1/gp1 + 1/gp2)**(-1) value = value[phase.throats(physics.name)] return value
def bulk_diffusion(physics, phase, network, pore_molar_density='pore.molar_density', pore_diffusivity='pore.diffusivity', pore_area='pore.area', pore_diameter='pore.diameter', throat_area='throat.area', throat_length='throat.length', throat_diameter='throat.diameter', calc_pore_len=True, shape_factor='throat.shape_factor', **kwargs): r""" Calculate the diffusive conductance of conduits in network, where a conduit is ( 1/2 pore - full throat - 1/2 pore ) based on the areas Parameters ---------- network : OpenPNM Network Object phase : OpenPNM Phase Object The phase of interest Notes ----- (1) This function requires that all the necessary phase properties already be calculated. (2) This function calculates the specified property for the *entire* network then extracts the values for the appropriate throats at the end. """ # Get Nt-by-2 list of pores connected to each throat Ps = network['throat.conns'] # Get properties in every pore in the network parea = network[pore_area] pdia = network[pore_diameter] # Get the properties of every throat tdia = network[throat_diameter] tarea = _sp.pi*(tdia/2)**2 tlen = network[throat_length] # Interpolate pore phase property values to throats cp = phase[pore_molar_density] ct = phase.interpolate_data(data=cp) DABp = phase[pore_diffusivity] DABt = phase.interpolate_data(data=DABp) if calc_pore_len: lengths = misc.conduit_lengths(network, mode='centroid') plen1 = lengths[:, 0] plen2 = lengths[:, 2] else: plen1 = (0.5*pdia[Ps[:, 0]]) plen2 = (0.5*pdia[Ps[:, 1]]) # Remove any non-positive lengths plen1[plen1 <= 0] = 1e-12 plen2[plen2 <= 0] = 1e-12 # Find g for half of pore 1 gp1 = ct*DABt*parea[Ps[:, 0]] / plen1 gp1[_sp.isnan(gp1)] = _sp.inf gp1[~(gp1 > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf # Find g for half of pore 2 gp2 = ct*DABt*parea[Ps[:, 1]] / plen2 gp2[_sp.isnan(gp2)] = _sp.inf gp2[~(gp2 > 0)] = _sp.inf # Set 0 conductance pores (boundaries) to inf # Find g for full throat, remove any non-positive lengths tlen[tlen <= 0] = 1e-12 # Get shape factor try: sf = network[shape_factor] except: sf = _sp.ones(network.num_throats()) sf[_sp.isnan(sf)] = 1.0 gt = (1/sf)*ct*DABt*tarea/tlen # Set 0 conductance pores (boundaries) to inf gt[~(gt > 0)] = _sp.inf value = (1/gt + 1/gp1 + 1/gp2)**(-1) value = value[phase.throats(physics.name)] return value