flowtube.viscosity_density

Handles the calculation of the viscosity and density of a variety of pure gases.

Citations

“A8: Van Der Waal’s Constants for Real Gases.” Chemistry LibreTexts, November 14, 2024. Accessed August 6, 2025. https://chem.libretexts.org/Ancillary_Materials/Reference/Reference_Tables/Atomic_and_Molecular_Properties/A8%3A_van_der_Waal’s_Constants_for_Real_Gases.

“NIST Chemistry Webbook, SRD 69.” Thermophysical Properties of Fluid Systems. Accessed August 6, 2025. https://webbook.nist.gov/chemistry/fluid/.

Reid, R.C., Prausnitz, J.M., Poling, B.E., 1987. The Properties of Gases and Liquids, 4th ed. McGraw-Hill, New York.

Attributes

a

b

T_c

P_c

mu

Classes

basic_attrs

Base class for protocol classes.

Functions

real_density(→ float)

Calculates the real density of a gas using van der Waal's equation

dynamic_viscosity(→ float)

Estimate absolute/dynamic viscosity of pure gases using the

Module Contents

class flowtube.viscosity_density.basic_attrs[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
P: float[source]
T: float[source]
flowtube.viscosity_density.a[source]
flowtube.viscosity_density.b[source]
flowtube.viscosity_density.T_c[source]
flowtube.viscosity_density.P_c[source]
flowtube.viscosity_density.mu[source]
flowtube.viscosity_density.real_density(obj: basic_attrs, gas: str) float[source]

Calculates the real density of a gas using van der Waal’s equation of state.

Parameters:
  • obj (basic_attrs) – Object with basic attributes (P in Pa, T in K).

  • gas (str) – Molecular formula of gas (supported: Ar, He, N2, O2).

Returns:

Real density of gas in kg m-3.

Return type:

float

flowtube.viscosity_density.dynamic_viscosity(obj: basic_attrs, gas: str) float[source]

Estimate absolute/dynamic viscosity of pure gases using the corresponding states method from Reid et al., 1987.

Parameters:
  • obj (basic_attrs) – Object with basic attributes (P in Pa, T in K).

  • gas (str) – Molecular formula of gas (supported: Ar, He, N2, O2).

Returns:

Gas viscosity (kg m-1 s-1).

Return type:

float