<commit_before>r"""
===============================================================================
Submodule -- capillary_pressure
===============================================================================

"""

import scipy as _sp

def washburn(physics,
             phase,
             network,
             pore_surface_tension='pore.surface_tension',
             pore_contact_angle='pore.contact_angle',
             throat_diameter='throat.diameter',
             **kwargs):
    r"""
    Computes the capillary entry pressure assuming the throat is a cylindrical tube.

    Parameters
    ----------
    network : OpenPNM Network Object
        The network on which to apply the calculation
    phase : OpenPNM Phase Object
        Phase object for the invading phases

    Notes
    -----
    The Washburn equation is:

    .. math::
        P_c = -\frac{2\sigma(cos(\theta))}{r}

    This is the most basic approach to calculating entry pressure and is 
    suitable for highly non-wetting invading phases in most materials.

    """
    sigma = phase[pore_surface_tension]
    sigma = phase.interpolate_data(data=sigma)
    theta = phase[pore_contact_angle]
    theta = phase.interpolate_data(data=theta)
    r = network[throat_diameter]/2
    value = -2*sigma*_sp.cos(_sp.radians(theta))/r
    value = value[phase.throats(physics.name)]
    return value

def purcell(physics,
            phase,
            network,
            r_toroid,
            pore_surface_tension='pore.surfac_tension',
            pore_contact_angle='pore.contact_angle',
            throat_diameter='throat.diameter',
            **kwargs):
    r"""
    Computes the throat capillary entry pressure assuming the throat is a toroid.

    Parameters
    ----------
    network : OpenPNM Network Object
        The network on which to apply the calculation
    sigma : float, array_like
        Surface tension of the invading/defending phase pair.  Units must be 
        consistent with the throat size values, but SI is encouraged.
    theta : float, array_like
        Contact angle formed by a droplet of the invading phase and solid 
        surface, measured through the defending phase phase.  Angle must be given in degrees.
    r_toroid : float or array_like
        The radius of the solid

    Notes
    -----<commit_msg>Fixed typo in purcell model of surface tension<commit_after>r"""
===============================================================================
Submodule -- capillary_pressure
===============================================================================

"""

import scipy as _sp

def washburn(physics,
             phase,
             network,
             pore_surface_tension='pore.surface_tension',
             pore_contact_angle='pore.contact_angle',
             throat_diameter='throat.diameter',
             **kwargs):
    r"""
    Computes the capillary entry pressure assuming the throat is a cylindrical tube.

    Parameters
    ----------
    network : OpenPNM Network Object
        The network on which to apply the calculation
    phase : OpenPNM Phase Object
        Phase object for the invading phases

    Notes
    -----
    The Washburn equation is:

    .. math::
        P_c = -\frac{2\sigma(cos(\theta))}{r}

    This is the most basic approach to calculating entry pressure and is 
    suitable for highly non-wetting invading phases in most materials.

    """
    sigma = phase[pore_surface_tension]
    sigma = phase.interpolate_data(data=sigma)
    theta = phase[pore_contact_angle]
    theta = phase.interpolate_data(data=theta)
    r = network[throat_diameter]/2
    value = -2*sigma*_sp.cos(_sp.radians(theta))/r
    value = value[phase.throats(physics.name)]
    return value

def purcell(physics,
            phase,
            network,
            r_toroid,
            pore_surface_tension='pore.surface_tension',
            pore_contact_angle='pore.contact_angle',
            throat_diameter='throat.diameter',
            **kwargs):
    r"""
    Computes the throat capillary entry pressure assuming the throat is a toroid.

    Parameters
    ----------
    network : OpenPNM Network Object
        The network on which to apply the calculation
    sigma : float, array_like
        Surface tension of the invading/defending phase pair.  Units must be 
        consistent with the throat size values, but SI is encouraged.
    theta : float, array_like
        Contact angle formed by a droplet of the invading phase and solid 
        surface, measured through the defending phase phase.  Angle must be given in degrees.
    r_toroid : float or array_like
        The radius of the solid

    Notes
    -----
{'fraction_non_alphanumeric': 0.1410859341598974, 'fraction_numerical': 0.0012825994014536127, 'mean_word_length': 2.57175572519084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7310401', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1178, 'n_words': 391}