bw2calc.least_squares
#
Module Contents#
Classes#
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]#
Bases:
bw2calc.lca.LCA
Solve overdetermined technosphere matrix with more products than activities using least-squares approximation.
See also:
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 deletingself.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.