python-microgrid

python-microgrid is a python library to generate and simulate a large number of microgrids.

https://github.com/ahalev/python-microgrid

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    1 of 10 committers (10.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.5%) to scientific vocabulary
Last synced: 7 months ago · JSON representation

Repository

python-microgrid is a python library to generate and simulate a large number of microgrids.

Basic Info
Statistics
  • Stars: 85
  • Watchers: 2
  • Forks: 10
  • Open Issues: 11
  • Releases: 3
Created about 3 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License

README.md

python-microgrid

Build

python-microgrid is a python library to generate and simulate a large number of microgrids. It is an extension of TotalEnergies' pymgrid.

For more context, please see the presentation done at Climate Change AI and the documentation.

Installation

The easiest way to install python-microgrid is with pip:

pip install -U python-microgrid

Alternatively, you can install from source. First clone the repo:

bash git clone https://github.com/ahalev/python-microgrid.git Then navigate to the root directory of python-microgrid and call

bash pip install .

Getting Started

Microgrids are straightforward to generate from scratch. Simply define some modules and pass them to a microgrid: ```python import numpy as np from pymgrid import Microgrid from pymgrid.modules import GensetModule, BatteryModule, LoadModule, RenewableModule

genset = GensetModule(runningminproduction=10, runningmaxproduction=50, genset_cost=0.5)

battery = BatteryModule(mincapacity=0, maxcapacity=100, maxcharge=50, maxdischarge=50, efficiency=1.0, init_soc=0.5)

Using random data

renewable = RenewableModule(time_series=50*np.random.rand(100))

load = LoadModule(timeseries=60*np.random.rand(100), lossload_cost=10)

microgrid = Microgrid([genset, battery, ("pv", renewable), load]) ```

This creates a microgrid with the modules defined above, as well as an unbalanced energy module -- which reconciles situations when energy demand cannot be matched to supply.

Printing the microgrid gives us its architecture:

```python

microgrid

Microgrid([genset x 1, load x 1, battery x 1, pv x 1, balancing x 1]) ```

A microgrid is contained of fixed modules and flex modules. Some modules can be both -- GridModule, for example -- but not at the same time.

A fixed module has requires a request of a certain amount of energy ahead of time, and then attempts to produce or consume said amount. LoadModule is an example of this; you must tell it to consume a certain amount of energy and it will then do so.

A flex module, on the other hand, is able to adapt to meet demand. RenewableModule is an example of this as it allows for curtailment of any excess renewable produced.

A microgrid will tell you which modules are which:

```python

microgrid.fixed_modules

{ "genset": "[GensetModule(runningminproduction=10, runningmaxproduction=50, gensetcost=0.5, co2perunit=0, costperunitco2=0, startuptime=0, winddowntime=0, allowabortion=True, initstartup=True, raiseerrors=False, providedenergyname=gensetproduction)]", "load": "[LoadModule(timeseries=, lossloadcost=10, forecaster=NoForecaster, forecasthorizon=0, forecasterincreaseuncertainty=False, raiseerrors=False)]", "battery": "[BatteryModule(mincapacity=0, maxcapacity=100, maxcharge=50, maxdischarge=50, efficiency=1.0, batterycostcycle=0.0, batterytransitionmodel=None, initcharge=None, initsoc=0.5, raise_errors=False)]" }

microgrid.flex_modules

{ "pv": "[RenewableModule(timeseries=, raiseerrors=False, forecaster=NoForecaster, forecasthorizon=0, forecasterincreaseuncertainty=False, providedenergyname=renewableused)]", "balancing": "[UnbalancedEnergyModule(raiseerrors=False, lossloadcost=10, overgenerationcost=2)]" }

```

Running the microgrid is straightforward. Simply pass an action for each fixed module to microgrid.run. The microgrid can also provide you a random action by calling microgrid.sample_action. Once the microgrid has been run for a certain number of steps, results can be viewed by calling microgrid.get_log.

```python

for j in range(10): action = microgrid.sampleaction(strictbound=True) microgrid.step(action)

microgrid.getlog(dropsingleton_key=True)

  genset  ...                     balance
  reward  ... fixed_absorbed_by_microgrid

0 -5.000000 ... 10.672095 1 -14.344353 ... 50.626726 2 -5.000000 ... 17.538018 3 -0.000000 ... 15.492778 4 -0.000000 ... 35.748724 5 -0.000000 ... 30.302300 6 -5.000000 ... 36.451662 7 -0.000000 ... 66.533872 8 -0.000000 ... 20.645077 9 -0.000000 ... 10.632957 ```

Benchmarking

pymgrid also comes pre-packaged with a set of 25 microgrids for benchmarking. The config files for these microgrids are available in data/scenario/pymgrid25. Simply deserialize one of the yaml files to load one of the saved microgrids; for example, to load the zeroth microgrid:

```python import yaml from pymgrid import PROJECT_PATH

yamlfile = PROJECTPATH / 'data/scenario/pymgrid25/microgrid0/microgrid0.yaml' microgrid = yaml.safeload(yamlfile.open('r')) ```

Alternatively, Microgrid.load(yaml_file.open('r')) will perform the same deserialization.

Citation

If you use this package for your research, please cite the following paper:

@misc{henri2020pymgrid, title={pymgrid: An Open-Source Python Microgrid Simulator for Applied Artificial Intelligence Research}, author={Gonzague Henri, Tanguy Levent, Avishai Halev, Reda Alami and Philippe Cordier}, year={2020}, eprint={2011.08004}, archivePrefix={arXiv}, primaryClass={cs.AI} }

You can find it on Arxiv here: https://arxiv.org/abs/2011.08004

Data

Data in pymgrid are based on TMY3 (data based on representative weather). The PV data comes from DOE/NREL/ALLIANCE (https://nsrdb.nrel.gov/about/tmy.html) and the load data comes from OpenEI (https://openei.org/doe-opendata/dataset/commercial-and-residential-hourly-load-profiles-for-all-tmy3-locations-in-the-united-states)

The CO2 data is from Jacque de Chalendar and his gridemissions API.

Contributing

Pull requests are welcome for bug fixes. For new features, please open an issue first to discuss what you would like to add.

Please make sure to update tests as appropriate.

License

This repo is under a GNU LGPL 3.0 (https://github.com/total-sa/pymgrid/edit/master/LICENSE)

Contact

For any questions or bugs, please open an issue in the Issues tab.

Owner

  • Name: Avishai Halev
  • Login: ahalev
  • Kind: user
  • Location: San Francisco, CA

GitHub Events

Total
  • Issues event: 12
  • Watch event: 26
  • Delete event: 2
  • Issue comment event: 8
  • Push event: 3
  • Pull request event: 6
  • Fork event: 4
  • Create event: 2
Last Year
  • Issues event: 12
  • Watch event: 26
  • Delete event: 2
  • Issue comment event: 8
  • Push event: 3
  • Pull request event: 6
  • Fork event: 4
  • Create event: 2

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 1,751
  • Total Committers: 10
  • Avg Commits per committer: 175.1
  • Development Distribution Score (DDS): 0.158
Past Year
  • Commits: 30
  • Committers: 1
  • Avg Commits per committer: 30.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
ahalev a****v@g****m 1,475
Gonzague Henri g****i@t****m 149
Gonzague Henri g****i@g****m 107
Tanguy t****2@g****m 9
Reda ALAMI 3****9 4
Yann BERTHERLOT y****t@c****m 3
pochelu p****u@t****m 1
RoKe2017 1****7 1
Alexis de Talhouët a****9@g****m 1
Bipin Paudel b****l@j****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 22
  • Total pull requests: 98
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 5 days
  • Total issue authors: 13
  • Total pull request authors: 2
  • Average comments per issue: 0.91
  • Average comments per pull request: 0.01
  • Merged pull requests: 88
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 6
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 18 days
  • Issue authors: 6
  • Pull request authors: 2
  • Average comments per issue: 1.33
  • Average comments per pull request: 0.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ahalev (6)
  • Alfonso00MA (3)
  • logicbai (1)
  • BZ03SL (1)
  • WDzhd (1)
  • akinar1990 (1)
  • DonovanSB (1)
  • TEKaal (1)
  • fusion-research (1)
  • Shezeenaqureshi (1)
  • Micoft (1)
  • AndelBenjamin (1)
  • RafaelGoncalvesUA (1)
Pull Request Authors
  • ahalev (94)
  • simonmpa (2)
Top Labels
Issue Labels
enhancement (2) bug (1) good first issue (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 21 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 6
  • Total maintainers: 1
proxy.golang.org: github.com/ahalev/python-microgrid
  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 7 months ago
pypi.org: python-microgrid

A simulator for tertiary control of electrical microgrids

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 21 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 10.7%
Forks count: 15.4%
Average: 18.2%
Dependent repos count: 21.6%
Downloads: 33.0%
Maintainers (1)
Last synced: 7 months ago

Dependencies

.github/workflows/build.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/documentation-links.yaml actions
  • readthedocs/actions/preview v1 composite
.github/workflows/garage-compat.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • wei/wget v1 composite
docs/requirements.txt pypi
  • Sphinx ==5.3.0
  • nbsphinx ==0.8.10
  • nbsphinx-link ==1.3.0
  • numpydoc ==1.5.0
  • pydata_sphinx_theme ==0.12.0
requirements.txt pypi
  • cufflinks >=0.17.3
  • cvxpy >=1.1.4
  • gym >=0.15.7
  • matplotlib >=3.1.1
  • numpy >=1.19.5
  • pandas >=1.0.3
  • plotly >=4.9.0
  • pyyaml >=1.5
  • scipy >=1.5.3
  • statsmodels >=0.11.1
  • tqdm >=4.1.0
setup.py pypi
  • cufflinks *
  • cvxpy *
  • gym *
  • matplotlib *
  • numpy *
  • pandas *
  • plotly *
  • pyyaml *
  • statsmodels *
  • tqdm *
pyproject.toml pypi