Skip to content

Commit

Permalink
Replace scikits.odes with scikit-sundae
Browse files Browse the repository at this point in the history
  • Loading branch information
c-randall committed Nov 8, 2024
1 parent 542e4bb commit 9b7ce8d
Show file tree
Hide file tree
Showing 84 changed files with 5,099 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/linters/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[codespell]
skip = build,docs,images,reports,sphinx,references
skip = build,docs,images,reports,references
ignore-words-list = thev
2 changes: 1 addition & 1 deletion .github/linters/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

max-line-length = 80
extend-ignore = E121,E122,E126,E127,E128,E131,E201,E202,E226,E241,E731
exclude = build,docs,sphinx,images,reports
exclude = build,docs,images,reports,references
52 changes: 34 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'CHANGELOG*'
- 'docs/*'
- 'images/*'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/*'

pull_request:
Expand All @@ -20,33 +21,38 @@ on:
- 'CHANGELOG*'
- 'docs/*'
- 'images/*'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/*'

jobs:
lint:
name: (Lint ${{ matrix.python-version }}, ${{ matrix.os }})

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python-version: ['3.12']
os: [ubuntu-latest]
python-version: ['3.13']

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Spell check
run: |
pip install codespell
codespell --config .github/linters/.codespellrc
- name: Code format
run: |
pip install flake8
Expand All @@ -55,34 +61,44 @@ jobs:
tests:
name: (Test ${{ matrix.python-version }}, ${{ matrix.os }})

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-13', 'macos-latest']
python-version: ['3.9', '3.12']
os: [macos-13, macos-latest, windows-latest, ubuntu-latest]
python-version: ['3.9', '3.13']

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup conda/python
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: 'rovi'
python-version: ${{ matrix.python-version }}
miniconda-version: 'latest'
auto-update-conda: true
- name: Conda dependencies
run: conda install scikits_odes_sundials -c conda-forge
miniconda-version: latest
python-version: ${{ matrix.python-version }}
activate-environment: rovi

- name: Verify environment
run: |
conda info
conda list
- name: Pip dependencies
run: pip install .
- name: List packages
run: conda list

- name: List info
run: |
conda info
conda list
- name: Pytest
run: |
pip install pytest
pytest
pytest .
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ instance/
.scrapy

# Sphinx documentation
docs/
sphinx/
docs/build

# PyBuilder
.pybuilder/
Expand Down
16 changes: 16 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set OS, Python version, and other tools for the build
build:
os: ubuntu-22.04
tools:
python: latest

# Location of sphinx configuration file
sphinx:
configuration: docs/source/conf.py
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
### New Features

### Optimizations
* Add ``options`` to the ``Experiment.print_steps()`` report. This makes it easier to check solver options for each step.
* Add `options` to the `Experiment.print_steps()` report. This makes it easier to check solver options for each step.

### Bug Fixes
* Make the final value of ``tspan`` always match ``t_max``. In cases where ``dt`` is used to construct the time array, the final ``dt`` may differ from the one given. Fixes [Issue #10](https://github.com/ROVI-org/thevenin/issues/10).
* Make the final value of `tspan` always match `t_max`. In cases where `dt` is used to construct the time array, the final `dt` may differ from the one given. Fixes [Issue #10](https://github.com/ROVI-org/thevenin/issues/10).

### Breaking Changes
* Drop support for Python 3.8 which reached end of support as of October 2024.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global-exclude tests/*
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,27 @@ The overall cell voltage is
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
We recommend using [Anaconda](https://anaconda.com) to install this package due to the [scikits-odes-sundials](https://scikits-odes.readthedocs.io) dependency, which is installed separately using `conda install` to avoid having to download and compile SUNDIALS locally. Please refer to the linked `scikits-odes` documentation if you prefer installing without using `conda`. Note that we plan to replace this dependency in a future release to streamline installation.

After cloning the repository, or downloading the files, use your terminal (MacOS/Linux) or Anaconda Prompt (Windows) to navigate into the folder with the `pyproject.toml` file. Once in the correct folder, execute the following commands:
`thevenin` is installable via either pip or conda. To install from [PyPI](https://pypi.org/project/thevenin) use the following command.

```
conda create -n rovi python=3.12 scikits_odes_sundials -c conda-forge
conda activate rovi
pip install .
pip install thevenin
```

The first command creates a new Python environment named `rovi`. The environment will be set up using Python 3.12 and will install the `scikits-odes-sundials` dependency from the `conda-forge` channel. Feel free to use an alternate environment name and/or to specify a different Python version >= 3.9. Although the package supports multiple Python versions, development and testing is primarily done using 3.12. Therefore, if you have issues with another version, you should revert to using 3.12. The last two commands activate your new environment and install `thevenin`.

If you plan to make changes to the package, you may also want to consider installing in "editable" mode using the `-e` flag, and including the optional developer dependencies, using `[dev]`, as shown below. If you plan to push any changes back into this repository, you should see the [contributing](#contributing) section first.
If you prefer using the `conda` package manager, you can install `thevenin` from the `conda-forge` channel using the command below.

```
pip install -e .[dev]
conda install -c conda-forge thevenin
```

## 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 see the documentation for any of the classes or their methods, use Python's built in `help()` function. You can also access the documentation by visiting the [website](https://rovi-org.github.io/thevenin) hosted through GitHub pages. The website includes search functionality and more detailed examples compared to those included in the docstrings.
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](https://thevenin.readthedocs.io/) on Read the Docs.

```python
import thevenin
import thevenin as thev

model = thevenin.Model()
model = thev.Model()

expr = thevenin.Experiment()
expr = thev.Experiment()
expr.add_step('current_A', 75., (3600., 1.), limits=('voltage_V', 3.))

soln = model.run(expr)
Expand All @@ -96,10 +90,28 @@ soln.plot('time_h', 'voltage_V')
**Notes:**
* If you are new to Python, check out [Spyder IDE](https://www.spyder-ide.org/). 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/ROVI-org/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](https://www.energy.gov/oe/rapid-operational-validation-initiative-rovi).

## Contributing
If you'd like to contribute to this package, please look through the existing [issues](https://github.com/ROVI-org/thevenin/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](https://rovi-org.github.io/thevenin/development).

## Acknowledgements
## 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.

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](https://www.energy.gov/oe/rapid-operational-validation-initiative-rovi).
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9b7ce8d

Please sign in to comment.