| name | midstream |
| description | Guide AI agents through pipeline transportation and storage operations. |
Skill: Midstream Pipeline
Guide AI agents through pipeline transportation and storage operations.
Purpose
Support pipeline engineers in ensuring safe and efficient hydrocarbon transportation and storage.
Roles
- Pipeline Engineer - Pipeline design, hydraulics, materials
- Operations Manager - Daily operations, scheduling, nominations
- Integrity Engineer - Inspection, corrosion management, repairs
Data Types
| Data | Source | Frequency |
|---|
| Flow rates | SCADA | Real-time (1-min) |
| Pressure | SCADA | Real-time (1-min) |
| Temperature | SCADA | Real-time |
| ILI (Inline Inspection) | Smart pig | 5-year cycle |
| Leak detection | CPM/DDS | Real-time (continuous) |
| Product quality | Lab | Batch/sample |
Workflow
Phase 1: Transport Scheduling
- Receive nominations (shipper requests)
- Check pipeline capacity
- Schedule batches/products
- Optimize pump/compressor runs
- Confirm deliveries
Phase 2: Real-Time Monitoring
- Monitor pressure/flow at key points
- Track batch locations
- Detect anomalies (leaks, theft)
- Adjust operations as needed
- Communicate with control center
Phase 3: Integrity Management
- Plan ILI (smart pigging)
- Analyze inspection data
- Identify defects (corrosion, cracks, dents)
- Prioritize repairs
- Verify repairs
Phase 4: Leak Detection
- Monitor CPM (Computational Pipeline Monitoring)
- Analyze mass balance
- Check pressure/flow deviations
- Investigate anomalies
- Emergency response if confirmed
Domain Tasks
These tasks are handled by this skill:
- Pipeline hydraulics calculation
- Leak detection analysis
- ILI data interpretation
- Integrity assessment
Software Tasks
These tasks invoke petropowers:oil-gas-delegation:
- SCADA monitoring dashboard
- Pipeline scheduling system
- ILI data management platform
- Leak detection alerting system
Example Workflows
Pipeline Hydraulics
import math
def pressure_drop_liquid(flow_bpd, diameter_in, length_ft, viscosity_cp, density_api):
"""Calculate pressure drop for liquid pipeline (simplified)"""
q_bpm = flow_bpd / 1440
d_ft = diameter_in / 12
area_sqft = math.pi * d_ft**2 / 4
velocity = q_bpm / 7.48 / area_sqft
rho = 62.4 * (141.5 / (density_api + 131.5))
re = rho * velocity * d_ft / (viscosity_cp * 0.000672)
f = 0.079 / re**0.25 if re > 4000 else 64 / re
delta_p = 2 * f * (length_ft / d_ft) * rho * velocity**2 / (32.2 * 144)
return delta_p
d_psi = pressure_drop_liquid(
flow_bpd=50000,
diameter_in=12,
length_ft=100 * 5280,
viscosity_cp=5,
density_api=35
)
print(f"Pressure drop: {d_psi:.0f} psi")
Leak Detection (Mass Balance)
def detect_leak(flow_in, flow_out, pressure_in, pressure_out,
linepack_initial, linepack_current, tolerance=0.01):
"""
Simple mass balance leak detection
Returns: (is_leak, discrepancy)
"""
linepack_change = linepack_current - linepack_initial
discrepancy = flow_in - flow_out - linepack_change
threshold = flow_in * tolerance
is_leak = abs(discrepancy) > threshold
return is_leak, discrepancy
flow_in = 50000
flow_out = 49500
linepack_initial = 10000
linepack_current = 10050
is_leak, discrepancy = detect_leak(flow_in, flow_out, 0, 0,
linepack_initial, linepack_current)
if is_leak:
print(f"LEAK DETECTED: {discrepancy:.0f} bpd discrepancy")
else:
print(f"Normal operation: {discrepancy:.0f} bpd discrepancy")
ILI Defect Assessment
def assess_corrosion_defect(depth_percent, length_in, diameter_in, smys_psi, maop_psi):
"""
Assess corrosion defect using ASME B31G (simplified)
Returns: safe operating pressure
"""
d = depth_percent / 100
if d > 0.80:
return 0
L = length_in / math.sqrt(diameter_in)
a = 0.893 * L / math.sqrt(diameter_in)
if L <= math.sqrt(diameter_in):
safe_pressure = maop_psi * (1 - 0.66 * d)
else:
safe_pressure = maop_psi * (1 - 0.66 * d) / (1 + 0.66 * d**2)
return safe_pressure
safe_p = assess_corrosion_defect(
depth_percent=30,
length_in=6,
diameter_in=12,
smys_psi=35000,
maop_psi=1440
)
print(f"Safe operating pressure: {safe_p:.0f} psi")
print(f"MAOP: 1440 psi")
print(f"Status: { safe_p >= }")
Batch Tracking
import pandas as pd
from datetime import datetime, timedelta
class BatchTracker:
def __init__(self, pipeline_length_km, avg_velocity_mps):
self.pipeline_length = pipeline_length_km
self.avg_velocity = avg_velocity_mps
self.batches = []
def inject_batch(self, batch_id, product, volume_bbl, timestamp):
self.batches.append({
'batch_id': batch_id,
'product': product,
'volume': volume_bbl,
'inject_time': timestamp,
'position_km': 0,
})
def update_positions(self, current_time):
time_hours = [(current_time - b['inject_time']).total_seconds() / 3600
for b in self.batches]
for i, batch in enumerate(self.batches):
position = self.avg_velocity * 3.6 * time_hours[i] / 1000
batch['position_km'] = min(position, self.pipeline_length)
def ():
[b b .batches b[] >= .pipeline_length]
tracker = BatchTracker(pipeline_length_km=, avg_velocity_mps=)
inject_time = datetime(, , , , )
tracker.inject_batch(, , , inject_time)
tracker.inject_batch(, , , inject_time + timedelta(hours=))
tracker.update_positions(inject_time + timedelta(hours=))
batch tracker.batches:
()
Performance Indicators
| KPI | Units | Target |
|---|
| Availability | % | >99% |
| Leak incidents | per 1000 km-yr | <0.5 |
| ILI compliance | % | 100% |
| On-time delivery | % | >98% |
| Energy efficiency | kWh/bbl | Minimize |
Safety Considerations
Pipeline safety critical areas:
- High consequence areas (populated, environmentally sensitive)
- Leak detection coverage must be continuous
- Emergency shutdown systems tested regularly
- Public awareness programs maintained
- One-call system for excavation permits
Quality Checklist
References
- ASME B31.4 (Liquid Pipelines)
- ASME B31.8 (Gas Pipelines)
- API 1160 (Pipeline Integrity Management)
- PHMSA regulations (US DOT)