Sensitivity analysis¶
This section presents the functions useful for sensitivity analysis of parametric inventories, and the generation of simplified algebraic models.
One at a time¶
- lca_algebraic.oat_matrix(model: Activity, impacts, functional_unit: float | Expr = 1, n=10, title='Impact variability (% of mean)', name_type=NameType.LABEL)[source]¶
This function generates a heat map of relative the variance of impacts for each parameter varying along its min/max values.
Parameters¶
- model:
Root activity of the inventory
- impacts:
Impact variabilityList of impact methods keys (tuples)
- functional_unit:
Float value of expression by which to divide each impact.
- lca_algebraic.oat_dashboard(model, impacts, functional_unit: float | Expr = 1, func_unit_name='kWh', **kwparams)[source]¶
This function runs a “one at a time” analysis on the selected param.
It makes each parameter vary on its min:max range, while keeping other parameters at their default values.
It returns an interactive dashboard.
Parameters¶
- model :
Root activity of the inventory
- methods :
List of methods keys (tuple)
- functional_unit:
Value of sympy expression by which to divide the impacts
- func_unit_name:
Name of the physical unit of the functional unit, for display
- figsize:
Size of figure fro graphs : (15, 15 by default)
- figspace:
Space between figures for graphs : (0.5, 0.5) by default
- sharex:
Shared X axes ? True by default
Returns¶
An interactive dashboard with selection of a parameter and graphs of impacts.
GSA / Sobol analysis¶
- lca_algebraic.incer_stochastic_dashboard(model: Activity, methods, n=1024, var_params=None, functional_unit=typing.Union[float, sympy.core.expr.Expr], **kwparams)[source]¶
This function runs a monte carlo & Sobol analysis (GSA) on a parametric model and displays a dashboard with results.
Parameters¶
- model:
The root activity of your inventory
- methods:
List of impact methods keys (tuples)
- var_params:
Optional list of parameters to vary. By default, all the parameters that are not marked as FIXED will be varyed.
- functional_unit:
Float value or Sympy expression by which to divide the impacts
- figsize:
Size of figure for violin plots : (15, 15) by default
- figspace:
Space between violin graphs (0.5, 0.5) by default
- sharex:
Share X axe for violin graph : True by default
Returns¶
An interactive dashboard with 4 tabs :
Violin graphs with distributions of impacts
Bar graph with relative variance of impacts
A heatmap amtrix of Sobol indices for each paramter x impact method
A detailed table with all values
Simplified models¶
- lca_algebraic.sobol_simplify_model(model: Activity, methods, min_ratio=0.8, functional_unit=1, n=2048, var_params=None, fixed_mode='median', num_digits=3, simple_sums=True, simple_products=True) List[LambdaWithParamNames] [source]¶
Computes Sobol indices and selects main parameters for explaining sensibility of at least ‘min_ratio’, Then generates simplified models for those parameters.
The other parameters are replaced by their mean or median values.
Also the term contributing to less than 1% of variation in sums and products are removed.
Decimal numbers are rounded to 3 digits.
Parameters¶
- model:
Root activity of the inventory
- methods:
List of impact methods to consider
- min_ratio:
[0, 1] minimum amount of first order variation (sum of S1) to explain; 0.8 (80%) by default.
- var_params:
Optional list of parameters to vary. If not provided, all parameters vary.
- fixed_mode :
What to replace minor parameters with : MEDIAN by default
- simple_sums:
If true (default) remove terms in sums that are lower than 1%
- simple_products:
If true (default) remove terms in products that contribute to less than 1% to variation
- num_digits:
Number of decimal places to round decimal number to (default 3)
Returns¶
List of LambdaWithParamNames, one per impact. The class LambdaWithParamNames wraps the simplified expression together with the list of required parameters and compiled lambda functions for fast evaluation.
The core simplified expresion may be access with res[i].expr
Examples¶
>>> res = sobol_simplify_model( >>> model=total_inventory, >>> methods=[climate_change], >>> functional_unit=total_energy) # Holds a sympy expression computing the total energy
>>> print(res[0].expr) # Dispalt the simplified expression
- lca_algebraic.compare_simplified(model: Activity, methods, simpl_lambdas, functional_unit=1, func_unit_name='', scales=None, unit_overrides=None, nb_cols=2, height=10, width=15, textboxright=0.6, r2_height=0.65, residuals=False, **kwargs)[source]¶
Compare distribution of simplified model with full model.
This functions runs the same monte caarlo random sample as input and feed it to oboth simplified models and full model. It displays graphs and metrics comparing the two.
Parameters¶
- model:
Root activity of the inventory
- methods :
List of impact methods
- functional_unit:
Float value or sympy expression by whicxh to devide the impacts
- func_unit_name:
Name of the physical functional unit
- simpl_lambdas :
Simplified lambdas, as returned by sobol_simplify_model(…)
- residuals :
If true, draw heat map of residuals, rather than distributions
- nb_cols:
number of columns for displaying graphs
- percentiles:
List of percentiles to compute [5, 95] by default