Crude Oil Tank Level & Custody Transfer Metering — Control Design
Shared by TSIMEREZIVO Team · 4 Oct 2026 · 39 views
# Oil & Gas Template: Crude Oil Tank Level & Custody Transfer Metering
## 1. Overview
**Purpose:**
Automatically measure crude oil tank inventory and compute **net barrels** (accounting for temperature, API gravity, water content) for custody transfer (ownership handoff between operator and buyer). Tank level measurement must be precise within ±0.1% to avoid billing disputes. Challenges: temperature affects density (1% per 10°C for crude); free water content varies; tank shape corrections apply.
**Industry Standards:**
- API 3 (Tank Gauging — Manual procedures)
- API 4 (Automatic Tank Gauging Systems)
- API 6 (Tank Proving methods — recalibration with meter standards)
- ASTM D1298 (Density of crude by hydrometer)
- IEEE 637 (Slave Pressure Transducers in Tanks)
- ISO 4266 (Tank Level Measurement — radar & float systems)
**Critical Constraints:**
- **Accuracy:** ±0.1% volume (±50 bbl for 50,000 bbl tank) required for billing
- **Temperature correction:** Crude density = ρ₀ × [1 − α(T − T₀)]; α ≈ 0.0006/°C
- **API gravity:** defines density; lighter crude (high API) = more valuable but less dense
- **Free water content:** measured weekly (Karl Fischer titration); affects net barrels sold
- **Tank shape:** not cylindrical in real tanks (settlement, dents, straps); requires multi-point gauging
- **Measurement lag:** radar level takes 2–5 sec to stabilize; temperature probe responds slowly (30 sec for RTD)
- **Custody transfer loss:** evaporation, pump slippage tolerated ±0.5% historically; modern targets <0.2%
**Relevant Physics:**
- **Density correction:** $\rho_{corrected} = \rho_{measured} × [1 − \alpha (T − 15°C)]$ (standard is 15°C/60°F)
- **API gravity:** $API = \frac{141.5}{\rho_{60F}} - 131.5$ (inverse relation to specific gravity)
- **Net barrels:** $V_{net} = V_{gross} × [1 − (W_c / 100)] × [\rho_{crude} / \rho_{ref}]$ (correcting for water, density, reference)
- **Vapor pressure loss:** depends on T and API; at 40°C, light crude (API 40) loses ~0.3% per day
---
## 2. Control Philosophy
**Challenge:**
Custody transfer pricing = flow × API spot price × net barrel count. A 0.1% error on 100,000 bbl = $500–1000 loss at $50/bbl. Must:
- Measure level with gauge-level radar or floats (±0.01 m typical precision ~0.05%)
- Correct level to volume (shape table interpolation)
- Apply temperature density correction (real-time RTD reading)
- Account for free water (lab update weekly or continuous water-cut probe)
- Track pump efficiency losses or calibration offsets
- Generate audit log for regulatory compliance
**Solution: Multi-Input Volume Corrector with Trending**
```
STEP 1: Raw Level Measurement
Input: Radar/float gauge (meters or inches)
Output: Level_raw
STEP 2: Temperature Density Correction
Inputs: Level_raw, RTD temperature, calibration density at 15°C
Output: Density_corrected = Density_ref × [1 − 0.0006 × (T − 15)]
STEP 3: Gross Volume Calculation
Input: Level_raw + tank strapping table (volume per inch/cm)
Output: Volume_gross (barrels or m³)
STEP 4: Free Water Correction
Input: Free water content (% from lab or online probe)
Output: Volume_net = Volume_gross × (1 − free_water_pct / 100)
STEP 5: Net Barrel Computation (for custody)
Inputs: Volume_net, Density_corrected, API gravity reference
Output: Net_Barrels = Volume_net × (Density_corrected / Density_60F_ref)
Note: Each degree above 60°F reduces barrels; buyer gets less if hotter
STEP 6: Loss Tracking
Previous_Inventory − Current_Inventory + Inputs − Outputs = Gain/Loss
Flag if loss >0.5% (possible theft, system error)
```
---
## 3. Control Logic (Condensed)
```pascal
{ === CRUDE OIL TANK LEVEL & CUSTODY TRANSFER METERING === }
PROCEDURE Tank_Level_Custody_Metering
CONSTANTS
TANK_CAPACITY_BBL = 50000
TANK_SHAPE_TABLE_SIZE = 500 { interpolation points }
REFERENCE_TEMP_F = 60 { standard API reference temperature }
REFERENCE_DENSITY_GRAVITY = 35 { API gravity reference }
DENSITY_ALPHA = 0.0006 { per °F; adjust per crude grade }
MAX_ACCEPTABLE_LOSS_PCT = 0.5
MEASUREMENT_ACCURACY_PCT = 0.1
VARIABLES
level_radar_inches : REAL { primary measurement }
level_radar_prev : REAL
tank_temperature_f : REAL { RTD inside tank }
free_water_content_pct : REAL { lab test, updated weekly }
api_gravity : REAL { 22–40 typical for crude }
density_at_reference_lbpgal : REAL { standard table lookup }
density_corrected_lbpgal : REAL { adjusted for T }
volume_gross_bbl : REAL { before corrections }
volume_net_bbl : REAL { after water correction }
net_barrels_custody : REAL { final custody count }
inventory_previous_bbl : REAL { from yesterday }
inventory_current_bbl : REAL
inputs_bbl : REAL { pumped/piped in }
outputs_bbl : REAL { pumped/piped out }
unaccounted_loss_pct : REAL { reconciliation }
audit_record : ARRAY[*] OF {timestamp, level, temp, fw_pct, net_bbls, notes}
BEGIN
{ === MEASUREMENT ACQUISITION === }
level_radar_inches = Read_Tank_Level_Radar()
tank_temperature_f = Read_TANK_INTERNAL_TEMP() { RTD }
api_gravity = Get_API_Gravity_From_Lab() { updated weekly }
free_water_content_pct = Get_Free_Water_Content() { lab or online probe }
{ === TEMPERATURE DENSITY CORRECTION === }
{ Get density at reference (60°F) for current crude API }
density_at_reference_lbpgal = API_To_Density_Table(api_gravity)
{ Correct to current tank temperature }
temp_delta_f = tank_temperature_f − REFERENCE_TEMP_F
density_corrected_lbpgal = density_at_reference_lbpgal ×
(1 − DENSITY_ALPHA × temp_delta_f)
{ === VOLUME CALCULATION === }
{ Interpolate tank shape table: level inches → volume barrels }
volume_gross_bbl = Interpolate_Tank_Strapping_Table(level_radar_inches)
{ Correct for free water (not saleable as crude) }
volume_net_bbl = volume_gross_bbl × (1 − free_water_content_pct / 100)
{ === CUSTODY NET BARREL COMPUTATION === }
{ Adjust net volume to standard density (60°F reference) }
net_barrels_custody = volume_net_bbl ×
(density_corrected_lbpgal / density_at_reference_lbpgal)
{ === INVENTORY RECONCILIATION === }
{ Today's material balance }
inputs_bbl = Get_Total_Inputs_Today() { dock flow meter total }
outputs_bbl = Get_Total_Outputs_Today() { sales + losses }
unaccounted_bbl = inventory_previous_bbl + inputs_bbl − outputs_bbl − inventory_current_bbl
unaccounted_loss_pct = (unaccounted_bbl / inventory_previous_bbl) × 100
{ === ALARM CHECKS === }
IF ABS(unaccounted_loss_pct) > MAX_ACCEPTABLE_LOSS_PCT THEN
Log_Alarm("EXCESSIVE_UNACCOUNTED_LOSS_" + STR(unaccounted_loss_pct) + "%")
Log_Alert("Possible inventory shrinkage, theft, or measurement error")
END IF
{ Temperature out of range (tank heating/cooling issues) }
IF tank_temperature_f < 32 THEN
Log_Warning("TANK_TEMP_BELOW_FREEZING_POSSIBLE_WAX_PRECIPITATION")
ELSIF tank_temperature_f > 150 THEN
Log_WARNING("TANK_TEMP_ELEVATED_CHECK_THERMAL_INSULATION")
END IF
{ === AUDIT LOG === }
APPEND audit_record {
timestamp: Get_Timestamp(),
level_inches: level_radar_inches,
temp_f: tank_temperature_f,
api_gravity: api_gravity,
free_water_pct: free_water_content_pct,
density_corrected: density_corrected_lbpgal,
volume_gross_bbl: volume_gross_bbl,
volume_net_bbl: volume_net_bbl,
net_barrels_custody: net_barrels_custody,
inputs_today_bbl: inputs_bbl,
outputs_today_bbl: outputs_bbl,
unaccounted_loss_pct: unaccounted_loss_pct,
notes: Notes_From_Technician()
}
{ === LOGGING === }
IF MOD(scan_count, 120) = 0 THEN { every 2 hours }
Log_Process_Data({
timestamp: Get_Timestamp(),
level_inches: level_radar_inches,
temperature_f: tank_temperature_f,
net_barrels: net_barrels_custody,
api_gravity: api_gravity,
free_water_pct: free_water_content_pct,
unaccounted_loss_pct: unaccounted_loss_pct
})
END IF
{ Daily custody report (at shift end) }
IF Hour(Get_Timestamp()) = 22 AND MOD(Day(Get_Timestamp()), 1) = 0 THEN { 10 PM daily }
Generate_Custody_Transfer_Report()
END IF
inventory_previous_bbl := inventory_current_bbl
END PROCEDURE
```
---
## 4. Tag List
```
TANK_LEVEL_RADAR_INCHES { primary measurement }
TANK_TEMPERATURE_F { for density correction }
TANK_DENSITY_CORRECTED_LBPGAL { adjusted for T }
API_GRAVITY { crude grade identifier }
FREE_WATER_CONTENT_PCT { non-saleable }
VOLUME_GROSS_BBL { before corrections }
VOLUME_NET_BBL { after water }
NET_BARRELS_CUSTODY { final billing count }
TEMPERATURE_CORRECTION_FACTOR { T-dependent density }
UNACCOUNTED_LOSS_PCT { reconciliation }
INPUTS_TODAY_BBL { dock meter total }
OUTPUTS_TODAY_BBL { sales + transfers }
AUDIT_LOG { compliance record }
```
---
## 5. Alarm & Trip Matrix
| **Condition** | **Severity** | **Action** |
|---|---|---|
| **Loss > 0.5%** | 🔴 CRIT | Flag for investigation; possible theft |
| **Temp < 32°F** | ⚠ WARN | Wax precipitation risk; heat tank |
| **Radar stuck** | ⚠ WARN | No level change >2 hours; manual gauging |
| **API/FW outdated** | 🟡 WARN | Lab test >7 days old; schedule retest |
---
## 6. HMI Layout (Custody Register)
```
╔════════════════════════════════════════════════════════════════════╗
║ CRUDE OIL TANK CUSTODY TRANSFER — Tank 101 ║
╚════════════════════════════════════════════════════════════════════╝
CURRENT INVENTORY SNAPSHOT (2026-04-13 22:00)
┌─────────────────────────────────────────────────────────────────┐
│ LEVEL MEASUREMENT & CORRECTIONS │
│ │
│ Radar Level: 247.32 inches ✓ │
│ Tank Temperature: 68°F (4°F above reference) │
│ Density @ 60°F: 50.8 lb/gal (API 32) │
│ Density Corrected: 50.6 lb/gal (temperature adjusted) │
│ Free Water Content: 1.2% (lab test 2026-04-13) │
│ │
│ Gross Volume: 49,875 bbl (shape table) │
│ Water Loss Deduction: 598 bbl (1.2% of gross) │
│ Net Volume: 49,277 bbl │
│ Custody Reference: 49,142 NET BARRELS @ 60°F/35°API │
│ (density correction: −135 bbl) │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ DAILY MATERIAL BALANCE (2026-04-13) │
│ │
│ Opening Inventory (00:00): 49,500 bbl / 49,367 NET │
│ Today's Inputs: +3,850 bbl / +3,802 NET │
│ Today's Outputs (dock sales): −4,200 bbl / −4,027 NET │
│ Closing Inventory (22:00): 49,150 bbl / 49,142 NET │
│ │
│ Material Balance Check: │
│ Opening + In − Out − Closing = Unaccounted │
│ 49,367 + 3,802 − 4,027 − 49,142 = 0 bbl ✓ 0.00% Loss │
│ │
│ Status: EXCELLENT RECONCILIATION ✓ │
│ (typical acceptable range: ±0.5%) │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ CUSTODY TRANSFER CERTIFICATION │
│ │
│ Crude Grade: Arabian Light (API 32) │
│ Custody Net Barrels: 49,142 bbl (per calculation above) │
│ Density @ 60°F: 50.8 lb/gal │
│ Water Content: 1.2% (Karl Fischer — 2026-04-13) │
│ Measurement Accuracy: ±0.1% (95% confidence) │
│ Last Tank Calibration: 2025-10-15 (6 months ago) │
│ │
│ Certification: │
│ [ ] Ready for Custody Transfer [✓] Approved for Sale │
│ [ ] Hold — Reconciliation issue [ ] Hold — Lab pending │
│ │
│ Auditor: Automated System Date: 2026-04-13 22:18 │
└─────────────────────────────────────────────────────────────────┘
HISTORICAL TREND (Last 30 days):
Tank Level: steady 245–249 inches (normal operations)
Temperature: fluctuated 55–72°F (seasonal, within range)
Daily Loss: never exceeded 0.3% (excellent integrity)
```
---
## 7. Configuration
**JSON (tank_custody_config.json)**
```json
{
"tank": {
"id": "Tank-101",
"capacity_bbl": 50000,
"api_gravity_reference": 32,
"density_60f_reference_lbgal": 50.8,
"density_alpha_per_f": 0.00004,
"strapping_table_file": "tank_101_strapping.csv"
},
"measurement": {
"level_type": "radar",
"accuracy_percent": 0.1,
"update_interval_sec": 30,
"temperature_sensor_type": "RTD_Pt100"
},
"corrections": {
"reference_temperature_f": 60,
"reference_api_gravity": 35,
"free_water_source": "lab_weekly|online_probe"
},
"reconciliation": {
"max_acceptable_loss_percent": 0.5,
"min_accumulation_hours": 1
},
"audit": {
"report_generation_time": "22:00",
"custody_transfer_daily": true,
"regulatory_compliance": "API_4_ATG"
}
}
```
---
**Document Version:** 1.0
**Last Updated:** 2026-04-13
**Status:** Ready for Production
**Approval:** Pipeline & Custody Engineering (pending)