dynamic_viscosity

dynamic_viscosity#

The dynamic viscosity is a property of the fluid, defining the resistance of the fluid to its own movement. The dynamic viscosity is calculated using the Sutherland formula (reference). The function can be found and is documented in util.dynamic_viscosity.py. It takes inputs of temperature, reference_viscosity, reference_temperature, and sutherland_constant. It returns a value for the dynamic viscosity at those variables. At default conditions (298.15 K and 101325 Pa), the dynamic viscosity is approximately 1.84e-5 kg/m/s. The Sutherland formula is

\[ \mu = \frac{\mu_{0}\, (T/T_{0})^{3/2}\, (T_{0} + C)}{C + T} \]

where \(\mu\) is the dynamic viscosity, \(\mu_{0}\) is the reference dynamic viscosity, \(T\) is temperature, \(T_{0}\) is the reference temperature, and \(C\) is the Sutherland constant.

from particula.environment import Environment
Environment().dynamic_viscosity() # will produce approx 1.84e-5 kg/m/s
1.8371493734583912×10-5 kilogram/(meter second)
from particula.util import dynamic_viscosity
help(dynamic_viscosity)
Help on module particula.util.dynamic_viscosity in particula.util:

NAME
    particula.util.dynamic_viscosity - calculating the dynamic viscosity

DESCRIPTION
    The dynamic viscocity is calculated using the Sutherland formula,
    assuming ideal gas behavior, as a function of temperature.
    
        "The dynamic viscosity equals the product of the sum of
        Sutherland's constant and the reference temperature divided by
        the sum of Sutherland's constant and the temperature,
        the reference viscosity and the ratio to the 3/2 power
        of the temperature to reference temperature."
    
        https://resources.wolframcloud.com/FormulaRepository/resources/Sutherlands-Formula

FUNCTIONS
    dyn_vis(temperature=<Quantity(298.15, 'kelvin')>, reference_viscosity=<Quantity(1.716e-05, 'pascal * second')>, reference_temperature=<Quantity(273.15, 'kelvin')>, sutherland_constant=<Quantity(110.4, 'kelvin')>, **kwargs)
        The dynamic viscosity of air via Sutherland formula.
        This formula depends on temperature (temp) and the reference
        temperature (t_ref) as well as the reference viscosity (mu_ref).
        
        Examples:
        ```
        >>> from particula import u
        >>> from particula.util.dynamic_viscosity import dyn_vis
        >>> # with units
        >>> dyn_vis(
        ... temperature=298.15*u.K,
        ... reference_viscosity=1.716e-5*u.Pa*u.s
        ... )
        <Quantity(1.83714937e-05, 'kilogram / meter / second')>
        >>> # without units and taking magnitude
        >>> dyn_vis(
        ... temperature=298.15,
        ... reference_viscosity=1.716e-5
        ... ).magnitude
        1.8371493734583912e-05
        >>> # without units, all keyword arguments
        >>> dyn_vis(
        ... temperature=298.15,
        ... reference_viscosity=1.716e-5,
        ... reference_temperature=273.15
        ... )
        <Quantity(1.83714937e-05, 'kilogram / meter / second')>
        >>> # for a list of temperatures
        >>> dyn_vis(temperature=[200, 250, 300, 400]).m
        array([1.32849751e-05, 1.59905239e-05, 1.84591625e-05, 2.28516090e-05])
        ```
        
        Inputs:
            temperature             (float) [K]     (default: 298.15)
            reference_viscosity     (float) [Pa*s]  (default: constants)
            reference_temperature   (float) [K]     (default: constants)
            sutherland_constant     (float) [K]     (default: constants)
        
        Returns:
                                    (float) [Pa*s]
        
        Using particula.constants:
            REF_VISCOSITY_AIR_STP   (float) [Pa*s]
            REF_TEMPERATURE_STP     (float) [K]
            SUTHERLAND_CONSTANT     (float) [K]

DATA
    REF_TEMPERATURE_STP = <Quantity(273.15, 'kelvin')>
    REF_VISCOSITY_AIR_STP = <Quantity(1.716e-05, 'pascal * second')>
    SUTHERLAND_CONSTANT = <Quantity(110.4, 'kelvin')>
    u = <pint.registry.UnitRegistry object>

FILE
    /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/particula/util/dynamic_viscosity.py
import inspect
print(inspect.getsource(dynamic_viscosity))
""" calculating the dynamic viscosity

    The dynamic viscocity is calculated using the Sutherland formula,
    assuming ideal gas behavior, as a function of temperature.

        "The dynamic viscosity equals the product of the sum of
        Sutherland's constant and the reference temperature divided by
        the sum of Sutherland's constant and the temperature,
        the reference viscosity and the ratio to the 3/2 power
        of the temperature to reference temperature."

        https://resources.wolframcloud.com/FormulaRepository/resources/Sutherlands-Formula

"""
from particula import u
from particula.constants import (REF_TEMPERATURE_STP, REF_VISCOSITY_AIR_STP,
                                 SUTHERLAND_CONSTANT)
from particula.util.input_handling import in_temperature, in_viscosity


def dyn_vis(
    temperature=298.15 * u.K,
    reference_viscosity=REF_VISCOSITY_AIR_STP,
    reference_temperature=REF_TEMPERATURE_STP,
    sutherland_constant=SUTHERLAND_CONSTANT,
    **kwargs,
):
    """ The dynamic viscosity of air via Sutherland formula.
        This formula depends on temperature (temp) and the reference
        temperature (t_ref) as well as the reference viscosity (mu_ref).

        Examples:
        ```
        >>> from particula import u
        >>> from particula.util.dynamic_viscosity import dyn_vis
        >>> # with units
        >>> dyn_vis(
        ... temperature=298.15*u.K,
        ... reference_viscosity=1.716e-5*u.Pa*u.s
        ... )
        <Quantity(1.83714937e-05, 'kilogram / meter / second')>
        >>> # without units and taking magnitude
        >>> dyn_vis(
        ... temperature=298.15,
        ... reference_viscosity=1.716e-5
        ... ).magnitude
        1.8371493734583912e-05
        >>> # without units, all keyword arguments
        >>> dyn_vis(
        ... temperature=298.15,
        ... reference_viscosity=1.716e-5,
        ... reference_temperature=273.15
        ... )
        <Quantity(1.83714937e-05, 'kilogram / meter / second')>
        >>> # for a list of temperatures
        >>> dyn_vis(temperature=[200, 250, 300, 400]).m
        array([1.32849751e-05, 1.59905239e-05, 1.84591625e-05, 2.28516090e-05])
        ```

        Inputs:
            temperature             (float) [K]     (default: 298.15)
            reference_viscosity     (float) [Pa*s]  (default: constants)
            reference_temperature   (float) [K]     (default: constants)
            sutherland_constant     (float) [K]     (default: constants)

        Returns:
                                    (float) [Pa*s]

        Using particula.constants:
            REF_VISCOSITY_AIR_STP   (float) [Pa*s]
            REF_TEMPERATURE_STP     (float) [K]
            SUTHERLAND_CONSTANT     (float) [K]

    """
    # trick to avoid triggering a linting error for kwargs
    temp = kwargs.get("temperature", temperature)
    temp = in_temperature(temperature)
    ref_vis = in_viscosity(reference_viscosity)
    ref_temp = in_temperature(reference_temperature)
    suth_const = in_temperature(sutherland_constant)

    return (
        ref_vis *
        (temp/ref_temp)**(3/2) *
        (ref_temp + suth_const) /
        (temp + suth_const)
    ).to_base_units()