t_rex_lca

A program for Life Cycle Assessment (LCA) calculations of supply chain waste and material footprints

https://github.com/stew-mcd/t-rex

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary

Keywords

critical-raw-materials footprint lca materials sustainability waste
Last synced: 6 months ago · JSON representation ·

Repository

A program for Life Cycle Assessment (LCA) calculations of supply chain waste and material footprints

Basic Info
Statistics
  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 6
Topics
critical-raw-materials footprint lca materials sustainability waste
Created over 2 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

T-reX: waste and material footprinting in LCA

DOI

Formerly known as "WasteAndMaterialFootprint"

T stands for tool and reX for the circular economy strategies reduce, reuse, recycle, etc.

A python program for Life Cycle Assessment (LCA) calculations of supply chain waste and material footprints in current and prospective databases.

Built as an extension to the brightway LCA ecosystem, using premise for the generation of future scenario databases and wurst for database expansion.

A paper introducing T-reX has been published (2025-06-11) by the journal Resources, Conservation and Recycling. The manuscript has its own github repo here. Reviews and comments are very welcome.

Email: T-reX@scmcd.ch

T-reX logo

Documentation

The documentation is available as a website. Also, as a pdf.

The documentation is still a work in progress, but the code is well commented and there is a full API reference.

The following readme provides a brief introduction to the program, how to install it, and how to use it.

See the example output here

Contents

Visual overview

Generalised and computational flowcharts

T-reX flowcharts

Installation

Dependencies

The program is written in Python and the required packages are listed in the requirements.txt file. These should be installed automatically when installing the program.

The main dependencies are:

Installation instructions

It is recommended to use a fresh virtual environment to install the program.

For example:

```bash conda -m T-reX_env python=3.11

OR

python -m venv T-reX_env

source T-reX/bin/activate

```

You can then clone the repo whereever you want it with the command:

bash git clone https://github.com/Stew-McD/T-reX.git

The easiest way is to install the program as an editable package. This will install the program and all of the dependencies, and allow you to easily edit the code and the configuration and run it without having to reinstall it.

bash cd T-reX pip install -e .

and then run:

bash cd T-reX python src/T-reX/main.py

If you only clone or download the repo without installing it, this will not install any of the dependencies, so you will need to install them manually if you don't already have them.

You can do that with this command:

bash pip install -r requirements.txt

Another option: the program can be installed using pip:

bash pip install T_reX_LCA

Or, if you want to install the latest version from GitHub:

bash pip install git+https://github.com/Stew-McD/T-reX.git

or for an editable install from GitHub:

bash git clone https://github.com/Stew-McD/T-reX.git cd T-reX pip install -e .

Usage

The program can be used directly from the command line, or imported as a Python module. This will run the program with the default settings.

Command line

You should clone the repo, navigate to the T-reX folder, and then run the program using:

bash python src/T-reX/main.py

Python module

The program can be imported as a Python module:

python import T_reX_LCA as TreX TreX.run()

Configuration

You can find the configuration files in the config folder (src/T-reX/config). Or if you install it with pip, you can find the config folder in the site-packages/T-reX/config folder of your Python venv installation.

If you have installed via pip, or want to have things separate, you can create a new folder somewhere and then run some built-in functions to create and reload the config files.

python import T_reX_LCA as TreX TreX.create_config()

This will create a folder config in the current working directory containing the default configuration files (see below).

You can then edit these files with some kind of text editor, and run:

python TreX.reload_config()

Note that you will need to close the Python session and start a new one to reload the config files.

If you want to revert to the default config files, you can run:

python TreX.reset_config()

And then close and restart the Python session.

If you are running the program as an editable package, you can edit the config files directly in the src/T-reX/config folder.

Details of the configuration files are given below.

General settings: user_settings.py

This is the main configuration file, the one that you might want to edit to match your project structure and your needs. By default, the program will take a brightway2 project named default and copy that to a new project named SSP-cutoff, which is then copied to a new project named T_reXootprint-SSP-cutoff.

Doing it this way isolates the components and allows you to keep your original brightway2 project as it was. If space is an issue, you can set all of the project names to be the same.

If you are happy with the default settings, you can just run the program and it will create the databases for you. If you want to change the settings, you can edit the user_settings.py file that you can find in the config directory of your working directory.

These are some extracts from user_settings.py with the most important settings (the ones you might want to change) and their default values:

```python

# Choose whether to use premise to create future scenario databases
use_premise = True
# Choose whether to use T-reX to edit the databases (you could also turn this off and just use the package as an easy way to make a set of future scenario databases)
use_T_reX = True

# Choose the names of the projects to use
project_premise_base = "default"
project_premise = "SSP-cutoff"
project_base = project_premise
project_T_reX = f"T-reX-{project_base}"

# Choose the name of the database to use (needed for premise only, the T-reX tool will run all databases except the biospheres)
database_name = "ecoinvent-3.9.1-cutoff"

# if you want to use a fresh project
delete_existing_premise_project = False
delete_existing_T_reX_project = False

# Choose the premise scenarios to generate (see FutureScenarios.py for more details)
# Not all combinations are available, the code in FutureScenarios.py will filter out the scenarios that are not possible
# the default is to have an optimistic and a pessimistic scenario with SSP2 for 2030, 2065 and 2100

models = ["remind"]
ssps = ["SSP2"]
rcps = ["Base","PkBudg500"]
years = [2030,2065,2100,]

```

Waste search settings: queries_waste.py

This file sets up search parameters for different waste and material flow categories, crucial for the SearchWaste.py script. It leverages a .pickle file created by ExplodeDatabase.py.

  • Categories: Handles various categories like digestion, composting, incineration, recycling, landfill, etc.
  • Query Types: Two sets of queries are created:
    1. queries_kg for waste flows in kilograms.
    2. queries_m3 for waste flows in cubic meters.

Adjusting Search Terms

  • Search Keywords: Tweak the AND, OR, NOT lists to refine your search.
Category-Specific Changes
  • Adding Categories: You can add new categories to the names list.
  • Modifying Queries: Update the query parameters for each category based on your requirements.
Optimising Search Efficiency

You can choose to include or exclude whatever you want. For instance, "non-hazardous" is not included as it's derivable from other categories and slows down the process.

Validating Search Terms

Isolate the function of SearchWaste.py to validate your search terms. That means, turning off the other functions in `user_settings.py, or running the module directly

You can achieve this by setting the following in user_settings.py:

python use_premise = False do_search = True do_methods = False do_edit = False

Material Search Settings: queries_materials.py

The queries_materials module creates demand methods in the T-reX tool. It aligns with the EU CRM list 2023 and the ecoinvent database, incorporating additional strategic materials for comprehensive analysis. More can be easily added, as wished by the user.

This function uses the string tests startswith in SearchMaterial.py to identify activities beginning with the specified material name. This allows one to be more specific with the search terms (the , can be critical sometimes).

Structure and Customisation

Tuple Structure
  • First Part (Activity Name): Specifies the exact activity in the database (e.g., market for chromium).
  • Second Part (Material Category): Aggregates related activities under a common category (e.g., chromium), enhancing data processing efficiency.
Customisation Options
  • Add or Remove Materials: Adapt the tuple list by including new materials or removing irrelevant ones.
  • Refine Search Terms: Update material categories for a better fit with your database, ensuring precision in naming, especially with the use of commas.

Use the same logic as in `querieswaste.pyto test and refine your search terms. That is, onlyusesearch = True`

Usage Considerations

  • Material Quantity: The current list comprises over 40 materials. Modify this count to suit your project's scope.
  • Database Alignment: Check that the material names correspond with your specific database version, like ecoinvent v3.9.1.
Example Tuples
  • ("market for chromium", "chromium")
  • ("market for coal", "coal")
  • ("market for cobalt", "cobalt")
  • ("market for coke", "coke")
  • ("market for copper", "copper")
  • ("market for tap water", "water")
  • ("market for water,", "water")

Examples

The examples folder contains some example scripts that show how to use the program and the kind of results you can get.

There is a basic case study about batteries in there.

Contributing

Contributions are very welcome! Test the code, report bugs, suggest features, etc. If you want to contribute code, please fork the repo and make a pull request.

See the CONTRIBUTING.md file for more details.

License

T-reX by Stewart Charles McDowall is marked with CC0 1.0 Universal, do whatever you want with it. - see the LICENSE file for details

Citation

If you use this code, please cite it as described in the CITATION.cff file (see the sidebar on the right).

When the paper is published, a citation for that will be added to the CITATION file.

Owner

  • Name: Stew
  • Login: Stew-McD
  • Kind: user
  • Location: under the sea
  • Company: @CMLPlatform

Environmental impact assessments and things like that with ex-ante LCA. PhD candidate at CML - Uni Leiden, NL.

Citation (CITATION.cff)

cff-version: 0.2.2
message: "If you use this software, please cite it as below."
authors:
- family-names: "McDowall"
  given-names: "Stewart Charles"
  orcid: "https://orcid.org/0000-0002-5688-1279"
- family-names: "Lanphear"
  given-names: "Elizabeth"
  orcid: "https://orcid.org/0009-0003-6364-0873"
title: "T-reX"
version: 0.2.2
doi: 10.5281/zenodo.10431180
date-released: 2024-04-02
url: "https://github.com/Stew-McD/T-reX"

# preferred-citation:
#   type: article
#   authors:
#   - family-names: "Lisa"
#     given-names: "Mona"
#     orcid: "https://orcid.org/0000-0000-0000-0000"
#   - family-names: "Bot"
#     given-names: "Hew"
#     orcid: "https://orcid.org/0000-0000-0000-0000"
#   doi: "10.0000/00000"
#   journal: "Journal Title"
#   month: 9
#   start: 1 # First page number
#   end: 10 # Last page number
#   title: "My awesome research software"
#   issue: 1
#   volume: 1
#   year: 2021

GitHub Events

Total
  • Release event: 1
  • Watch event: 1
  • Push event: 8
  • Create event: 1
Last Year
  • Release event: 1
  • Watch event: 1
  • Push event: 8
  • Create event: 1

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 15 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
pypi.org: t_rex_lca

A tool for analysing waste and material footprints in Life Cycle Assessment (LCA) databases

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 15 Last month
Rankings
Dependent packages count: 9.7%
Average: 37.0%
Dependent repos count: 64.2%
Maintainers (1)
Last synced: 6 months ago