A comprehensive Python library for interacting with openLCA desktop application through the IPC (Inter-Process Communication) protocol. Built for life cycle assessment (LCA) workflows based on ISO-14040/14044 standards.
You can cite all versions by using the DOI 10.5281/zenodo.17567634. This DOI represents all versions, and will always resolve to the latest one.
- Simple, Pythonic API - High-level utilities that abstract complex IPC operations
- Comprehensive LCA Workflow - Search, create, calculate, and analyze in one package
- Contribution Analysis - Identify key contributors to environmental impacts
- Uncertainty Analysis - Monte Carlo simulations with statistical summaries
- Scenario Analysis - Parameter sensitivity and scenario comparison
- Export Utilities - CSV and Excel export for results
- AI Agent Friendly - Clear documentation and structured outputs for automation
- MCP Server - Model Context Protocol server for n8n and AI workflow automation
- ISO Compliant - Follows ISO-14040/14044 LCA standards
- Python 3.10 or higher
- openLCA desktop application (version 2.x)
- openLCA IPC server running (Tools → Developer Tools → IPC Server)
pip install openlca-ipc# Clone the repository
git clone https://github.com/dernestbank/openlca-ipc.git
cd openlca-ipc
# Install in editable mode
pip install -e .
# Or install with optional dependencies
pip install -e ".[full]"# Core dependencies only
pip install -r requirements.txt
# Development dependencies
pip install -r requirements-dev.txtBefore using the library, start the IPC server in openLCA:
- Open openLCA desktop application
- Go to Tools → Developer Tools → IPC Server
- Click Start (default port: 8080)
from openlca_ipc import OLCAClient
# Connect to openLCA
with OLCAClient(port=8080) as client:
# Test connection
if client.test_connection():
print("Connected to openLCA!")
# Search for a material
steel_flow = client.search.find_flow(['steel', 'production'])
print(f"Found: {steel_flow.name}")
# Find provider process
provider = client.search.find_best_provider(steel_flow)
print(f"Provider: {provider.name if provider else 'None'}")from openlca_ipc import OLCAClient
with OLCAClient(port=8080) as client:
# 1. Search for materials
steel = client.search.find_flow(['steel'])
steel_provider = client.search.find_best_provider(steel)
# 2. Create a new process
product = client.data.create_product_flow("Steel plate")
exchanges = [
client.data.create_exchange(product, 1.0, is_input=False, is_quantitative_reference=True),
client.data.create_exchange(steel, 1.0, is_input=True, provider=steel_provider)
]
process = client.data.create_process("Plate production", exchanges=exchanges)
# 3. Create product system
system = client.systems.create_product_system(process)
# 4. Select impact method
method = client.search.find_impact_method(['TRACI'])
# 5. Calculate impacts
result = client.calculate.simple_calculation(system, method)
# 6. Get results
impacts = client.results.get_total_impacts(result)
for impact in impacts:
print(f"{impact['name']}: {impact['amount']:.4e} {impact['unit']}")
# 7. Clean up
result.dispose()from openlca_ipc import OLCAClient
client = OLCAClient(port=8080)
# Run calculation with contribution analysis
result = client.calculate.contribution_analysis(system, method)
# Get all impacts
impacts = client.results.get_total_impacts(result)
# Analyze top contributors for each impact
for impact in impacts:
print(f"\n{impact['name']}:")
# Get top 5 contributors
contributors = client.contributions.get_top_contributors(
result,
impact['category'],
n=5,
min_share=0.01 # Minimum 1% contribution
)
for i, contrib in enumerate(contributors, 1):
print(f" {i}. {contrib.name}: {contrib.share*100:.1f}% ({contrib.amount:.4e})")
result.dispose()from openlca_ipc import OLCAClient
import matplotlib.pyplot as plt
client = OLCAClient(port=8080)
# Run Monte Carlo simulation
results = client.uncertainty.run_monte_carlo(
system=my_system,
impact_method=traci_method,
iterations=1000,
progress_callback=lambda i, total: print(f"Progress: {i}/{total}")
)
# Analyze global warming potential
gwp_key = next(k for k in results.keys() if 'warming' in k.lower())
gwp_result = results[gwp_key]
print(f"Mean: {gwp_result.mean:.4e}")
print(f"Std Dev: {gwp_result.std:.4e}")
print(f"CV: {gwp_result.cv:.2%}")
print(f"95% CI: [{gwp_result.percentile_5:.4e}, {gwp_result.percentile_95:.4e}]")
# Plot distribution
plt.figure(figsize=(10, 6))
plt.hist(gwp_result.values, bins=50, edgecolor='black', alpha=0.7)
plt.axvline(gwp_result.mean, color='red', linestyle='--', label='Mean')
plt.xlabel('Global Warming Potential')
plt.ylabel('Frequency')
plt.title('Monte Carlo Simulation Results')
plt.legend()
plt.savefig('gwp_distribution.png')from openlca_ipc import OLCAClient
import pandas as pd
client = OLCAClient(port=8080)
# Analyze how transport distance affects impacts
scenarios = client.parameters.run_scenario_analysis(
system=transport_system,
impact_method=traci_method,
parameter_name='transport_distance',
values=[100, 200, 500, 1000, 2000, 5000]
)
# Create comparison DataFrame
data = []
for distance, impacts in scenarios.items():
row = {'Distance (km)': distance}
for impact in impacts:
row[impact['name']] = impact['amount']
data.append(row)
df = pd.DataFrame(data)
print(df)
# Export to CSV
client.export.export_comparison_to_csv(scenarios, 'scenario_results.csv')Automate LCA workflows with AI agents using the included MCP (Model Context Protocol) server:
# For AI agents in n8n, Claude Desktop, or other MCP-compatible tools
# The MCP server exposes 15+ LCA tools organized by ISO phases:
Phase 1 (Goal & Scope): search_flows, search_impact_methods, find_providers
Phase 2 (LCI): create_product_flow, create_process, create_product_system
Phase 3 (LCIA): calculate_impacts, get_inventory_results
Phase 4 (Interpretation): analyze_contributions, export_results
# See mcp-server/ directory for complete setupQuick Start with n8n:
- Install MCP server:
cd mcp-server && pip install -r requirements.txt - Configure in n8n: See mcp-server/docs/n8n-integration.md
- Import workflow:
mcp-server/examples/n8n-workflows/basic_lca_workflow.json - Automate LCA! 🤖
The library is organized into specialized modules:
OLCAClient- Main client for connecting to openLCA IPC serversearch- Search and discovery utilities for flows, processes, and impact methodsdata- Create and modify flows, exchanges, and processessystems- Build and configure product systemscalculate- Run LCA calculations with various configurationsresults- Extract and format calculation resultscontributions- Analyze contributions by process or flowuncertainty- Monte Carlo simulations and statistical analysisparameters- Parameter scenarios and sensitivity analysisexport- Export results to CSV, Excel, and other formats
# Good - automatic cleanup with context manager
with OLCAClient(port=8080) as client:
result = client.calculate.simple_calculation(system, method)
impacts = client.results.get_total_impacts(result)
result.dispose() # Always dispose!
# Also good - explicit cleanup
client = OLCAClient(port=8080)
try:
result = client.calculate.simple_calculation(system, method)
# Process results
finally:
result.dispose()# Always check search results
pet_flow = client.search.find_flow(['polyethylene', 'terephthalate'])
if not pet_flow:
# Try alternative keywords
pet_flow = client.search.find_flow(['PET'])
if not pet_flow:
print("Material not found in database")
return
# Proceed safely
provider = client.search.find_best_provider(pet_flow)import logging
# Enable logging to see what's happening
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Library modules will log automatically
client = OLCAClient(port=8080)
# Output: "INFO - Connected to openLCA IPC server on port 8080"- Setup Guide - Detailed installation and configuration
- Examples - Working example scripts and Jupyter notebooks
- API Reference - Module structure and API details
- Complete Documentation - Full documentation hub
- MCP Server - For AI agent automation
olca-ipc>=2.4.0- openLCA IPC protocol implementationolca-schema>=2.4.0- openLCA data schemanumpy>=1.24.0- Numerical operations
Install with pip install openlca-ipc[full]:
scipy>=1.10.0- Statistical analysis for uncertaintymatplotlib>=3.7.0- Visualizationpandas>=2.0.0- Data export and analysis
# Clone repository
git clone https://github.com/dernestbank/openlca-ipc.git
cd openlca-ipc
# Create conda environment (if using conda)
conda create -n openlca_dev python=3.11
conda activate openlca_dev
# Install in editable mode with dev dependencies
pip install -e ".[full]"
pip install -r requirements-dev.txt# Install test dependencies
pip install pytest pytest-cov
# Run tests
pytest tests/
# Run with coverage
pytest --cov=openlca_ipc tests/# Format code
black openlca_ipc/
# Lint code
flake8 openlca_ipc/
# Type checking
mypy openlca_ipc/Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Problem: Cannot connect to openLCA IPC server
Solution:
- Ensure openLCA desktop application is running
- Start IPC server: Tools → Developer Tools → IPC Server
- Check port number (default: 8080)
- Verify firewall settings
Problem: Search returns None for materials
Solution:
- Check if the material exists in your openLCA database
- Try different search keywords
- Use partial matching:
client.search.find_flows(['steel'])instead of exact names
Problem: All impact values are zero or very small
Solution:
- Verify that input exchanges have providers linked
- Check that the product system was created correctly
- Ensure the impact method is appropriate for your flows
- Verify that your database has characterization factors
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this library in your research, please cite:
@software{openlca_ipc,
author = {Danquah Boakye, Ernest},
title = {openLCA IPC Python Library},
year = {2025},
url = {https://github.com/dernestbank/openlca-ipc}
}- Built on top of olca-ipc and olca-schema
- Follows ISO 14040 and ISO 14044 standards
- Inspired by the openLCA community and LCA practitioners worldwide
- Issues: GitHub Issues
- Documentation: Read the Docs
- Email: dernestbanksch@gmail.com
Made with ❤️ for the LCA Community