bw2calc.monte_carlo
#
Module Contents#
Classes#
First draft approach at comparative LCA |
|
Base class to use iterative techniques instead of LU factorization in Monte Carlo. |
|
Monte Carlo uncertainty analysis with separate random number generators (RNGs) for each set of parameters. |
|
Base class to use iterative techniques instead of LU factorization in Monte Carlo. |
|
Monte Carlo uncertainty analysis with separate random number generators (RNGs) for each set of parameters. |
|
This is a class for the efficient calculation of many demand vectors from |
|
Split a Monte Carlo calculation into parallel jobs |
Functions#
|
|
|
Calculate a single Monte Carlo iteration for many demands. |
|
|
|
- class bw2calc.monte_carlo.ComparativeMonteCarlo(demands, *args, **kwargs)[source]#
Bases:
IterativeMonteCarlo
First draft approach at comparative LCA
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
- class bw2calc.monte_carlo.DirectSolvingMixin(demand, method=None, iter_solver=cgs, seed=None, *args, **kwargs)[source]#
Bases:
IterativeMonteCarlo
Base class to use iterative techniques instead of LU factorization in Monte Carlo.
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
- solve_linear_system()[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.
- class bw2calc.monte_carlo.DirectSolvingMonteCarloLCA(demand, method=None, iter_solver=cgs, seed=None, *args, **kwargs)[source]#
Bases:
MonteCarloLCA
,DirectSolvingMixin
Monte Carlo uncertainty analysis with separate random number generators (RNGs) for each set of parameters.
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
- class bw2calc.monte_carlo.IterativeMonteCarlo(demand, method=None, iter_solver=cgs, seed=None, *args, **kwargs)[source]#
Bases:
bw2calc.lca.LCA
Base class to use iterative techniques instead of LU factorization in Monte Carlo.
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
- solve_linear_system()[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.
- class bw2calc.monte_carlo.MonteCarloLCA(demand, method=None, iter_solver=cgs, seed=None, *args, **kwargs)[source]#
Bases:
IterativeMonteCarlo
Monte Carlo uncertainty analysis with separate random number generators (RNGs) for each set of parameters.
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
- class bw2calc.monte_carlo.MultiMonteCarlo(demands, method, iterations, cpus=None)[source]#
Bases:
object
This is a class for the efficient calculation of many demand vectors from each Monte Carlo iteration.
- Parameters
dictionaries (* args is a list of demand) β
method (* method is a LCIA) β
desired (* iterations is the number of Monte Carlo iterations) β
the (* cpus is) β
The input list can have complex demands, so
[{('foo', 'bar'): 1, ('foo', 'baz'): 1}, {('foo', 'another'): 1}]
is OK.Call
.calculate()
to generate results.
- class bw2calc.monte_carlo.ParallelMonteCarlo(demand, method, iterations=1000, chunk_size=None, cpus=None, log_config=None)[source]#
Bases:
object
Split a Monte Carlo calculation into parallel jobs