API-reference¶
The API reference provides detailed descriptions of the monee’s classes and functions.
- monee.enable_islanding(network: monee.model.network.Network, electricity=None, gas=None, water=None)[source]¶
Enable islanding for network and return the
NetworkIslandingConfig.Each carrier argument accepts: *
True- use the defaultIslandingModefor that carrier. * AnIslandingModeinstance - use a custom mode. *None(default) - islanding disabled for that carrier.The resulting config is attached to
network.islanding_configso thatGEKKOSolver/PyomoSolverpick it up automatically onsolve().
- monee.run_energy_flow(net: monee.model.network.Network, solver=None, simulation: bool = True, **kwargs)[source]¶
Performs a basic energy flow analysis on a network without applying optimization constraints.
This function provides a straightforward assessment of energy flows within a network, making it useful for initial feasibility checks, diagnostics, or scenarios where optimization is not required. Use this function when you need quick insights into network behavior or as a baseline before introducing optimization-based analyses. It fits into workflows involving network validation, troubleshooting, or preliminary studies. Internally, the function delegates to run_energy_flow_optimization with the optimization problem set to None, utilizing the same solver infrastructure but bypassing optimization logic.
- Parameters:
net (
monee.model.network.Network) – The network to analyze, represented as an mm.Network instance. The network must be fully defined, including all necessary nodes and parameters.solver (optional) – The solver to use for the energy flow computation. If not specified, a default compatible solver is chosen. The solver must support the network’s structure.
simulation (
bool) – WhenTrue(default), solve as a square steady-state simulation (GEKKO IMODE=1, falling back to IMODE=3 if the model is not square). PassFalseto force the optimize-the-feasibility-problem path. Ignored by backends without a simulation mode (e.g. Pyomo). Checkresult.mode_usedto see which path actually ran.**kwargs – Additional keyword arguments for solver configuration or analysis tuning. Refer to the solver’s documentation for supported options.
- Returns:
The result of the energy flow analysis, typically including calculated flow values and status information. The exact structure depends on the solver and network configuration.
- Return type:
Any
- Raises:
ValueError – If the network is incomplete, invalid, or if incompatible parameters are provided.
SolverError – If the solver fails to compute the energy flow or encounters an error during analysis.
Examples
- Run a basic energy flow analysis with a specified solver:
result = run_energy_flow(my_network, solver=’default_solver’)
- Run analysis with additional solver options:
result = run_energy_flow(my_network, max_iter=500, tol=1e-5)
- monee.run_energy_flow_optimization(net: monee.model.network.Network, optimization_problem: monee.problem.core.OptimizationProblem, solver=None, **kwargs)[source]¶
Executes an energy flow optimization on a given network using a specified optimization problem and solver.
This function determines the optimal distribution of energy flows within a network, subject to constraints and objectives defined by the provided optimization problem. Use this function when you need to solve power grid management, load balancing, or energy distribution planning tasks. It is typically integrated into simulation, planning, or real-time control workflows for energy systems. The function delegates the optimization process to a solver, which processes the network and problem definition to compute the optimal solution.
- Parameters:
net (
monee.model.network.Network) – The network to optimize. Must be a fully specified mm.Network object with all nodes, edges, and parameters defined.optimization_problem (
monee.problem.core.OptimizationProblem) – The optimization problem instance, specifying constraints and objectives for the energy flow.solver (optional) – The solver to use for optimization. If None, a default compatible solver is selected. Must support the problem’s formulation.
**kwargs – Additional keyword arguments for solver configuration or optimization tuning. Refer to the solver’s documentation for supported options.
- Returns:
The optimization result, which may include optimal energy flows, solution status, and additional diagnostic information. The exact structure depends on the solver and problem definition.
- Return type:
Any
- Raises:
ValueError – If the network or optimization problem is invalid, incomplete, or incompatible.
SolverError – If the solver fails to find a feasible solution or encounters an internal error.
Examples
- Optimize energy flow with a custom solver:
result = run_energy_flow_optimization(my_network, my_problem, solver=’cbc’)
- Use the default solver with additional options:
result = run_energy_flow_optimization(my_network, my_problem, max_iter=1000, tol=1e-6)
- monee.solve_load_shedding_problem(network: monee.model.network.Network, *, bounds_vm: tuple = (0.9, 1.1), bounds_pressure: tuple = (0.9, 1.1), bounds_t: tuple = (0.9, 1.1), bounds_ext_el: tuple = (-3, 3), bounds_ext_gas: tuple = (-10, 10), bounds_ext_heat: tuple = (-10, 10), include_ext_grids=True, check_lp=True, check_vm=True, check_pressure=True, check_t=True, debug=False, **kwargs)[source]¶
Solves a load shedding optimization problem for a network using specified operational bounds across subsystems.
The bound / check parameters mirror
create_min_load_shedding_problem()one-to-one, using the physical-quantity vocabulary:bounds_vm(voltage magnitude),bounds_t(temperature),bounds_pressure(gas pressure),bounds_ext_el/bounds_ext_gas/bounds_ext_heat(external-grid exchange) and thecheck_vm/check_t/check_pressure/check_lptoggles. Any remaining keyword argument is forwarded to the solver viarun_energy_flow_optimization().- Parameters:
network (
monee.model.network.Network) – The network to optimize, representing the system’s topology and parameters.bounds_vm (
tuple) – Per-unit voltage-magnitude bounds (min, max) for the electrical subsystem.bounds_pressure (
tuple) – Per-unit pressure bounds (min, max) for the gas subsystem.bounds_t (
tuple) – Per-unit temperature bounds (min, max) for the thermal subsystem.bounds_ext_el (
tuple) – External electrical-grid exchange bounds (min, max).bounds_ext_gas (
tuple) – External gas-grid exchange bounds (min, max).bounds_ext_heat (
tuple) – External heat-grid exchange bounds (min, max).include_ext_grids (bool) – Constrain external-grid exchange. Defaults to True.
check_lp (bool) – Enforce the line-loading limit. Defaults to True.
check_vm (bool) – Enforce voltage-magnitude bounds. Defaults to True.
check_pressure (bool) – Enforce gas-pressure bounds. Defaults to True.
check_t (bool) – Enforce temperature bounds. Defaults to True.
debug (bool, optional) – If True, enables verbose logging and diagnostics. Defaults to False.
**kwargs – Additional keyword arguments forwarded to the solver. Refer to the solver documentation for supported options.
- Returns:
The result of the load shedding optimization, typically including optimized energy flows, load shedding amounts, and status information. The structure of the result depends on the solver and problem formulation.
- Return type:
Any
- Raises:
ValueError – If the network or any bounds are missing, improperly defined, or incompatible.
SolverError – If the solver fails to find a feasible solution or encounters an error during optimization.
Examples
Solve a load shedding problem with specific operational bounds:
result = solve_load_shedding_problem( my_network, bounds_vm=(0.95, 1.05), bounds_t=(60, 80), bounds_pressure=(30, 50), bounds_ext_el=(0.9, 1.1), bounds_ext_gas=(25, 45), debug=True, )
This executes the optimization with the specified bounds and returns the results.
By subpackages¶
- monee express
- monee models
- monee.model.formulation
- monee.model.extension
- monee.model.phys
- monee io
- monee network
create_chp_in_combined_generated_network()create_coupling_points_for_mes()create_gas_net_for_power()create_gas_tree_net_for_power()create_heat_net_for_power()create_heat_supply_return_net_for_power()create_monee_benchmark_net()create_mv_multi_cigre()create_p2g_in_combined_generated_network()create_p2h_in_combined_generated_network()generate_mes_based_on_power_net()generate_supply_return_mes_based_on_power_net()get_length()- Reference energy systems
- Generated MES from SimBench
- Restoration benchmark
- monee optimization problem
- monee simulation
- monee solver
- monee visualization