A comprehensive Python library for petroleum engineering calculations
Project description
PetroCalc
PetroCalc is a comprehensive Python library for petroleum engineering calculations. It provides modular, well-documented implementations for drilling, reservoir engineering, production, fluid properties, well testing, petrophysics, geomechanics, enhanced oil recovery, facilities engineering, and economic analysis.
Features
- 17 modules covering core petroleum engineering disciplines.
- 800+ implemented formulas and utility functions.
- Clear API for common engineering tasks and advanced analyses.
- Examples and usage snippets for quick integration.
- Designed for scientific, engineering, and production workflows.
Core Modules (high-level)
petrocalc.drilling— Mud properties, hydraulics, wellbore engineering, cementing, pressure analysis.petrocalc.reservoir— Reservoir properties, material balance, recovery, advanced calculations.petrocalc.well_testing— Buildup and flow test analysis, dimensionless parameters, radius of investigation.petrocalc.production— IPR/PR curves, artificial lift support, fracturing, perforation, completion fluids.petrocalc.flow— Dimensionless numbers, pressure drop, Darcy-Weisbach, high-pressure gas flow.petrocalc.gas_reservoir— Gas material balance, drive mechanisms, CBM calculations, special deliverability.petrocalc.thermodynamics— Heat transfer, phase behavior, thermal properties.petrocalc.economics— NPV, IRR, cash flow, cost estimation, break-even analysis.petrocalc.fluids— Oil, gas, and water properties, formation volume factors, viscosities, density.petrocalc.rock_properties— Porosity, permeability averaging, relative permeability, resistivity models.petrocalc.pressure— Effective compressibility, hydrostatic gradients, hydrate dissociation.petrocalc.facilities— Separator design, vessel sizing, compressor energy, process utilities.
Installation
Install from PyPI:
pip install petrocalc
For development:
git clone https://github.com/your-username/petrocalc.git
cd petrocalc
pip install -e .
Quick start
import petrocalc
# Drilling: mud weight to pressure gradient
mud_grad = petrocalc.drilling.mud_weight_to_pressure_gradient(12.0, "ppg")
# Reservoir: API gravity conversion
api = petrocalc.reservoir.api_gravity_from_specific_gravity(0.85)
# Production: Vogel IPR
oil_rate = petrocalc.production.vogel_ipr(
reservoir_pressure=3000, bottomhole_pressure=2000, maximum_oil_rate=1000
)
# Fluids: oil compressibility
oil_comp = petrocalc.fluids.isothermal_oil_compressibility_vasquez_beggs(
solution_gor=500, gas_gravity=0.7, oil_gravity=35, temperature=180, pressure=2500
)
Usage examples
Reservoir engineering example
from petrocalc import reservoir
# API gravity conversions
api_gravity = reservoir.api_gravity_from_specific_gravity(0.85)
# Permeability averaging for heterogeneous reservoir
perms = [100, 50, 200]
heights = [10, 20, 15]
avg_perm = reservoir.average_permeability_parallel_layers(perms, heights)
Production engineering example
from petrocalc import production
# Gas well productivity
gas_pi = production.gas_well_productivity_index(
flow_rate=1000, reservoir_pressure=3000, bottomhole_pressure=2000
)
# Critical rate for horizontal well using Joshi correlation
critical_rate = production.horizontal_well_critical_rate_joshi(
oil_density=50, water_density=62.4, horizontal_permeability=100,
vertical_permeability=10, net_pay=100, horizontal_well_length=1000, distance_to_contact=50
)
Fluid properties example
from petrocalc import fluids
# Oil density using Standing's correlation
oil_density = fluids.oil_density_standing(
oil_specific_gravity=0.85, solution_gas_oil_ratio=500, gas_specific_gravity=0.7, temperature=180
)
# Water formation volume factor using McCain correlation
water_fvf = fluids.water_formation_volume_factor(temperature=180, pressure=2500, salinity=50000)
Advanced calculations and utilities
- Material balance and drive analysis functions.
- Well test diagnostics and dimensionless transforms.
- Facilities and process equipment sizing utilities.
- Economic evaluation helpers: NPV, IRR, discounted cash flows.
Recent updates
- Expanded formula coverage across modules.
- New critical rate correlations and viscosity correlations.
- Enhanced wellbore radius methods and material balance tools.
- Additional examples and improved documentation.
Contributing
- Contributions, bug reports, and feature requests are welcome via the repository.
- Follow repository contribution guidelines and tests for pull requests.
License
- See LICENSE file for terms.
Contact
- For questions or commercial support, open an issue or contact the repository maintainers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file petrocalc-1.2.1.tar.gz.
File metadata
- Download URL: petrocalc-1.2.1.tar.gz
- Upload date:
- Size: 107.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.19 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f0318b914bf7b29adf89bd43b23344c4106e37c94fe51ba009bfd1c641f8576
|
|
| MD5 |
aa1d23cbb497db79f2357d111bd8d2d8
|
|
| BLAKE2b-256 |
18710cb78db38bbe247d3c79103bbf0e1bcbb149f0e579a69c50cb8981e8d288
|
File details
Details for the file petrocalc-1.2.1-py3-none-any.whl.
File metadata
- Download URL: petrocalc-1.2.1-py3-none-any.whl
- Upload date:
- Size: 115.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.19 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d623368234fc2cd2f89f98da71a6e0becf2acac80f5a27a173bf2ec1764ee7b
|
|
| MD5 |
e6562bb3f5b8223d67bb0a8e366103aa
|
|
| BLAKE2b-256 |
f9f22af4d981896eb2dc1dd82c55466501d130ef83342aa285e46f4b64330f77
|