GithubHelp home page GithubHelp logo

romainsacchi / carculator Goto Github PK

View Code? Open in Web Editor NEW
48.0 7.0 14.0 132.64 MB

Prospective environmental and economic life cycle assessment of vehicles made blazing fast.

Home Page: http://carculator.psi.ch

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

carculator's Introduction

carculator

DOI

Prospective environmental and economic life cycle assessment of vehicles made blazing fast.

A fully parameterized Python model developed by the Technology Assessment group of the Paul Scherrer Institut to perform life cycle assessments (LCA) of passenger cars and light-duty vehicles.

See the documentation for more detail, validation, etc.

See our examples notebook as well.

Table of Contents

Background

What is Life Cycle Assessment?

Life Cycle Assessment (LCA) is a systematic way of accounting for environmental impacts along the relevant phases of the life of a product or service. Typically, the LCA of a passenger vehicle includes the raw material extraction, the manufacture of the vehicle, its distribution, use and maintenance, as well as its disposal. The compiled inventories of material and energy required along the life cycle of the vehicle is characterized against some impact categories (e.g., climate change).

In the research field of mobility, LCA is widely used to investigate the superiority of a technology over another one.

Why carculator?

carculator allows to:

  • produce life cycle assessment (LCA) results that include conventional midpoint impact assessment indicators as well cost indicators
  • carculator uses time- and energy scenario-differentiated background inventories for the future, based on outputs of Integrated Asessment Model REMIND.
  • calculate hot pollutant and noise emissions based on a specified driving cycle
  • produce error propagation analyzes (i.e., Monte Carlo) while preserving relations between inputs and outputs
  • control all the parameters sensitive to the foreground model (i.e., the vehicles) but also to the background model (i.e., supply of fuel, battery chemistry, etc.)
  • and easily export the vehicle models as inventories to be further imported in the Brightway2 LCA framework or the SimaPro LCA software.

carculator integrates well with the Brightway LCA framework.

carculator was built based on work described in Uncertain environmental footprint of current and future battery electric vehicles by Cox, et al (2018).

Install

carculator is at an early stage of development and is subject to continuous change and improvement. Three ways of installing carculator are suggested.

We recommend the installation on Python 3.7 or above.

Installation of the latest version, using conda

conda install -c romainsacchi carculator

Installation of a stable release from Pypi

pip install carculator

Usage

As a Python library

Calculate the fuel efficiency (or Tank to wheel energy requirement) in km/L of petrol-equivalent of current SUVs for the driving cycle WLTC 3.4 over 800 Monte Carlo iterations:

    from carculator import *
    import matplotlib.pyplot as plt
    
    cip = CarInputParameters()
    cip.stochastic(800)
    dcts, array = fill_xarray_from_input_parameters(cip)
    cm = CarModel(array, cycle='WLTC 3.4')
    cm.set_all()
    TtW_energy = 1 / (cm.array.sel(size='SUV', year=2020, parameter='TtW energy') / 42000)  # assuming 42 MJ/L petrol
    
    l_powertrains = TtW_energy.powertrain
    [plt.hist(e, bins=50, alpha=.8, label=e.powertrain.values) for e in TtW_energy]
    plt.xlabel('km/L petrol-equivalent')
    plt.ylabel('number of iterations')
    plt.legend()

MC results

Compare the carbon footprint of electric vehicles with that of rechargeable hybrid vehicles for different size categories today and in the future over 500 Monte Carlo iterations:

    from carculator import *
    cip = CarInputParameters()
    cip.stochastic(500)
    dcts, array = fill_xarray_from_input_parameters(cip)
    cm = CarModel(array, cycle='WLTC')
    cm.set_all()
    scope = {
      'powertrain': ['BEV', 'PHEV'],
    }
    ic = InventoryCalculation(cm)
    
    results = ic.calculate_impacts()
    data_MC = results.sel(impact_category='climate change').sum(axis=3).to_dataframe('climate change')
    plt.style.use('seaborn')
    data_MC.unstack(level=[0, 1, 2]).boxplot(showfliers=False, figsize=(20, 5))
    plt.xticks(rotation=70)
    plt.ylabel('kg CO2-eq./vkm')

MC results

For more examples, see examples.

As a Web app

carculator has a graphical user interface for fast comparisons of vehicles.

Support

Do not hesitate to contact the development team at [email protected].

Maintainers

Contributing

See contributing.

License

BSD-3-Clause. Copyright 2023 Paul Scherrer Institut.

carculator's People

Contributors

a-sterni avatar cmutel avatar isolveit avatar romainsacchi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

carculator's Issues

Return type hint in EnergyConsumptionModel.motive_energy_per_km breaks python < 3.9

Current

Tests with python 3.7 and 3.8 don't pass because of:

...
../../../../miniconda3/envs/premise-dev/lib/python3.8/site-packages/carculator/energy_consumption.py:135: in EnergyConsumptionModel
) -> tuple[Union[float, Any], Any, Union[float, Any]]:
E   TypeError: 'type' object is not subscriptable
/opt/conda/envs/py37/lib/python3.7/site-packages/carculator/energy_consumption.py:135: in EnergyConsumptionModel
) -> tuple[Union[float, Any], Any, Union[float, Any]]:
E   TypeError: 'type' object is not subscriptable

Expected

The readme of the repo says carculator is compatible with python 3.7 and onwards. If this is still the case, a fix for this bug is necessary.

tank-to-wheel E consumption ICEV-p's

Hey,

I'm (starting to) exploring your rrreally cool LCA-modelling project (congratulations and thank you for developing this, this is what everybody needs!).

I don't know if this is the right place to ask these types of questions (I also tried on Twitter, but I have the impression that that medium is not the most frequently visited ;)), but:

On page 21 of your preprint, you mention that the tank-to-wheel E consumption of petrol fuelled ICEVs might decrease with 48 % by 2050 (180 gCO2/km -> 91 gCO2/km) due to decrease in curb mass (-8.5 %) and increase in powertrain and engine efficiency (+50%). I'm not sufficiently qualified in ICE combustion engine technology, but I was wondering on which paper/database/forecast this projection is based on (especially the powertrain/engine efficiency evolution) ? Intuitively, I would expect a rather constant engine efficiency, considering decades of ICE development. Or am I too naive and are carmakers only now starting to consider the fuel efficiency of their cars? :p

If you have time, I would be happy to get to know a bit more about this assumption, as I am intrigued by the forecast (at least for some countries) that in the long term ICEVs emission intensity might converge with those from BEV (as indicated in Figure 9 on p. 22 of the preprint):

Screenshot 2021-06-04 at 23 10 23

Need for improving values filling in xarray

99.7% of the time consumed by fill_xarray_from_input_parameters is spent on:

for param in cip:
    for size in cip.metadata[param]["sizes"]:
        for powertrain in cip.metadata[param]["powertrain"]:
            array[
                size_dict[size],
                powertrain_dict[powertrain],
                parameter_dict[cip.metadata[param]["name"]],
                year_dict[cip.metadata[param]["year"]],
                :,
            ] = cip.values[param]

remove pytest from dependencies

Current

Installing carculator with pip requires "pytest"

Expected

Installing carculator doesn't bring a testing dependency

Importing carculator database to Activity Browser

Hi there,

Currently, I am trying to import a Carculator excel file into Activity Browser (which runs on Brightway 2). However, when I try to import the excel file as a database, the whole AB environment shuts down. It might be that it's due to missing biosphere flows? @marc-vdm mentioned I could perhaps post the issue here. The reason I am trying to import the file is to get a relevant database to perform an LCA on EV technologies, as evoinvent does not include all EV related data.

What I did:

  • I picked the advanced configurator on the Carculator website.
  • I made two comparisons between electric and petrol vehicle for a 2022 and 2030 scenario.
  • I calculated the results and exported the inventory database to an excel file (and did not modify the file).
  • Then, I tried importing the file to the AB environment, however, then it shuts down and does not import the excel file.

A link to the excel file that I am trying to import to AB:
carculator_inventory_2022-04-13_for_ei_3.8_brightway2.xlsx

Do you know what I can do to fix this?

Thanks in advance!

Double defined parameters

86 parameters are defined twice in the file "default_parameters.json"

For example: ('Large', 'BEV', 'lightweighting', 2000) is defined here:

"355-2000-lightweighting": {

and here:

"1035-2000-lightweighting": {

The double-defined parameters cause the following problem in carculator 1.9.0.dev1 with carculator_utils 1.2.0.dev6:
Error

I have attached a file with all double defined parameters. Do you have a convenient way to remove the double defined parameters or is it necessary to remove them manually.
Double defined paramters.txt

quick results for Belgium seem way off for EVs

Hello

Impressive tool which can really be helpful!
I didn't do a dive in the data or code, but the quick results for Belgium (new cars), give only a 20% advantages for EVs compared to Diesel:
https://carculator.psi.ch/display_quick_results/BE

image

This would contradict other recent estimates like:
https://www.transportenvironment.org/what-we-do/electric-cars/how-clean-are-electric-cars
image

or:
https://www.carbonbrief.org/factcheck-how-electric-vehicles-help-to-tackle-climate-change

and also this tool:

https://climobil.connecting-project.lu/
image

[webtool feature idea] Grouping midpoint indicator graphs by year/car type/

An idea while exploring the graphs of the midpoint indicators in the webtool: it might be handy to be able to (maybe hiërarchically?) group the presented graph by either year, car size or car type, for easier comparison over time for a specific group/year/car size.

Is it possible to go through / contribute to the webtool graphs? I could not find (yet) a reference in the domentation or in this repository, but if it is possible, I might be interested to look at it. I have some experience with R, Javascript, Dash/Plotly and Highcharts, if any of those (or something similar) has been used.

Thanks again for your work!

Waste treatment for glider and engine

All activities "Car, …" (e.g., Car, diesel, Large, 2030, Euro-7) include “treatment of used glider” and “treatment of used internal combustion engine”. However, this waste treatment is already included in “glider production, passenger car” and in “internal combustion engine production, passenger car”. I would suggest to remove it from the activity "Car, …".
To be precise, you could consider "treatment of waste plastic" for the fuel tank and you could considered the reduced demand of “treatment of used glider” due to glider lightweighting directly in the activity "glider lightweighting".

Glider base masses

I was wondering if it wouldn't make sense to consider equal glider base masses for all powertrains because all powertrain specific masses are considered separately.

In particular, I was wondering about the following weights:

  • Large vehicle: PHEV-e weights 1650 kg all others 1550 kg
  • Mini vehicle: PHEV-e weights 810 kg all others 700 kg
  • Medium SUV: BEV and PHEV-e weight 1400 kg all others 1200 kg.
Weights

Better definition of annual mileage per year of age

Currently, it is assumed that the annual mileage is constant through time.
This assumption is quite important as it influences the lifetime-weighted electricity mix used to charge batteries or produce hydrogen.
But we know from data (for example here) that the annual mileage goes up after the first year of use, culminates between year 2 and 8 and slightly fades until the vehicle disposal.

It would be much better to adopt such distribution.

Override calculated parameters caused ValueError

Hi Romain,
While I played with the custom parameters, I encountered such error as shown below:

Bildschirmfoto 2021-02-04 um 10 04 09 AM

I tried to fix it by restarting terminal and it works but again when after I restart notebook, the error comes again.

It seems that I cannot override the parameters in array (6,1) as they do not match the other elements.
Any lead or tip would be appreciated. Sorry if the question is not relevant and technical.

Best regards,
Rena

ValueError: unsupported pickle protocol: 5

@romainsacchi
Good day Mr. Sacchi,
after installing the new version of carculator (1.8), unfortunately I get the value error "unsupported pickle protocol: 5" directly right after import carculator command.

The package from conda install -c romainsacchi carculator looks like has some version control problem, then I decided to install the package from PyPi but looks like the problem is still there.

I would appreciate any help regarding this issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.