bw2calc.least_squares#

Module Contents#

Classes#

 LeastSquaresLCA Solve overdetermined technosphere matrix with more products than activities using least-squares approximation.
class bw2calc.least_squares.LeastSquaresLCA(demand, method=None, weighting=None, normalization=None, database_filepath=None, log_config=None, presamples=None, seed=None, override_presamples_seed=False)[source]#

Solve overdetermined technosphere matrix with more products than activities using least-squares approximation.

Create a new LCA calculation.

Parameters
• demand (*) – The demand or functional unit. Needs to be a dictionary to indicate amounts, e.g. {("my database", "my process"): 2.5}.

• method (*) – LCIA Method tuple, e.g. ("My", "great", "LCIA", "method"). Can be omitted if only interested in calculating the life cycle inventory.

Returns

A new LCA object

abstract decompose_technosphere()[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 deleting self.solver when doing these types of advanced calculations.

solve_linear_system(solver=lsmr)[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 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.