LEWIS

Excel Usage

=LEWIS(D, alpha, Cp, k, rho)
  • D (float, required): Diffusivity of a species [m^2/s]
  • alpha (float, optional, default: null): Thermal diffusivity [m^2/s]
  • Cp (float, optional, default: null): Heat capacity [J/kg/K]
  • k (float, optional, default: null): Thermal conductivity [W/m/K]
  • rho (float, optional, default: null): Density [kg/m^3]

Returns (float): Lewis number [-]

Examples

Example 1: Example with alpha

Inputs:

D alpha
0.0000226 0.0000191

Excel formula:

=LEWIS(0.0000226, 0.0000191)

Expected output:

0.8451327433628318

Example 2: Example with rho, Cp, k

Inputs:

D rho k Cp
0.0000226 800 0.2 2200

Excel formula:

=LEWIS(0.0000226, 800, 0.2, 2200)

Expected output:

0.00502815768302494

Example 3: Higher diffusivity with alpha

Inputs:

D alpha
0.00003 0.00002

Excel formula:

=LEWIS(0.00003, 0.00002)

Expected output:

0.66667

Example 4: Water with thermal properties

Inputs:

D rho Cp k
0.000025 998 4182 0.6

Excel formula:

=LEWIS(0.000025, 998, 4182, 0.6)

Expected output:

0.00575

Python Code

from fluids.core import Lewis as fluids_Lewis

def lewis(D, alpha=None, Cp=None, k=None, rho=None):
    """
    Calculate the Lewis number.

    See: https://fluids.readthedocs.io/fluids.core.html#fluids.core.Lewis

    This example function is provided as-is without any representation of accuracy.

    Args:
        D (float): Diffusivity of a species [m^2/s]
        alpha (float, optional): Thermal diffusivity [m^2/s] Default is None.
        Cp (float, optional): Heat capacity [J/kg/K] Default is None.
        k (float, optional): Thermal conductivity [W/m/K] Default is None.
        rho (float, optional): Density [kg/m^3] Default is None.

    Returns:
        float: Lewis number [-]
    """
    try:
        D_val = float(D)
    except Exception:
        return "Error: D must be a numeric value."

    # Validate physical meaning
    if D_val <= 0:
        return "Error: Diffusivity must be positive."

    # If alpha is provided, use it
    if alpha is not None:
        try:
            alpha_val = float(alpha)
        except Exception:
            return "Error: alpha must be a numeric value."
        if alpha_val <= 0:
            return "Error: Thermal diffusivity must be positive."
        try:
            result = fluids_Lewis(D_val, alpha=alpha_val)
            return float(result)
        except Exception as e:
            return f"Error: Failed to calculate Lewis number: {str(e)}"

    # Otherwise, need rho, Cp, k
    if None in (Cp, k, rho):
        return "Error: must provide either alpha or all of rho, Cp, and k."
    try:
        Cp_val = float(Cp)
        k_val = float(k)
        rho_val = float(rho)
    except Exception:
        return "Error: Cp, k, and rho must be numeric values."
    if rho_val <= 0 or Cp_val <= 0 or k_val <= 0:
        return "Error: rho, Cp, and k must all be positive."
    try:
        result = fluids_Lewis(D_val, Cp=Cp_val, k=k_val, rho=rho_val)
        return float(result)
    except Exception as e:
        return f"Error: Failed to calculate Lewis number: {str(e)}"

Online Calculator