MOCA is a Python package to perform efficient and parallelised uncertainty quantification for Life Cycle Assessment (LCA). It is built to work with the Brightway2 framework. Currently, MOCA includes a class for high-speed Monte Carlo Simulation. More methodologies for uncertainty quantification are planned to be implemented going forward.
This package has been developed by the German Aerospace Center (DLR e.V.), at the Institute of Maintenance, Repair and Overhaul.
Simply install this package via pip using:
pip install moca-uncertainty-lcaYou can find a very simple usage example below. For more information regarding customisation options and how MOCA could be integrated into your existing code framework, please feel free to visit our documentation.
import moca_uncertainty_lca as moca
import brightway2 as bw
# setting up Brightway
bw.projects.set_current("your project")
# specify the LCIA method / characterisation model
method = ('EF v3.1','climate change','global warming potential (GWP100)')
# build the demand dictionary for the Monte Carlo LCA
demand = {bw.Database("your_database").get("your_code"): 1}
# initialize and execute the Monte Carlo LCA
mc_lca = moca.MonteCarloLCA(demand, method)
mc_lca.execute_monte_carlo(iterations=100)
# retrieve the results and write them to files
mc_results = mc_lca.mc_results
mc_lca.results_to_json()
mc_lca.stats_to_json()Find more detailed documentation here!
There are two main reasons:
-
MOCA is faster! Depending on the complexity and size of your calculation setup, the speed-up can range from twice as fast to more than 40 times as fast.
-
MOCA is easy to use and comes with built-in functions to make your life easier, such as automatic formatting and exporting.
MOCA is licensed with the BSD 3-Clause. For more information, see here.
Contributions are very welcome! If you’d like to help, here’s how you can get started:
- Report bugs or request features: Open an issue and describe the problem or idea as clearly as possible (what you expected, what happened, steps to reproduce, versions, etc.)
- Improve the code or documentation
- Open an issue or find one that you want to work on
- Fork the repository, create a feature branch, and write your code
- Ideally: Add tests for new features
- Format code with Black
- Create a pull request and reference any related issues
- Discussion and questions: If you’re not sure whether your idea fits the project, feel free to open an issue and ask before you start coding
Please feel free to create an issue on Github or to contact Maria Höller (maria.hoeller@dlr.de) for support.