Skip to main content

An implementation of the Battery Parameter eXchange (BPX) format in Pydantic.

Project description

🔋 BPX

tests codecov

An implementation of the Battery Parameter eXchange (BPX) format in Pydantic. BPX, an outcome of the Faraday Institution Multi-scale Modelling project, is an open standard for physics-based Li-ion battery models that has been developed to reduce costs and time-to-market through a common definition of physics-based battery models that can be used widely across industry. To find out more, visit the BPX website.

This repository features a Pydantic-based parser for JSON files in the BPX format, which validates your file against the schema.

To support the new open standard, About:Energy have supplied two parameter sets for an NMC and LFP cell. The BPX files and associated examples and information can be found on the A:E BPX Parameterisation repository.

To see how to use BPX with PyBaMM, check out the BPX example notebook.

🚀 Installation

The BPX package can be installed using pip

pip install bpx

BPX is available on GNU/Linux, MacOS and Windows. We strongly recommend to install PyBaMM within a python virtual environment, in order not to alter any distribution python files.

💻 Usage

To create a BPX object from a JSON file, you can use the parse_bpx_file function

import bpx

filename = 'path/to/my/file.json'
my_params = bpx.parse_bpx_file(filename)

my_params will now be of type BPX, which acts like a python dataclass with the same attributes as the BPX format. To obtain example files, see the examples folder, the A:E BPX Parameterisation repository, or the BPX example repository.

Attributes of the class can be printed out using the standard Python dot notation, for example, you can print out the initial temperature of the cell using

print('Initial temperature of cell:', my_params.parameterisation.cell.initial_temperature)

Alternatively, you can export the BPX object as a dictionary and use the string names (aliases) of the parameters from the standard

my_params_dict = my_params.dict(by_alias=True)
print('Initial temperature of cell:', my_params_dict["Parameterisation"]["Cell"]["Initial temperature [K]"])

The entire BPX object can be pretty-printed using the devtools package

from devtools import pprint
pprint(my_params)

You can convert any Function objects in BPX to regular callable Python functions, for example:

positive_electrode_diffusivity = my_params.parameterisation.positive_electrode.diffusivity.to_python_function()
diff_at_one = positive_electrode_diffusivity(1.0)
print('positive electrode diffusivity at x = 1.0:', diff_at_one)

If you want to output the complete JSON schema in order to build a custom tool yourself, you can do so:

print(bpx.BPX.schema_json(indent=2))

According to the pydantic docs, the generated schemas are compliant with the specifications: JSON Schema Core, JSON Schema Validation and OpenAPI.

📖 Documentation

API documentation for the bpx package can be built locally using Sphinx. To build the documentation first clone the repository, install the bpx package, and 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

📫 Get in touch

If you have any questions please get in touch via email bpx@faraday.ac.uk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bpx-0.5.0.tar.gz (68.3 kB view details)

Uploaded Source

Built Distribution

bpx-0.5.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file bpx-0.5.0.tar.gz.

File metadata

  • Download URL: bpx-0.5.0.tar.gz
  • Upload date:
  • Size: 68.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for bpx-0.5.0.tar.gz
Algorithm Hash digest
SHA256 141f9056cf614d67515a05fd552d4fbc9af9d2c13c2555bc7efb1dfd25d7f1af
MD5 108a98f0df63d1ca3225ab544fa89ffd
BLAKE2b-256 c6980ea29dc780329d16317f4b48a48660f1ec435d4f3c22119bb71737ca9716

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpx-0.5.0.tar.gz:

Publisher: publish_pypi.yml on FaradayInstitution/BPX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bpx-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: bpx-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for bpx-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cba2cc03ea0c2fdc24b837c9445095c8fcefc04114e37a8dd18c2a7ef3598f5
MD5 82a9e89ad06b633e3afeba307d2db043
BLAKE2b-256 26295035750cea0fea782dd4e8129d23fdb07a1648c23791908e8d3f0961313a

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpx-0.5.0-py3-none-any.whl:

Publisher: publish_pypi.yml on FaradayInstitution/BPX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page