Name | solar-and-storage JSON |
Version |
0.0.5
JSON |
| download |
home_page | |
Summary | Modelling for Solar and Storage |
upload_time | 2023-02-08 12:34:53 |
maintainer | |
docs_url | None |
author | Peter Dudfield |
requires_python | |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Solar and Storage
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
import plotly.graph_objects as go
from plotly.subplots import make_subplots
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 = make_subplots(rows=3, cols=1, subplot_titles=["Solar profile", "Price", "SOC"])
fig.add_trace(go.Scatter(y=e_soc[:24], name="SOC"), row=3, col=1)
fig.add_trace(go.Scatter(y=solar, name="solar", line_shape="hv"), row=1, col=1)
fig.add_trace(
go.Scatter(y=solar_power_to_grid, name="solar to gird", line_shape="hv"), row=1, col=1
)
fig.add_trace(go.Scatter(y=prices, name="price", line_shape="hv"), row=2, col=1)
fig.show(rendered="browser")
```
![Example1](https://raw.githubusercontent.com/openclimatefix/solar-and-storage/main/examples/solar_and_storage.png)
The first plot shows the solar profile, the second shows the prices that day. The third shows the battery profile.
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
Raw data
{
"_id": null,
"home_page": "",
"name": "solar-and-storage",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Peter Dudfield",
"author_email": "info@openclimatefix.org",
"download_url": "https://files.pythonhosted.org/packages/ca/54/2c5f146f6f04f7bd60d17a0e2f1db7fbfe475451a6908e3be8c6322eb396/solar_and_storage-0.0.5.tar.gz",
"platform": null,
"description": "# Solar and Storage\n\nA Python Library to run solar and storage optimization.\nThis uses mixed integer linear programming and maximises revenue made by charging and discharging the battery.\nThe model uses variable prices and a solar generation profile.\n\n## Installation\n\n```\npip install solar-and-storage\n```\n\n\n## Example\n\nImport the packages\n```python\nimport numpy as np\nimport plotly.graph_objects as go\nfrom plotly.subplots import make_subplots\n\nfrom solar_and_storage.solar_and_storage import SolarAndStorage\n\n```\nMake the fake price and solar data\n```python\n# make prices\nprices = np.zeros(24) + 30\nprices[6:19] = 40\nprices[9] = 50\nprices[12:14] = 30\nprices[16:18] = 50\nprices[17] = 60\n\n# make solar profile\nsolar = np.zeros(24)\nsolar[8:16] = 2.0\nsolar[10:14] = 4.0\n```\n\nThen run optimization\n```python\nsolar_and_storage = SolarAndStorage(prices=prices, solar_generation=list(solar))\nsolar_and_storage.run_optimization()\nresult_df = solar_and_storage.get_results()\n```\n\n\n\nNow plot the data\n```python\nfig = make_subplots(rows=3, cols=1, subplot_titles=[\"Solar profile\", \"Price\", \"SOC\"])\nfig.add_trace(go.Scatter(y=e_soc[:24], name=\"SOC\"), row=3, col=1)\nfig.add_trace(go.Scatter(y=solar, name=\"solar\", line_shape=\"hv\"), row=1, col=1)\nfig.add_trace(\n go.Scatter(y=solar_power_to_grid, name=\"solar to gird\", line_shape=\"hv\"), row=1, col=1\n)\nfig.add_trace(go.Scatter(y=prices, name=\"price\", line_shape=\"hv\"), row=2, col=1)\n\n\nfig.show(rendered=\"browser\")\n```\n\n\n![Example1](https://raw.githubusercontent.com/openclimatefix/solar-and-storage/main/examples/solar_and_storage.png)\nThe first plot shows the solar profile, the second shows the prices that day. The third shows the battery profile.\nYou can see that the battery charged from the solar site at the end of the solar maximum\n\n\n\n## Thanks\n\nThanks you to the follow repos for inspiration\n- https://github.com/ADGEfficiency/energy-py-linear\n- https://github.com/wzyfrank/battery/\n- https://github.com/greysonchung/Battery-Optimisation/\n- https://github.com/edu230991/battery-optimization/\nsdk-python-ci.yml\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Modelling for Solar and Storage",
"version": "0.0.5",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f213741c694184657e6bf0335f1cee3ad9e04214c9d176c3717a20a7852825a2",
"md5": "d64152848417a7599769f916a93db9b0",
"sha256": "2ee15b2327d0e17a7a46a680c61e02b852a7971504c87072ce7db0d359e22347"
},
"downloads": -1,
"filename": "solar_and_storage-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d64152848417a7599769f916a93db9b0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4815,
"upload_time": "2023-02-08T12:34:50",
"upload_time_iso_8601": "2023-02-08T12:34:50.675661Z",
"url": "https://files.pythonhosted.org/packages/f2/13/741c694184657e6bf0335f1cee3ad9e04214c9d176c3717a20a7852825a2/solar_and_storage-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ca542c5f146f6f04f7bd60d17a0e2f1db7fbfe475451a6908e3be8c6322eb396",
"md5": "68c6596f10ad8077941ce0e33ae2e6d6",
"sha256": "774b331b03a0b09990e5349407d61bcdeeb169b864091de2f7e826153a2e9397"
},
"downloads": -1,
"filename": "solar_and_storage-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "68c6596f10ad8077941ce0e33ae2e6d6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4825,
"upload_time": "2023-02-08T12:34:53",
"upload_time_iso_8601": "2023-02-08T12:34:53.040356Z",
"url": "https://files.pythonhosted.org/packages/ca/54/2c5f146f6f04f7bd60d17a0e2f1db7fbfe475451a6908e3be8c6322eb396/solar_and_storage-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-08 12:34:53",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "solar-and-storage"
}