Introduction
Brightway2 is a open source framework for life cycle assessment (LCA). It doesn’t try to replace software like SimaPro or OpenLCA, but rather to offer new possibilities to those who want to break the limits of conventional LCA. So it's not for everyone, and you will need to invest some time learning about Python to use Brightway2. Basically, this is the framework for you if your project lies at the intersection of LCA and your imagination.
Features
- More than 100 Monte Carlo iterations/second
- Use with Jupyter notebooks
- Downstream and upstream supply chain traversal
- Multiple database backends
- Graphs in Python (Matplotlib) or Javascript (D3.js)
Principles
-
Open. All code in Brightway2 is open source, and made available under the BSD license.
-
Agile. The simplicity of the data format and calculation engine make it easy to adapt the code or add new functionality.
-
Freedom. A inventory dataset is a document with a few required fields, and can be adapted to your particular model or problem domain.
-
Modular. Each set of functions is split into a package, with its own tests and documentation.
In [1]: from brightway2 import *
In [2]: def do_lca():
...: lca = LCA(
...: demand={Database("ecoinvent 2.2").random(): 1},
...: method=methods.random()
...: )
...: lca.lci()
...: lca.lcia()
...: return lca.score
...:
In [3]: %timeit do_lca()
1 loops, best of 3: 1.12 s per loop
In [1]: from brightway2 import *
In [2]: fp = "/Users/cmutel/Documents/LCA Documents/Ecoinvent/3.2/cutoff/datasets"
In [3]: ei = SingleOutputEcospold2Importer(fp, "ecoinvent 3.2 cutoff")
Extracting ecospold2 files:
0% 100%
[##############################] | ETA[sec]: 0.000 | Item ID: fff1a27b-b651-444
Total time elapsed: 127.138 sec
Extracted 12916 datasets in 127.87 seconds
In [4]: ei.apply_strategies()
Applying strategy: normalize_units
Applying strategy: remove_zero_amount_coproducts
Applying strategy: remove_zero_amount_inputs_with_no_activity
Applying strategy: remove_unnamed_parameters
Applying strategy: es2_assign_only_product_with_amount_as_reference_product
Applying strategy: assign_single_product_as_activity
Applying strategy: create_composite_code
Applying strategy: drop_unspecified_subcategories
Applying strategy: link_biosphere_by_flow_uuid
Applying strategy: link_internal_technosphere_by_composite_code
Applying strategy: delete_exchanges_missing_activity
Applying strategy: delete_ghost_exchanges
Applying strategy: nuncertainty
Applied 13 strategies in 3.53 seconds
In [5]: ei.statistics()
12916 datasets
459268 exchanges
0 unlinked exchanges
Out[5]: (12916, 459268, 0)
In [6]: ei.write_database()
Writing activities to SQLite3 database:
0% 100%
[##############################] | ETA[sec]: 0.000
Total time elapsed: 76.513 sec
Created database: ecoinvent 3.2 cutoff
In [1]: from brightway2 import *
In [2]: from scipy.stats import kendalltau
In [3]: import numpy as np
In [4]: db = Database("ecoinvent 3.2 cutoff")
In [5]: gwp, usetox = ('IPCC 2013', 'climate change', 'GWP 100a'), ('USEtox', 'human toxicity', 'total')
In [6]: lca = LCA({db.random(): 1}, method=gwp); lca.lci(factorize=True); lca.lcia()
In [7]: def calculate_correlation(n=1000):
....: results = np.zeros((2, n))
....: for x, method in enumerate((gwp, usetox)):
....: lca.switch_method(method)
....: for y, activity in enumerate(db):
....: if y == n:
....: break
....: lca.redo_lcia({activity: 1})
....: results[x, y] = lca.score
....: return results
In [8]: kendalltau(*calculate_correlation())
Out[8]: KendalltauResult(correlation=-0.004769486612148318, pvalue=0.82132482572697252)