Skip to content

rodlift.flow

rodlift.flow

Multiphase gas-liquid flow in pipes.

:class:FlowState describes the local flow conditions; each correlation turns it into a :class:GradientResult (friction, elevation and acceleration components of the pressure loss per unit length, plus liquid holdup and flow regime).

Examples:

>>> from rodlift.flow import FlowState, pressure_gradient
>>> state = FlowState(vsl=1.0, vsg=2.0, rho_l=850.0, rho_g=60.0, mu_l=2e-3,
...                   mu_g=1.5e-5, sigma=0.025, diameter=0.0762, pressure=8e6)
>>> g = pressure_gradient(state, method="beggs_brill")
>>> round(g.total)  # Pa/m
4622

FlowRegime

Bases: IntEnum

Flow regime reported by a correlation.

UNKNOWN class-attribute instance-attribute

UNKNOWN = 0

The correlation does not identify a regime.

LIQUID class-attribute instance-attribute

LIQUID = 1

Single-phase liquid.

BUBBLE class-attribute instance-attribute

BUBBLE = 2

Bubble or distributed flow.

SLUG class-attribute instance-attribute

SLUG = 3

Slug or intermittent flow.

TRANSITION class-attribute instance-attribute

TRANSITION = 4

Transition between slug and mist/annular.

ANNULAR class-attribute instance-attribute

ANNULAR = 5

Mist, segregated or annular flow.

STRATIFIED class-attribute instance-attribute

STRATIFIED = 6

Stratified flow.

GAS class-attribute instance-attribute

GAS = 7

Single-phase gas.

DISPERSED class-attribute instance-attribute

DISPERSED = 8

Dispersed bubble flow.

CHURN class-attribute instance-attribute

CHURN = 9

Churn flow.

FlowState dataclass

FlowState(
    vsl: float,
    vsg: float,
    rho_l: float,
    rho_g: float,
    mu_l: float,
    mu_g: float,
    sigma: float,
    diameter: float,
    roughness: float = 0.0,
    inclination: float = math.pi / 2,
    pressure: float = 101325.0,
    temperature: float = math.nan,
    vso: float | None = None,
    vsw: float | None = None,
    gas_sg: float = math.nan,
    z: float = math.nan,
    gas_liquid_ratio: float = math.nan,
    liquid_sg_standard: float = math.nan,
    upstream: FlowState | None = None,
    downstream: FlowState | None = None,
    segment_length: float = math.nan,
)

Gas-liquid flow conditions at one point (or segment mid-point) of a pipe. SI units.

Attributes:

Name Type Description
vsl, vsg

Superficial liquid and gas velocities, m/s.

rho_l, rho_g

In-situ liquid and gas densities, kg/m³.

mu_l, mu_g

Liquid and gas viscosities, Pa·s.

sigma float

Gas-liquid surface tension, N/m.

diameter float

Pipe inside diameter, m.

roughness float

Absolute pipe roughness, m.

inclination float

Angle from horizontal in the flow direction, rad (+π/2 = vertical upward flow, −π/2 = vertical downward flow).

pressure float

Absolute pressure, Pa.

temperature float

Temperature, K (needed only by a few correlations).

vso, vsw

Superficial oil and water velocities, m/s. Default: all liquid is oil.

gas_sg float

Free-gas specific gravity (air = 1), for correlations that use the gas law.

z float

Gas compressibility factor, for correlations that use the gas law.

gas_liquid_ratio float

Producing gas-liquid ratio at standard conditions, m³/m³ (correlations based on the total mass per stock-tank barrel).

liquid_sg_standard float

Specific gravity of the stock-tank liquid (oil/water mix, water = 1), for the same correlations.

upstream, downstream

States at the two ends of the segment, used by correlations that compute the acceleration term from the change in kinetic energy across a segment.

segment_length float

Length of that segment, m.

area property

area: float

Pipe cross-sectional area, m².

vm property

vm: float

Mixture velocity, m/s.

no_slip_holdup property

no_slip_holdup: float

No-slip liquid holdup (input liquid fraction) λ_L.

rho_ns property

rho_ns: float

No-slip mixture density, kg/m³.

mu_ns property

mu_ns: float

No-slip mixture viscosity, Pa·s.

relative_roughness property

relative_roughness: float

Relative roughness ε/D.

mass_flow_liquid property

mass_flow_liquid: float

In-situ liquid mass flow rate, kg/s.

mass_flow_gas property

mass_flow_gas: float

In-situ gas mass flow rate, kg/s.

GradientResult dataclass

GradientResult(
    friction: float,
    elevation: float,
    acceleration: float,
    holdup: float,
    regime: FlowRegime = FlowRegime.UNKNOWN,
)

Pressure gradient and holdup returned by a flow correlation.

Attributes:

Name Type Description
friction, elevation, acceleration

Components of the pressure loss per unit length in the flow direction, Pa/m.

holdup float

In-situ (slip) liquid volume fraction.

regime FlowRegime

Flow regime identified by the correlation.

total property

total: float

Total pressure loss per unit length, Pa/m.

available_correlations

available_correlations() -> list[str]

Names of the correlations implemented in this version.

get_correlation

get_correlation(name: str) -> CorrelationFunction

Return the correlation function registered under name.

Raises:

Type Description
ValueError

If the name is unknown.

NotImplementedError

If the correlation is registered but not yet available in this version.

single_phase_gradient

single_phase_gradient(state: FlowState) -> GradientResult

Pressure gradient when only one phase flows.

The phase is liquid when the no-slip holdup is at least 0.9, gas otherwise. Friction uses :func:rodlift.flow.friction.moody_friction_factor. For gas, the acceleration term is included through the kinetic-energy group E_k = ρ v² / (g_c p).

pressure_gradient

pressure_gradient(
    state: FlowState, method: str = "beggs_brill"
) -> GradientResult

Pressure gradient with the named correlation.

When the no-slip liquid holdup is at most 0.001 or at least 0.999, the flow is treated as single phase (:func:single_phase_gradient) regardless of method.

Parameters:

Name Type Description Default
state FlowState

Local flow conditions.

required
method str

Correlation name; see :func:available_correlations.

'beggs_brill'