Unit Conversions and Special Functions

Overview

Petroleum engineering calculations frequently require:

  • Unit conversions — between field units (psi, bbl, ft) and SI units (Pa, m³, m)
  • Gravity transformations — between API gravity and specific gravity
  • Special mathematical functions — particularly the exponential integral for pressure transient analysis

These utility functions provide the foundation for accurate engineering calculations.


Unit Conversion System

The UnitConverter function provides general-purpose conversion between compatible units.

Supported Unit Categories

Category Example Units
Pressure psi, psia, psig, bar, kPa, MPa, atm
Length ft, m, in, cm, mm
Volume bbl, stb, scf, m³, L, gal
Flow Rate stb/d, bbl/d, m³/d, scf/d, Mscf/d
Temperature degF, degC, degR, K
Viscosity cP, mPa·s, Pa·s
Permeability md, D, m²
Compressibility 1/psi, 1/bar, 1/kPa

Usage Pattern

The function takes a value in the source unit and converts to the target unit:

Result = UnitConverter(Value, "SourceUnit", "TargetUnit")

Example: Convert 2,500 psi to bar:

UnitConverter(2500, "psi", "bar") → 172.4 bar

Function

Function Description
UnitConverter Convert value between any compatible units

Gravity Transformations

Crude oil density is commonly expressed as either:

  • Specific Gravity (SG) — density relative to water at 60°F
  • API Gravity — American Petroleum Institute scale, inversely related to density

Relationship Between API and Specific Gravity

The API gravity scale was designed so that:

  • Water has API gravity of 10°
  • Lighter oils have higher API values
  • Heavier oils have lower API values
γAPI=141.5γo131.5\gamma_{API} = \frac{141.5}{\gamma_o} - 131.5γo=141.5γAPI+131.5\gamma_o = \frac{141.5}{\gamma_{API} + 131.5}

Where:

  • γAPI\gamma_{API} = API gravity, °API
  • γo\gamma_o = oil specific gravity (water = 1.0)

Classification by API Gravity

Classification API Gravity Specific Gravity
Light crude > 31.1° < 0.87
Medium crude 22.3° – 31.1° 0.87 – 0.92
Heavy crude 10° – 22.3° 0.92 – 1.00
Extra-heavy < 10° > 1.00

Functions

Function Conversion Formula
SG2API SG → API γAPI=141.5γo131.5\gamma_{API} = \frac{141.5}{\gamma_o} - 131.5
API2SG API → SG γo=141.5γAPI+131.5\gamma_o = \frac{141.5}{\gamma_{API} + 131.5}

Examples

Input Function Output
γo=0.85\gamma_o = 0.85 SG2API 34.97° API
γAPI=35°\gamma_{API} = 35° API2SG 0.850
γo=1.00\gamma_o = 1.00 (water) SG2API 10° API
γAPI=10°\gamma_{API} = 10° API2SG 1.00

Exponential Integral Function

The exponential integral Ei(x)\text{Ei}(x) is a fundamental special function in pressure transient analysis.

Definition

Ei(x)=xettdt(x>0)\text{Ei}(x) = \int_{-\infty}^{x} \frac{e^t}{t} \, dt \quad (x > 0)

For practical computation with negative arguments (as used in well testing):

Ei(x)=xettdt(x>0)-\text{Ei}(-x) = \int_{x}^{\infty} \frac{e^{-t}}{t} \, dt \quad (x > 0)

Role in Well Testing

The line source solution for pressure drawdown in an infinite-acting reservoir is:

pD(rD,tD)=12Ei(rD24tD)p_D(r_D, t_D) = -\frac{1}{2} \text{Ei}\left( -\frac{r_D^2}{4 t_D} \right)

At the wellbore (rD=1r_D = 1):

pD(tD)=12Ei(14tD)p_D(t_D) = -\frac{1}{2} \text{Ei}\left( -\frac{1}{4 t_D} \right)

Logarithmic Approximation

For small arguments (large tDt_D, i.e., late-time behavior):

Ei(x)ln(x)γfor x<0.01-\text{Ei}(-x) \approx -\ln(x) - \gamma \quad \text{for } x < 0.01

Where γ=0.5772...\gamma = 0.5772... is the Euler-Mascheroni constant.

This gives the familiar semi-log approximation:

pD12[ln(tD)+0.80907]p_D \approx \frac{1}{2} \left[ \ln(t_D) + 0.80907 \right]

Function

Function Description
ExpIntegralEi Evaluate Ei(x)\text{Ei}(x) for any real xx

Numerical Implementation

The function uses different algorithms depending on the argument magnitude:

Argument Range Method
x<6|x| < 6 Taylor series expansion
6x<126 \le |x| < 12 Chebyshev approximation
x12|x| \ge 12 Asymptotic expansion


References

  1. American Petroleum Institute. "API Gravity." API Manual of Petroleum Measurement Standards, Chapter 11.1.

  2. Abramowitz, M. and Stegun, I.A. (1964). Handbook of Mathematical Functions. National Bureau of Standards. Chapter 5: Exponential Integral and Related Functions.

  3. Cody, W.J. and Thacher, H.C. (1968). "Rational Chebyshev Approximations for the Exponential Integral E₁(x)." Mathematics of Computation, 22(103), pp. 641-649.

  4. Lee, J., Rollins, J.B., and Spivey, J.P. (2003). Pressure Transient Testing. SPE Textbook Series Vol. 9. Chapter 2.

Related Functions:PO.UnitConverter

Related Blueprints

ESP Gas Handling Analysis

Analyze gas handling requirements for ESP systems. Calculate void fraction and evaluate need for gas separators.

CO2 Corrosion Analysis

CO2 corrosion analysis using the de Waard-Milliams correlation. Calculates corrosion rate, severity classification, inhibited rate, and required corrosion allowance for carbon steel pipelines.

Unit Conversion Examples

Demonstrate unit conversion for common petroleum engineering quantities. Includes pressure, temperature, volume, and flow rate conversions.

An unhandled error has occurred. Reload X