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.

Attributes#

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, metadata: apparun.impact_model.ModelMetadata | None = ModelMetadata(), compile_models: bool = True, parameters: dict | 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.

  • parameters – an ImpactModelParam object will have to be created for each

parameter used in all used datasets. See ImpactModelParam attributes to know required fields.

static actToExpression(act: bw2data.backends.peewee.Activity, impact_model_tree_node: apparun.impact_tree.ImpactTreeNode)#

Determines the arithmetic model corresponding to activity’s impact function of model’s parameters. :param act: Brightway activity corresponding to the node. :param impact_model_tree_node: node of the tree to store result in. :return:

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_impact_tree_and_parameters(functional_unit_bw: lca_algebraic.ActivityExtended, methods: List[str]) Tuple[apparun.impact_tree.ImpactTreeNode, apparun.parameters.ImpactModelParams]#

Perform LCA, construct all arithmetic models and collect used parameters. :param functional_unit_bw: Brightway activity producing the reference flow. :param methods: list of methods to generate arithmetic models for. Expected method format is Appa Run method keys. :return: root node (corresponding to the reference flow) and used parameters.

find_functional_unit_in_bw() 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 configuration file :param lca_config_path: path to the file holding the configuration. :return: the Impact Model Builder

bw_user_database#
compile_models = True#
functional_unit#
metadata#
methods#
output_path#
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.

appabuild.model.builder.act_symbols#