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().- Return type:
- monee.run_energy_flow(net: monee.model.network.Network, solver=None, **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 (mm.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.
**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 (mm.Network) – The network to optimize. Must be a fully specified mm.Network object with all nodes, edges, and parameters defined.
optimization_problem (mp.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, bounds_t: tuple, bounds_pressure: tuple, bounds_ext_el: tuple, bounds_ext_gas: tuple, use_ext_grid_bounds=False, use_ext_grid_objective=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.
This function is designed for scenarios where minimizing load shedding is essential, such as during network contingencies or in energy management systems. Use it when you need to enforce operational limits on voltage, temperature, and pressure for electrical, thermal, and gas subsystems, as well as external grid interfaces. The function constructs a load shedding optimization problem using the provided bounds and delegates the solution process to the energy flow optimization routine. Enabling debug mode provides additional diagnostic output for troubleshooting or analysis.
- Parameters:
network (Network) – The network to optimize, representing the system’s topology and parameters.
bounds_vm (tuple) – Voltage magnitude bounds (min, max) for the electrical subsystem. Must be a tuple of two numeric values.
bounds_t (tuple) – Temperature bounds (min, max) for the thermal subsystem. Must be a tuple of two numeric values.
bounds_pressure (tuple) – Pressure bounds (min, max) for the gas subsystem. Must be a tuple of two numeric values.
bounds_ext_el (tuple) – External grid voltage bounds (min, max) for the electrical subsystem. Must be a tuple of two numeric values.
bounds_ext_gas (tuple) – External grid pressure bounds (min, max) for the gas subsystem. Must be a tuple of two numeric values.
debug (bool, optional) – If True, enables verbose logging and diagnostics. Defaults to False.
**kwargs – Additional keyword arguments for solver configuration or optimization tuning. 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
create_bus()create_chp()create_consume_hydr_grid()create_el_branch()create_el_child()create_ext_hydr_grid()create_ext_power_grid()create_g2h()create_g2p()create_gas_child()create_gas_ext_grid()create_gas_grid_forming_source()create_gas_junction()create_gas_pipe()create_gas_sink()create_gas_source()create_grid_forming_generator()create_grid_forming_source()create_heat_exchanger()create_junction()create_line()create_multi_energy_network()create_p2g()create_p2h()create_power_generator()create_power_load()create_sink()create_source()create_trafo()create_water_child()create_water_ext_grid()create_water_grid_forming_source()create_water_junction()create_water_pipe()create_water_sink()create_water_source()
- monee models
- monee.model.formulation
- monee io
- monee network
create_chp_in_combined_generated_network()create_gas_net_for_power()create_heat_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()get_length()- monee generate net from simbench
- monee optimization problem
- monee simulation
- monee solver
- monee visualization