fluxopt¶
Energy system optimization with linopy — detailed dispatch, scaled to multi-period planning.
-
Composable elements
Build models from
Flow,Bus,Converter,Storage, andEffect— 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)