This project uses PyBaMM (Python Battery Mathematical Modelling), an open-source battery simulation package written in Python. PyBaMM's mission is to accelerate battery modelling research by providing open-source tools for multi-institutional, interdisciplinary collaboration. Broadly, PyBaMM consists of (i) a framework for writing and solving systems of differential equations, (ii) a library of battery models and parameters, and (iii) specialized tools for simulating battery-specific experiments and visualizing the results. Together, these enable flexible model definitions and fast battery simulations, allowing users to explore the effect of different battery designs and modeling assumptions under a variety of operating scenarios.
The repository is structured as follows:
projectnanme
: contains the source codedocs
: contains documentationexamples
: contains examples of how to use the code
To add a new parameter set to the package, first add a python file to the projectname/parameters
folder. The file should define a function get_parameter_values
that returns a dictionary of parameter values. See the existing PyBaMM parameter sets for examples. Then register a new entry point in pyproject.toml
under [project.entry-points.pybamm_parameter_sets]
with the name of the parameter set and the path to the python file. For example:
[project.entry-points.pybamm_parameter_sets]
MyCell = "projectname.parameters.mycell:get_parameter_values"
After adding new entry points you will need to reinstall the package using pip install .
(or pip install -e .
for a local installation) in the root directory.
It is of course possible to simply define a parameter set locally and import it into a script or notebook, but adding an entry point allows it to be used in the same way as the other PyBaMM parameter sets (pybamm.ParameterValues("name")
).
All data is stored separately from this repository. You can set a data filepath as an environment varibale by creating a .env
file in the root folder with the following contents:
DATA_PATH="path/to/data"
Then, in any script or notebook you can retive the data path by doing
import hackion
data_path = hackion.utils.environ["DATA_PATH"]
Make sure you add .env
to .gitignore
. Alternatively, you can simply specify the filepath manually.
The following example...
Documentation can be found in the docs
directory.
The following instruction are for installing the package locally so that its contents can be edited. To install in site-packages
simply use pip install .
instead of pip install -e .
. 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.
To install the requirements on Linux/Mac OS use the following terminal commands:
- Clone the repository or download and unzip the source code.
- Change into the
project-template
directory
cd project-template
- Create a virtual environment
virtualenv env
- Activate the virtual environment
source env/bin/activate
- Install the package
pip install -e .
Using pip install -e .
instead of just pip install .
will install the package in editable mode from the local project path instead of trying to install in site-packages
.
To install the requirements on Windows use the following commands:
- Clone the repository or download and unzip the source code.
- Change into the
project-template
directory
cd project-template
- Create a virtual environment
python -m virtualenv env
- Activate the virtual environment
env\Scripts\activate
where env
is the path to the environment created in step 3 (e.g. C:\Users\'Username'\env\Scripts\activate.bat
).
- Install the package
pip install -e .
Using pip install -e .
instead of just pip install .
will install the package in editable mode from the local project path instead of trying to install in site-packages
.
As an alternative, you can set up Windows Subsystem for Linux. This allows you to run a full Linux distribution within Windows.
Problem: ModuleNotFoundError: No module named 'wheel'
.
Solution: Try pip install wheel
before pip install .
.
Problem: Changes I make to the code in the project-template
folder aren't reflected when I try to run the code.
Solution: Install in editable model by doing pip install -e .
.
If you have any questions please get in touch via email [email protected].