A scenario is a set of parameter values that represents one version of your model: a different manufacturing site, a different transport route, a different energy mix. This article covers a script that reads scenarios from a CSV, runs them all through openLCA via IPC, and writes the results side by side in one output file.
This tool is available on the Below280 Life Cycle Assessment Github, within openLCA-IPC-tools
Before you start
The IPC server needs to be running and the Python packages installed. The Getting Started section covers both if this is your first time.
Your model also needs parameters. The script works by redefining parameter values, so your exchanges need to reference parameters rather than containing fixed numbers. The Parameters article in Getting Started covers this.
The scenario CSV
The CSV file has parameter names in the first column and one scenario per additional column. Parameter names must match your openLCA model exactly (case-sensitive).
Parameter,Baseline,High_transport,Low_energy
electricity_kWh,170,170,140
resin_kg,8,8,6.5
transport_km,50,200,50
water_m3,0.35,0.35,0.3
You only need to include the parameters you want to vary. Any parameter not in the CSV keeps its default value from the model.
Running the script
Interactive mode:
python B280_olca_scenarios.py
This shows a list of product systems and impact methods to choose from. Pressing Enter accepts the defaults (first product system, EF v3.1).
Fully scripted:
python B280_olca_scenarios.py -p "My Product System" -i "EF v3.1" -s scenarios.csv
| Flag | What it sets | Default |
|---|---|---|
-p | Product system name (exact match) | First system in database |
-i | Impact assessment method (exact match) | EF v3.1 |
-s | Path to scenarios CSV | scenarios.csv |
--help gives full usage details.
What the script does
For each scenario column in the CSV, the script reads the parameter values, matches each one to its context in the product system, runs the calculation, and collects the results. After all scenarios are done, it writes one output CSV with every result.
The output
The script creates scenario_results_<method_name>.csv:
Impact Category,Baseline,High_transport,Low_energy
Acidification potential (mol H+ eq),1.27,1.45,1.15
Global Warming Potential - fossil (kg CO2 eq),248.3,312.1,210.7
...
One row per impact category, one column per scenario.
Parameter contexts
Every parameter in a product system has a context: it’s either global (context is None) or it belongs to a specific process. When redefining a parameter for a calculation, the context needs to be included so openLCA knows which parameter is meant.
The script handles this automatically by calling client.get_parameters() on the product system and building a lookup of parameter name to context.
If a parameter name in your CSV doesn’t match anything in the product system, check the console output, which reports any parameters it couldn’t match. Verify the spelling and case against the product system’s Parameters tab in openLCA.
Things to watch
Parameter names are case-sensitive. Copying them from the product system’s Parameters tab in openLCA avoids typos.
Units need to match. If your parameter is electricity_kWh, the exchange it controls needs to actually be in kWh. The script passes the number straight through to openLCA.
Identical results across scenarios usually means the parameters in the CSV aren’t feeding into exchanges in the selected product system.
