Equivalent circuit models in Python.
Project description
thevenin
Summary
This package is a wrapper for the well-known Thevenin equivalent circuit model. The model is comprised of a single series reistor followed by any number of parallel RC pairs. Figure 1 below illustrates a circuit with 2 RC pairs; however, the model can be run with as few as zero, and as many as $N$.
Figure 1: 2RC Thevenin circuit.
This system is governed by the evolution of the state of charge (SOC, -), RC overpotentials ($V_j$, V), cell voltage ($V_{\rm cell}$, V), and temperature ($T_{\rm cell}$, K). SOC and $V_j$ evolve in time as
\begin{align}
&\frac{d\rm SOC}{dt} = \frac{-I}{3600 Q_{\rm max}}, \\
&\frac{dV_j}{dt} = -\frac{V_j}{R_jC_j} + \frac{I}{C_j},
\end{align}
where $I$ is the load current (A), $Q_{\rm max}$ is the maximum nominal cell capacity (Ah), and $R_j$ and $C_j$ are the resistance (Ohm) and capacitance (F) of each RC pair $j$. Note that the sign convention for $I$ is chosen such that positive $I$ discharges the battery (reduces SOC) and negative $I$ charges the battery (increases SOC). This convention is consistent with common physics-based models, e.g., the single particle model or pseudo-2D model. While not explicitly included in the equations above, $R_j$ and $C_j$ are functions of SOC and $T_{\rm cell}$. The temperature increases while the cell is active according to
\begin{equation}
mC_p\frac{dT_{\rm cell}}{dt} = \dot{Q}_{\rm gen} + \dot{Q}_{\rm conv},
\end{equation}
where $m$ is mass (kg), $C_p$ is specific heat capacity (J/kg/K), $Q_{\rm gen}$ is the heat generation (W), and $Q_{\rm conv}$ is the convective heat loss (W). Heat generation and convection are defined by
\begin{align}
&\dot{Q}_{\rm gen} = I \times (V_{\rm OCV}({\rm SOC}) - V_{\rm cell}), \\
&\dot{Q}_{\rm conv} = hA(T_{\infty} - T_{\rm cell}),
\end{align}
where $h$ is the convecitive heat transfer coefficient (W/m2/K), $A$ is heat loss area (m2), and $T_{\infty}$ is the air/room temperature (K). $V_{\rm OCV}$ is the open circuit voltage (V) and is a function of SOC.
The overall cell voltage is
\begin{equation}
V_{\rm cell} = V_{\rm OCV}({\rm SOC}) - \sum_j V_j - IR_0,
\end{equation}
where $R_0$ is the lone series resistance (Ohm), as shown in Figure 1. Just like the other resistive elements, $R_0$ is a function of SOC and $T_{\rm cell}$.
Installation
thevenin
is installable via either pip or conda. To install from PyPI use the following command.
pip install thevenin
If you prefer using the conda
package manager, you can install thevenin
from the conda-forge
channel using the command below.
conda install -c conda-forge thevenin
If you run into issues with installation due to the scikit-sundae dependency, please submit an issue here. We also manage this solver package, but distribute it separately since it is not developed in pure Python.
For those interested in setting up a developer and/or editable version of this software please see the directions available in the "Development" section of our documentation.
Get Started
The API is organized around three main classes that allow you to construct the model, define an experiment, and interact with the solution. A basic example for a constant-current discharge is given below. To learn more about the model and see more detailed examples check out the documentation on Read the Docs.
import thevenin as thev
model = thev.Model()
expr = thev.Experiment()
expr.add_step('current_A', 75., (3600., 1.), limits=('voltage_V', 3.))
soln = model.run(expr)
soln.plot('time_h', 'voltage_V')
Notes:
- If you are new to Python, check out Spyder IDE. Spyder is a powerful interactive development environment (IDE) that can make programming in Python more approachable to new users.
Citing this Work
This work was authored by researchers at the National Renewable Energy Laboratory (NREL). The project is tracked in NREL's software records under SWR-24-132 and has a DOI available for citing the work. If you use use this package in your work, please include the following citation:
Placeholder... waiting for DOI.
For convenience, we also provide the following for your BibTex:
@misc{Randall2024,
title = {{thevenin: Equivalent circuit models in Python}},
author = {Randall, Corey R.},
year = {2024},
doi = {placeholder... waiting for DOI},
url = {https://github.com/NREL/thevenin},
}
Acknowledgements
The motivation and funding for this project came from the Rapid Operational Validation Initiative (ROVI) sponsored by the Office of Electricity. The focus of ROVI is "to greatly reduce time required for emerging energy storage technologies to go from lab to market by developing new tools that will accelerate the testing and validation process needed to ensure commercial success." If interested, you can read more about ROVI here.
Contributing
If you'd like to contribute to this package, please look through the existing issues. If the bug you've caught or the feature you'd like to add isn't already being worked on, please submit a new issue before getting started. You should also read through the developer guidelines.
Disclaimer
This work was authored by the National Renewable Energy Laboratory (NREL), operated by Alliance for Sustainable Energy, LLC, for the U.S. Department of Energy (DOE). The views expressed in the repository do not necessarily represent the views of the DOE or the U.S. Government.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file thevenin-0.1.0.tar.gz
.
File metadata
- Download URL: thevenin-0.1.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9af91958781c2ae0c7606806d5d45825ea528b5f56607e84c4d073f7bcac7365 |
|
MD5 | 0654939be55e47751d9723c833d0aa88 |
|
BLAKE2b-256 | ee40e5d3f0776cf869fa89975e15546cb38571be80930028920c36806ed30d9f |
File details
Details for the file thevenin-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: thevenin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5e33a9b2592c235176f5488d3ded1a1a4feb6dd13c3770344f50a893837d79f |
|
MD5 | 704ffc8f0d748ebe58a4534752e8ef05 |
|
BLAKE2b-256 | 083d4dd05e37f9c7578d496d656c8fbd32e7b509ab63aef521e379c3f76c885e |