appabuild.model.builder#

Module containing all required classes and methods to run LCA and build impact models. Majority of the code is copied and adapted from lca_algebraic package.

Classes#

ImpactModelBuilder

Main purpose of this class is to build Impact Models.

Functions#

to_bw_method(→ Tuple[str, str, str])

Find corresponding method as known by Brightway.

Module Contents#

class appabuild.model.builder.ImpactModelBuilder(user_database_name: str, functional_unit: str, methods: list[str], output_path: str | None = None, activities_name_to_include: List[str] | None = None, metadata: apparun.impact_model.ModelMetadata | None = ModelMetadata(), parameters: apparun.parameters.ImpactModelParams | None = None)#

Main purpose of this class is to build Impact Models.

Initialize the model builder :param user_database_name: name of the user database (foreground database) :param functional_unit: uuid of the activity producing the reference flow. :param methods: list of methods to generate arithmetic models for.

Expected method format is Appa Run method keys.

Parameters:
  • metadata – information about the LCA behind the impact model. Should contain, or link to all information necessary for the end user’s proper understanding of the impact model.

  • activities_name_to_include – list of activities name regexes to use as an

alternative to the include_in_tree activity flag. Any activity whose name matches one of the regex in the list will be included in the impact model. This disables the include_in_tree activity flag. :param parameters: an ImpactModelParam object will have to be created for each parameter used in all used datasets. See ImpactModelParam attributes to know required fields.

build_impact_model(foreground_database: appabuild.database.databases.ForegroundDatabase | None = None) apparun.impact_model.ImpactModel#

Build an Impact Model, the model is a represented as a tree with the functional unit as its root. :param foreground_database: database containing the functional unit :return: built impact model.

build_tree_node(tree_node: apparun.impact_tree.ImpactTreeNode)#
check_symbols_are_known_parameters(symbols_in_amount: Set[str])#
compute_node_models(tree_node: apparun.impact_tree.ImpactTreeNode, methods, free_symbols: Set)#
declare_parameters_in_lcaa()#

Declare used parameters in conf file as a lca_algebraic parameter to enable model building (will not be used afterwards)

find_activity_in_bw(activity_name) lca_algebraic.ActivityExtended#

Find the bw activity matching the functional unit in the bw database. A single activity should be found as it is to be used as the root of the tree.

static from_yaml(lca_config_path: str) ImpactModelBuilder#

Initializes a build with information contained in a YAML config file :param lca_config_path: path to the file holding the config. :return: the Impact Model Builder

activities_name_to_include = None#
bw_user_database#
functional_unit#
metadata#
methods#
output_path = None#
parameters = None#
user_database_name#
appabuild.model.builder.to_bw_method(method_full_name: apparun.impact_methods.MethodFullName) Tuple[str, str, str]#

Find corresponding method as known by Brightway. :param method_full_name: method to be found. :return: Brightway representation of the method.