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. |
|
Normal |
|
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.
- Args:
demand (dict): The demand or functional unit. Needs to be a dictionary to indicate amounts, e.g.
{7: 2.5}
.method (tuple, optional): 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(*args, iter_solver=cgs, **kwargs)[source]#
Bases:
MonteCarloLCA
Base class to use iterative techniques instead of LU factorization in Monte Carlo.
Create a new LCA calculation.
- Args:
demand (dict): The demand or functional unit. Needs to be a dictionary to indicate amounts, e.g.
{7: 2.5}
.method (tuple, optional): 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(*args, **kwargs)[source]#
Bases:
bw2calc.lca.LCA
Normal
LCA
class now supports Monte Carlo and iterative use. You normally want to use it instead.Create a new LCA calculation.
- Args:
demand (dict): The demand or functional unit. Needs to be a dictionary to indicate amounts, e.g.
{7: 2.5}
.method (tuple, optional): 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=None, data_objs=None, iterations=100, cpus=None)[source]#
This is a class for the efficient calculation of many demand vectors from each Monte Carlo iteration.
- Args:
args
is a list of demand dictionariesmethod
is a LCIA methoditerations
is the number of Monte Carlo iterations desiredcpus
is the (optional) number of CPUs to use
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=None, data_objs=None, iterations=1000, chunk_size=None, cpus=None, log_config=None)[source]#
Split a Monte Carlo calculation into parallel jobs