https://github.com/openclimatefix-archives/solar-and-storage
Solar and Storage optimization code
https://github.com/openclimatefix-archives/solar-and-storage
Last synced: about 1 month ago
JSON representation
Solar and Storage optimization code
- Host: GitHub
- URL: https://github.com/openclimatefix-archives/solar-and-storage
- Owner: openclimatefix
- License: bsd-2-clause
- Created: 2022-12-20T10:09:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-13T09:45:28.000Z (about 1 year ago)
- Last Synced: 2025-03-24T10:11:05.679Z (about 1 year ago)
- Language: Python
- Size: 146 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Solar and Storage
[](#contributors-)
A Python Library to run solar and storage optimization.
This uses mixed integer linear programming and maximises revenue made by charging and discharging the battery.
The model uses variable prices and a solar generation profile.
## Installation
```
pip install solar-and-storage
```
## Example
Import the packages
```python
import numpy as np
from solar_and_storage.solar_and_storage import SolarAndStorage
```
Make the fake price and solar data
```python
# make prices
prices = np.zeros(24) + 30
prices[6:19] = 40
prices[9] = 50
prices[12:14] = 30
prices[16:18] = 50
prices[17] = 60
# make solar profile
solar = np.zeros(24)
solar[8:16] = 2.0
solar[10:14] = 4.0
```
Then run optimization
```python
solar_and_storage = SolarAndStorage(prices=prices, solar_generation=list(solar))
solar_and_storage.run_optimization()
result_df = solar_and_storage.get_results()
```
Now plot the data
```python
fig = solar_and_storage.get_figure()
fig.show(rendered="browser")
```

The first plot shows the solar profile, the second shows the prices that day. The third shows the battery profile. Finally the fourth shows profit.
You can see that the battery charged from the solar site at the end of the solar maximum
## Thanks
Thanks you to the follow repos for inspiration
- https://github.com/ADGEfficiency/energy-py-linear
- https://github.com/wzyfrank/battery/
- https://github.com/greysonchung/Battery-Optimisation/
- https://github.com/edu230991/battery-optimization/
sdk-python-ci.yml
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!