Coder Social home page Coder Social logo

pybamm-tea's Introduction

PyBaMM-TEA-logo

PyBaMM-TEA

This repository contains the work of the "Google Summer of Code" project on a techno-economic analysis library for battery cells, which can be combined with PyBaMM's functionality. So far, there is a method to visualize mass- and volume- loadings of an electrode stack and to estimate energy densities without simulation. The project further aims to estimate cell metrics with simulations (e.g. a Ragone plot) and manufacturing metrics with a Process-based Cost Model.

Installation

We recommend installing within a virtual environment in order to not alter any python distribution files on your machine.

PyBaMM is available on GNU/Linux, MacOS and Windows. For more detailed instructions on how to install PyBaMM, see the PyBaMM documentation.

Linux/Mac OS

  1. Clone the repository using git
git clone https://github.com/pybamm-team/PyBaMM-TEA.git

or download (and extract) the ZIP file by clicking the green button on the top right of the page or use GitHub Desktop. 2. Change into the pybamm-tea directory

cd pybamm-tea
  1. Create a virtual environment
virtualenv env
  1. Activate the virtual environment
source env/bin/activate
  1. Install the package
pip install .

To install the project in editable mode use pip install -e .

Windows To install the package from the local project path on Windows use the following commands:

  1. Clone the repository using git
git clone https://github.com/pybamm-team/PyBaMM-TEA.git

or download (and extract) the ZIP file by clicking the green button on the top right of the page or use GitHub Desktop. 2. Change into the pybamm-tea directory

cd pybamm-tea
  1. Create a virtual environment
virtualenv env
  1. Activate the virtual environment
\path\to\env\Scripts\activate

where \path\to\env is the path to the environment created in step 3 (e.g. C:\Users\'Username'\env\Scripts\activate.bat). 5. Install the package

pip install .

To install the project in editable mode use pip install -e .

As an alternative, you can set up Windows Subsystem for Linux. This allows you to run a full Linux distribution within Windows.

Example usage

Create a script - e.g. to plot a mass- and volume-breakdown of an electrode stack - as below or as in the example notebook.

from pybamm_tea import TEA
import pybamm

# Load a base parameter set from PyBaMM
param_nco = pybamm.ParameterValues("Ecker2015")

# Provide additional input data for the TEA model
nco_input_data = {
    "Electrolyte density [kg.m-3]": 1276,  # EC:EMC
    "Negative electrode active material density [kg.m-3]": 2266,  # Graphite
    "Positive electrode active material density [kg.m-3]": 4750,  # NCO
}

# Create a TEA object, passing in the parameter set and input data
tea_nco = TEA(param_nco, nco_input_data)

# Plot a mass- and volume-loading breakdown for an electrode stack
tea_nco.plot_stack_breakdown()

# Print a dataframe with values of the mass- and volume-loading breakdown for an
# electrode stack
print(tea_nco.stack_breakdown_dataframe)

Documentation

API documentation for the pybamm_tea package can be built locally using Sphinx. To build the documentation first clone the repository, then run the following command:

sphinx-build docs docs/_build/html  

This will generate a number of html files in the docs/_build/html directory. To view the documentation, open the file docs/_build/html/index.html in a web browser, e.g. by running

open docs/_build/html/index.html

pybamm-tea's People

Contributors

julian-evers avatar rtimms avatar

Stargazers

Agriya Khetarpal avatar Tanner Leo avatar

Watchers

Martin Robinson avatar Valentin Sulzer avatar Scott Marquis avatar  avatar  avatar

pybamm-tea's Issues

Packaging

Add folders for source code, docs, and tests. Add .gitignore &pyproject.toml

For a simple example see the BPX repo
For a guide see here

Testing

Add tests and infrastructure

Dict of list instead of list of dicts to populate data frames

Doing

data = {"a": [1, 3], "b": [2, 4], "c": [3, 6]}
pd.DataFrame(data)

is equivalent to (and shorter than) doing

data = [{"a": 1, "b":2 , "c": 3}, {"a": 3, "b":5 , "c": 6}]
data = [{"a": 1, "b":2 , "c": 3}, {"a": 3, "b":5 , "c": 6}]

This can be used to clean up a bunch of code in TEA, e.g.

        stack_ed = self.stack_energy_densities
        data = [
            {
                "Parameter": "Volumetric energy density",
                "Unit": "Wh.L-1",
                "Value": stack_ed.get("Volumetric stack energy density [Wh.L-1]"),
            },
            {
                "Parameter": "Gravimetric energy density",
                "Unit": "Wh.kg-1",
                "Value": stack_ed.get("Gravimetric stack energy density [Wh.kg-1]"),
            },
            {
                "Parameter": "Stack average OCP",
                "Unit": "V",
                "Value": stack_ed.get("Stack average OCP [V]"),
            },
            {
                "Parameter": "Capacity",
                "Unit": "mA.h.cm-2",
                "Value": stack_ed.get("Capacity [mA.h.cm-2]"),
            },
            {
                "Parameter": "(Single-) stack thickness",
                "Unit": "um",
                "Value": 10**6 * stack_ed.get("Stack thickness [m]"),
            },
            {
                "Parameter": "Stack density",
                "Unit": "kg.L-1",
                "Value": 10**-3 * stack_ed.get("Stack density [kg.m-3]"),
            },
        ]
        # Create the DataFrame from the list of dictionaries
        df = pd.DataFrame(data)

could be much shorter and more readable.

Better testing

I think a more robust test would be to create a TEA class from some known parameters and then check all the calculations are correctly compared - then you will catch if anyone accidentally changes a calculation to give the incorrect result.

Set inputs in the class init

Set the inputs when you make an instance of the class instead of on the methods. This will ensure consistency across calculations.

Structure

Think about how to structure the code. Some suggestions to get started:

  • A class that does the calculations for a single parameter set (the TEA class)
  • A class that takes a list of parameter_values, loops over them and create a TEA class for each, does the relevant calculations and plots or displays some kind of summary.
  • Think about API for getting economic numbers into the workflow e.g. material prices

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.