<commit_before>
"""
module hydraulic_conductance
===============================================================================

"""

import scipy as sp

def constant(physics,network,fluid,propname,value,**params):
    r"""
    Assigns specified constant value
    """
    network.set_throat_data(phase=fluid,prop=propname,data=value)

def na(physics,network,fluid,propname,**params):
    value = -1
    network.set_throat_data(phase=fluid,prop=propname,data=value)

def hagen_poiseuille(physics,network,fluid,propname,**params):
    r"""
    Calculates the hydraulic conductvity of throat assuming square geometry using a modified Hagen Poiseuille model

    Parameters
    ----------
    network : OpenPNM Network Object

    fluid : OpenPNM Fluid Object
    """
    mup = network.get_pore_data(phase=fluid,prop='viscosity')
    mut = network.interpolate_throat_data(mup)
    #Get Nt-by-2 list of pores connected to each throat
    pores = network.find_connected_pores(network.get_throat_data(prop='numbering'),flatten=0)
    #Find g for half of pore 1
    gp1 = 2.28*(network.get_pore_data(prop='diameter')[pores[:,0]]/2)**4/(network.get_pore_data(prop='diameter')[pores[:,0]]*mut)
    gp1[~(gp1>0)] = sp.inf #Set 0 conductance pores (boundaries) to inf
    #Find g for half of pore 2
    gp2 = 2.28*(network.get_pore_data(prop='diameter')[pores[:,1]]/2)**4/(network.get_pore_data(prop='diameter')[pores[:,1]]*mut)
    gp2[~(gp2>0)] = sp.inf #Set 0 conductance pores (boundaries) to inf
    #Find g for full throat
    gt = 2.28*(network.get_throat_data(prop='diameter')/2)**4/(2*network.get_throat_data(prop='length')*mut)
    value = (1/gt + 1/gp1 + 1/gp2)**(-1)
    network.set_throat_data(phase=fluid,prop=propname,data=value)


<commit_msg>Added the functionality for naming properties.<commit_after>
"""
module hydraulic_conductance
===============================================================================

"""

import scipy as sp

def constant(physics,
             network,
             fluid,
             propname,
             value,
             **params):
    r"""
    Assigns specified constant value
    """
    network.set_throat_data(phase=fluid,prop=propname,data=value)

def na(physics,
       network,
       fluid,
       propname,
       **params):
    value = -1
    network.set_throat_data(phase=fluid,prop=propname,data=value)

def hagen_poiseuille(physics,
                     network,
                     fluid,
                     propname,
                     viscosity='viscosity',
                     throat_diameter = 'diameter',
                     throat_length = 'length',
                     pore_diameter = 'diameter',
                     **params):
    r"""
    Calculates the hydraulic conductvity of throat assuming square geometry using a modified Hagen Poiseuille model

    Parameters
    ----------
    network : OpenPNM Network Object

    fluid : OpenPNM Fluid Object
    """
    mup = network.get_pore_data(phase=fluid,prop=viscosity)
    mut = network.interpolate_throat_data(mup)
    #Get Nt-by-2 list of pores connected to each throat
    tind = network.get_throat_indices()
    pores = network.find_connected_pores(tind,flatten=0)
    #Find g for half of pore 1
    pdia = network.get_pore_data(prop=pore_diameter)
    gp1 = 2.28*(pdia[pores[:,0]]/2)**4/(pdia[pores[:,0]]*mut)
    gp1[~(gp1>0)] = sp.inf #Set 0 conductance pores (boundaries) to inf
    #Find g for half of pore 2
    gp2 = 2.28*(pdia[pores[:,1]]/2)**4/(pdia[pores[:,1]]*mut)
    gp2[~(gp2>0)] = sp.inf #Set 0 conductance pores (boundaries) to inf
    #Find g for full throat
    tdia = network.get_throat_data(prop=throat_diameter)
    tlen = network.get_throat_data(prop=throat_length)
    gt = 2.28*(tdia/2)**4/(2*tlen*mut)
    value = (1/gt + 1/gp1 + 1/gp2)**(-1)
    network.set_throat_data(phase=fluid,prop=propname,data=value)


{'fraction_non_alphanumeric': 0.1679152673727719, 'fraction_numerical': 0.021183156807026607, 'mean_word_length': 3.345679012345679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2387249', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1264, 'n_words': 253}