| name | refining |
| description | Guide AI agents through refinery operations and process optimization. |
Skill: Refining Pipeline
Guide AI agents through refinery operations and process optimization.
Purpose
Support process and chemical engineers in refinery operations, optimization, and product quality control.
Roles
- Process Engineer - Unit operations, optimization, troubleshooting
- Chemical Engineer - Reaction engineering, catalysts, chemistry
- Plant Operator - Daily operations, monitoring, adjustments
- Lab Technician - Product quality testing, sampling
Data Types
| Data | Source | Frequency |
|---|
| Crude assay | Lab/Supplier | Batch |
| Temperature/pressure | DCS | Real-time (1-sec) |
| Flow rates | DCS | Real-time (1-sec) |
| Product qualities | Lab | 4-8 hours |
| Catalyst activity | Lab | Weekly |
| Energy consumption | Meters | Hourly |
Workflow
Phase 1: Crude Selection & Blending
- Receive crude assays (composition, properties)
- Optimize crude blend for:
- Target product slate
- Unit constraints
- Margin maximization
- Plan crude deliveries
- Monitor crude tank quality
Phase 2: Process Operations
- Monitor unit operations (DCS)
- Optimize cut points (distillation)
- Adjust operating conditions
- Monitor yields and quality
- Troubleshoot upsets
Phase 3: Product Quality
- Sample products (gasoline, diesel, jet, fuel oil)
- Test in lab (ASTM methods)
- Blend components to meet specs
- Certify products for release
- Track product inventory
Phase 4: Energy & Yield Optimization
- Monitor energy consumption
- Optimize heat integration
- Maximize yield of high-value products
- Minimize fuel gas, steam consumption
- Reduce CO2 emissions
Domain Tasks
These tasks are handled by this skill:
- Crude oil assay analysis
- Distillation optimization
- Product blending calculations
- Energy balance analysis
- Yield accounting
Software Tasks
These tasks invoke petropowers:oil-gas-delegation:
- Process monitoring dashboard
- Laboratory information system (LIMS)
- Blending optimization tool
- Production accounting system
Example Workflows
Crude Oil Assay
def simplify_crude_assay(api, sulfur_percent, tbp_points):
"""
Simplified crude assay analysis
TBP (True Boiling Point) points: [(temp_F, vol_percent), ...]
"""
print(f"API Gravity: {api:.1f}°")
print(f"Classification: {'Light' if api > 35 else 'Medium' if api > 25 else 'Heavy'}")
print(f"Sulfur: {sulfur_percent:.2f}%")
print(f"Type: {'Sweet' if sulfur_percent < 0.5 else 'Sour'}")
tbp_df = pd.DataFrame(tbp_points, columns=['temp_f', 'vol_pct'])
naphtha_yield = tbp_df[tbp_df['temp_f'] < 400]['vol_pct'].max()
diesel_yield = tbp_df[(tbp_df['temp_f'] >= 400) & (tbp_df['temp_f'] < 650)]['vol_pct'].max() - naphtha_yield
gasoil_yield = tbp_df[(tbp_df['temp_f'] >= 650) & (tbp_df['temp_f'] < )][].() - naphtha_yield - diesel_yield
()
()
()
()
()
api =
sulfur =
tbp_points = [
(, ),
(, ),
(, ),
(, ),
(, ),
(, ),
]
simplify_crude_assay(api, sulfur, tbp_points)
Distillation Cut Point Optimization
def optimize_cut_points(demand_prices, unit_capacity, crude_rate):
"""
Optimize cut points based on product prices
Simplified linear programming approach
"""
gasoline_price = demand_prices['gasoline']
diesel_price = demand_prices['diesel']
fueloil_price = demand_prices['fuel_oil']
if gasoline_price > diesel_price * 1.1:
naphtha_cut_temp = 380
diesel_cut_temp = 650
elif diesel_price > gasoline_price * 1.1:
naphtha_cut_temp = 400
diesel_cut_temp = 680
else:
naphtha_cut_temp = 390
diesel_cut_temp = 665
return {
'naphtha_end_temp_f': naphtha_cut_temp,
'diesel_end_temp_f': diesel_cut_temp,
}
prices = {
'gasoline': 85,
'diesel': 95,
'fuel_oil': 60,
}
cuts = optimize_cut_points(prices, unit_capacity=, crude_rate=)
()
Product Blending
def blend_gasoline(components, target_ron, target_rvp):
"""
Simple gasoline blending for RON (Octane) and RVP (Vapor Pressure)
components: [{'name': str, 'vol': bbl, 'ron': float, 'rvp': float}, ...]
"""
total_vol = sum(c['vol'] for c in components)
blended_ron = sum(c['vol'] * c['ron'] for c in components) / total_vol
blended_rvp = sum(c['vol'] * c['rvp'] for c in components) / total_vol
meets_ron = blended_ron >= target_ron
meets_rvp = blended_rvp <= target_rvp
return {
'ron': blended_ron,
'rvp': blended_rvp,
'volume': total_vol,
'meets_specs': meets_ron and meets_rvp,
'ron_ok': meets_ron,
'rvp_ok': meets_rvp,
}
components = [
{'name': 'FCC Gasoline', 'vol': 20000, 'ron': 92, 'rvp': 8.0},
{'name': 'Reformate', 'vol': 15000, 'ron': 100, 'rvp': 4.5},
{'name': , : , : , : },
{: , : , : , : },
]
result = blend_gasoline(components, target_ron=, target_rvp=)
()
()
Energy Balance
def calculate_refinery_efficiency(energy_in_mmbtu, crude_in_bbl, product_out_bbl):
"""
Calculate refinery energy efficiency
"""
energy_per_bbl = energy_in_mmbtu / crude_in_bbl
if energy_per_bbl < 0.3:
rating = "Excellent"
elif energy_per_bbl < 0.4:
rating = "Good"
elif energy_per_bbl < 0.5:
rating = "Fair"
else:
rating = "Poor"
return {
'energy_mmbtu_per_bbl': energy_per_bbl,
'energy_mj_per_bbl': energy_per_bbl * 1055,
'rating': rating,
'total_energy_mmbtu': energy_in_mmbtu,
}
energy_result = calculate_refinery_efficiency(
energy_in_mmbtu=60000,
crude_in_bbl=150000,
product_out_bbl=145000
)
print(f"Energy intensity: {energy_result['energy_mmbtu_per_bbl']:.2f} MMBTU/bbl")
print(f"Rating: {energy_result['rating']}")
Yield Accounting
def simple_yield_accounting(crude_in, outputs):
"""
Simple mass balance for refinery yield
"""
total_out = sum(outputs.values())
loss = crude_in - total_out
print(f"Input: {crude_in:,} bbl")
print(f"\nOutputs:")
for product, volume in outputs.items():
yield_pct = volume / crude_in * 100
print(f" {product}: {volume:,} bbl ({yield_pct:.1f}%)")
print(f"\nLoss: {loss:,} bbl ({loss/crude_in*100:.2f}%)")
print(f"Recovery: {total_out/crude_in*100:.2f}%")
return {
'loss': loss,
'recovery': total_out / crude_in,
'yields': {k: v/crude_in for k, v in outputs.items()}
}
yield_result = simple_yield_accounting(
crude_in=100000,
outputs={
'gasoline': 45000,
'diesel': 30000,
'jet_fuel': 8000,
'fuel_oil': 12000,
'lpg': 3000,
}
)
Key Products
| Product | Key Specs | Typical Yield |
|---|
| Gasoline | RON, RVP, Sulfur | 40-50% |
| Diesel | Cetane, Sulfur, Flash | 25-35% |
| Jet Fuel | Flash, Freeze, Smoke | 5-10% |
| Fuel Oil | Viscosity, Sulfur | 5-15% |
| LPG | Composition | 2-5% |
Performance Indicators
| KPI | Units | Target |
|---|
| Utilization | % | >95% |
| Energy intensity | MMBTU/bbl | <0.4 |
| On-spec products | % | >99% |
| Yield (high-value) | % | Maximize |
| Safety (TRIR) | per 200k hrs | <0.5 |
Safety Considerations
Refinery hazards:
- Fire/explosion (hydrocarbons under pressure)
- Toxic releases (H2S, ammonia, HF)
- Runaway reactions (alkylation, hydrocracking)
- Loss of containment
Critical safety systems:
- Relief valves and flare systems
- Fire detection and suppression
- Gas detection (H2S, LEL)
- Emergency shutdown (ESD)
Quality Checklist
References
- Gary & Handwerk (2001), "Petroleum Refining"
- ASTM Standards for petroleum products
- API Recommended Practices
- NPRA publications