Skip to main content

Optimizing energy assets with mixed-integer linear programming.

Project description

energy-py-linear

Checked with mypy


Documentation: energypylinear.adgefficiency.com


A Python library for optimizing energy assets with mixed-integer linear programming:

  • electric batteries,
  • combined heat & power (CHP) generators,
  • electric vehicle smart charging,
  • heat pumps,
  • renewable (wind & solar) generators.

Assets can be optimized to either maximize profit or minimize carbon emissions, or for user defined custom objective functions. Custom constraints can be used to further constrain asset behaviour.

A site is a collection of assets that can be optimized together. Sites can use custom objectives and constraints.

Energy balances are performed on electricity, high, and low temperature heat.

Setup

Requires Python 3.11 or 3.12:

$ pip install energypylinear

Quick Start

Asset API

The asset API allows optimizing a single asset at once:

import energypylinear as epl

#  2.0 MW, 4.0 MWh battery
asset = epl.Battery(
    power_mw=2,
    capacity_mwh=4,
    efficiency_pct=0.9,
    # different electricity prices for each interval
    # length of electricity_prices is the length of the simulation
    electricity_prices=[100.0, 50, 200, -100, 0, 200, 100, -100],
    # a constant value for each interval
    export_electricity_prices=40,
)

simulation = asset.optimize()

Site API

The site API allows optimizing multiple assets together:

import energypylinear as epl

assets = [
    #  2.0 MW, 4.0 MWh battery
    epl.Battery(power_mw=2.0, capacity_mwh=4.0),
    #  30 MW open cycle generator
    epl.CHP(
        electric_power_max_mw=100, electric_power_min_mw=30, electric_efficiency_pct=0.4
    ),
    #  2 EV chargers & 4 charge events
    epl.EVs(
        chargers_power_mw=[100, 100],
        charge_events_capacity_mwh=[50, 100, 30, 40],
        charge_events=[
            [1, 0, 0, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 0, 1, 1],
            [0, 1, 0, 0, 0],
        ],
    ),
    #  natural gas boiler to generate high temperature heat
    epl.Boiler(),
    #  valve to generate low temperature heat from high temperature heat
    epl.Valve(),
]

site = epl.Site(
    assets=assets,
    # length of energy prices is the length of the simulation
    electricity_prices=[100, 50, 200, -100, 0],
    # these should match the length of the export_electricity_prices
    # if they don't, they will be repeated or cut to match the length of electricity_prices
    high_temperature_load_mwh=[105, 110, 120, 110, 105],
    low_temperature_load_mwh=[105, 110, 120, 110, 105],
)

simulation = site.optimize()

Documentation

See more asset types & use cases in the documentation.

Test

$ make test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

energypylinear-1.4.1.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

energypylinear-1.4.1-py3-none-any.whl (69.6 kB view details)

Uploaded Python 3

File details

Details for the file energypylinear-1.4.1.tar.gz.

File metadata

  • Download URL: energypylinear-1.4.1.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.5 Linux/6.14.0-1017-azure

File hashes

Hashes for energypylinear-1.4.1.tar.gz
Algorithm Hash digest
SHA256 ba133e1716b2541117635d05f9923da156b0dab07629552d93c312ab0988de12
MD5 847837648a96af25656c2c1176cd038a
BLAKE2b-256 c1027d1f1295afb9b23e23bb501b827036ee9a18163fcc371e6b6d742626d1b1

See more details on using hashes here.

File details

Details for the file energypylinear-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: energypylinear-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 69.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.5 Linux/6.14.0-1017-azure

File hashes

Hashes for energypylinear-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25d4477d42768a96e29f2bcb52463e72874f2c15fb0b926c42c2f077235060bf
MD5 75533c8b1c830d3bdbd4d5fc7d59c4d0
BLAKE2b-256 ba428322bf8e14c82d07d67fb165fc3ee10f2791640c9c8d3a6179bd35bf658f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page