Skip to content

fluxopt

Energy system optimization with linopy — detailed dispatch, scaled to multi-period planning.

PyPI Downloads License: MIT Python 3.12+ Ruff

Get Started GitHub


  • Composable elements


    Build models from Flow, Bus, Converter, Storage, and Effect — clear separation of physics, costs, and topology.

  • xarray-native


    Time series, parameters, and results as xr.Dataset — vectorized constraints via linopy.

  • Sizing & status


    Capacity optimization and on/off behavior as first-class concerns, not bolt-ons.

  • HiGHS out of the box


    Open-source MIP solver bundled. Swap in Gurobi, CPLEX, or any linopy-supported backend.

  • Math, documented


    Every constraint has a formulation page with notation, derivation, and the line of code that emits it.

  • Companion ecosystem


    Lean core, optional companions for plotting, YAML loading, and (planned) interactive marimo apps.

# A gas boiler covers a heat demand, minimizing fuel cost
from datetime import datetime
from fluxopt import Carrier, Converter, Effect, Flow, Port, optimize

result = optimize(
    timesteps=[datetime(2024, 1, 1, h) for h in range(4)],
    carriers=[Carrier('gas'), Carrier('heat')],
    effects=[Effect('cost')],
    ports=[
        Port('grid', imports=[
            Flow('gas', size=500, effects_per_flow_hour={'cost': 0.04})
        ]),
        Port('demand', exports=[
            Flow('heat', size=100, fixed_relative_profile=[0.4, 0.7, 0.5, 0.6])
        ])
    ],
    converters=[
        Converter.boiler(
            'boiler',
            thermal_efficiency=0.9,
            fuel_flow=Flow('gas', size=300),
            thermal_flow=Flow('heat', size=200)
        )
    ],
    objective_effects='cost',
)

print(f"Total cost: {result.objective:.2f}")
print(result.flow_rates)

Where to next

  • Learn by example


    Seven executable notebooks from quickstart through investment and piecewise conversion.

    Notebooks

  • Math reference


    Notation, objective, and per-element formulations.

    Math

  • API reference


    Auto-generated from source — every public class, every parameter.

    API