pvtlib.metering.differential_pressure_flowmeters

MIT License

Copyright (c) 2025 Christian Hågenvik

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

calculate_C_orifice_ReaderHarrisGallagher(D, ...)

Calculate the discharge coefficient (C) for an orifice plate using the Reader-Harris/Gallagher equation [10].

calculate_C_wetgas_venturi_ReaderHarrisGraham(...)

Calculate the discharge coefficient correction for wet-gas Venturi flow meters using the Reader-Harris/Graham correlation [12].

calculate_beta_DP_meter(D, d)

Calculate the diameter ratio (beta) for a traditional DP based meter, such as venturi and orifice plates.

calculate_beta_V_cone(D, dc)

Calculates V-cone beta according to ISO 5167-5:2022 [6].

calculate_expansibility_Stewart_V_cone(beta, ...)

Calculates the expansibility factor for a cone flow meter based on the geometry of the cone meter, measured differential pressures of the V-cone meter and the isentropic exponent of the fluid [5].

calculate_expansibility_orifice(P1, dP, ...)

Calculate the expansibility factor for an orifice meter according to ISO 5167-2:2022 [#pvtlib-metering-differential-pressure-flowmeters-calculate-expansibility-orifice-1]_[#pvtlib-metering-differential-pressure-flowmeters-calculate-expansibility-orifice-2]_.

calculate_expansibility_venturi(P1, dP, ...)

Calculate the expansibility factor for a Venturi meter [2].

calculate_flow_V_cone(D, beta, dP, rho1[, ...])

Calculate mass flowrate and volume flowrate of a V-cone meter.

calculate_flow_orifice(D, d, dP, rho1[, mu, ...])

Calculate the flow rate through an orifice plate according to ISO 5167-2:2022 [7].

calculate_flow_venturi(D, d, dP, rho1[, C, ...])

Calculate the flow rates (mass flow, volume flow, and velocity) through a Venturi meter.

calculate_flow_wetgas_venturi_ReaderHarrisGraham(D, ...)

Calculate flowrates for a standard venturi meter in wet-gas conditions using the Reader-Harris/Graham correlation [13], described in ISO/TR 11583:2012 [14].

pvtlib.metering.differential_pressure_flowmeters.calculate_flow_venturi(D, d, dP, rho1, C=None, epsilon=None, check_input=False)[source]

Calculate the flow rates (mass flow, volume flow, and velocity) through a Venturi meter. Calculations performed according to ISO 5167-4:2022 [1].

If discharge coefficient is not provided, the function uses the value of 0.984 given in ISO 5167-4:2022 for “as cast” Venturi tubes.

Parameters:
  • D (float) – Diameter of the pipe (must be greater than zero). [m]

  • d (float) – Diameter of the throat (must be greater than zero). [m]

  • dP (float) – Differential pressure (must be greater than zero). [mbar]

  • rho1 (float) – Density of the fluid (must be greater than zero). [kg/m3]

  • C (float, optional) – Discharge coefficient (default is 0.984). [-]

  • epsilon (float, optional) – Expansion factor (default is None). [-]

  • check_input (bool, optional) – If True, the function will raise an exception if any of the input parameters are invalid. The default value is False, and the reason is to prevent the function from running into an exception if the input parameters are invalid.

Returns:

results (dict) – Dictionary containing the following keys: - ‘MassFlow’: Mass flow rate [kg/h]. - ‘VolFlow’: Volume flow rate [m3/h]. - ‘Velocity’: Flow velocity [m/s]. - ‘C’: Discharge coefficient used. - ‘epsilon’: Expansion factor used. - ‘beta’: Diameter ratio (d/D).

Raises:

Exception – If any of the input parameters are invalid (negative or zero where not allowed).

References

pvtlib.metering.differential_pressure_flowmeters.calculate_expansibility_venturi(P1, dP, beta, kappa)[source]

Calculate the expansibility factor for a Venturi meter [2].

Parameters:
  • P1 (float) – Upstream pressure. [bara]

  • dP (float) – Differential pressure. [mbar]

  • beta (float) – Diameter ratio (d/D). [-]

  • kappa (float) – Isentropic exponent. [-]

Returns:

epsilon (float) – Expansibility factor. [-] Returns 1.0 for dP = 0, which is the limit of the formula as the pressure ratio tau approaches 1. Returns NaN for non-finite input, P1 <= 0, dP < 0, dP >= P1 (non-positive downstream pressure), beta outside (0, 1), kappa <= 0 or kappa = 1 (the formula is singular for kappa = 1).

References

pvtlib.metering.differential_pressure_flowmeters.calculate_beta_DP_meter(D, d)[source]

Calculate the diameter ratio (beta) for a traditional DP based meter, such as venturi and orifice plates. Calculation according to ISO 5167:2022 (part 1,2,4) [3].

Parameters:
  • D (float) – The diameter of the pipe at the upstream tapping(s). Must be greater than zero.

  • d (float) – The diameter of the throat.

Returns:

beta (float) – The beta ratio (d/D).

Raises:

Exception – If the diameter of the pipe (D) is less than or equal to zero.

Notes

This function cannot be used for cone meters, as the diameter ratio is defined differently (see calculate_beta_V_cone).

References

pvtlib.metering.differential_pressure_flowmeters.calculate_flow_V_cone(D, beta, dP, rho1, C=None, epsilon=None, check_input=False)[source]

Calculate mass flowrate and volume flowrate of a V-cone meter. Calculations performed according to NS-EN ISO 5167-5:2022 [4].

Parameters:
  • D (float) – The diameter of the pipe at the beta edge, D. [m] Assumes that the diameter of the pipe at the upstream tapping, DTAP, is equal to the diameter of the pipe at the beta edge, D. In easier terms, its the inlet diameter.

  • beta (float) – V-cone beta.

  • dP (float) – Differential pressure [mbar].

  • rho1 (float) – Density at the upstream tapping [kg/m3].

  • C (float, optional) – Discharge coefficient. If no value of C is provided, the function uses the value of 0.82 given in NS-EN ISO 5167-5:2022.

  • epsilon (float, optional) – expansibility factor (ε) is a coefficient used to take into account the compressibility of the fluid. If no expansibility is provided, the function will use 1.0.

  • check_input (bool, optional) – If True, the function will raise an exception if any of the input parameters are invalid. The default value is False, and the reason is to prevent the function from running into an exception if the input parameters are invalid.

Returns:

results (dict) – Dictionary containing the following keys: - ‘MassFlow’: Mass flow rate [kg/h]. - ‘VolFlow’: Volume flow rate [m3/h]. - ‘Velocity’: Flow velocity [m/s]. - ‘C’: Discharge coefficient used. - ‘epsilon’: Expansion factor used.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_expansibility_Stewart_V_cone(beta, P1, dP, k, check_input=False)[source]

Calculates the expansibility factor for a cone flow meter based on the geometry of the cone meter, measured differential pressures of the V-cone meter and the isentropic exponent of the fluid [5].

Parameters:
  • beta (float) – V-cone beta, [-]

  • P1 (float) – Static pressure of fluid upstream of cone meter at the cross-section of the pressure tap, [bara]

  • dP (float) – Differential pressure [mbar]

  • k (float) – Isentropic exponent of fluid, [-]

Returns:

expansibility (float) – Expansibility factor (1 for incompressible fluids, less than 1 for real fluids) [-]

Notes

This formula was determined for the range of P2/P1 >= 0.75; the only gas used to determine the formula is air.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_beta_V_cone(D, dc)[source]

Calculates V-cone beta according to ISO 5167-5:2022 [6].

beta edge: maximum circumference of the cone

Parameters:
  • D (float) – The diameter of the pipe at the beta edge, D. Assumes that the diameter of the pipe at the upstream tapping is equal to the diameter of the pipe at the beta edge, D. In easier terms, its the inlet inner diameter.

  • dc (float) – dc is the diameter of the cone in the plane of the beta edge [m]. In easier terms, its the outer diameter of the cone.

Returns:

beta (float) – V-cone beta.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_flow_orifice(D, d, dP, rho1, mu=None, C=None, epsilon=None, tapping='corner', check_input=False)[source]

Calculate the flow rate through an orifice plate according to ISO 5167-2:2022 [7].

Parameters:
  • D (float) – Pipe diameter (m).

  • d (float) – Orifice diameter (m).

  • dP (float) – Differential pressure across the orifice (mbar).

  • rho1 (float) – Fluid density upstream of the orifice (kg/m3).

  • mu (float, optional) – Dynamic viscosity of the fluid (Pa*s). Required if C is not provided.

  • C (float, optional) – Discharge coefficient. If not provided, it will be calculated iteratively.

  • epsilon (float, optional) – Expansibility factor. If not provided, 1.0 will be used (valid for incompressible fluids).

  • tapping (str, optional) – Tapping type for the orifice plate. Default is ‘corner’.

  • check_input (bool, optional) – If True, the function will raise exceptions for invalid input parameters. If False, it will return a dictionary with NaN values for invalid inputs.

Returns:

results (dict) – Dictionary containing the following keys: - ‘MassFlow’: Mass flow rate [kg/h]. - ‘VolFlow’: Volume flow rate [m3/h]. - ‘Velocity’: Flow velocity [m/s]. - ‘C’: Discharge coefficient used. - ‘epsilon’: Expansion factor used. - ‘Re’: Reynolds number.

Raises:

Exception – If check_input is True and any of the input parameters are invalid, or if the iterative calculation for the discharge coefficient does not converge.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_expansibility_orifice(P1, dP, beta, kappa)[source]

Calculate the expansibility factor for an orifice meter according to ISO 5167-2:2022 [#pvtlib-metering-differential-pressure-flowmeters-calculate-expansibility-orifice-1]_[#pvtlib-metering-differential-pressure-flowmeters-calculate-expansibility-orifice-2]_. The calculation is valid under the criterias given by the standard.

Parameters:
  • P1 (float) – Upstream pressure. [bara]

  • dP (float) – Differential pressure. [mbar]

  • beta (float) – Diameter ratio (d/D). [-]

  • kappa (float) – Isentropic exponent. [-]

Returns:

epsilon (float) – Expansibility factor. [-] Returns NaN for non-finite input, P1 <= 0, dP < 0, dP >= P1 (non-positive downstream pressure), beta outside (0, 1) or kappa <= 0.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_C_orifice_ReaderHarrisGallagher(D, beta, Re, tapping='corner', check_input=False)[source]

Calculate the discharge coefficient (C) for an orifice plate using the Reader-Harris/Gallagher equation [10]. Calculations performed according to ISO 5167-2:2022 [11].

Parameters:
  • D (float) – Pipe diameter in meters.

  • beta (float) – Diameter ratio (orifice diameter / pipe diameter).

  • Re (float) – Reynolds number.

  • tapping (str, optional) – Type of pressure tapping. Options are ‘corner’, ‘D’, ‘D/2’, or ‘flange’. Default is ‘corner’.

  • check_input (bool, optional) – If True, input values are checked for validity. Default is False.

Returns:

C (float) – Discharge coefficient (C). Returns NaN if inputs are invalid and check_input is False.

Raises:

Exception – If check_input is True and any of the inputs are invalid.

Notes

The function converts the pipe diameter to millimeters as required by the Reader-Harris/Gallagher equation. The equation includes an additional term for pipe diameters less than 71.12 mm as specified by ISO 5167-1:2022.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_C_wetgas_venturi_ReaderHarrisGraham(Fr_gas_th, X)[source]

Calculate the discharge coefficient correction for wet-gas Venturi flow meters using the Reader-Harris/Graham correlation [12].

Parameters:
  • Fr_gas_th (float) – Gas densiometric Froude number (Frg) [-]

  • X (float) – Lockhart-Martinelli parameter [-]

Returns:

C_wet (float) – Wet gas discharge coefficient [-]. NaN for non-finite or negative input.

References

pvtlib.metering.differential_pressure_flowmeters.calculate_flow_wetgas_venturi_ReaderHarrisGraham(D, d, P1, dP, rho_g, rho_l, GMF=None, GVF=None, H=1, epsilon=None, kappa=None, check_input=False)[source]

Calculate flowrates for a standard venturi meter in wet-gas conditions using the Reader-Harris/Graham correlation [13], described in ISO/TR 11583:2012 [14].

The function uses an iterative approach to solve for the corrected gas mass flow rate. It calculates initial flow rates, then iteratively updates the Lockhart-Martinelli parameter, Froude numbers, discharge coefficient, and over-read factor until convergence is achieved.

The function accepts either gas mass fraction (GMF) or gas volume fraction (GVF) as input. If both are provided, GMF is used. The function accepts either expansibility (epsilon) or isentropic exponent (kappa) as input. If both are provided, epsilon is used.

H is a dimensionless parameter which is a function of the surface tension of the liquid. H equals 1 for hydrocarbon liquids, 1.35 for water.

Valid for the following conditions: 0.4 ≤ β ≤ 0.75 0 < X ≤ 0.3 3 < Fr_gas,th 0.02 < rho_g/rho_l D ≥ 50 mm

Parameters:
  • D (float) – Pipe diameter [m]

  • d (float) – Throat diameter [m]

  • P1 (float) – Upstream pressure [bara]. Must be greater than zero.

  • dP (float) – Differential pressure [mbar]. Must be non-negative and smaller than P1 (after unit conversion). dP = 0 gives zero flow rates.

  • rho_g (float) – Gas density [kg/m3]. Must be greater than zero.

  • rho_l (float) – Liquid density [kg/m3]. Must be greater than rho_g.

  • GMF (float, optional) – Gas mass fraction (by mass, 0 < GMF <= 1). Either GMF or GVF must be provided.

  • GVF (float, optional) – Gas volume fraction (by volume, 0 < GVF <= 1). Either GMF or GVF must be provided.

  • H (float, optional) – Dimensionless fluid parameter, greater than zero (default 1, which is used for hydrocarbon liquids, 1.35 for water)

  • epsilon (float, optional) – Expansion factor, in the range (0, 1]. If not provided, calculated from kappa.

  • kappa (float, optional) – Isentropic exponent, greater than zero and not equal to 1 (required if epsilon is not provided)

  • check_input (bool, optional) – If True, raises exceptions for invalid inputs and non-convergence. If False, returns NaN results for invalid inputs and non-convergence.

Returns:

results (dict) – Dictionary containing: - ‘MassFlow_gas_initial’: Initial uncorrected gas mass flow [kg/h] - ‘MassFlow_gas_corrected’: Final corrected gas mass flow [kg/h] - ‘MassFlow_liq’: Final liquid mass flow [kg/h] - ‘MassFlow_tot’: Final total mass flow [kg/h] - ‘VolFlow_gas’: Final gas volume flow [m3/h] - ‘VolFlow_liq’: Final liquid volume flow [m3/h] - ‘VolFlow_tot’: Final total volume flow [m3/h] - ‘OverRead’: Final over-read factor (OR) [-] - ‘C_wet’: Final wet-gas discharge coefficient [-] - ‘LockhartMartinelli’: Final Lockhart-Martinelli parameter X [-] - ‘Fr_gas’: Final gas densiometric Froude number [-] - ‘Fr_gas_th’: Final throat gas densiometric Froude number [-] - ‘n’: Final n parameter [-] - ‘C_Ch’: Final Chisholm coefficient [-] - ‘epsilon’: Expansion factor used [-] - ‘iterations’: Number of iterations to convergence [-]

If inputs are invalid and check_input=False, all values will be NaN.

Raises:
  • ValueError – If check_input=True and any input is non-finite or outside the ranges given above.

  • RuntimeError – If check_input=True and the iteration does not converge.

Notes

The iteration process continues until the relative change in corrected gas mass flow is less than 1e-10 or until 100 iterations are reached. If convergence is not achieved and check_input=True, an exception is raised. If check_input=False, NaN results are returned.

The Lockhart-Martinelli parameter is calculated from the phase mass ratio (1 - GMF)/GMF and the densities. It is therefore also defined for dP = 0, where all flow rates are zero and the correlation outputs (C_wet, n, C_Ch, OverRead) are evaluated at a Froude number of zero.

References