bpx


Namebpx JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryAn implementation of the Battery Parameter eXchange (BPX) format in Pydantic.
upload_time2024-12-20 18:40:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseCopyright (c) 2022 University of Oxford Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords battery bpx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🔋 BPX
![tests](https://github.com/FaradayInstitution/BPX/actions/workflows/test.yml/badge.svg)
[![codecov](https://codecov.io/gh/FaradayInstitution/BPX/branch/main/graph/badge.svg?token=Krv0JW3gYZ)](https://codecov.io/gh/FaradayInstitution/BPX)

An implementation of the Battery Parameter eXchange (BPX) format in Pydantic. BPX, an outcome of the Faraday Institution [Multi-scale Modelling project](https://www.faraday.ac.uk/research/lithium-ion/battery-system-modelling/), 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](https://bpxstandard.com/).

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](https://www.aboutenergy.io/) 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](https://github.com/About-Energy-OpenSource/About-Energy-BPX-Parameterisation/).

To see how to use BPX with [PyBaMM](https://www.pybamm.org/), check out the [BPX example notebook]([https://github.com/pybamm-team/bpx-example](https://github.com/pybamm-team/PyBaMM/blob/1ead6c512a6cff3effaa35f47efb354ec4a3c8c8/docs/source/examples/notebooks/parameterization/bpx.ipynb)).

## 🚀 Installation
The BPX package can be installed using pip
```bash
pip install bpx
```

BPX is available on GNU/Linux, MacOS and Windows. We strongly recommend to install PyBaMM within a python [virtual environment](https://docs.python.org/3/tutorial/venv.html), 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
```python
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](https://github.com/About-Energy-OpenSource/About-Energy-BPX-Parameterisation/), or the [BPX example repository](https://github.com/pybamm-team/bpx-example).

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
```python
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
```python
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 
```python
from devtools import pprint
pprint(my_params)
```

You can convert any `Function` objects in `BPX` to regular callable Python functions, for example:
```python
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:
```python
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](https://www.sphinx-doc.org/en/master/). To build the documentation first [clone the repository](https://github.com/git-guides/git-clone), install the `bpx` package, and then run the following command:
```bash
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
```bash
open docs/_build/html/index.html
```

## 📫 Get in touch
If you have any questions please get in touch via email <bpx@faraday.ac.uk>.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bpx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "battery, bpx",
    "author": null,
    "author_email": "Martin Robinson <martin.robinson@dtc.ox.ac.uk>",
    "download_url": "https://files.pythonhosted.org/packages/c6/98/0ea29dc780329d16317f4b48a48660f1ec435d4f3c22119bb71737ca9716/bpx-0.5.0.tar.gz",
    "platform": null,
    "description": "# \ud83d\udd0b BPX\n![tests](https://github.com/FaradayInstitution/BPX/actions/workflows/test.yml/badge.svg)\n[![codecov](https://codecov.io/gh/FaradayInstitution/BPX/branch/main/graph/badge.svg?token=Krv0JW3gYZ)](https://codecov.io/gh/FaradayInstitution/BPX)\n\nAn implementation of the Battery Parameter eXchange (BPX) format in Pydantic. BPX, an outcome of the Faraday Institution [Multi-scale Modelling project](https://www.faraday.ac.uk/research/lithium-ion/battery-system-modelling/), 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](https://bpxstandard.com/).\n\nThis repository features a Pydantic-based parser for JSON files in the BPX format, which validates your file against the schema.\n\nTo support the new open standard, [About:Energy](https://www.aboutenergy.io/) 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](https://github.com/About-Energy-OpenSource/About-Energy-BPX-Parameterisation/).\n\nTo see how to use BPX with [PyBaMM](https://www.pybamm.org/), check out the [BPX example notebook]([https://github.com/pybamm-team/bpx-example](https://github.com/pybamm-team/PyBaMM/blob/1ead6c512a6cff3effaa35f47efb354ec4a3c8c8/docs/source/examples/notebooks/parameterization/bpx.ipynb)).\n\n## \ud83d\ude80 Installation\nThe BPX package can be installed using pip\n```bash\npip install bpx\n```\n\nBPX is available on GNU/Linux, MacOS and Windows. We strongly recommend to install PyBaMM within a python [virtual environment](https://docs.python.org/3/tutorial/venv.html), in order not to alter any distribution python files.\n\n## \ud83d\udcbb Usage\nTo create a BPX object from a JSON file, you can use the `parse_bpx_file` function\n```python\nimport bpx\n\nfilename = 'path/to/my/file.json'\nmy_params = bpx.parse_bpx_file(filename)\n```\n`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](https://github.com/About-Energy-OpenSource/About-Energy-BPX-Parameterisation/), or the [BPX example repository](https://github.com/pybamm-team/bpx-example).\n\nAttributes 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\n```python\nprint('Initial temperature of cell:', my_params.parameterisation.cell.initial_temperature)\n```\n\nAlternatively, you can export the `BPX` object as a dictionary and use the string names (aliases) of the parameters from the standard\n```python\nmy_params_dict = my_params.dict(by_alias=True)\nprint('Initial temperature of cell:', my_params_dict[\"Parameterisation\"][\"Cell\"][\"Initial temperature [K]\"])\n```\n\nThe entire BPX object can be pretty-printed using the `devtools` package \n```python\nfrom devtools import pprint\npprint(my_params)\n```\n\nYou can convert any `Function` objects in `BPX` to regular callable Python functions, for example:\n```python\npositive_electrode_diffusivity = my_params.parameterisation.positive_electrode.diffusivity.to_python_function()\ndiff_at_one = positive_electrode_diffusivity(1.0)\nprint('positive electrode diffusivity at x = 1.0:', diff_at_one)\n```\n\nIf you want to output the complete JSON schema in order to build a custom tool yourself, you can do so:\n```python\nprint(bpx.BPX.schema_json(indent=2))\n```\n\nAccording to the `pydantic` docs, the generated schemas are compliant with the specifications: JSON Schema Core, JSON Schema Validation and OpenAPI.\n\n## \ud83d\udcd6 Documentation\nAPI documentation for the `bpx` package can be built locally using [Sphinx](https://www.sphinx-doc.org/en/master/). To build the documentation first [clone the repository](https://github.com/git-guides/git-clone), install the `bpx` package, and then run the following command:\n```bash\nsphinx-build docs docs/_build/html  \n```\nThis 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\n```bash\nopen docs/_build/html/index.html\n```\n\n## \ud83d\udceb Get in touch\nIf you have any questions please get in touch via email <bpx@faraday.ac.uk>.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2022 University of Oxford  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "An implementation of the Battery Parameter eXchange (BPX) format in Pydantic.",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/FaradayInstitution/BPX",
        "Repository": "https://github.com/FaradayInstitution/BPX"
    },
    "split_keywords": [
        "battery",
        " bpx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26295035750cea0fea782dd4e8129d23fdb07a1648c23791908e8d3f0961313a",
                "md5": "82a9e89ad06b633e3afeba307d2db043",
                "sha256": "1cba2cc03ea0c2fdc24b837c9445095c8fcefc04114e37a8dd18c2a7ef3598f5"
            },
            "downloads": -1,
            "filename": "bpx-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82a9e89ad06b633e3afeba307d2db043",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 13947,
            "upload_time": "2024-12-20T18:40:09",
            "upload_time_iso_8601": "2024-12-20T18:40:09.593241Z",
            "url": "https://files.pythonhosted.org/packages/26/29/5035750cea0fea782dd4e8129d23fdb07a1648c23791908e8d3f0961313a/bpx-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6980ea29dc780329d16317f4b48a48660f1ec435d4f3c22119bb71737ca9716",
                "md5": "108a98f0df63d1ca3225ab544fa89ffd",
                "sha256": "141f9056cf614d67515a05fd552d4fbc9af9d2c13c2555bc7efb1dfd25d7f1af"
            },
            "downloads": -1,
            "filename": "bpx-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "108a98f0df63d1ca3225ab544fa89ffd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 68254,
            "upload_time": "2024-12-20T18:40:12",
            "upload_time_iso_8601": "2024-12-20T18:40:12.067602Z",
            "url": "https://files.pythonhosted.org/packages/c6/98/0ea29dc780329d16317f4b48a48660f1ec435d4f3c22119bb71737ca9716/bpx-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-20 18:40:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FaradayInstitution",
    "github_project": "BPX",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bpx"
}
        
Elapsed time: 0.42006s