API-reference

The API reference provides detailed descriptions of the monee’s classes and functions.

class monee.Network(active_grid=None, el_model=PowerGrid(name='power', sn_mva=1), water_model=WaterGrid(name='water', fluid_density=998, dynamic_visc=0.000596, t_ref=356, pressure_ref=1000000), gas_model=GasGrid(name='gas', compressibility=1, molar_mass=0.0165, gas_temperature=300, dynamic_visc=1.2190162697374919e-05, higher_heating_value=15.3, universal_gas_constant=8.314, t_k=300, t_ref=356, pressure_ref=1000000))[source]

No docstring provided.

activate(component)[source]

No docstring provided.

activate_by_id(cls, id)[source]

No docstring provided.

activate_grid(grid)[source]

No docstring provided.

all_components()[source]

No docstring provided.

all_models()[source]

No docstring provided.

all_models_with_grid()[source]

No docstring provided.

apply_formulation(network_formulation: monee.model.formulation.core.NetworkFormulation)[source]
as_dataframe_dict()[source]

No docstring provided.

as_dataframe_dict_str()[source]

No docstring provided.

as_result_dataframe_dict()[source]

No docstring provided.

branch(model, from_node_id, to_node_id, formulation=None, constraints=None, grid=None, name=None, auto_node_creator=None, auto_grid_key=None, **kwargs)[source]

No docstring provided.

branch_by_id(branch_id)[source]

No docstring provided.

property branches: list[Branch]

No docstring provided.

branches_by_ids(branch_ids)[source]

No docstring provided.

Return type:

list[monee.model.core.Branch]

branches_by_type(cls)[source]

No docstring provided.

branches_connected_to(node_id)[source]

No docstring provided.

Return type:

list[monee.model.core.Branch]

child(model, attach_to_node_id=None, formulation=None, constraints=None, overwrite_id=None, name=None, auto_node_creator=None, auto_grid_key=None)[source]

No docstring provided.

child_by_id(child_id)[source]

No docstring provided.

child_to(model, node_id, formulation=None, constraints=None, overwrite_id=None, name=None, auto_node_creator=None, auto_grid_key=None)[source]

No docstring provided.

property childs: list[Child]

No docstring provided.

childs_by_ids(child_ids)[source]

No docstring provided.

Return type:

list[monee.model.core.Child]

childs_by_type(cls)[source]

No docstring provided.

clear_childs()[source]

No docstring provided.

components_connected_to(node_id)[source]

No docstring provided.

Return type:

list[monee.model.core.Component]

compound(model: monee.model.core.CompoundModel, formulation=None, constraints=None, overwrite_id=None, **connected_node_ids)[source]

No docstring provided.

compound_by_id(compound_id)[source]

No docstring provided.

compound_of(subcomponent_component_id)[source]

No docstring provided.

Return type:

list[monee.model.core.Component]

compound_of_node(node_id)[source]

No docstring provided.

property compounds: list[Compound]

No docstring provided.

compounds_by_type(cls)[source]

No docstring provided.

compounds_connected_to(node_id)[source]

No docstring provided.

Return type:

list[monee.model.core.Component]

constraint(constraint_equation)[source]

No docstring provided.

property constraints

No docstring provided.

copy()[source]

No docstring provided.

property cps: list[GenericModel]

No docstring provided.

deactivate(component)[source]

No docstring provided.

deactivate_by_id(cls, id)[source]

No docstring provided.

first_node()[source]

No docstring provided.

get_branch_between(node_id_one, node_id_two)[source]

No docstring provided.

get_childs_by_type(branch, cls)[source]

No docstring provided.

Return type:

list[monee.model.core.Child]

property graph

No docstring provided.

property grids

No docstring provided.

has_any_child_of_type(branch, cls)[source]

No docstring provided.

Return type:

bool

has_branch(branch_id)[source]

No docstring provided.

has_branch_between(node_id_one, node_id_two)[source]

No docstring provided.

has_child(child_id)[source]

No docstring provided.

has_node(node_id)[source]

No docstring provided.

is_blacklisted(obj)[source]

No docstring provided.

move_branch(branch_id, new_from_id, new_to_id)[source]

No docstring provided.

node(model, grid=None, formulation=None, child_ids=None, constraints=None, overwrite_id=None, name=None, position=None)[source]

No docstring provided.

node_by_id(node_id)[source]

No docstring provided.

Return type:

monee.model.core.Node

node_by_id_or_create(node_id, auto_node_creator, auto_grid_key)[source]

No docstring provided.

property nodes: list[Node]

No docstring provided.

nodes_by_type(cls)[source]

No docstring provided.

objective(objective_function)[source]

No docstring provided.

property objectives

No docstring provided.

remove_branch(branch_id)[source]

No docstring provided.

remove_branch_between(node_one, node_two, key=0)[source]

No docstring provided.

remove_child(child_id)[source]

No docstring provided.

remove_compound(compound_id)[source]

No docstring provided.

remove_node(node_id)[source]

No docstring provided.

set_default_grid(key, grid)[source]

No docstring provided.

statistics()[source]

No docstring provided.

class monee.StepHook[source]

No docstring provided.

post_run(net, base_net, step)[source]

No docstring provided.

pre_run(net, base_net, step)[source]

No docstring provided.

class monee.TimeseriesData[source]

No docstring provided.

add_branch_series(branch_id: int, attribute: str, series: list)[source]

No docstring provided.

add_child_series(child_id: int, attribute: str, series: list)[source]

No docstring provided.

add_child_series_by_name(child_name: str, attribute: str, series: list)[source]

No docstring provided.

add_compound_series(compound_id: int, attribute: str, series: list)[source]

No docstring provided.

property branch_id_data

No docstring provided.

property child_id_data

No docstring provided.

property child_name_data

No docstring provided.

property compound_id_data

No docstring provided.

extend(td)[source]

No docstring provided.

class monee.TimeseriesResult(raw)[source]

No docstring provided.

get_result_for(type, attribute: str)[source]

No docstring provided.

Return type:

pandas.DataFrame

property raw

No docstring provided.

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.run_timeseries(net: monee.model.network.Network, timeseries_data: monee.simulation.timeseries.TimeseriesData, steps: int, step_hooks: list[monee.simulation.timeseries.StepHook | collections.abc.Callable] = None, solver=None, optimization_problem=None, solve_flag=True)

No docstring provided.

monee.solve(net: monee.model.network.Network, optimization_problem: monee.problem.core.OptimizationProblem, solver=None, **kwargs)[source]

No docstring provided.

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