TutorialVersion 0.4.1
openLCA IPC quickstart
Connect to openLCA, search the active database, and follow the basic calculation pattern.
Before you begin
- openlca-ipc is installed
- openLCA is running
- the intended database is open
- the IPC server is running
1. Connect
python
from openlca_ipc import OLCAClient
with OLCAClient(port=8080) as client:
assert client.test_connection()
print("Connected")2. Search the database
python
from openlca_ipc import OLCAClient
with OLCAClient(port=8080, read_only=True) as client:
flow = client.search.find_flow(["steel"])
method = client.search.find_impact_method(["TRACI"])
print(flow.name if flow else "No steel flow found")
print(method.name if method else "No TRACI method found")Search instead of hard-coding guessed IDs. Databases differ in naming, geography, and available methods.
3. Start from a model you understand
For a first calculation, use an existing product system or process whose reference product and functional basis you can verify.
4. Run a calculation
python
result = client.calculate.simple_calculation(system, method)
try:
impacts = client.results.get_total_impacts(result)
for impact in impacts[:5]:
print(impact["name"], impact["amount"], impact["unit"])
finally:
result.dispose()Warning
Always dispose calculation results when you are finished with them.
5. Inspect before rerunning
Use the same result for inventory inspection, contribution analysis, normalization, weighting, Sankey data, or exports where possible. This reduces the chance of silently analyzing a changed model.