Skip to content

Commit

Permalink
Move main repo to NREL
Browse files Browse the repository at this point in the history
  • Loading branch information
c-randall committed Nov 11, 2024
1 parent 53708b7 commit 65b203e
Show file tree
Hide file tree
Showing 43 changed files with 641 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: I just have a question...
url: https://github.com/ROVI-org/thevenin/discussions
url: https://github.com/NREL/thevenin/discussions
about: Join our discussion instead. Search for existing questions, or ask a new one!
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Please include a summary of the change and which issue is fixed. Please also inc
Fixes # (issue)

## Type of change
Please add a line in the relevant section of [CHANGELOG.md](https://github.com/ROVI-org/thevenin/blob/main/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Please add a line in the relevant section of [CHANGELOG.md](https://github.com/NREL/thevenin/blob/main/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

- [ ] New feature (non-breaking change which adds functionality)
- [ ] Optimization (back-end change that improves speed/readability/etc.)
Expand Down
193 changes: 193 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+a[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+b[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'

env:
PACKAGE_NAME: '<PACKAGE_NAME>'

jobs:
details:
runs-on: ubuntu-latest
outputs:
tag_version: ${{ steps.release.outputs.tag_version }}

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

- name: Extract tag details
id: release
run: |
if [[ "${{ github.ref_type }}" = "tag" ]]; then
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "tag_version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "Tag version is $TAG_VERSION"
else
echo "No tag found"
exit 1
fi
check-version:
needs: details
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.13'

- name: Fetch info from PyPI
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest_pypi_version=$(echo $response | grep -oP '"releases":\{"\K[^"]+' | sort -rV | head -n 1)
if [[ -z "$latest_pypi_version" ]]; then
echo "Package not found on PyPI."
latest_pypi_version="0.0.0"
fi
echo "Latest version on PyPI: $latest_pypi_version"
echo "latest_pypi_version=$latest_pypi_version" >> $GITHUB_ENV
- name: Compare version against PyPI and exit if not newer
run: |
TAG_VERSION=${{ needs.details.outputs.tag_version }}
PYPI_VERSION=$latest_pypi_version
TAG_BASE=${TAG_VERSION%%[a-z]}
PYPI_BASE=${PYPI_VERSION%%[a-z]}
TAG_SUFFIX=${TAG_VERSION#$TAG_BASE}
PYPI_SUFFIX=${PYPI_VERSION#$PYPI_BASE}
suffix_count=0
[[ -n "$TAG_SUFFIX" ]] && ((suffix_count++))
[[ -n "$PYPI_SUFFIX" ]] && ((suffix_count++))
if [[ "$TAG_VERSION" == "$PYPI_VERSION" ]]; then
echo "The tag $TAG_VERSION matches the PyPI version $PYPI_VERSION."
exit 1
elif [[ "$suffix_count" == 1 && "$TAG_BASE" == "$PYPI_BASE" ]]; then
if [[ -n "$PYPI_SUFFIX" ]]; then
echo "The tag $TAG_VERSION is newer than PyPI $PYPI_VERSION."
else
echo "The tag $TAG_VERSION is older than PyPI $PYPI_VERSION."
exit 1
fi
else
newest=$(printf "%s\n%s" "$TAG_VERSION" "$PYPI_VERSION" | sort -V | tail -n 1)
if [[ "$TAG_VERSION" == "$newest" ]]; then
echo "The tag $TAG_VERSION is newer than PyPI $PYPI_VERSION."
else
echo "The tag $TAG_VERSION is older than PyPI $PYPI_VERSION."
exit 1
fi
fi
- name: Verify tag and pyproject.toml versions match
run: |
python -m pip install --upgrade pip
pip install setuptools numpy cython
PKG_VERSION=$(python setup.py --version)
TAG_VERSION=${{ needs.details.outputs.tag_version }}
if [[ "$PKG_VERSION" != "$TAG_VERSION" ]]; then
echo "Version mismatch: setup.py has $PKG_VERSION, but tag is $TAG_VERSION."
exit 1
else
echo "Package and tag versions match: $PKG_VERSION == $TAG_VERSION."
fi
build:
name: (build ubuntu-latest, 3.13)
needs: [details, check-version]
runs-on: ubuntu-latest

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

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.13'

- name: Install build
run: pip install build

- name: Build distributions
run: python -m build

- name: Test binary installation
run: |
pip uninstall thevenin
pip cache purge
python -m pip install --upgrade pip
pip install dist/*.whl -v
pip install pytest
pytest ./tests
- name: Test source installation
run: |
pip uninstall thevenin
pip cache purge
python -m pip install --upgrade pip
pip install dist/*.tar.gz -v
pip install pytest
pytest ./tests
- name: Upload
uses: actions/upload-artifact@v4
with:
name: builds
path: dist/*

pypi-publish:
name: Upload to PyPI
needs: build
runs-on: ubuntu-latest

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/
pattern: builds*
merge-multiple: true

- name: Check files
run: ls dist

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install twine
run: pip install twine

- name: Check builds and upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine check dist/*
twine upload dist/*
21 changes: 17 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# thevenin Changelog

## [Version 0.1.1]()
## [Unreleased](https://github.com/NREL/thevenin)

### New Features

### Optimizations
* 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).

### Breaking Changes
* Drop support for Python 3.8 which reached end of support as of October 2024.

## [v1.0.0](https://github.com/NREL/thevenin/tree/v1.0.0)
This is the first official release of `thevenin`. Main features/capabilities are listed below.

### Features
- Support for any number of RC pairs
- Run constant or dynamic loads with current, voltage, or power control
- Parameters have temperature and state of charge dependence
- Experiment limits to trigger switching between steps
- Multi-limit support (end at voltage, time, etc. - whichever occurs first)

### Notes
- Implemented `pytest` with full package coverage
- Source/binary distributions available on [PyPI](https://pypi.org/project/thevenin)
- Documentation available on [Read the Docs](https://thevenin.readthedocs.io/)

24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<!-- <img alt='Logo' style='width: 75%; min-width: 250px; max-width: 500px;'
src='https://github.com/NREL/thevenin/blob/main/images/dark.png?raw=true#gh-dark-mode-only'/>
<img alt='Logo' style='width: 75%; min-width: 250px; max-width: 500px;'
src='https://github.com/ROVI-org/thevenin/blob/main/images/dark.png?raw=true#gh-dark-mode-only'/>
<img alt='Logo' style='width: 75%; min-width: 250px; max-width: 500px;'
src='https://github.com/ROVI-org/thevenin/blob/main/images/light.png?raw=true#gh-light-mode-only'/>
src='https://github.com/NREL/thevenin/blob/main/images/light.png?raw=true#gh-light-mode-only'/> -->

<br>
# thevenin

[![CI][ci-b]][ci-l] &nbsp;
![tests][test-b] &nbsp;
![coverage][cov-b] &nbsp;
[![pep8][pep-b]][pep-l]

[ci-b]: https://github.com/ROVI-org/thevenin/actions/workflows/ci.yaml/badge.svg
[ci-l]: https://github.com/ROVI-org/thevenin/actions/workflows/ci.yaml
[ci-b]: https://github.com/NREL/thevenin/actions/workflows/ci.yaml/badge.svg
[ci-l]: https://github.com/NREL/thevenin/actions/workflows/ci.yaml

[test-b]: https://github.com/ROVI-org/thevenin/blob/main/images/tests.svg?raw=true
[cov-b]: https://github.com/ROVI-org/thevenin/blob/main/images/coverage.svg?raw=true
[test-b]: https://github.com/NREL/thevenin/blob/main/images/tests.svg?raw=true
[cov-b]: https://github.com/NREL/thevenin/blob/main/images/coverage.svg?raw=true

[pep-b]: https://img.shields.io/badge/code%20style-pep8-orange.svg
[pep-l]: https://www.python.org/dev/peps/pep-0008
Expand All @@ -24,7 +24,7 @@ This package is a wrapper for the well-known Thevenin equivalent circuit model.

<p align="center">
<img alt="2RC Thevenin circuit." style="width: 75%; min-width: 250px; max-width: 500px;"
src="https://github.com/ROVI-org/thevenin/blob/main/images/example_circuit.png?raw=true"/>
src="https://github.com/NREL/thevenin/blob/main/images/example_circuit.png?raw=true"/>
</br>
Figure 1: 2RC Thevenin circuit.
</p>
Expand Down Expand Up @@ -72,6 +72,8 @@ If you prefer using the `conda` package manager, you can install `thevenin` from
conda install -c conda-forge thevenin
```

If you run into issues with installation due to the [scikit-sundae](https://github.com/NREL/scikit-sundae) dependency, please submit an issue [here](https://github.com/NREL/scikit-sundae/issues). We also manage our own solver package, but distribute it separately.

## 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](https://thevenin.readthedocs.io/) on Read the Docs.

Expand Down Expand Up @@ -103,15 +105,15 @@ For convenience, we also provide the following for your BibTex:
author = {Randall, Corey R.},
year = {2024},
doi = {placeholder... waiting for DOI},
url = {https://github.com/ROVI-org/thevenin},
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](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).
If you'd like to contribute to this package, please look through the existing [issues](https://github.com/NREL/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://thevenin.readthedocs.io/development).

## 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.
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.
12 changes: 6 additions & 6 deletions docs/jupyter_execute/examples/ramping.ipynb

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/jupyter_execute/examples/step_functions.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/jupyter_execute/examples/yaml_inputs.ipynb

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 21 additions & 13 deletions docs/jupyter_execute/user_guide/basic_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"metadata": {},
"source": [
"# Basic Tutorial\n",
"The Thevenin package is built around three main classes:\n",
"The `thevenin` package is built around three main classes:\n",
"\n",
"1. `Model` - used to construct instances of an equivalent circuit.\n",
"2. `Experiment` - used to define an experimental protocol containing current, voltage, and/or power-controlled steps.\n",
Expand All @@ -29,15 +29,15 @@
"output_type": "stream",
"text": [
"Model(\n",
"\tnum_RC_pairs=1,\n",
"\tsoc0=1.0,\n",
"\tcapacity=75.0,\n",
"\tmass=1.9,\n",
"\tisothermal=False,\n",
"\tCp=745.0,\n",
"\tT_inf=300.0,\n",
"\th_therm=12.0,\n",
"\tA_therm=1.0,\n",
" num_RC_pairs=1,\n",
" soc0=1.0,\n",
" capacity=75.0,\n",
" mass=1.9,\n",
" isothermal=False,\n",
" Cp=745.0,\n",
" T_inf=300.0,\n",
" h_therm=12.0,\n",
" A_therm=1.0,\n",
")\n"
]
},
Expand All @@ -46,7 +46,7 @@
"output_type": "stream",
"text": [
"\n",
"[thevenin UserWarning]: Using the default parameter file 'params.yaml'.\n",
"[thevenin UserWarning] Using the default parameter file 'params.yaml'.\n",
"\n"
]
}
Expand Down Expand Up @@ -161,7 +161,7 @@
"output_type": "stream",
"text": [
"success = [True, True]\n",
"Solve time: 0.008 s\n"
"0.006 s\n"
]
}
],
Expand All @@ -186,7 +186,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"dict_keys(['time_s', 'time_min', 'time_h', 'soc', 'temperature_K', 'voltage_V', 'current_A', 'power_W', 'capacity_Ah', 'eta0_V', 'eta1_V'])\n"
"CycleSolution(\n",
" solvetime=0.006 s,\n",
" success=[True, True],\n",
" status=[2, 1],\n",
" nfev=[232, 39],\n",
" njev=[34, 23],\n",
" vars=['time_s', 'time_min', 'time_h', 'soc', 'temperature_K', 'voltage_V',\n",
" 'current_A', 'power_W', 'capacity_Ah', 'eta0_V', 'eta1_V'],\n",
")\n"
]
}
],
Expand Down
Loading

0 comments on commit 65b203e

Please sign in to comment.