\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "75d0feda",
"metadata": {},
"source": [
" **What is the goal of this notebook ?** \n",
" \n",
"This notebook explains how to do a basic parameterised Life Cycle Assessment (LCA) using brightway and lca_algebraic librairies. This notebook gives the main coding parts and tries to explain for each parts how to use the main functions and how to write code. \n",
"\n",
" **How to read this notebook?** \n",
" \n",
"Their are 2 types of sections in this notebook :\n",
"* **\"To do\" sections** that countain the cells you need to run to make a basic LCA. Some of this sections are optional (*optional* in the title of the section) and should not be mandatory run.\n",
"\n",
"* **Explanation section** that explain how to find the usefull information to write the \"to do\" sections. You don't need to run them to make the LCA. This sections title starts with *explain*.\n",
"\n",
"Note : If you have the \"collapsible headings\" extensions on Jupyter, the explanation sections can be hidden. \n",
"\n",
" **Warning** \n",
" \n",
"The inventories examples given are not representative for real physical systems. The inventories have just been built to learn how to use lca_algebraic functions. "
]
},
{
"cell_type": "markdown",
"id": "48c2ee5d",
"metadata": {},
"source": [
"# Setup\n",
"\n",
"First, create and activate a dedicated Python (>=3.10) environement with [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) or [Pip](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/)\n",
"\n",
"Then install **Jupyter** and **lca_algebraic** (>=1.1.2) :\n",
"```bash\n",
"pip install jupyter\n",
"pip install lca_algebraic\n",
"```\n",
"\n",
"\n",
"You may also install [Activity Browser](https://github.com/LCA-ActivityBrowser/activity-browser) :\n",
"\n",
"```\n",
"pip install activity-browser\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "3b432549",
"metadata": {},
"source": [
"## Import the libaries "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a1f1deb1",
"metadata": {},
"outputs": [],
"source": [
"# Initialise the library with instructions \n",
"from init import *"
]
},
{
"cell_type": "markdown",
"id": "1411d2a2",
"metadata": {},
"source": [
"### Explain : librairies imported\n"
]
},
{
"cell_type": "markdown",
"id": "202fd235",
"metadata": {},
"source": [
" **What does init.py do?** \n",
"\n",
"* init.py loads the required libraries to run this notebook. \n",
"* in init files, pay attention on the shortnames of libraries that will be used for using the functions of the loaded libraries.\n",
"* Warning : the file init.py shall be in the same file as the file of this notebook !\n",
"\n",
" **Librairies** \n",
" This notebook uses functions from 6 librairies : \n",
"* **brightway** is a library for computing advanced LCA. \n",
"* **lca_algebraic** is library specificaly developped to build paramterized LCA model and perform sensitivity analysis (very efficiently by relying on symbolic calculus). \n",
"* **pandas** is a usefull library for data manipulation and data analysis\n",
"* **numpy** is a basic library for numeric calculations\n",
"* **scipy** is a library for scientific tools \n",
"* **matplotlib** is a library for plotting.\n",
"\n",
"Scipy and matplotlib are just partly imported. Indeed, lca_algebraic imports only the usefull tools from this libraries.\n",
"\n",
"\n",
" **LCA librairies resources** \n",
"\n",
"* **brightway** > \n",
" * Brightway2 website \n",
" * Tutorial \n",
"\n",
" \n",
"* **lca_algebraic** > lca_algebraic relies on brightway2 and has additional functionnalities.\n",
" * lca_algebraic github \n",
" * lca_algebraic documentation\n"
]
},
{
"cell_type": "markdown",
"id": "25e57757",
"metadata": {},
"source": [
"## Init Brightway project\n",
"\n",
"The following code creates or open a Brightsay projet and clear the foreground database and parameters.\n",
"It is recommended to do so in order to start your code with a fresh inventory."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c8095a3b",
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"# To do : update the name of the bightway project\n",
"NAME_PROJECT=\"name-project\"\n",
"\n",
"# To do : update the name of the user database that will be stored in the brightway project\n",
"NAME_USER_DB='name of my database'\n",
"\n",
"\n",
"#Open a brightway project associated with the project name chosen\n",
"bw2data.projects.set_current(NAME_PROJECT)\n",
"bw2data.projects.current\n",
"\n",
"# Create and reset the user (foreground) database\n",
"agb.resetDb(NAME_USER_DB)\n",
"\n",
"# Reset the definition of all parameters \n",
"agb.resetParams()"
]
},
{
"cell_type": "markdown",
"id": "3c5dd5be",
"metadata": {},
"source": [
"## Load the background ecoinvent database"
]
},
{
"cell_type": "markdown",
"id": "cc2588eb",
"metadata": {},
"source": [
"This should be done only once : "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fedb4e98",
"metadata": {},
"outputs": [],
"source": [
"#Give the password associated with your ecoinvent account\n",
"#Warning don't share your id/password on git\n",
"from ecoinvent_interface import Settings, permanent_setting\n",
"permanent_setting(\"username\", \"put_here_your_username\")\n",
"permanent_setting(\"password\", \"put_here_your_password\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6e13160c",
"metadata": {},
"outputs": [],
"source": [
"#load the chosen vesion of ecoinvent. Here an example with ecoinvent 3.9.1, cut off\n",
"bw2io.import_ecoinvent_release(\"3.9.1\", \"cutoff\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "233edcdc",
"metadata": {},
"outputs": [],
"source": [
"# Optional : If you need to manipulate the database keep references a reference to it\n",
"ecoinvent = bw2data.Database('ecoinvent-3.9.1-cutoff')"
]
},
{
"cell_type": "markdown",
"id": "45452907",
"metadata": {},
"source": [
"## Managing databases"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d6efe60",
"metadata": {},
"outputs": [],
"source": [
"# Print the databases that have been set up with brightway function\n",
"bw.databases"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5a58c6cf",
"metadata": {},
"outputs": [],
"source": [
"# Print the databases that have been set up with lca_algebraic function\n",
"agb.list_databases() \n",
"#The size of database and the type of database (foregroung/background/biosphere) is also printed "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4dab8a2d",
"metadata": {},
"outputs": [],
"source": [
"#Optional : if you need to delete a USER_DB\n",
"#del bw.databases[\"name-db-to-delete\"]\n",
"\n",
"#Optional : If you need to manipulate a database, give it a variable name\n",
"#ecoinvent_3_8 = bw2data.Database('ecoinvent-3.8-cutoff')"
]
},
{
"cell_type": "markdown",
"id": "3b905747",
"metadata": {},
"source": [
"# Select LCIA method and impacts categories"
]
},
{
"cell_type": "markdown",
"id": "bd0c56d3",
"metadata": {},
"source": [
"## Select LCIA methods"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "71c02819",
"metadata": {},
"outputs": [],
"source": [
"# Pick the LCIA method you want to use\n",
"# To do : update the name of the method you want to use\n",
"LCIA_method = 'EF v2.0 2018 no LT'"
]
},
{
"cell_type": "markdown",
"id": "cbe61c19",
"metadata": {},
"source": [
"### Explain : how to find the name of the LCIA method\n",
"\n",
"* *bw.methods* is a brightway dictionnary that contains all LCIA methods and impacts categories that were imported when initialising the notebook.\n",
"* Objects in bw.methods are triplet (LCIA method, endpoint category, midpoint category) that corresponds to impacts categories calculated with a given LCIA method."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a3730c9",
"metadata": {},
"outputs": [],
"source": [
"#See all triplets of bw.methods\n",
"list(bw.methods)\n",
"\n",
"# Note : With Activity browser / section \"impact categories\", this list can alsobe explored easily"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa4dea4c",
"metadata": {},
"outputs": [],
"source": [
"# See all the LCIA methods available in Brightway 2\n",
"list_LCIA_methods = [m[0] for m in bw.methods]\n",
"list_LCIA_methods = [*set(list_LCIA_methods)]\n",
"list_LCIA_methods"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "85e749cc",
"metadata": {},
"outputs": [],
"source": [
"# See all the LCIA methods that were imported that contains ReCiPe in their name\"\n",
"# Update the name of the \"keywords\" according to your search\n",
"list_LCIA_methods = [m[0] for m in bw.methods if \"ReCiPe\" in str(m)]\n",
"list_LCIA_methods = [*set(list_LCIA_methods)] #this line automatically delete the duplicates\n",
"list_LCIA_methods"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab50d308",
"metadata": {},
"outputs": [],
"source": [
"# See all the LCIA methods that were imported excluding the one containing keywords such as \"no LT\" or \"obsolete\"\n",
"# Update the name of the \"excluding keywords\" according to your search\n",
"list_LCIA_methods = [m[0] for m in bw.methods if not \"no LT\" in str(m) and not'obsolete' in str(m)]\n",
"list_LCIA_methods = [*set(list_LCIA_methods)] #this line automatically delete the duplicates\n",
"list_LCIA_methods"
]
},
{
"cell_type": "markdown",
"id": "65588b29",
"metadata": {},
"source": [
"## Select impacts categories"
]
},
{
"cell_type": "markdown",
"id": "7b364bf0",
"metadata": {},
"source": [
"### Select impact categories"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0bf64fa",
"metadata": {},
"outputs": [],
"source": [
"#Select the impacts categories you want to calculate\n",
"#Remind : impact_categories are triplet (LCIA method, endpoint category, midpoint category)\n",
"# To do : update the name of the endpoint and midpoint category in the triplet and the name of impact_categories\n",
"climate = (LCIA_method, 'climate change no LT','global warming potential (GWP100) no LT')\n",
"resources = (LCIA_method, 'energy resources: non-renewable no LT','abiotic depletion potential (ADP): fossil fuels no LT')\n",
"soil = (LCIA_method, 'climate change: land use and land use change no LT','global warming potential (GWP100) no LT')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6b6c5f88",
"metadata": {},
"outputs": [],
"source": [
"# Define a list of impacts categories chosen and print it\n",
"# To do : update the name of the impact categories in the list\n",
"impacts = [climate, resources, soil]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a944d599",
"metadata": {},
"outputs": [],
"source": [
"# Print the selected impact categories\n",
"# To do : nothing\n",
"nb_impacts=len(impacts)\n",
"print(f\"We have selected {nb_impacts} impacts categories calculated with the LCIA method : '{LCIA_method}' that are :\")\n",
"print(\" \")\n",
"for m in impacts : print(m[1],\">\", m[-1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1b9b0ba4",
"metadata": {},
"outputs": [],
"source": [
"#Test if the triplet you have just defined are methods in bw.methods\n",
"bw.methods[climate]\n",
"bw.methods[resources]\n",
"bw.methods[soil]\n",
"print(\"If there is no error, it means it is ok. If there is an error, it means at least one of the impact categories is not correctly defined and does not correspond to an existing impact category. Check that there is no tipping error. \")"
]
},
{
"cell_type": "markdown",
"id": "dda71dd7",
"metadata": {},
"source": [
"### Explain : how to choose impact categories with function `agb.findMethods`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "010265cd",
"metadata": {},
"outputs": [],
"source": [
"# We list all the impacts categories that can be calculated with the selected LCIA method \n",
"# with the function agb.findMethods\n",
"# To do : nothing \n",
"list_impact_categories=agb.findMethods(\"\",LCIA_method)\n",
"nb_impacts=len(list_impact_categories)\n",
"\n",
"#Print the categories\n",
"# To do : nothing \n",
"print(f\"There are {nb_impacts} impacts categories calculated with the LCIA method : '{LCIA_method}' that are :\")\n",
"list_impact_categories\n",
"\n",
"# Note : With Activity browser / section impact categories, this list can be explored easily "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab611f62",
"metadata": {},
"outputs": [],
"source": [
"# Find all impacts categories calculated with the LCIA method chosen that contain a keyword such as \"climate\"\n",
"# with agb.findMethods(\"keyword\", LCIA methods)\n",
"# To do : update the keyword\n",
"agb.findMethods(\"climate\", LCIA_method)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b6af7481",
"metadata": {},
"outputs": [],
"source": [
"# Other example with keyword \"resource\"\n",
"# To do : update the keyword\n",
"\n",
"agb.findMethods(\"resource\", LCIA_method)"
]
},
{
"cell_type": "markdown",
"id": "9f4a56d4",
"metadata": {},
"source": [
"# Define the parameters"
]
},
{
"cell_type": "markdown",
"id": "023945c7",
"metadata": {},
"source": [
"You can create a **python variable** `density=3` in a code cell, and then use `density` to calculate a flows amount. \n",
"You can change `density`'s value, re-run the code parts that use `density`to remake the calculations with the updated value of `density`.\n",
"\n",
"\n",
"**\"lca_algebraic parameters\"** have functionalities that helps manipulating parameters while doing LCA. For example, it helps calculating scenarios or conducting fast sensitivity analysis for example.\n",
"\n",
"In practice in your code, part of the parameters that you don't want to make vary will be defined as standard python variables (eg density) and only the parameters you want to change will be defined as lca_algebraic parameters:\n",
"* 1. define python variables (also called static variables)\n",
"* 2. define lca_algebraic parameters as explained below\n",
" \n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "0ccce972",
"metadata": {},
"source": [
"## python variables / static parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7df1c5a1",
"metadata": {},
"outputs": [],
"source": [
"STEEL_DENSITY=7850 #kg/m3"
]
},
{
"cell_type": "markdown",
"id": "5d129ca2",
"metadata": {},
"source": [
"## lca_algebraic parameters\n",
"**lca_algebraic** can define 3 types of parameters :\n",
"* Float parameter, with `newFloatParam(...)`\n",
"* Bool parameter, with `newBoolParam(...)`\n",
"* \"Exclusive choice\", that corresponds to the definition of several boolean parameters with `newEnumParam(...)` > for example, for an electricity mix, we have to choose one mix among others"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "887acb68",
"metadata": {},
"outputs": [],
"source": [
"# Float parameters definition > newFloatParam\n",
"# To do : You need to fulfill at least, \"name\" and \"default value\"\n",
"\n",
"# Example : PV power installed in kWpeak \n",
"power_capacity = agb.newFloatParam(\n",
" name=\"power_capacity\", # short name\n",
" label=\"roof system\", # label\n",
" description=\"installed peak power\", # long description\n",
" unit=\"kWp\", # unit\n",
" group=\"intallation\", # (optional) to class your parameters in group\n",
" default=1500, # default value\n",
" min=3, # min value\n",
" max=300, # max value \n",
" distrib=agb.DistributionType.TRIANGLE) # (optional) statistic distribution of the parameter\n",
"\n",
"# Note: statistic distribution of the parameter can be : agb.DistributionType.NORMAL or .TRIANGLE or .LINEAR or.LOGNORMAL\n",
"# if \"distrib\" is empty, a uniform distribution will be chosen by default \n",
"# https://oie-mines-paristech.github.io/lca_algebraic/doc/params.html#lca_algebraic.params.DistributionType\n",
"\n",
"# ignore the warning"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "889df90a",
"metadata": {},
"outputs": [],
"source": [
"# Bool parameters definition > newBoolParam\n",
"\n",
"# Example: Bool parameter that defines the installation type \n",
"# 1 = on roof / installation sur toit\n",
"# 0 = on soil / installation au sol\n",
"\n",
"on_roof=agb.newBoolParam(\n",
" name=\"on_roof\", # short name\n",
" label=\"mounting system\", # long label\n",
" description=\"mounting system roof (on_roof=1) or ground mounting system (on_roof=0)\", # long description\n",
" group=\"installation\", # (optional) to class your parameters in group\n",
" default=1 # default value\n",
" ) \n",
"\n",
"#We can define a variable that is a function of the lca_algebraic boolean parameter we have just created\n",
"on_ground = (1-on_roof)\n",
"\n",
"#ignore the warning"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b1a7b07",
"metadata": {},
"outputs": [],
"source": [
"# Definition of parameters that can select several exclusive choice > function newEnumParam*\n",
"\n",
"# Example : electric mixes\n",
"# This parameter defines 5 boolean parameters\n",
"\n",
"elec_mix_country=agb.newEnumParam( \n",
" \"elec_mix_country\", # Short name\n",
" label=\"electricial mix\", # label\n",
" description=\"country chosen for the electricity mix\", # Long description \n",
" group=\"manufacturing\", # (optional) to class your parameters in group\n",
" values =[ # Statistic weight of each option that fits with the market\n",
" \"senegal\",\n",
" \"france\",\n",
" \"italy\",\n",
" \"germany\"\n",
" ],\n",
" default=\"senegal\") # the default value is a string\n",
"\n",
"# Ignore the warning\n",
"\n",
"# If you used advanced functionalities of lca_algebraic, you can add statistic weight of each option by creating a dictionary\n",
"# values ={\"france\": 2.4,\"germany\": 7.4,\"italy\": 71.4,\"senegal\": 5.7}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "041231e5",
"metadata": {},
"outputs": [],
"source": [
"# Definition of an other float parameter\n",
"# note : nothing new compared with the first float parameter\n",
"# we just need to define it to run the model later\n",
"\n",
"# Module efficacity, kWp/m2\n",
"efficacite_module = agb.newFloatParam(\n",
" \"efficacite_module\",\n",
" distrib=agb.DistributionType.TRIANGLE, # Distribution triangulaire, privilégiant la valeur par défaut\n",
" default=0.175, min=0.15, max=0.22,\n",
" group=\"installation\",\n",
" label_fr=\"efficacité module\",\n",
" description=\"efficacité du module par surface installée\",\n",
" unit=\"kWp/m²\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cdb54e3e",
"metadata": {},
"outputs": [],
"source": [
"# Print the list of the parameters\n",
"agb.list_parameters()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d12605c",
"metadata": {},
"outputs": [],
"source": [
"#Warning\n",
"#When you define a lca_algebraic parameter, the name of the parameter has to be the same as the name of the variable\n",
"\n",
"#Test if the name of parameters are the same as the name of the variable\n",
"for name, var in list(globals().items()):\n",
" if isinstance(var, agb.ParamDef) and var.name != name :\n",
" print(\"Warning : param name is different for var name : %s <> %s\" % (var.name, name))"
]
},
{
"cell_type": "markdown",
"id": "832d4bd6",
"metadata": {},
"source": [
"# Parameters and variables values printing"
]
},
{
"cell_type": "markdown",
"id": "027f011b",
"metadata": {},
"source": [
"## lca_algebraic parameters with default value"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "495776ba",
"metadata": {},
"outputs": [],
"source": [
"#If you print an lca_algebraic parameter, its name is prnted but not its value\n",
"power_capacity"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4ec3408",
"metadata": {},
"outputs": [],
"source": [
"#Print the name, default value and unit of one parameter\n",
"(power_capacity.name, power_capacity.default, power_capacity.unit)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "053a24e8",
"metadata": {},
"outputs": [],
"source": [
"#Print the informations about parameters in one table with the function agb.list_parameters()\n",
"agb.list_parameters()"
]
},
{
"cell_type": "markdown",
"id": "0368b562",
"metadata": {},
"source": [
"## python variables that are functions of lca_algebraic parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "66c2c39d",
"metadata": {},
"outputs": [],
"source": [
"#If you print the python variable surface, its expression (function of lca_algebrauic parameters) is printed \n",
"surface = power_capacity / efficacite_module\n",
"surface"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a44562f",
"metadata": {},
"outputs": [],
"source": [
"#To get its value with default parameters value : \n",
"agb.compute_value(surface)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "18c3f8e5",
"metadata": {},
"outputs": [],
"source": [
"#To get its value with chosen parameters value (if you do not put a parameter value, the default one will be used for the calculation) : \n",
"agb.compute_value(\n",
" surface,\n",
" #power_capacity=1000,\n",
" efficacite_module=0.2)"
]
},
{
"cell_type": "markdown",
"id": "6f7d9282",
"metadata": {},
"source": [
"# Activities of the inventory"
]
},
{
"cell_type": "markdown",
"id": "1d87c316",
"metadata": {},
"source": [
"## Explain "
]
},
{
"cell_type": "markdown",
"id": "e861f168",
"metadata": {},
"source": [
"There are 3 main databases : \n",
"* The **biosphere database** that contains all the flows from and to the biosphere\n",
"* The **background reference database**: the modelised inventory is built with activities taken from the reference database for background. In this notebook, the reference database is ecoinvent. \n",
"* The **model database** : the modelised inventory is set up in the database 'USER_DB' that is independant of the reference database, so that the reference database is not modified.\n",
"\n",
"In the following part, the terms \"flow\" and \"activity\" have the same meaning. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "537dcf7f",
"metadata": {},
"outputs": [],
"source": [
"# The database that have been set up are :\n",
"bw.databases"
]
},
{
"cell_type": "markdown",
"id": "b52d2447",
"metadata": {},
"source": [
"## Find activities in the reference database"
]
},
{
"cell_type": "markdown",
"id": "4c01b38c",
"metadata": {},
"source": [
"### Activities in the biosphere"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58ac275d",
"metadata": {},
"outputs": [],
"source": [
"# Define a biosphere flow \n",
"# To do : update the right termonology to find the right activity and update the activity_name\n",
"water_in_air = agb.findBioAct(\"Water, in air\")\n",
"\n",
"# Print this activity with the function agb.printAct\n",
"#To do : update the name of the activity\n",
"agb.printAct(water_in_air)"
]
},
{
"cell_type": "markdown",
"id": "b6d230aa",
"metadata": {},
"source": [
"#### Explain : How to find activities related to **biosphere** in the reference database ?µ"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58638541",
"metadata": {},
"outputs": [],
"source": [
"# Find activities in biosphere based on keyword with agb.findBioAct\n",
"# To do : update the keyword\n",
"\n",
"# Warning 1: put \"*\" meaning it is not finished\n",
"# Warning 2 : the flow name starts with a Capital letter\n",
"# Warning 3 : let \"single=False\" so that the list is printed\n",
"\n",
"agb.findBioAct(\"Water*\", single=False)\n",
"\n",
"#Note : These activities can also be easily searched based on keywords with activity-browser in 'Project / Activities section'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "faef12c2",
"metadata": {},
"outputs": [],
"source": [
"# Looking at the list printed above, pick the right name of the activity \n",
"# To do : update the name and delete \"single = false\"\n",
"# If there is no error, it means the activity is well identified\n",
"agb.findBioAct(\"Water, in air\")"
]
},
{
"cell_type": "markdown",
"id": "71a2a0a2",
"metadata": {},
"source": [
"### Activities in the technosphere"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8f31075b",
"metadata": {},
"outputs": [],
"source": [
"# Define a technosphere flow \n",
"# To do : update the right termonology to find the right activity and update the activity_name\n",
"ground_mounting_system = agb.findTechAct('photovoltaic mounting system production, for 570kWp open ground module')\n",
"\n",
"# Print this activity with the function agb.printAct(name_of_the_activity)\n",
"#To do : update the name of the activity\n",
"agb.printAct(ground_mounting_system)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "232d96dc",
"metadata": {},
"outputs": [],
"source": [
"# Define another technosphere flow\n",
"# To do : if there are several activities in the database with the same name but not the same location, add the location as shown in this example\n",
"inverter = agb.findTechAct('inverter production, 0.5kW','RER')\n",
"pv_panel =agb.findTechAct(\"market for photovoltaic panel, multi-Si wafer\")"
]
},
{
"cell_type": "markdown",
"id": "09649d28",
"metadata": {},
"source": [
"#### Explain : How to find activities related to **technosphere** in the reference database ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a57d9049",
"metadata": {},
"outputs": [],
"source": [
"## Find activities in technosphere based on keyword with agb.findTechAct\n",
"# To do : update the keyword\n",
"\n",
"# Warning 1: put \"*\" meaning it is not finished\n",
"# Warning 2 : the flow name starts with a Capital letter\n",
"# Warning 3 : let \"single=False\" so that the list is printed\n",
"\n",
"agb.findTechAct(\"mounting system*\",single=False)\n",
"\n",
"#Note : These activities can also be easily searched based on keywords with activity-browser in 'Project / Activities section'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c106bfe2",
"metadata": {},
"outputs": [],
"source": [
"# Looking at the list printed above, pick the right name of the activity \n",
"# To do : update the name and delete \"single = false\"\n",
"# If there is no error, it means the activity is well identified\n",
"agb.findTechAct('photovoltaic mounting system production, for 570kWp open ground module',\"GLO\", single=False)"
]
},
{
"cell_type": "markdown",
"id": "f9ba7c84",
"metadata": {},
"source": [
"#### Warning : If there is more than one technosphere background database, use findActivity "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2c224f7",
"metadata": {},
"outputs": [],
"source": [
"#Similar as function agb.findTechAct + specify the database name\n",
"steel= agb.findActivity('market for steel, low-alloyed',db_name='ecoinvent-3.8-cutoff')\n",
"aluminium=agb.findActivity('market for copper, cathode', db_name='ecoinvent-3.8-cutoff')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0c3e6ba0",
"metadata": {},
"outputs": [],
"source": [
"#Redatabases: to print database names\n",
"bw.databases"
]
},
{
"cell_type": "markdown",
"id": "b1942a0a",
"metadata": {},
"source": [
"## Parameterized inventory"
]
},
{
"cell_type": "markdown",
"id": "5cfc4ff0",
"metadata": {},
"source": [
"While doing the LCA of a new system, there are two main options to modelise the system : \n",
"* Either **modify an existing activity**\n",
"* Either **create a new activity** and add all the flows with corresponding quantities\n",
"\n",
"\n",
"For both options, you can define the quantity as a mathematic formula of a parameter that have been defined above, to obtain a **parameterized inventory** "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a074c6ad",
"metadata": {},
"outputs": [],
"source": [
"#Remind : to print the list of parameters defined above, run this cell \n",
"agb.list_parameters()"
]
},
{
"cell_type": "markdown",
"id": "983612f1",
"metadata": {},
"source": [
"## Create a new activity "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f38cfdf3",
"metadata": {},
"outputs": [],
"source": [
"# Create a new activity with the function agb.newActivity\n",
"new_activity = agb.newActivity(\n",
" db_name=NAME_USER_DB, # Database where the new activity is created\n",
" name=\"new activity name \", # Activity name \n",
" unit=\"unit\", # Unit\n",
" exchanges = {\n",
" ground_mounting_system : 1, #add flows and amount \n",
" inverter: 2 #add flows and amount \n",
" }\n",
" )\n",
" \n",
"#Print the activity that you have just created\n",
"agb.printAct(new_activity)"
]
},
{
"cell_type": "markdown",
"id": "a1b20029",
"metadata": {},
"source": [
"## Modify an existing activity"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a9ba6f67",
"metadata": {},
"outputs": [],
"source": [
"#If it is an activity from the reference database, \n",
"# First copy the activity that will be modified with the function agb.copyActivity\n",
"# and to do all the modification in the user database\n",
"#otherwise you will modify ecoinvent database !\n",
"\n",
"#To do : update the name of the original and copied activities and the name of the copied activities\n",
"\n",
"modified_mounting_system = agb.copyActivity(\n",
" db_name=NAME_USER_DB, # Database where the new activity is copied\n",
" activity = ground_mounting_system, # initial activity\n",
" code = \"mounting system adjusted\") # new name\n",
"\n",
"#Print the copied activity that is for now not yet modified\n",
"agb.printAct(modified_mounting_system)"
]
},
{
"cell_type": "markdown",
"id": "120380da",
"metadata": {},
"source": [
"There are 4 main ways of modifying an existing activity :\n",
"* **change the value of a flow of this activity** (with another number or with a mathematic formula)\n",
"\n",
"*example : technology development enables to reduce a quantity of a material.* \n",
"\n",
"* **change a flow by another flow** : the new flow is either another flow of the background database or a flow that has been specifically created.\n",
"\n",
"*example : if I want to change the electric mix by antoher one.* \n",
"\n",
"* **add a new flow**\n",
"\n",
"*example : there is a new material used in a new technology.* \n",
"\n",
"* **delete an existing flow**\n",
"\n",
"*example : if I have a photovoltaic installation on a roof (and not on the soil), I want to delete the concrete flow in the mounting system activity.* "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c47f5a4",
"metadata": {},
"outputs": [],
"source": [
"# 1. change the value of a flow of this activity (with another number or with a mathematic formula) with the function updateExchanges\n",
"modified_mounting_system.updateExchanges({ \n",
" 'zinc coat, coils' : 0.11 * on_ground, \n",
" 'reinforcing steel' : 7.25*0.8})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "071bcfd9",
"metadata": {},
"outputs": [],
"source": [
"# 2. change a flow by another flow with the function updateExchanges\n",
"\n",
"#define the new flow you want to introduce instead of another flow and name it\n",
"other_concrete=agb.findTechAct('market for concrete, sole plate and foundation')\n",
"\n",
"#change the initial flow in the inventory with the new flow \n",
"modified_mounting_system.updateExchanges({ \n",
" 'concrete, normal' : other_concrete}) #'name of the modified flow' : name of the new flow"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "af076562",
"metadata": {},
"outputs": [],
"source": [
"# 3. Add a new flow with the function addExchanges\n",
"\n",
"#find the flow you want to add with agb.findTechAct and name it\n",
"steel_2= agb.findTechAct('market for steel, low-alloyed, hot rolled')\n",
"\n",
"#add it to the inventory with the function addExchanges \n",
"modified_mounting_system.addExchanges({\n",
" steel_2: 7.25*0.2 })"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eaf93100",
"metadata": {},
"outputs": [],
"source": [
"# 4. Delete an existing flow with the function updateExchanges\n",
"modified_mounting_system.updateExchanges({ \n",
" 'polyethylene, high density, granulate' : None})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5f330fc8",
"metadata": {},
"outputs": [],
"source": [
"# Print the differences between the original activity and the modified activity with the function agb.printAct\n",
"agb.printAct(ground_mounting_system, modified_mounting_system)\n",
"\n",
"# Note : The modifications appear in YELLOW ! \n",
"# Note : the mathematic formula with parameters are not calculated with default values > the mathematic formula are printed"
]
},
{
"cell_type": "markdown",
"id": "eb00bb75",
"metadata": {},
"source": [
"## Switching activity / enum parameter\n",
"If you want to use an enum parameter to switch from an activity to another"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "254e1839",
"metadata": {},
"outputs": [],
"source": [
"senegalese_elec_mix=agb.findTechAct('market for electricity, high voltage','SN')\n",
"french_elec_mix=agb.findTechAct('market for electricity, high voltage','FR')\n",
"german_elec_mix=agb.findTechAct('market for electricity, high voltage','DE')\n",
"italian_elec_mix=agb.findTechAct('market for electricity, high voltage','IT')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8db4911f",
"metadata": {},
"outputs": [],
"source": [
"elec_mix = agb.newSwitchAct(\n",
" NAME_USER_DB, # Database where the new activity is created\n",
" \"electricity mix\", \n",
" elec_mix_country, #enum parameter that is used to switch the activity\n",
" {\n",
" \"senegal\":senegalese_elec_mix,\n",
" \"france\": french_elec_mix,\n",
" \"germany\": german_elec_mix,\n",
" \"italy\": italian_elec_mix,\n",
" })\n"
]
},
{
"cell_type": "markdown",
"id": "e5c47038",
"metadata": {},
"source": [
"# Inventory of the system\n",
"Gather all the activities of the system in an inventory (called \"system\") that will represent our whole system. "
]
},
{
"cell_type": "markdown",
"id": "3db07c4c",
"metadata": {},
"source": [
"## System inventory"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8586e31e",
"metadata": {},
"outputs": [],
"source": [
"# Create a new activity for the full system with the function agb.newActivity\n",
"system = agb.newActivity(\n",
" db_name=NAME_USER_DB, # Database where we load the new activity\n",
" name=\"full system\", # System name \n",
" unit=\"unit\") # Unit\n",
"\n",
"# If need, intermediate variables can be introduced\n",
"volume_steel_m3=0.03\n",
"mass_steel_kg=STEEL_DENSITY*volume_steel_m3\n",
"\n",
"# Add new flows and corresponding quantity with the function addExchanges\n",
"system.addExchanges({\n",
" modified_mounting_system : surface,\n",
" pv_panel : surface,\n",
" inverter: power_capacity/0.5,\n",
" steel_2:mass_steel_kg,\n",
" elec_mix:1000,\n",
" \n",
"})\n",
"\n",
"# Print the inventory of the modelised system\n",
"agb.printAct(system)"
]
},
{
"cell_type": "markdown",
"id": "0a816b7f",
"metadata": {},
"source": [
"# Impacts calculation\n",
"Most of the impacts calculations are performed with the functions agb.compute_impacts. If you need more information about a function, you can use '?' or help as shown below\n",
"?agb.resetDb"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5bbf8566",
"metadata": {},
"outputs": [],
"source": [
"agb.compute_impacts?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "69561cab",
"metadata": {},
"outputs": [],
"source": [
"help(agb.compute_impacts)"
]
},
{
"cell_type": "markdown",
"id": "56ab024b",
"metadata": {},
"source": [
"## How to calculate impacts of one activity ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e82936a6",
"metadata": {},
"outputs": [],
"source": [
"# Calculate the impacts of the system modelised with the function agb.multiLCAAlgebric\n",
"# The calculation is done with the selected LCIA_methods for the selected impact categories\n",
"\n",
"agb.compute_impacts(\n",
" system, # activity whose impacts are calculated\n",
" impacts) # list of selected impacts\n",
"\n",
"# If there is no specific value for parameters, default values are automatically chosen"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b0ea9511",
"metadata": {},
"outputs": [],
"source": [
"#You can also print in a second sheet : the default parameters value and chosen parameters value for the calculation \n",
"\n",
"agb.compute_impacts(\n",
" system, # activity whose impacts are calculated\n",
" impacts, # list of selected impacts \n",
" return_params=True) # To create the second sheet with parameters value\n"
]
},
{
"cell_type": "markdown",
"id": "6661b322",
"metadata": {},
"source": [
"## How to calculate impacts of several activities ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "510cc195",
"metadata": {},
"outputs": [],
"source": [
"agb.compute_impacts(\n",
" [modified_mounting_system, inverter], # list [] of activities\n",
" impacts) # list of selected impacts\n",
"\n",
"# If there is no specific value for parameters, default values are automatically chosen"
]
},
{
"cell_type": "markdown",
"id": "ce01fa35",
"metadata": {},
"source": [
"## Parameter values change\n",
"These functionalities only work woth lca_algebraic parameters and not with python variables !"
]
},
{
"cell_type": "markdown",
"id": "7aad2feb",
"metadata": {},
"source": [
"### How to specify the value of some parameters to calculate the impacts of a specific set of parameters ? "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "849d7c13",
"metadata": {},
"outputs": [],
"source": [
"# idem + specify parameters values \n",
"agb.compute_impacts(\n",
" system, \n",
" impacts, \n",
" power_capacity = 50, # parameters value\n",
" on_roof=0, # boolen parameters value 0 or 1\n",
" elec_mix_country=\"italy\",\n",
" return_params=True, # To create the second sheet with parameters value\n",
" ) "
]
},
{
"cell_type": "markdown",
"id": "eeba271f",
"metadata": {},
"source": [
"### How to compare several values of one parameter ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e1df3559",
"metadata": {},
"outputs": [],
"source": [
"# idem + compare several values for one parameter\n",
"agb.compute_impacts(\n",
" system, \n",
" impacts, \n",
" power_capacity = [50,100,200],\n",
" #return_params=True, # optional : To create the second sheet with parameters value\n",
") "
]
},
{
"cell_type": "markdown",
"id": "aed2ec57",
"metadata": {},
"source": [
"### How to compare several set of values of several parameter ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ede6500b",
"metadata": {},
"outputs": [],
"source": [
"# idem + compare several values for 2 or more parameter\n",
"# Warning : either you put one value for a given parameter, either you put a list of parameters values that shall have the same length for each parameters\n",
"\n",
"agb.compute_impacts(\n",
" system, \n",
" impacts, \n",
" power_capacity = [50,100,200],\n",
" on_roof=0,\n",
" elec_mix_country=[\"italy\",\"senegal\",\"france\"],\n",
" #return_params=True, # optional : To create the second sheet with parameters value\n",
"\n",
") "
]
},
{
"cell_type": "markdown",
"id": "690487fb",
"metadata": {},
"source": [
"## How to change the functional unit ?"
]
},
{
"cell_type": "markdown",
"id": "0201b194",
"metadata": {},
"source": [
"### Option 1: Create a new activity for the normalised system and calculate its impacts"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e5f1f89",
"metadata": {},
"outputs": [],
"source": [
"system_normalised_kWp = agb.newActivity(\n",
" NAME_USER_DB, # Database where we load the new activity\n",
" \"impact per kWp installed\", # normalised system name\n",
" \"unit\", # Unit \n",
" exchanges={system: 1 / power_capacity}) #divide the inventory of the system by the normalisation factor"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f7dcc79",
"metadata": {},
"outputs": [],
"source": [
"agb.compute_impacts(\n",
" system_normalised_kWp, \n",
" impacts,\n",
") "
]
},
{
"cell_type": "markdown",
"id": "0780337c",
"metadata": {},
"source": [
"### Option 2 : use the functional_unit option in agb.compute_impacts "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "59733879",
"metadata": {},
"outputs": [],
"source": [
"agb.compute_impacts(\n",
" system, \n",
" impacts,\n",
" functional_unit=power_capacity #The impacts of the mentionned activity will be divided by this amount\n",
")"
]
},
{
"cell_type": "markdown",
"id": "5ab9a43c",
"metadata": {},
"source": [
"## How display the impact per subactivities ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0dafd516",
"metadata": {},
"outputs": [],
"source": [
"#Displays all exchanges of one or several activities and their impacts.\n",
"#Warning, in this case, the first argument is the impact category and not the activity\n",
"agb.exploreImpacts(\n",
" climate, #impact category \n",
" system, #name of the activity\n",
" power_capacity = 1300 #optional : change the parameter value\n",
" )"
]
},
{
"cell_type": "markdown",
"id": "dd4f8b93",
"metadata": {},
"source": [
"## Axis functionnality\n",
"Divide your system in axis/subcategories to calculate the contribution of each subcategories to the impacts. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "77b1ea8f",
"metadata": {},
"outputs": [],
"source": [
"#Axis : subsystem with two subcategories\n",
"BOP=\"balance of plant\"\n",
"PV=\"PV panels\"\n",
"#Axis: stage (life cycle stage) with two subcategories\n",
"MANUFACTURING = \"phase 1 = manufacturing\"\n",
"OPERATION = \"phase 2 = operation and maintenance\""
]
},
{
"cell_type": "markdown",
"id": "c3c3eda6",
"metadata": {},
"source": [
"### Manufacturing stage for PV + BOP"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2384c28",
"metadata": {},
"outputs": [],
"source": [
"#When creating the activity, you flag the chosen axis (The axis can be named as you want)\n",
"\n",
"#Activity to model the manufacturing of the balance of plant\n",
"balance_of_plant_manufacturing = agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the balance of plant\", \n",
" unit=\"unit\", \n",
" subsystem=BOP, #axis subsystem\n",
" stage=MANUFACTURING,#axis stage\n",
" exchanges={\n",
" modified_mounting_system : surface, \n",
" inverter: power_capacity/0.5 \n",
" })\n",
"\n",
"#Activity to model the manufacturing of pv panel\n",
"pv_panel_manufacturing=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the pv panel\", \n",
" unit=\"unit\", \n",
" subsystem=PV, #axis subsystem\n",
" stage=MANUFACTURING, #axis stage\n",
" exchanges={\n",
" pv_panel: surface, \n",
" })\n",
"\n",
"#Activity to model the manufacturing of the whole system\n",
"system_manufacturing=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the system\", \n",
" unit=\"unit\", \n",
" #no need to put the axis name as it is associated with the chosen acitivites as it is done for the subactivities\n",
" exchanges={\n",
" balance_of_plant_manufacturing: 1, \n",
" pv_panel_manufacturing: 1, \n",
" })"
]
},
{
"cell_type": "markdown",
"id": "7f4631d0",
"metadata": {},
"source": [
"### Operantion and maintenance stage for PV + BOP"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4128d1ad",
"metadata": {},
"outputs": [],
"source": [
"#When creating the activity, you flag the chosen axis (The axis can be named as you want)\n",
"\n",
"#Activity to model the operation and maintenance of the balance of plant\n",
"balance_of_plant_operation = agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"operation and maintenance of the balance of plant\", \n",
" unit=\"unit\", \n",
" subsystem=BOP, #axis subsystem\n",
" stage=OPERATION, #axis stage\n",
" exchanges={\n",
" elec_mix : 1000\n",
" })\n",
"\n",
"#Activity to model the operation and maintenance of pv panel\n",
"pv_panel_operation = agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"operation and maintenance of the pv panels\", \n",
" unit=\"unit\", \n",
" exchanges={\n",
" elec_mix : 5000\n",
" })\n",
"\n",
"#If the activity is already created, you can add the flags as shown below. Do not forget to save !!\n",
"pv_panel_operation[\"subsystem\"]=PV\n",
"pv_panel_operation.save()\n",
"\n",
"pv_panel_operation[\"stage\"]=OPERATION\n",
"pv_panel_operation.save()\n",
"\n",
"#Activity to model the operation and maintenance of the whole system\n",
"system_operation=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"operation and maintenance of the system\", \n",
" unit=\"unit\", \n",
" #no need to put the axis name as it is associated with the chosen acitivites\n",
" exchanges={\n",
" balance_of_plant_operation: 1, \n",
" pv_panel_operation: 1, \n",
" })"
]
},
{
"cell_type": "markdown",
"id": "e8f2dbce",
"metadata": {},
"source": [
"### Impacts of full system per axis"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "32ddab43",
"metadata": {},
"outputs": [],
"source": [
"#Activity to model the whole system\n",
"system_full=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"full system for axis function\", \n",
" unit=\"unit\", \n",
" exchanges={\n",
" system_manufacturing: 1, \n",
" system_operation: 1, \n",
" })"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b26f0541",
"metadata": {},
"outputs": [],
"source": [
"agb.compute_impacts(\n",
" system_full,\n",
" impacts,\n",
" #functional_unit=power_capacity,\n",
" #axis=\"subsystem\",)\n",
" axis=\"stage\")\n",
" "
]
},
{
"cell_type": "markdown",
"id": "a992202e",
"metadata": {},
"source": [
"### Advices for a correct use of axis functionalities "
]
},
{
"cell_type": "markdown",
"id": "1da6d901",
"metadata": {},
"source": [
"* You can add as much axis as you want and name them as you want. \n",
"* If the line _ other _ is not equal to zero, it means that you forgot to flag part of your modeled system. \n",
"* **Warning** If you flag an inventory for a given axis (subsytem=\"pv panel\"), you can not flag an inventory that uses this inventory with another for this given axis. Otherwise you will get an issue while computing the impacts as shown in the example below. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e63ac113",
"metadata": {},
"outputs": [],
"source": [
"#Axis subsystem=BOP\n",
"balance_of_plant_manufacturing_2 = agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the balance of plant\", \n",
" unit=\"unit\", \n",
" subsystem=BOP, #axis subsystem\n",
" stage=MANUFACTURING, #axis stage\n",
" exchanges={\n",
" modified_mounting_system : surface, \n",
" inverter: power_capacity/0.5 \n",
" })\n",
"\n",
"#Axis subsystem=PV\n",
"pv_panel_manufacturing_2=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the pv panel\", \n",
" unit=\"unit\", \n",
" subsystem=PV, #axis subsystem\n",
" stage=MANUFACTURING, #axis stage\n",
" exchanges={\n",
" pv_panel: surface, \n",
" })\n",
"\n",
"\n",
"#Axis subsystem=\"full system\"\n",
"system_manufacturing_2=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the system\", \n",
" unit=\"unit\", \n",
" exchanges={\n",
" balance_of_plant_manufacturing: 1, \n",
" pv_panel_manufacturing: 1, \n",
" })\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "986fdec8",
"metadata": {},
"outputs": [],
"source": [
"#You get an error when computing the impacts as their is a flag conflict \n",
"agb.compute_impacts(\n",
" system_manufacturing_2,\n",
" impacts,\n",
" axis=\"subsystem\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "31772381",
"metadata": {
"lines_to_next_cell": 0
},
"outputs": [],
"source": [
"system_manufacturing_3=agb.newActivity(\n",
" db_name=NAME_USER_DB, \n",
" name=\"manufacturing of the system\", \n",
" unit=\"unit\", \n",
" other_axis_name=\"plant\", \n",
" exchanges={\n",
" balance_of_plant_manufacturing: 1, \n",
" pv_panel_manufacturing: 1, \n",
" })\n",
"\n",
"agb.compute_impacts(\n",
" system_manufacturing_3,\n",
" impacts,\n",
" axis=\"subsystem\")"
]
},
{
"cell_type": "markdown",
"id": "6b1398db",
"metadata": {},
"source": [
"\n"
]
},
{
"cell_type": "markdown",
"id": "4671130e",
"metadata": {},
"source": [
"# Export Excel"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c1f51536",
"metadata": {},
"outputs": [],
"source": [
"# Export excel of results\n",
"\n",
"df = agb.compute_impacts(\n",
" [system, modified_mounting_system],\n",
" impacts,\n",
" functional_unit=power_capacity))\n",
"\n",
"df.to_excel(\"data/impact_test.xlsx\")\n",
"df #To print it in Jupyter"
]
}
],
"metadata": {
"jupytext": {
"formats": "md,Rmd,ipynb"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}