Skip to content

Interval Data

Interval data is a key input to an energypylinear simulation.

By default, energypylinear accepts interval data for things like electricity prices, carbon intensities and site electricity and heat consumption:

class Site:
    """
    The Site asset can optimize many assets together in a single linear program.

    All assets are connected to the same site electricity, high and low temperature networks.
    """

    def __init__(
        self,
        assets: list,
        electricity_prices: np.ndarray | list[float] | float | None = None,
        export_electricity_prices: np.ndarray | list[float] | float | None = None,
        electricity_carbon_intensities: np.ndarray | list[float] | float | None = None,
        gas_prices: np.ndarray | list[float] | float | None = None,
        electric_load_mwh: np.ndarray | list[float] | float | None = None,
        high_temperature_load_mwh: np.ndarray | list[float] | float | None = None,
        low_temperature_load_mwh: np.ndarray | list[float] | float | None = None,
        low_temperature_generation_mwh: np.ndarray | list[float] | float | None = None,
        name: typing.Literal["site"] = "site",
        freq_mins: int = defaults.freq_mins,
        import_limit_mw: float = 10000,
        export_limit_mw: float = 10000,
        constraints: "list[epl.Constraint] | list[dict] | None" = None,
        **kwargs: typing.Any,
    ):
        """
        Initialize a Site.

        Args:
            assets: Assets to optimize together.
            electricity_prices: The price of import electricity in each interval.
                Will define both import and export prices if `export_electricity_prices` is None.
            export_electricity_prices: The price of export electricity in each interval.
            electricity_carbon_intensities: Carbon intensity of electricity in each interval.
            electric_load_mwh: Electricity demand consumed by the site.
            gas_prices: Price of natural gas, used in CHP and boilers in each interval.
            high_temperature_load_mwh: High temperature load of the site.
            low_temperature_load_mwh: Low temperature load of the site.
            name: The site name.
            freq_mins: Size of an interval in minutes.
            import_limit_mw: Maximum import power of the site.
            export_limit_mw: Minimum import power of the site.
            constraints: Additional custom constraints to apply to the linear program.
            kwargs: Keyword arguments attempted to be used as extra interval data.
        """

These arguments are passed to the SiteIntervalData object, which is responsible for managing interval data for a site:

import energypylinear as epl

asset = epl.Battery(electricity_prices=[100, 50, 200])
print(asset.site.cfg.interval_data)
electricity_prices=array([100.,  50., 200.]) export_electricity_prices=array([100.,  50., 200.]) electricity_carbon_intensities=array([0.1, 0.1, 0.1]) gas_prices=array([20, 20, 20]) electric_load_mwh=array([0, 0, 0]) high_temperature_load_mwh=array([0, 0, 0]) low_temperature_load_mwh=array([0, 0, 0]) low_temperature_generation_mwh=array([0, 0, 0]) idx=array([0, 1, 2])

Custom Interval Data

Often you will want to use different interval data for your simulation - for example modelling site network charges.

Additional keyword arguments passed into a site or asset __init__ are attempted to be parsed into interval data. These will be parsed into site interval data, even if passed into an asset.

For example, when we pass in a network_charge argument, we end up with a network_charge attribute on our asset.site.cfg.interval_data object:

import energypylinear as epl

electricity_prices = [100, 50, 200]
asset = epl.Battery(electricity_prices=[100, 50, 200], network_charges=[10, 20, 30])
print(asset.site.cfg.interval_data)
electricity_prices=array([100.,  50., 200.]) export_electricity_prices=array([100.,  50., 200.]) electricity_carbon_intensities=array([0.1, 0.1, 0.1]) gas_prices=array([20, 20, 20]) electric_load_mwh=array([0, 0, 0]) high_temperature_load_mwh=array([0, 0, 0]) low_temperature_load_mwh=array([0, 0, 0]) low_temperature_generation_mwh=array([0, 0, 0]) idx=array([0, 1, 2]) network_charges=array([10., 20., 30.])

Custom Interval Data in Simulation Results

All custom interval data will appear in the simulation results:

import energypylinear as epl

asset = epl.Battery(electricity_prices=[100, 50, 200], network_charges=[10, 20, 30])
simulation = asset.optimize(verbose=3)
print(simulation.results["site-network_charges"])
0    10.0
1    20.0
2    30.0
Name: site-network_charges, dtype: float64

Custom Interval Data in Custom Objective Functions

Custom interval data can be used in a custom objective function:

import energypylinear as epl

asset = epl.Battery(electricity_prices=[100, 50, 200], network_charges=[10, 20, 30])
simulation = asset.optimize(
    objective={
        "terms": [
            {
                "asset_type": "site",
                "variable": "import_power_mwh",
                "interval_data": "electricity_prices",
            },
            {
                "asset_type": "site",
                "variable": "export_power_mwh",
                "interval_data": "electricity_prices",
                "coefficient": -1,
            },
        ]
    },
    verbose=3
)