monee network

monee.network.mes.create_chp_in_combined_generated_network(new_mes_net: monee.model.network.Network, net_power, bus_to_heat_junc, end_bus_to_heat_junc, bus_to_gas_junc, chp_density, seed=None)[source]
monee.network.mes.create_coupling_points_for_mes(mes_net: monee.model.network.Network, bus_to_gas_junc, bus_to_heat_supply_junc, heat_return_junc, density=0.2, centralized=False, central_node_id=None, couplings=('chp', 'p2g', 'p2h'), chp_efficiency_power=0.4, chp_efficiency_heat=0.45, chp_diameter_m=0.05, chp_p_share=0.5, p2g_efficiency=0.7, p2g_p_share=1.0, p2h_efficiency=0.95, p2h_p_share=1.0, p2h_diameter_m=0.01, cp_size_multiplier=1.0, regulation=1.0, use_hg_variants=False, seed=None, replace_primary_generation=False)[source]

Add CHP / P2G / P2H coupling points to an MES network.

density ∈ [0,1] is per-node Bernoulli in decentralised mode and ceil(density·N) units on one hub in centralised mode. Capacities scale from each bus’s local p_ref via the per-type *_p_share and a global cp_size_multiplier.

replace_primary_generation=True (default False is additive) drains the matching primary fleet to keep total rated production per carrier invariant. In node-based heat mode, heat-side replacement drains HeatGenerator children (no slack fallback).

Returns list[{"type", "node", "id"}].

monee.network.mes.create_gas_net_for_power(power_net, target_net: monee.model.network.Network, gas_deployment_rate, scaling=1, source_scaling=1, default_diameter_m=0.3, length_scale=1, default_length=100, seed=None, gas_type='lgas')[source]
monee.network.mes.create_gas_tree_net_for_power(power_net: monee.model.network.Network, target_net: monee.model.network.Network, gas_load_share=3.0, gas_gen_share=1.0, default_diameter_m=0.3, length_scale=1, default_length=100, min_load_kgs=0.00018, min_source_kgs=0.00018, slack_node_id=None, extra_mesh_pipes=0, mesh_diameter_factor=0.5, mesh_length_factor=2.0, mesh_seed=None)[source]

Build a gas grid on the spanning tree of power_net.

Loads/generators are sized from electrical magnitudes via gas_load_share / gas_gen_share and the HHV; extra_mesh_pipes add tie-lines so a single failure doesn’t isolate a subtree. min_load_kgs / min_source_kgs floor per-bus values at ~10 kW thermal.

Returns {power_node_id gas_junction_id}.

monee.network.mes.create_heat_net_for_power(power_net, target_net, heat_deployment_rate, mass_flow_rate_kgs=0.075, default_diameter_m=0.12, length_scale=1, default_length=100, power_scale=1, design_flow_headroom=1.5, seed=None)[source]
monee.network.mes.create_heat_supply_return_net_for_power(power_net: monee.model.network.Network, target_net: monee.model.network.Network, heat_load_share=1.0, heat_gen_share=0.5, default_diameter_m=0.12, return_diameter_m=None, length_scale=1, default_length=100, return_length_m=None, min_load_mw=0.005, min_gen_mw=0.005, slack_node_id=None, node_based_heat_loads=False, balance_gen_to_load=True, heat_plant_mode='closing_pipe', return_t_k=326, return_pressure_pu=0.95, return_pin_temperature=False, node_heat_gen_share=1.0, supply_slack_t_k=356, auto_diameter=False, auto_diameter_v_mps=None, auto_diameter_headroom=1.5, auto_min_diameter_m=None)[source]

Build a supply/return DHS grid on the spanning tree of power_net.

Supply junctions mirror the buses; one shared return junction collects all consumer returns and feeds the generators. HX-Load and HX-Gen branches bridge supply and return.

heat_plant_mode:
  • "closing_pipe" (default) - single supply slack + return-to-supply closing pipe. Robust under the LinearHeatExchanger formulation but the slack t-pin collapses some supply/return ΔT.

  • "two_port" - second slack at the return junction. Cleaner physics but needs McCormick-DHS (node_based_heat_loads=True).

  • "screening" - closing pipe plus an oversized return Sink; faster but mass flow is no longer physical.

Capacities scale from electrical magnitudes via heat_load_share / heat_gen_share; balance_gen_to_load rescales generators to match. In node-based mode node_heat_gen_share distributes HeatGenerator children at every PowerGenerator bus (set to 0.0 for slack-only).

auto_diameter (default off) sizes each supply pipe - and the return / closing pipe - to the mass flow it must carry instead of the flat default_diameter_m. The required flow is the cumulative downstream consumer demand (the same per-pipe subtree total used for the McCormick-DHS envelopes), so trunk pipes near the slack come out wider than leaf pipes. Each diameter is the smallest that keeps the design velocity_mps at auto_diameter_v_mps (defaults to the grid’s v_max_mps) after a auto_diameter_headroom margin on the flow, floored at auto_min_diameter_m (defaults to default_diameter_m so leaf pipes are never thinned below the flat default). Without it, a large radial DHS (e.g. simbench MV-urban: ~256 kg/s through 0.12 m pipes) is physically infeasible - the trunk flow exceeds the velocity_mps cap and the Darcy pressure drop blows up.

Returns ({power_node_id supply_junction_id}, return_junction_id).

monee.network.mes.create_monee_benchmark_net()[source]
monee.network.mes.create_mv_multi_cigre()[source]
monee.network.mes.create_p2g_in_combined_generated_network(new_mes_net, net_power, bus_to_gas_junc, p2g_density, seed=None)[source]
monee.network.mes.create_p2h_in_combined_generated_network(new_mes_net: monee.model.network.Network, net_power, bus_to_heat_junc, end_bus_to_heat_junc, p2h_density, seed=None)[source]
monee.network.mes.generate_mes_based_on_power_net(net_power: monee.model.network.Network, heat_deployment_rate, gas_deployment_rate, chp_density=0.1, p2g_density=0.02, p2h_density=0.1, seed=None)[source]
monee.network.mes.generate_supply_return_mes_based_on_power_net(net_power: monee.model.network.Network, *, coupling_density=0.2, centralized=False, central_node_id=None, couplings=('chp', 'p2g', 'p2h'), heat_kwargs=None, gas_kwargs=None, coupling_kwargs=None)[source]

Wrap create_gas_tree_net_for_power() + create_heat_supply_return_net_for_power() + create_coupling_points_for_mes() into one call. gas_kwargs / heat_kwargs / coupling_kwargs forward to those builders.

monee.network.mes.get_length(net: monee.model.network.Network, branch, node1_id, node2_id, default_length=100)[source]

Reference energy systems

monee.network.res.create_large_urban_mes_net(n_districts: int = 6)[source]

Scaled multi-district urban MES for large-grid restoration evaluation.

Replicates the urban-district pattern n_districts times under a shared HV slack and a shared external gas feeder, linking adjacent districts with normally-open MV power ties and live gas trunks. Heat is intentionally local-only (one return-side consumer pair per district), so the heat sector decomposes into one connected component per district while electricity and gas remain single-component.

Sizing (per district): 5 power buses, 4 gas junctions, 4 water junctions, 2 heat consumers, 3 CPs (CHP/P2G/G2P), 4 internal ties.

Defaults (n_districts=6) yield ~96 nodes / ~30 children. Set n_districts=20 for a ~320-node / ~100-child stress test that actually exercises gossip scaling and meaningful holon formation in the heat sector (one group per district).

Parameters:

n_districts (int) – Number of urban districts to replicate. Must be ≥1.

Return type:

monee.model.network.Network

monee.network.res.create_urban_district_net()[source]

Urban residential district: 20 kV power + medium-pressure gas + district heat.

5 buses · 5 gas junctions · 4 heat junctions (3 supply + 1 return) · 3 CPs. Highest CP-to-node ratio of the three grids. Suitable for: testing CHP-centred resilience.

The heat grid uses a supply-return two-pipe structure: the CHP injects heat on the return→supply side (r1→s1, ~176 kW) and a single HeatExchangerLoad consumer extracts on the supply→return side (s3→r1).

Return type:

monee.model.network.Network

Generated MES from SimBench

Restoration benchmark

Multi-energy benchmark grid for grid restoration studies.

Topology

Electricity (~27 buses):

Two 110 kV feeders (ext-grids) supply a meshed 20 kV distribution backbone via transformers. Three open chains (industrial, commercial, residential) carry loads and distributed generation. A battery provides storage flexibility.

Gas (~30 junctions):

Two high-pressure feeders supply a medium-pressure distribution network via compressors. Three distribution chains serve gas sinks. A gas storage cavern adds flexibility.

Thermal / District Heating (121 junctions – 120 supply + 1 return):

One heat plant feeds a 120-junction supply-pipe chain. A single shared return junction collects cooled water (no mirrored return chain). Heat exchangers bridge supply junctions to the return junction at consumer nodes. Coupling points feed the supply chain.

Coupling points (7 total – all variants):
  • 2 x CHP (gas -> electricity + heat)

  • 1 x P2H (electricity -> heat)

  • 1 x G2H (gas -> heat)

  • 1 x P2G (electricity -> gas)

  • 2 x G2P (gas -> electricity)

Extensions:
  • GasLinepack – inherent gas storage in pipes

  • LumpedThermalCapacitance – thermal inertia at junctions (LTC)

The grid is intended for multi-period optimisation, restoration sequence planning, and resilience studies.

Note

This benchmark is designed for the PyomoSolver with ipopt. Recommended solver options:

from monee.solver.pyo import DEFAULT_SOLVER_OPTIONS
DEFAULT_SOLVER_OPTIONS["max_iter"] = 5000
DEFAULT_SOLVER_OPTIONS["tol"] = 1e-4
DEFAULT_SOLVER_OPTIONS["acceptable_tol"] = 1e-3
DEFAULT_SOLVER_OPTIONS["acceptable_iter"] = 10
monee.network.bench.restoration.create_restoration_benchmark(*, linepack: bool = False, ltc: bool = False, misocp: bool = True)[source]

Build and return the multi-energy restoration benchmark grid.

Parameters:
  • linepack (bool) – Attach GasLinepack extension. Default False.

  • ltc (bool) – Attach LumpedThermalCapacitance extension. Default False.

  • misocp (bool) – Replace the default AC power-flow formulation with the MISOCP relaxation (suitable for PyomoSolver). Default True.

Returns:

The fully built network.

Returns:

monee.model.network.Network