REGISTER NOW: Brightway Spring School! 🇨🇦 Québec City (Canada) 🗓️ 20.-24. May 2024


Module Contents#



Convert the technosphere_matrix to a numpy array and solve with numpy.linalg.

class bw2calc.dense_lca.DenseLCA(demand: dict, method: tuple | None = None, weighting: str | None = None, normalization: str | None = None, data_objs: Iterable[pathlib.Path | fs.base.FS | bw_processing.DatapackageBase] | None = None, remapping_dicts: Iterable[dict] | None = None, log_config: dict | None = None, seed_override: int | None = None, use_arrays: bool | None = False, use_distributions: bool | None = False, selective_use: dict | None = False)[source]#

Bases: bw2calc.lca.LCA

Inheritance diagram of bw2calc.dense_lca.DenseLCA

Convert the technosphere_matrix to a numpy array and solve with numpy.linalg.

Create a new LCA calculation object.

Compatible with Brightway2 and 2.5 semantics. Can be static, stochastic, or iterative (scenario-based), depending on the data_objs input data..

This class supports both stochastic and static LCA, and can use a variety of ways to describe uncertainty. The input flags use_arrays and use_distributions control some of this stochastic behaviour. See the [documentation for matrix_utils](brightway-lca/matrix_utils) for more information on the technical implementation.


demanddict[object: float]

The demand for which the LCA will be calculated. The keys can be Brightway Node instances, (database, code) tuples, or integer ids.


Tuple defining the LCIA method, such as (‘foo’, ‘bar’). Only needed if not passing data_objs.


Tuple defining the LCIA weighting, such as (‘foo’, ‘bar’). Only needed if not passing data_objs.


String defining the LCIA normalization, such as ‘foo’. Only needed if not passing data_objs.


List of bw_processing.Datapackage objects. Can be loaded via bw2data.prepare_lca_inputs or constructed manually. Should include data for all needed matrices.

remapping_dictsdict[str, dict]

Dict of remapping dictionaries that link Brightway Node ids to (database, code) tuples. remapping_dicts can provide such remapping for any of activity, product, biosphere.


Optional arguments to pass to logging. Not yet implemented.


RNG seed to use in place of Datapackage seed, if any.


Use arrays instead of vectors from the given data_objs


Use probability distributions from the given data_objs

selective_usedict[str, dict]

Dictionary that gives more control on whether use_arrays or use_distributions should be used. Has the form {matrix_label: {“use_arrays”|”use_distributions”: bool}. Standard matrix labels are technosphere_matrix, biosphere_matrix, and characterization_matrix.


Master solution function for linear system \(Ax=B\).

To most numerical analysts, matrix inversion is a sin.

—Nicolas Higham, Accuracy and Stability of Numerical Algorithms, Society for Industrial and Applied Mathematics, Philadelphia, PA, USA, 2002, p. 260.

We use pypardiso or UMFpack, which is a very fast solver for sparse matrices.

If the technosphere matrix has already been factorized, then the decomposed technosphere (self.solver) is reused. Otherwise the calculation is redone completely.