bw2calc.lca_base#
Classes#
Base class for single and multi LCA classes |
Module Contents#
- class bw2calc.lca_base.LCABase[source]#
Bases:
collections.abc.Iterator
Base class for single and multi LCA classes
- decompose_technosphere() None [source]#
Factorize the technosphere matrix into lower and upper triangular matrices, \(A=LU\). Does not solve the linear system \(Ax=B\).
Doesn’t return anything, but creates
self.solver
.Warning
Incorrect results could occur if a technosphere matrix was
factorized, and then a new technosphere matrix was constructed, as
self.solver
would still be the factorized older technosphere matrix. You are responsible for deletingself.solver
when doing these types of advanced calculations.
- has(label: str) bool [source]#
Shortcut to find out if matrix data for type
{label}_matrix
is present in the given data objects.Returns a boolean. Will return
True
even if data for a zero-dimensional matrix is given.
- invert_technosphere_matrix()[source]#
Use one-shot approach to efficiently calculate the inverse of the technosphere matrix by simultaneously solving
Ax=b
for allb
.Technosphere matrix inversion is often not the most efficient approach. See brightway-lca/brightway2-calc#35
See Intel forum for a discussion on why we use this approach.
- keep_first_iteration()[source]#
Set a flag to use the current values as first element when iterating.
When creating the class instance, we already use the first index. This method allows us to use the values for the first index.
Note that the methods
.lci_calculation()
and.lcia_calculation()
will be called on the current values, even if these calculations have already been done.
- lci(demand: dict | None = None, factorize: bool = False) None [source]#
Calculate a life cycle inventory.
- Load LCI data, and construct the technosphere and biosphere
matrices.
Build the demand array
- Solve the linear system to get the supply array and life cycle
inventory.
- Parameters:
factorize (*) – Factorize the technosphere matrix.
matrix (Makes additional calculations with the same technosphere)
LCI (much faster. Default is False; not useful is only doing one)
calculation.
builder (*) – Default is
bw2calc.matrices.MatrixBuilder
cases. (which is fine for most)
creative (Custom matrix builders can be used to manipulate data in)
matrices. (ways before building the)
Doesn’t return anything, but creates
self.supply_array
andself.inventory
.
- lcia(demand: dict | None = None) None [source]#
Calculate the life cycle impact assessment.
Load and construct the characterization matrix
Multiply the characterization matrix by the life cycle inventory
Doesn’t return anything, but creates
self.characterized_inventory
.
- load_lci_data(nonsquare_ok=False) None [source]#
Load inventory data and create technosphere and biosphere matrices.
- redo_lci(demand: dict | None = None) None [source]#
Redo LCI with same databases but different demand.
- Parameters:
demand (*) – A demand dictionary.
Doesn’t return anything, but overwrites
self.demand_array
,self.supply_array
, andself.inventory
.Warning
If you want to redo the LCIA as well, use
redo_lcia(demand)
directly.
- redo_lcia(demand: dict | None = None) None [source]#
Redo LCIA, optionally with new demand.
- Parameters:
demand (*) – New demand dictionary. Optional,
self.demand. (defaults to)
Doesn’t return anything, but overwrites
self.characterized_inventory
. Ifdemand
is given, also overwritesself.demand_array
,self.supply_array
, andself.inventory
.
- remap_inventory_dicts() None [source]#
Remap
self.dicts.activity|product|biosphere
andself.demand
from database integer IDs to keys ((database name, code)
).Uses remapping dictionaries in
self.remapping_dicts
.
- solve_linear_system(demand: numpy.ndarray | None = None) None [source]#
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.
- weight() None [source]#
Multiply characterized inventory by weighting value.
Can be done with or without normalization.