monee models¶
Package-level re-exports¶
Most model classes are re-exported directly from monee.model, so
import monee.model as mm gives access to everything listed below. The
per-module sections that follow document each submodule under its canonical
path (e.g. Var, Bus).
- class monee.model.Branch(model, from_node_id, to_node_id, formulation=None, constraints=None, grid=None, name=None, active=True, independent=True)[source]
Bases:
Component- equations(grid, from_node_model, to_node_model, **kwargs)[source]
- minimize(grid, from_node_model, to_node_model, **kwargs)[source]
- property tid
- class monee.model.BranchModel(**kwargs)[source]
Bases:
GenericModelAbstract base class for network branches (lines, pipes). Subclasses define branch equations.
- abstractmethod equations(grid, from_node_model, to_node_model, **kwargs)[source]
- init(grid)[source]
- is_cp()[source]
- loss_percent()[source]
- minimize(grid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.Bus(base_kv)[source]
Bases:
NodeModel- calc_signed_power_values(from_branch_models, to_branch_models, child_models)[source]
- equations(grid, from_branch_models, to_branch_models, child_models, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- p_mw_equation(child_models)[source]
- q_mvar_equation(child_models)[source]
- class monee.model.CHP(diameter_m: float, efficiency_power: float, efficiency_heat: float, mass_flow_setpoint_kgs: float, q_mvar_setpoint: float = 0, temperature_ext_k: float = 293, regulation=1)[source]
Bases:
MultiGridCompoundModel- create(network: monee.model.network.Network, gas_node: monee.model.core.Node, heat_node: monee.model.core.Node, heat_return_node: monee.model.core.Node, power_node: monee.model.core.Node)[source]
Add sub-components (nodes, branches, children) to network.
- set_active(activation_flag)[source]
- class monee.model.CHPControlNode(mass_flow_capacity_kgs, efficiency_power, efficiency_heat, hhv, q_mvar=0, regulation=1, **kwargs)[source]
Bases:
MultiGridNodeModel,Junction,BusControl node for a CHP unit; couples power, heat, and gas domains.
- equations(grid, from_branch_models, to_branch_models, childs, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- class monee.model.CHPHG(efficiency_power: float, efficiency_heat: float, mass_flow_setpoint_kgs: float, q_mvar_setpoint: float = 0, regulation=1)[source]
Bases:
MultiGridCompoundModelHeatGenerator-based
CHPvariant: heat is injected via aSubHGchild atheat_nodeinstead of via an HX branch. Noheat_return_node/diameter_mrequired.- create(network: monee.model.network.Network, gas_node: monee.model.core.Node, heat_node: monee.model.core.Node, power_node: monee.model.core.Node)[source]
Add sub-components (nodes, branches, children) to network.
- class monee.model.CHPHGControlNode(mass_flow_capacity_kgs, efficiency_power, efficiency_heat, hhv, sub_hg, q_mvar=0, regulation=1, **kwargs)[source]
Bases:
MultiGridNodeModel,Junction,BusCHP control node using a node-based HeatGenerator (no HX branch).
Like
CHPControlNodebut only on power+gas; heat goes through aSubHGchild attached at the heat node byCHPHG.- equations(grid, from_branch_models, to_branch_models, childs, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- class monee.model.Child(child_id, model, formulation=None, constraints=None, grid=None, name=None, active=True, independent=True)[source]
Bases:
Component- equations(grid, node_model, **kwargs)[source]
- minimize(grid, node_model, **kwargs)[source]
- class monee.model.ChildModel(regulation: float = 1.0, **kwargs)[source]
Bases:
GenericModelLeaf component attached to a single node (loads, generators, ext-grids).
Load convention: positive = consumption, negative = generation. Generator subclasses negate the user-supplied magnitude so the public API takes positive numbers.
regulationin[0.0, 1.0]scales the setpoint; used by multi-energy couplers (P2H, CHP) for partial dispatch.- abstractmethod equations(grid, node_model, **kwargs)[source]
- minimize(grid, node_model, **kwargs)[source]
- overwrite(node_model, grid)[source]
Pin node variables to fixed setpoints (grid-forming children). Default: no-op.
- class monee.model.Component(id, model, formulation=None, constraints=None, grid=None, name=None, active=True, independent=True)[source]
Bases:
ABC- property nid
- property tid
- class monee.model.Compound(compound_id, model: monee.model.core.CompoundModel, connected_to, subcomponents, formulation=None, constraints=None, grid=None, name=None, active=True)[source]
Bases:
Component- component_of_type(comp_type)[source]
- equations(network, **kwargs)[source]
- minimize(network, **kwargs)[source]
- class monee.model.CompoundModel(**kwargs)[source]
Bases:
GenericModelComposite component spanning multiple nodes/carriers (e.g. P2H unit).
Subclasses implement
create()to add sub-components to the network, and may overrideequations()for coupling constraints.- abstractmethod create(network)[source]
Add sub-components (nodes, branches, children) to network.
- equations(network, **kwargs)[source]
- minimize(network, **kwargs)[source]
- class monee.model.Const(value)[source]
Bases:
objectA fixed (non-optimised) constant that participates in the model attribute protocol.
Used in
overwrite()to pin a node variable to a fixed setpoint instead of turning it into a free decision variable.
- class monee.model.ConsumeHydrGrid(mass_flow_kgs=0.1, pressure_pu=1, t_k=293, **kwargs)[source]
Bases:
NoVarChildModelHydraulic demand point: fixed pressure setpoint plus a free mass_flow_kgs Var.
- class monee.model.ElectricStorage(e_mwh_initial, e_mwh_max, p_max_mw, p_mw_initial=0.0, efficiency_charge=1.0, efficiency_discharge=1.0, regulation=1, **kwargs)[source]
Bases:
ChildModelBattery/electric storage attached to a power bus.
SoC update:
e_mwh(t) = e_mwh(t-1) + dt_h * p_mw(t). With efficiency losses,p_mw = p_charge_mw - p_discharge_mw(both \(\ge\) 0) and SoC uses \(\eta_c \cdot p_{charge} - p_{discharge} / \eta_d\).- equations(grid, node, **kwargs)[source]
- inter_temporal_equations(temporal_state: monee.solver.core.InterStepState, component_id, **kwargs)[source]
- make_controllable()[source]
Promote
p_mw(and loss-split vars if lossy) into solver Vars.
- class monee.model.ElectricityIslandingMode(angle_bound: float = 3.15, big_m_conn: int = 200)[source]
Bases:
IslandingModeElectricity islanding: connectivity flow plus \(\theta=0\) at GF buses and energisation-gated angle bounds elsewhere.
- add_physical_constraints(network, gf_nodes, regular_nodes, e_vars)[source]
Carrier-specific physics (override in subclasses). Empty by default.
- Return type:
- carrier_grid_type
alias of
PowerGrid
- prepare(network: monee.model.network.Network)[source]
Add Var placeholders before solver variable injection.
- Return type:
- var_prefix: str = 'el'
- class monee.model.ExtHydrGrid(mass_flow_kgs=-1, pressure_pu=1, t_k=356, max_import_kgs=None, max_export_kgs=None, pin_temperature=True, **kwargs)[source]
Bases:
NoVarChildModel,GridFormingMixinExternal hydraulic slack source. Pins pressure (and optionally temperature), leaves mass_flow_kgs as a free Var. Load convention: negative mass_flow_kgs = injection.
- overwrite(node_model, grid)[source]
Pin pressure; pin temperature only if
pin_temperature(default True). Set False on return-side slacks so T emerges from upstream heat balance.
- class monee.model.ExtPowerGrid(p_mw, q_mvar, vm_pu=1, va_degree=0, max_import_mw=None, max_export_mw=None, **kwargs)[source]
Bases:
NoVarChildModel,GridFormingMixinExternal slack-bus connection. Pins vm_pu and va_degree, leaves p_mw/q_mvar as free Vars absorbing the island’s imbalance. Load convention: positive p_mw = import.
- overwrite(node_model, grid)[source]
Pin the bus voltage magnitude and angle to the configured setpoints.
- class monee.model.GasCompressor(compression_ratio=1.5, max_flow_kgs=10.0)[source]
Bases:
BranchModelIdeal compressor - fixed pressure ratio, unidirectional (suction → discharge). Forward flow lives in
mass_flow_neg_kgsto match GasPipe’s Weymouth convention.- equations(grid: monee.model.grid.GasGrid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.GasGrid(name: str, molar_mass: float, dynamic_visc_pas: float, higher_heating_value_kwh_per_kg: float, universal_gas_constant: float, t_k: float, t_ref_k: float, pressure_ref_pa: float, nominal_pressure_pu: float, max_mass_flow_kgs: float, pressure_squared_pu_max: float, pressure_squared_pu_min: float, compressibility: float = None, pressure_ambient_pa: float = 0.0)[source]
Bases:
GridGas grid domain. Construct via
create_gas_grid()for defaults.compressibilitydefaults toNoneand is then derived from the reference pressure (pressure_ref_pa), temperature (t_k) andmolar_massvia the Papay real-gas correlation (seemonee.model.phys.core.properties), so Z reflects the grid’s declared operating pressure rather than a fixed ideal-gas 1. Pass an explicit value to override (e.g. to force ideal gas withcompressibility=1).- compressibility: float = None
- dynamic_visc_pas: float
- higher_heating_value_kwh_per_kg: float
- max_mass_flow_kgs: float
- molar_mass: float
- nominal_pressure_pu: float
- pressure_ambient_pa: float = 0.0
- pressure_ref_pa: float
- pressure_squared_pu_max: float
- pressure_squared_pu_min: float
- t_k: float
- t_ref_k: float
- universal_gas_constant: float
- class monee.model.GasIslandingMode(big_m_conn: int = 200)[source]
Bases:
IslandingModeGas islanding: connectivity flow plus \(pressure_{pu} \le 2 \cdot e\) on regular junctions (GF junctions already pin pressure via overwrite()).
- add_physical_constraints(network, gf_nodes, regular_nodes, e_vars)[source]
Carrier-specific physics (override in subclasses). Empty by default.
- Return type:
- carrier_grid_type
alias of
GasGrid
- prepare(network: monee.model.network.Network)[source]
Add Var placeholders before solver variable injection.
- Return type:
- var_prefix: str = 'gas'
- class monee.model.GasLinepack(overrides: dict[int, dict] | None = None)[source]
Bases:
NetworkAspectLinepack extension. Injects
linepack_kgandnet_pack_kgson every GasPipe; auto-sizes initial/max from grid params. Per-pipe overrides via theoverrides{branch_id: {"linepack_kg_initial": ..., "linepack_kg_max": ...}}.- activate_timeseries(network, ignored_nodes: set, step_state=None)[source]
Mark timeseries so equations() stops pinning net_pack_kgs=0; warm-start linepack_kg from step_state when available.
- Return type:
- equations(network, ignored_nodes: set)[source]
\(\text{linepack\_kg} = V_{pipe} \cdot \text{gas\_density\_kg\_per\_m3}\); pin
net_pack_kgs = 0in steady-state mode.- Return type:
- class monee.model.GasPipe(diameter_m, length_m, temperature_ext_k=296.15, roughness_m=0.0001, on_off=1, friction=None)[source]
Bases:
BranchModel- equations(grid: monee.model.grid.GasGrid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.GasStorage(m_stored_kg_initial, m_stored_kg_max, flow_max_kgs, mass_flow_initial_kgs=0.0, efficiency_charge=1.0, efficiency_discharge=1.0, regulation=1, **kwargs)[source]
Bases:
ChildModelPressurised gas storage at a gas junction.
SoC update:
m_stored_kg(t) = m_stored_kg(t-1) + dt_s * mass_flow_kgs(t). Lossy:mass_flow_kgs = flow_charge_kgs - flow_discharge_kgswithη_c * charge - discharge / η_din the SoC update.- equations(grid, node, **kwargs)[source]
- inter_temporal_equations(temporal_state: monee.solver.core.InterStepState, component_id, **kwargs)[source]
- make_controllable()[source]
Promote
mass_flow_kgs(and loss-split vars if lossy) into solver Vars.
- class monee.model.GasToHeat(heat_energy_mw, diameter_m, temperature_ext_k, efficiency, regulation=1)[source]
Bases:
MultiGridCompoundModel- create(network: monee.model.network.Network, gas_node: monee.model.core.Node, heat_node: monee.model.core.Node, heat_return_node: monee.model.core.Node)[source]
Add sub-components (nodes, branches, children) to network.
- set_active(activation_flag)[source]
- class monee.model.GasToHeatControlNode(gas_mass_flow_kgs, efficiency_heat, hhv, regulation=1, **kwargs)[source]
Bases:
MultiGridNodeModel,Junction- equations(grid, from_branch_models, to_branch_models, childs, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- class monee.model.GasToHeatHG(heat_energy_mw, efficiency, regulation=1)[source]
Bases:
MultiGridBranchModelTwo-endpoint Gas→Heat coupling (gas withdrawal at from-end, q_mw_heat injection at to-end). Junction heat balance picks up
q_mw_heatdirectly.- equations(grids, from_node_model, to_node_model, **kwargs)[source]
- init(grids)[source]
- loss_percent()[source]
- class monee.model.GasToPower(efficiency, p_mw_setpoint, q_mvar_setpoint=0, regulation=1)[source]
Bases:
MultiGridBranchModel- equations(grids, from_node_model, to_node_model, **kwargs)[source]
- loss_percent()[source]
- class monee.model.GenericModel(**kwargs)[source]
Bases:
ABCBase class for all component models (nodes, branches, children, compounds).
Public attributes (no leading
_) form the solver-visible state. UseVarfor decision variables,Constfor pinned setpoints, plain scalars for parameters.- is_cp()[source]
- property values
- property vars
- class monee.model.GenericPowerBranch(tap, shift, br_r_pu, br_x_pu, g_fr_pu, b_fr_pu, g_to_pu, b_to_pu, max_i_ka=3.19, backup=False, on_off=1, **kwargs)[source]
Bases:
BranchModel- equations(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model, **kwargs)[source]
- property loading_pu
- loss_percent()[source]
- class monee.model.GenericTransferBranch(flow_init_kgs: float = 1.0, p_init_mw: float = 1.0, **kwargs)[source]
Bases:
MultiGridBranchModel- equations(grids, from_node_model, to_node_model, **kwargs)[source]
- init(grids)[source]
- is_cp()[source]
- class monee.model.Grid(name: str)[source]
Bases:
objectMarker/base for a resource domain (electrical, gas, heat).
- name: str
- class monee.model.GridFormingGenerator(p_mw_max: float, q_mvar_max: float, vm_pu: float = 1.0, **kwargs)[source]
Bases:
NoVarChildModel,GridFormingMixinGrid-forming generator: variable p_mw/q_mvar (absorbs island imbalance) with a pinned vm_pu. Angle is pinned by
ElectricityIslandingMode.
- class monee.model.GridFormingMixin[source]
Bases:
objectMarker: this child can serve as the slack/reference for an islanded sub-network.
Carriers must implement
overwrite()to pin their reference variable. Islanding keeps components containing aGridFormingMixinchild in the solve.
- class monee.model.GridFormingSource(pressure_pu: float = 1.0, t_k: float = 356.0, mass_flow_max_kgs: float = 1000000.0)[source]
Bases:
ChildModel,GridFormingMixinGrid-forming source: pins pressure (and t_pu/t_k) on the junction, leaves mass_flow_kgs as a Var to absorb island imbalance.
- equations(grid, node_model, **kwargs)[source]
- class monee.model.HeatExchanger(q_mw, mass_flow_design_kgs=None, T_delta_design_K=30, regulation=1)[source]
Bases:
BranchModel- equations(grid: monee.model.grid.WaterGrid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.HeatExchangerGenerator(q_mw, mass_flow_design_kgs=None, regulation=1)[source]
Bases:
HeatExchanger
- class monee.model.HeatExchangerLoad(q_mw, mass_flow_design_kgs=None, regulation=1)[source]
Bases:
HeatExchanger
- class monee.model.HeatGenerator(q_mw, **kwargs)[source]
Bases:
NoVarChildModelNode-based heat injection (
H_G,i). Takes positive magnitude; sign is internal.
- class monee.model.HeatLoad(q_mw, **kwargs)[source]
Bases:
NoVarChildModelNode-based heat withdrawal (
H_L,i). Positive q_mw = consumption.
- class monee.model.Intermediate(value=0)[source]
Bases:
objectA computed (derived) quantity, not a decision variable.
The solver evaluates the matching
IntermediateEqand writes the result back to.valueafter each solve.
- class monee.model.IntermediateEq(attr, eq)[source]
Bases:
objectDeclares how to compute an
Intermediateattribute from other variables.Return an
IntermediateEqfrom a model’sequations()to register a derived quantity; the solver evaluateseqand stores the result on the attribute named byattr.
- class monee.model.IslandingMode[source]
Bases:
NetworkAspect,ABCPer-carrier islanding base. Subclasses set
carrier_grid_typeandvar_prefix, and may overrideadd_physical_constraints()to add e.g. angle pinning / pressure bounds.- add_physical_constraints(*_)[source]
Carrier-specific physics (override in subclasses). Empty by default.
- Return type:
- carrier_grid_type: type
- equations(network: monee.model.network.Network, ignored_nodes: set)[source]
Return solver-agnostic relational expressions (empty by default).
- Return type:
- abstractmethod prepare(network: monee.model.network.Network)[source]
Add Var placeholders before solver variable injection.
- Return type:
- var_prefix: str
- class monee.model.Junction[source]
Bases:
NodeModel- calc_signed_heat_flow(from_branch_models, to_branch_models, child_models, grid)[source]
- calc_signed_mass_flow(from_branch_models, to_branch_models, child_models)[source]
- equations(grid, from_branch_models, to_branch_models, child_models, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- class monee.model.LumpedThermalCapacitance(default_t_init: float | None = None, t_init_overrides: dict | None = None, first_step_steady_state: bool = False)[source]
Bases:
NetworkAspectLTC extension. Nodes with a GridFormingMixin child are excluded.
First-step anchor precedence (anchored mode, the default - required for NLP solvers like GEKKO/IPOPT):
t_init_overrides[node_id]→default_t_init→ the junction’s ownt_puVar initialiser. Passdefault_t_initnear the operating mean to skip the warm-up transient.first_step_steady_state=Truedrops the first-step inertia term (emitsnet_heat == 0); MIP backends only.- activate_timeseries(network, ignored_nodes: set, step_state=None)[source]
Mark LTC junctions
_ltc_activeso the default degenerate heat balance is skipped (avoids a near-singular Jacobian); warm-start t_pu.- Return type:
- equations(network, ignored_nodes: set)[source]
Return solver-agnostic relational expressions (empty by default).
- Return type:
- inter_temporal_equations(network, ignored_nodes: set, temporal_state)[source]
\(\rho \cdot V \cdot (T_{pu}(t) - T_{pu}(t-1))/\Delta t = \text{net\_convective\_heat\_in}\) per LTC junction.
T_prevfalls back to the first-step anchor (see class docstring) whentemporal_state.getreturns None.- Return type:
- class monee.model.MultiGridBranchModel(**kwargs)[source]
Bases:
BranchModelBranch that couples multiple grid domains (e.g. CHP, P2H). Always a control point.
- abstractmethod equations(grids, from_node_model, to_node_model, **kwargs)[source]
- init(grids)[source]
- is_cp()[source]
- class monee.model.MultiGridCompoundModel(**kwargs)[source]
Bases:
CompoundModel- is_cp()[source]
- class monee.model.Network(active_grid=None, el_model=None, water_model=None, gas_model=None)[source]
Bases:
object- activate(component)[source]
- activate_by_id(cls, id)[source]
- activate_grid(grid)[source]
- add_extension(ext: monee.model.extension.core.NetworkAspect)[source]
Register a NetworkAspect extension on this network.
- Return type:
- all_components()[source]
- all_models()[source]
- all_models_with_grid()[source]
- apply_formulation(network_formulation)[source]
Record network_formulation as the network-level default.
Accepts the same spec as the solver’s
formulationargument (resolve_formulation()): a registry key string ("smooth_nlp"), aNetworkFormulation, or a sequence of either (merged left to right).Side-effect free: only the network’s formulation map is updated - components and their models are untouched. The choice materialises when a solver runs
attach_formulationson its solve-time copy. Aformulationargument passed to the solver overrides this choice; per-component formulations passed to the builder methods override both. Repeated calls merge: later registrations win per type key.
- as_dataframe_dict()[source]
- as_dataframe_dict_str()[source]
- as_result_dataframe_dict()[source]
- as_result_dataframe_dict_str()[source]
- 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]
- branch_by_id(branch_id)[source]
- branches_by_ids(branch_ids)[source]
- Return type:
- branches_by_type(cls)[source]
- branches_connected_to(node_id)[source]
- Return type:
- 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]
- child_by_id(child_id)[source]
- child_to(model, node_id, formulation=None, constraints=None, overwrite_id=None, name=None, auto_node_creator=None, auto_grid_key=None)[source]
- childs_by_ids(child_ids)[source]
- Return type:
- childs_by_type(cls)[source]
- clear_childs()[source]
- components_connected_to(node_id)[source]
- Return type:
- compound(model: monee.model.core.CompoundModel, formulation=None, constraints=None, overwrite_id=None, **connected_node_ids)[source]
- compound_by_id(compound_id)[source]
- compound_of(subcomponent_component_id)[source]
- Return type:
- compound_of_node(node_id)[source]
- compounds_by_type(cls)[source]
- compounds_connected_to(node_id)[source]
- Return type:
- constraint(constraint_equation)[source]
- property constraints
- copy()[source]
- property cps: list[GenericModel]
- deactivate(component)[source]
- deactivate_by_id(cls, id)[source]
- property extensions: list[NetworkAspect]
Solver-agnostic network-level extensions.
- first_node()[source]
- get_branch_between(node_id_one, node_id_two, bid=0)[source]
- get_childs_by_type(branch, cls)[source]
- Return type:
- property graph
- property grids
- has_branch(branch_id)[source]
- has_branch_between(node_id_one, node_id_two)[source]
- has_child(child_id)[source]
- has_node(node_id)[source]
- is_blacklisted(obj)[source]
- lookup_formulation(model, grid)[source]
The network-level formulation for model (and grid) accumulated from
apply_formulationcalls, or None. Last matching registration wins, mirroringNetworkFormulation.lookup().- Return type:
- move_branch(branch_id, new_from_id, new_to_id)[source]
- node(model, grid=None, formulation=None, child_ids=None, constraints=None, overwrite_id=None, name=None, position=None)[source]
- node_by_id(node_id)[source]
- Return type:
- node_by_id_or_create(node_id, auto_node_creator, auto_grid_key)[source]
- nodes_by_type(cls)[source]
- objective(objective_function)[source]
- property objectives
- remove_branch(branch_id)[source]
- remove_branch_between(node_one, node_two, key=0)[source]
- remove_child(child_id)[source]
- remove_compound(compound_id)[source]
- remove_node(node_id)[source]
- set_default_grid(key, grid)[source]
- statistics()[source]
- class monee.model.NetworkAspect[source]
Bases:
objectSolver-agnostic network-level extension.
Analogous to
BranchFormulation/NodeFormulationbut spanning the entire network. Register withnetwork.add_extension(aspect).Phase 1 -
prepare(network): called before variable injection; addVarplaceholders to model objects so the injection loop picks them up.Phase 2 -
equations(network, ignored_nodes) → list: called after variable injection; return relational expressions (==,<=,>=) built from injected model attributes. The solver registers them withm.Equations(eqs)/pm.cons.addwithout inspecting their content - exactly like branch/node equations.- activate_timeseries(network, ignored_nodes: set, step_state=None)[source]
Called after
prepare()and variable injection, before node equations are assembled, when a timeseries or multi-period solve begins.Override to set flags on model objects that modify equation assembly for coupled solves - for example, suppressing a degenerate algebraic equation whose role is taken over by an inter-step constraint.
step_state is provided so extensions can warm-start solver variable initializations from the previous step’s solved values. No-op by default.
- Return type:
- equations(network, ignored_nodes: set)[source]
Return solver-agnostic relational expressions (empty by default).
- Return type:
- inter_period_equations(network, ignored_nodes: set, period_state)[source]
Return expressions coupling current variables to other period values (multi-period only). Empty by default.
- Return type:
- inter_step_equations(network, ignored_nodes: set, step_state)[source]
Return expressions coupling current variables to previous-step values (timeseries only). Empty by default.
- Return type:
- class monee.model.NetworkIslandingConfig(electricity: monee.model.extension.islanding.core.IslandingMode | None = None, gas: monee.model.extension.islanding.core.IslandingMode | None = None, water: monee.model.extension.islanding.core.IslandingMode | None = None)[source]
Bases:
NetworkAspectBundle per-carrier
IslandingModeinstances; register vianetwork.add_extensionorenable_islanding().- equations(network: monee.model.network.Network, ignored_nodes: set)[source]
Return solver-agnostic relational expressions (empty by default).
- Return type:
- modes()[source]
- Return type:
- prepare(network: monee.model.network.Network)[source]
Add Var placeholders before variable injection (no-op by default).
- Return type:
- class monee.model.Node(node_id, model, child_ids=None, formulation=None, constraints=None, grid=None, name=None, position=None, active=True, independent=True)[source]
Bases:
ComponentNetwork node tracking attached child components and incoming/outgoing branches.
- add_from_branch_id(branch_id)[source]
- add_to_branch_id(branch_id)[source]
- equations(grid, in_branch_models, out_branch_models, childs, **kwargs)[source]
- minimize(grid, in_branch_models, out_branch_models, childs, **kwargs)[source]
- remove_branch(branch_id)[source]
Remove
branch_idand its reversed counterpart from both branch lists.
- class monee.model.NodeModel(**kwargs)[source]
Bases:
GenericModelAbstract base class for node models (buses, junctions). Subclasses define nodal equations.
- abstractmethod equations(grid, in_branch_models, out_branch_models, childs, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- minimize(grid, in_branch_models, out_branch_models, childs, **kwargs)[source]
Optional objective contribution (e.g. slack penalties). Default: none.
- class monee.model.PassiveHeatExchanger(q_mw, diameter_m, roughness_m=0.0001, length_m=2.5, temperature_ext_k=293, regulation=1, friction=None, loss_coefficient=None)[source]
Bases:
BranchModelPassive heat exchanger injecting/extracting fixed
q_mwinto a free-flowing water branch. Mass flow is determined by surrounding hydraulics; temperature change follows from q_mw and actual mass flow.Sign: positive q_mw = load, negative = generator.
Hydraulics: by default the pressure drop is Darcy-Weisbach friction over
length_m. Passingloss_coefficient(zeta) instead switches to the pandapipesheat_exchangermodel - a zero-length minor loss \(\Delta p = \zeta \cdot \tfrac{\rho}{2} v^2\) (length_m/ friction are then ignored;loss_coefficient=0is a lossless heat injector).- equations(grid: monee.model.grid.WaterGrid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.PassiveHeatExchangerGenerator(q_mw, diameter_m, temperature_ext_k=293, loss_coefficient=None)[source]
Bases:
PassiveHeatExchangerPassive heat exchanger that injects heat (generator,
q_mw < 0).
- class monee.model.PassiveHeatExchangerLoad(q_mw, diameter_m, temperature_ext_k=293, loss_coefficient=None)[source]
Bases:
PassiveHeatExchangerPassive heat exchanger that consumes heat (load,
q_mw > 0).
- class monee.model.PostProcess(fn, value=0)[source]
Bases:
objectA report-only quantity computed after the solve, outside the solver, from the solved model values via
fn(values), wherevaluesis a namespace of the model’s solved fields (read asvalues.vm_pu).Unlike
Intermediate, it is never injected as a solver variable nor referenced by any equation - it carries no degrees of freedom and cannot affect convergence or squareness. The clean home for derived reports (e.g.vm_pu_squared = vm_pu^2): physics stays in the solver, reporting outside.
- class monee.model.PowerBranch(tap, shift, backup=False, on_off=1, **kwargs)[source]
Bases:
GenericPowerBranch,ABC- abstractmethod calc_r_x(grid, from_node_model, to_node_model)[source]
- equations(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.PowerGenerator(p_mw, q_mvar, **kwargs)[source]
Bases:
NoVarChildModelFixed-setpoint active/reactive generator. Constructor takes positive magnitudes; sign is internal.
- class monee.model.PowerGrid(name: str, sn_mva: float = 1, vm_pu_max: float = 1.5, vm_pu_min: float = 0.5)[source]
Bases:
GridElectrical grid domain.
- sn_mva: float = 1
- vm_pu_max: float = 1.5
- vm_pu_min: float = 0.5
- class monee.model.PowerLine(length_m, r_ohm_per_m, x_ohm_per_m, parallel, backup=False, on_off=1, **kwargs)[source]
Bases:
PowerBranch- calc_r_x(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model)[source]
- class monee.model.PowerLoad(p_mw, q_mvar, **kwargs)[source]
Bases:
NoVarChildModelFixed-setpoint power load. Load convention: positive = consumption.
- class monee.model.PowerToGas(efficiency, mass_flow_setpoint_kgs, consume_q_mvar_setpoint=0, regulation=1)[source]
Bases:
MultiGridBranchModel- equations(grids, from_node_model, to_node_model, **kwargs)[source]
- loss_percent()[source]
- class monee.model.PowerToHeat(heat_energy_mw, diameter_m, temperature_ext_k, efficiency, q_mvar_setpoint=0, regulation=1)[source]
Bases:
MultiGridCompoundModel- create(network: monee.model.network.Network, power_node: monee.model.core.Node, heat_node: monee.model.core.Node, heat_return_node: monee.model.core.Node)[source]
Add sub-components (nodes, branches, children) to network.
- set_active(activation_flag)[source]
- class monee.model.PowerToHeatControlNode(load_p_mw, load_q_mvar, efficiency, regulation=1, **kwargs)[source]
Bases:
MultiGridNodeModel,Junction,Bus- equations(grid, from_branch_models, to_branch_models, childs, **kwargs)[source]
Return nodal equations (e.g. flow conservation, voltage balance).
- class monee.model.PowerToHeatHG(heat_energy_mw, efficiency, q_mvar_setpoint=0, regulation=1)[source]
Bases:
MultiGridBranchModelTwo-endpoint Power→Heat coupling (p_from_mw at from-end, q_mw_heat at to-end). Junction heat balance picks up
q_mw_heatdirectly.- equations(grids, from_node_model, to_node_model, **kwargs)[source]
- loss_percent()[source]
- class monee.model.Sink(mass_flow_kgs, **kwargs)[source]
Bases:
NoVarChildModelFixed-setpoint mass-flow sink. Positive = consumption (load convention).
- class monee.model.Source(mass_flow_kgs, t_k=None, **kwargs)[source]
Bases:
NoVarChildModelFixed-setpoint mass-flow source. Constructor takes positive magnitude; sign is internal.
t_k(optional) is the temperature of the injected stream. Without it the injection is credited at the junction’s own (mixed) temperature.
- class monee.model.SubHG(**kwargs)[source]
Bases:
NoVarChildModelSubordinate node-based heat generator used inside
CHPHG.Like HeatGenerator but with q_mw_heat as a Var constrained by the parent compound’s control-node equations. Two-endpoint HG variants (GasToHeatHG / PowerToHeatHG) don’t use this - they carry q_mw_heat directly on the branch.
- class monee.model.ThermalStorage(m_stored_kg_initial, m_stored_kg_max, flow_max_kgs, mass_flow_initial_kgs=0.0, loss_factor_per_h=0.0, regulation=1, **kwargs)[source]
Bases:
ChildModelThermal storage (e.g. hot-water tank) at a water junction.
SoC update:
m_stored_kg(t) = m_stored_kg(t-1) - loss*dt_h*m_stored_kg(t-1) + dt_s*mass_flow_kgs(t).- equations(grid, node, **kwargs)[source]
- inter_temporal_equations(temporal_state: monee.solver.core.InterStepState, component_id, **kwargs)[source]
- make_controllable()[source]
Promote
mass_flow_kgsinto a solver Var.
- class monee.model.Trafo(vk_percent=12.2, vkr_percent=0.25, sn_trafo_mva=160, shift=0)[source]
Bases:
PowerBranch- calc_r_x(grid: monee.model.grid.PowerGrid, lv_model, hv_model)[source]
- equations(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model, **kwargs)[source]
- class monee.model.Var(value, max=None, min=None, integer=False, name=None)[source]
Bases:
objectA decision variable (or mutable parameter) in the optimisation model.
Sign convention for child components: positive = consumption (load), negative = generation.
PowerGenerator(p_mw=5)storesp_mw=-5.Comparison operators compare against the bound, not the value, and return
Falseif the relevant bound isNone.
- class monee.model.WaterGrid(name: str, t_ref_k: float = 356, pressure_ref_pa: float = 1000000, max_mass_flow_kgs: float = 200, v_max_mps: float = 5.0, fluid_density_kg_per_m3: float = None, dynamic_visc_pas: float = None)[source]
Bases:
GridWater/heat grid domain.
fluid_density_kg_per_m3anddynamic_visc_pasdefault toNoneand are then derived fromt_ref_kvia the standard water correlations (seemonee.model.phys.core.properties), so the transport properties always match the grid’s declared operating temperature. Pass explicit values to override (e.g. to model a non-water fluid or a different reference).- dynamic_visc_pas: float = None
- fluid_density_kg_per_m3: float = None
- max_mass_flow_kgs: float = 200
- pressure_ref_pa: float = 1000000
- t_ref_k: float = 356
- v_max_mps: float = 5.0
- class monee.model.WaterIslandingMode(big_m_conn: int = 200)[source]
Bases:
IslandingModeWater/heat islanding. Use
GridFormingSourcefrom the gas module.- add_physical_constraints(network, gf_nodes, regular_nodes, e_vars)[source]
Carrier-specific physics (override in subclasses). Empty by default.
- Return type:
- carrier_grid_type
alias of
WaterGrid
- prepare(network: monee.model.network.Network)[source]
Add Var placeholders before solver variable injection.
- Return type:
- var_prefix: str = 'water'
- class monee.model.WaterPipe(diameter_m, length_m, temperature_ext_k=283.15, roughness_m=4.5e-05, lambda_insulation_w_per_m_k=0.025, insulation_thickness_m=0.12, on_off=1, friction=None, unidirectional=False)[source]
Bases:
BranchModel- equations(grid: monee.model.grid.WaterGrid, from_node_model, to_node_model, **kwargs)[source]
- loss_percent()[source]
- monee.model.calc_coordinates(network: monee.model.network.Network, component: monee.model.core.Component)[source]
- monee.model.create_gas_grid(name, type='lgas', t_ref_k=None, pressure_ref_pa=None)[source]
Return a
GasGridpopulated fromGAS_GRID_ATTRS[type].t_ref_k/pressure_ref_paoverride the reference condition so the derived compressibility tracks the grid’s actual operating pressure. Pass them here rather than mutating the grid afterwards, so__post_init__derives Z from the final values (a post-construction assignment leaves the already-derived Z stale).
- monee.model.create_power_grid(name, sn_mva=1)[source]
- monee.model.create_water_grid(name, t_ref_k=356, pressure_ref_pa=1000000)[source]
Return a
WaterGridwhose density/viscosity are derived fromt_ref_k(seeWaterGrid). Passt_ref_khere rather than mutating the grid afterwards, so the derived properties match the final reference temperature.
- monee.model.lower(var_or_const)[source]
Return the lower bound of a
Var(or its value if unbounded); pass through otherwise.
- monee.model.make_heat_convex_milp_formulation(num_partitions: int = 1, include_heat_exchangers: bool = True)[source]
McCormick district-heating relaxation: LP for
num_partitions == 1, piecewise MILP above. Raise the partition count only whenmccormick_dhs_gap_bound_k()shows the LP corner is non-physical on the network at hand.include_heat_exchangersalso maps the active/passive heat exchangers to their convex variants so the sector has no non-convex fallback; disable it to reproduce the legacy pipes-only McCormick apply.- Return type:
- monee.model.model(cls)[source]
Register a model class in the global
component_listregistry.
- monee.model.to_spanning_tree(network: monee.model.network.Network)[source]
- monee.model.tracked
alias of
Var
- monee.model.transform_network(network: monee.model.network.Network, graph_transform)[source]
- monee.model.upper(var_or_const)[source]
Return the upper bound of a
Var(or its value if unbounded); pass through otherwise.
- monee.model.value(var_or_const)[source]
Extract
.valuefrom aVar/Const/Intermediate/PostProcess; pass through plain scalars.
Core protocol¶
Attribute types (Var, Const, Intermediate, PostProcess),
abstract model bases and the component containers.
- class monee.model.core.Branch(model, from_node_id, to_node_id, formulation=None, constraints=None, grid=None, name=None, active=True, independent=True)[source]¶
Bases:
Component- property tid¶
- class monee.model.core.BranchModel(**kwargs)[source]¶
Bases:
GenericModelAbstract base class for network branches (lines, pipes). Subclasses define branch equations.
- class monee.model.core.Child(child_id, model, formulation=None, constraints=None, grid=None, name=None, active=True, independent=True)[source]¶
Bases:
Component
- class monee.model.core.ChildModel(regulation: float = 1.0, **kwargs)[source]¶
Bases:
GenericModelLeaf component attached to a single node (loads, generators, ext-grids).
Load convention: positive = consumption, negative = generation. Generator subclasses negate the user-supplied magnitude so the public API takes positive numbers.
regulationin[0.0, 1.0]scales the setpoint; used by multi-energy couplers (P2H, CHP) for partial dispatch.
- class monee.model.core.Component(id, model, formulation=None, constraints=None, grid=None, name=None, active=True, independent=True)[source]¶
Bases:
ABC- property nid¶
- property tid¶
- class monee.model.core.Compound(compound_id, model: monee.model.core.CompoundModel, connected_to, subcomponents, formulation=None, constraints=None, grid=None, name=None, active=True)[source]¶
Bases:
Component
- class monee.model.core.CompoundModel(**kwargs)[source]¶
Bases:
GenericModelComposite component spanning multiple nodes/carriers (e.g. P2H unit).
Subclasses implement
create()to add sub-components to the network, and may overrideequations()for coupling constraints.
- class monee.model.core.Const(value)[source]¶
Bases:
objectA fixed (non-optimised) constant that participates in the model attribute protocol.
Used in
overwrite()to pin a node variable to a fixed setpoint instead of turning it into a free decision variable.
- class monee.model.core.GenericModel(**kwargs)[source]¶
Bases:
ABCBase class for all component models (nodes, branches, children, compounds).
Public attributes (no leading
_) form the solver-visible state. UseVarfor decision variables,Constfor pinned setpoints, plain scalars for parameters.- property values¶
- property vars¶
- class monee.model.core.Intermediate(value=0)[source]¶
Bases:
objectA computed (derived) quantity, not a decision variable.
The solver evaluates the matching
IntermediateEqand writes the result back to.valueafter each solve.
- class monee.model.core.IntermediateEq(attr, eq)[source]¶
Bases:
objectDeclares how to compute an
Intermediateattribute from other variables.Return an
IntermediateEqfrom a model’sequations()to register a derived quantity; the solver evaluateseqand stores the result on the attribute named byattr.
- class monee.model.core.MultiGridBranchModel(**kwargs)[source]¶
Bases:
BranchModelBranch that couples multiple grid domains (e.g. CHP, P2H). Always a control point.
- class monee.model.core.MultiGridCompoundModel(**kwargs)[source]¶
Bases:
CompoundModel
- class monee.model.core.MultiGridNodeModel(**kwargs)[source]¶
Bases:
NodeModelNode that participates in multiple grid domains. Always a control point.
- class monee.model.core.Node(node_id, model, child_ids=None, formulation=None, constraints=None, grid=None, name=None, position=None, active=True, independent=True)[source]¶
Bases:
ComponentNetwork node tracking attached child components and incoming/outgoing branches.
- class monee.model.core.NodeModel(**kwargs)[source]¶
Bases:
GenericModelAbstract base class for node models (buses, junctions). Subclasses define nodal equations.
- class monee.model.core.PostProcess(fn, value=0)[source]¶
Bases:
objectA report-only quantity computed after the solve, outside the solver, from the solved model values via
fn(values), wherevaluesis a namespace of the model’s solved fields (read asvalues.vm_pu).Unlike
Intermediate, it is never injected as a solver variable nor referenced by any equation - it carries no degrees of freedom and cannot affect convergence or squareness. The clean home for derived reports (e.g.vm_pu_squared = vm_pu^2): physics stays in the solver, reporting outside.
- class monee.model.core.Var(value, max=None, min=None, integer=False, name=None)[source]¶
Bases:
objectA decision variable (or mutable parameter) in the optimisation model.
Sign convention for child components: positive = consumption (load), negative = generation.
PowerGenerator(p_mw=5)storesp_mw=-5.Comparison operators compare against the bound, not the value, and return
Falseif the relevant bound isNone.
- monee.model.core.lower(var_or_const)[source]¶
Return the lower bound of a
Var(or its value if unbounded); pass through otherwise.
- monee.model.core.set_initial_value(var, value)[source]¶
Seed a variable’s initial guess / warm start, backend-agnostically.
A model attribute may be a monee
Varor, once a backend has runinject_vars(e.g. inactivate_timeseries), the backend’s own variable object. moneeVar/ GEKKOGKVariable/ PyomoVarall expose a settablevalue; gurobipyVarinstead carries its warm start inStart(and has novalue, sovar.value = ...raises). Duck-type on the available attribute so callers in the model layer never need to know which solver backend is active.A backend symbol that seeds its warm start elsewhere (e.g. the CasADi
CasSym, which capturesx0atinject_varstime and exposes neither attribute) is deliberately a silent no-op. A plain scalar/string target is never a valid warm-start sink, so reject it loudly to catch the wrong-target programming error the no-op would otherwise mask.- Return type:
Network container¶
- class monee.model.network.Network(active_grid=None, el_model=None, water_model=None, gas_model=None)[source]¶
Bases:
object- add_extension(ext: monee.model.extension.core.NetworkAspect)[source]¶
Register a NetworkAspect extension on this network.
- Return type:
- apply_formulation(network_formulation)[source]¶
Record network_formulation as the network-level default.
Accepts the same spec as the solver’s
formulationargument (resolve_formulation()): a registry key string ("smooth_nlp"), aNetworkFormulation, or a sequence of either (merged left to right).Side-effect free: only the network’s formulation map is updated - components and their models are untouched. The choice materialises when a solver runs
attach_formulationson its solve-time copy. Aformulationargument passed to the solver overrides this choice; per-component formulations passed to the builder methods override both. Repeated calls merge: later registrations win per type key.
- 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]¶
- 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]¶
- child_to(model, node_id, formulation=None, constraints=None, overwrite_id=None, name=None, auto_node_creator=None, auto_grid_key=None)[source]¶
- compound(model: monee.model.core.CompoundModel, formulation=None, constraints=None, overwrite_id=None, **connected_node_ids)[source]¶
- property constraints¶
- property cps: list[GenericModel]¶
- property extensions: list[NetworkAspect]¶
Solver-agnostic network-level extensions.
- property graph¶
- property grids¶
- lookup_formulation(model, grid)[source]¶
The network-level formulation for model (and grid) accumulated from
apply_formulationcalls, or None. Last matching registration wins, mirroringNetworkFormulation.lookup().- Return type:
- node(model, grid=None, formulation=None, child_ids=None, constraints=None, overwrite_id=None, name=None, position=None)[source]¶
- property objectives¶
- monee.model.network.calc_coordinates(network: monee.model.network.Network, component: monee.model.core.Component)[source]¶
- monee.model.network.to_spanning_tree(network: monee.model.network.Network)[source]¶
- monee.model.network.transform_network(network: monee.model.network.Network, graph_transform)[source]¶
Grids¶
Per-carrier physical constants and bounds.
- class monee.model.grid.GasGrid(name: str, molar_mass: float, dynamic_visc_pas: float, higher_heating_value_kwh_per_kg: float, universal_gas_constant: float, t_k: float, t_ref_k: float, pressure_ref_pa: float, nominal_pressure_pu: float, max_mass_flow_kgs: float, pressure_squared_pu_max: float, pressure_squared_pu_min: float, compressibility: float = None, pressure_ambient_pa: float = 0.0)[source]¶
Bases:
GridGas grid domain. Construct via
create_gas_grid()for defaults.compressibilitydefaults toNoneand is then derived from the reference pressure (pressure_ref_pa), temperature (t_k) andmolar_massvia the Papay real-gas correlation (seemonee.model.phys.core.properties), so Z reflects the grid’s declared operating pressure rather than a fixed ideal-gas 1. Pass an explicit value to override (e.g. to force ideal gas withcompressibility=1).
- class monee.model.grid.Grid(name: str)[source]¶
Bases:
objectMarker/base for a resource domain (electrical, gas, heat).
- class monee.model.grid.NoGrid(name: str)[source]¶
Bases:
GridMarker for components not bound to any grid.
- class monee.model.grid.PowerGrid(name: str, sn_mva: float = 1, vm_pu_max: float = 1.5, vm_pu_min: float = 0.5)[source]¶
Bases:
GridElectrical grid domain.
- class monee.model.grid.WaterGrid(name: str, t_ref_k: float = 356, pressure_ref_pa: float = 1000000, max_mass_flow_kgs: float = 200, v_max_mps: float = 5.0, fluid_density_kg_per_m3: float = None, dynamic_visc_pas: float = None)[source]¶
Bases:
GridWater/heat grid domain.
fluid_density_kg_per_m3anddynamic_visc_pasdefault toNoneand are then derived fromt_ref_kvia the standard water correlations (seemonee.model.phys.core.properties), so the transport properties always match the grid’s declared operating temperature. Pass explicit values to override (e.g. to model a non-water fluid or a different reference).
- monee.model.grid.create_gas_grid(name, type='lgas', t_ref_k=None, pressure_ref_pa=None)[source]¶
Return a
GasGridpopulated fromGAS_GRID_ATTRS[type].t_ref_k/pressure_ref_paoverride the reference condition so the derived compressibility tracks the grid’s actual operating pressure. Pass them here rather than mutating the grid afterwards, so__post_init__derives Z from the final values (a post-construction assignment leaves the already-derived Z stale).
Node models¶
- class monee.model.node.Bus(base_kv)[source]¶
Bases:
NodeModel
Branch models¶
- class monee.model.branch.GasCompressor(compression_ratio=1.5, max_flow_kgs=10.0)[source]¶
Bases:
BranchModelIdeal compressor - fixed pressure ratio, unidirectional (suction → discharge). Forward flow lives in
mass_flow_neg_kgsto match GasPipe’s Weymouth convention.- equations(grid: monee.model.grid.GasGrid, from_node_model, to_node_model, **kwargs)[source]¶
- class monee.model.branch.GasPipe(diameter_m, length_m, temperature_ext_k=296.15, roughness_m=0.0001, on_off=1, friction=None)[source]¶
Bases:
BranchModel- equations(grid: monee.model.grid.GasGrid, from_node_model, to_node_model, **kwargs)[source]¶
- class monee.model.branch.GenericPowerBranch(tap, shift, br_r_pu, br_x_pu, g_fr_pu, b_fr_pu, g_to_pu, b_to_pu, max_i_ka=3.19, backup=False, on_off=1, **kwargs)[source]¶
Bases:
BranchModel- equations(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model, **kwargs)[source]¶
- property loading_pu¶
- class monee.model.branch.HeatExchanger(q_mw, mass_flow_design_kgs=None, T_delta_design_K=30, regulation=1)[source]¶
Bases:
BranchModel- equations(grid: monee.model.grid.WaterGrid, from_node_model, to_node_model, **kwargs)[source]¶
- class monee.model.branch.HeatExchangerGenerator(q_mw, mass_flow_design_kgs=None, regulation=1)[source]¶
Bases:
HeatExchanger
- class monee.model.branch.HeatExchangerLoad(q_mw, mass_flow_design_kgs=None, regulation=1)[source]¶
Bases:
HeatExchanger
- class monee.model.branch.PassiveHeatExchanger(q_mw, diameter_m, roughness_m=0.0001, length_m=2.5, temperature_ext_k=293, regulation=1, friction=None, loss_coefficient=None)[source]¶
Bases:
BranchModelPassive heat exchanger injecting/extracting fixed
q_mwinto a free-flowing water branch. Mass flow is determined by surrounding hydraulics; temperature change follows from q_mw and actual mass flow.Sign: positive q_mw = load, negative = generator.
Hydraulics: by default the pressure drop is Darcy-Weisbach friction over
length_m. Passingloss_coefficient(zeta) instead switches to the pandapipesheat_exchangermodel - a zero-length minor loss \(\Delta p = \zeta \cdot \tfrac{\rho}{2} v^2\) (length_m/ friction are then ignored;loss_coefficient=0is a lossless heat injector).- equations(grid: monee.model.grid.WaterGrid, from_node_model, to_node_model, **kwargs)[source]¶
- class monee.model.branch.PassiveHeatExchangerGenerator(q_mw, diameter_m, temperature_ext_k=293, loss_coefficient=None)[source]¶
Bases:
PassiveHeatExchangerPassive heat exchanger that injects heat (generator,
q_mw < 0).
- class monee.model.branch.PassiveHeatExchangerLoad(q_mw, diameter_m, temperature_ext_k=293, loss_coefficient=None)[source]¶
Bases:
PassiveHeatExchangerPassive heat exchanger that consumes heat (load,
q_mw > 0).
- class monee.model.branch.PowerBranch(tap, shift, backup=False, on_off=1, **kwargs)[source]¶
Bases:
GenericPowerBranch,ABC- equations(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model, **kwargs)[source]¶
- class monee.model.branch.PowerLine(length_m, r_ohm_per_m, x_ohm_per_m, parallel, backup=False, on_off=1, **kwargs)[source]¶
Bases:
PowerBranch- calc_r_x(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model)[source]¶
- class monee.model.branch.Trafo(vk_percent=12.2, vkr_percent=0.25, sn_trafo_mva=160, shift=0)[source]¶
Bases:
PowerBranch- calc_r_x(grid: monee.model.grid.PowerGrid, lv_model, hv_model)[source]¶
- equations(grid: monee.model.grid.PowerGrid, from_node_model, to_node_model, **kwargs)[source]¶
- class monee.model.branch.WaterPipe(diameter_m, length_m, temperature_ext_k=283.15, roughness_m=4.5e-05, lambda_insulation_w_per_m_k=0.025, insulation_thickness_m=0.12, on_off=1, friction=None, unidirectional=False)[source]¶
Bases:
BranchModel- equations(grid: monee.model.grid.WaterGrid, from_node_model, to_node_model, **kwargs)[source]¶
Child models¶
- class monee.model.child.ConsumeHydrGrid(mass_flow_kgs=0.1, pressure_pu=1, t_k=293, **kwargs)[source]¶
Bases:
NoVarChildModelHydraulic demand point: fixed pressure setpoint plus a free mass_flow_kgs Var.
- class monee.model.child.ExtHydrGrid(mass_flow_kgs=-1, pressure_pu=1, t_k=356, max_import_kgs=None, max_export_kgs=None, pin_temperature=True, **kwargs)[source]¶
Bases:
NoVarChildModel,GridFormingMixinExternal hydraulic slack source. Pins pressure (and optionally temperature), leaves mass_flow_kgs as a free Var. Load convention: negative mass_flow_kgs = injection.
- class monee.model.child.ExtPowerGrid(p_mw, q_mvar, vm_pu=1, va_degree=0, max_import_mw=None, max_export_mw=None, **kwargs)[source]¶
Bases:
NoVarChildModel,GridFormingMixinExternal slack-bus connection. Pins vm_pu and va_degree, leaves p_mw/q_mvar as free Vars absorbing the island’s imbalance. Load convention: positive p_mw = import.
- class monee.model.child.GridFormingMixin[source]¶
Bases:
objectMarker: this child can serve as the slack/reference for an islanded sub-network.
Carriers must implement
overwrite()to pin their reference variable. Islanding keeps components containing aGridFormingMixinchild in the solve.
- class monee.model.child.HeatGenerator(q_mw, **kwargs)[source]¶
Bases:
NoVarChildModelNode-based heat injection (
H_G,i). Takes positive magnitude; sign is internal.
- class monee.model.child.HeatLoad(q_mw, **kwargs)[source]¶
Bases:
NoVarChildModelNode-based heat withdrawal (
H_L,i). Positive q_mw = consumption.
- class monee.model.child.NoVarChildModel(regulation: float = 1.0, **kwargs)[source]¶
Bases:
ChildModelChildModelwith only scalar parameters and no equations of its own.
- class monee.model.child.PowerGenerator(p_mw, q_mvar, **kwargs)[source]¶
Bases:
NoVarChildModelFixed-setpoint active/reactive generator. Constructor takes positive magnitudes; sign is internal.
- class monee.model.child.PowerLoad(p_mw, q_mvar, **kwargs)[source]¶
Bases:
NoVarChildModelFixed-setpoint power load. Load convention: positive = consumption.
- class monee.model.child.Sink(mass_flow_kgs, **kwargs)[source]¶
Bases:
NoVarChildModelFixed-setpoint mass-flow sink. Positive = consumption (load convention).
- class monee.model.child.Source(mass_flow_kgs, t_k=None, **kwargs)[source]¶
Bases:
NoVarChildModelFixed-setpoint mass-flow source. Constructor takes positive magnitude; sign is internal.
t_k(optional) is the temperature of the injected stream. Without it the injection is credited at the junction’s own (mixed) temperature.
Storage models¶
Storage child models for multi-energy timeseries simulation.
Each model exposes a tracked SoC variable persisted to StepState between
timesteps; inter_step_equations couples it to the previous step.
Load convention: positive = charging (consume from network), negative = discharging.
Dispatch (p_mw / mass_flow_kgs) is a plain float by default - fixed setpoint
in energy-flow solves. Call make_controllable() (or
OptimizationProblem.controllable_storages()) to promote it to a Var.
- class monee.model.storage.ElectricStorage(e_mwh_initial, e_mwh_max, p_max_mw, p_mw_initial=0.0, efficiency_charge=1.0, efficiency_discharge=1.0, regulation=1, **kwargs)[source]¶
Bases:
ChildModelBattery/electric storage attached to a power bus.
SoC update:
e_mwh(t) = e_mwh(t-1) + dt_h * p_mw(t). With efficiency losses,p_mw = p_charge_mw - p_discharge_mw(both \(\ge\) 0) and SoC uses \(\eta_c \cdot p_{charge} - p_{discharge} / \eta_d\).- inter_temporal_equations(temporal_state: monee.solver.core.InterStepState, component_id, **kwargs)[source]¶
- class monee.model.storage.GasStorage(m_stored_kg_initial, m_stored_kg_max, flow_max_kgs, mass_flow_initial_kgs=0.0, efficiency_charge=1.0, efficiency_discharge=1.0, regulation=1, **kwargs)[source]¶
Bases:
ChildModelPressurised gas storage at a gas junction.
SoC update:
m_stored_kg(t) = m_stored_kg(t-1) + dt_s * mass_flow_kgs(t). Lossy:mass_flow_kgs = flow_charge_kgs - flow_discharge_kgswithη_c * charge - discharge / η_din the SoC update.- inter_temporal_equations(temporal_state: monee.solver.core.InterStepState, component_id, **kwargs)[source]¶
- class monee.model.storage.ThermalStorage(m_stored_kg_initial, m_stored_kg_max, flow_max_kgs, mass_flow_initial_kgs=0.0, loss_factor_per_h=0.0, regulation=1, **kwargs)[source]¶
Bases:
ChildModelThermal storage (e.g. hot-water tank) at a water junction.
SoC update:
m_stored_kg(t) = m_stored_kg(t-1) - loss*dt_h*m_stored_kg(t-1) + dt_s*mass_flow_kgs(t).- inter_temporal_equations(temporal_state: monee.solver.core.InterStepState, component_id, **kwargs)[source]¶
Multi-energy couplers¶
- class monee.model.multi.CHP(diameter_m: float, efficiency_power: float, efficiency_heat: float, mass_flow_setpoint_kgs: float, q_mvar_setpoint: float = 0, temperature_ext_k: float = 293, regulation=1)[source]¶
Bases:
MultiGridCompoundModel- create(network: monee.model.network.Network, gas_node: monee.model.core.Node, heat_node: monee.model.core.Node, heat_return_node: monee.model.core.Node, power_node: monee.model.core.Node)[source]¶
Add sub-components (nodes, branches, children) to network.
- class monee.model.multi.CHPControlNode(mass_flow_capacity_kgs, efficiency_power, efficiency_heat, hhv, q_mvar=0, regulation=1, **kwargs)[source]¶
Bases:
MultiGridNodeModel,Junction,BusControl node for a CHP unit; couples power, heat, and gas domains.
- class monee.model.multi.CHPHG(efficiency_power: float, efficiency_heat: float, mass_flow_setpoint_kgs: float, q_mvar_setpoint: float = 0, regulation=1)[source]¶
Bases:
MultiGridCompoundModelHeatGenerator-based
CHPvariant: heat is injected via aSubHGchild atheat_nodeinstead of via an HX branch. Noheat_return_node/diameter_mrequired.- create(network: monee.model.network.Network, gas_node: monee.model.core.Node, heat_node: monee.model.core.Node, power_node: monee.model.core.Node)[source]¶
Add sub-components (nodes, branches, children) to network.
- class monee.model.multi.CHPHGControlNode(mass_flow_capacity_kgs, efficiency_power, efficiency_heat, hhv, sub_hg, q_mvar=0, regulation=1, **kwargs)[source]¶
Bases:
MultiGridNodeModel,Junction,BusCHP control node using a node-based HeatGenerator (no HX branch).
Like
CHPControlNodebut only on power+gas; heat goes through aSubHGchild attached at the heat node byCHPHG.
- class monee.model.multi.GasToHeat(heat_energy_mw, diameter_m, temperature_ext_k, efficiency, regulation=1)[source]¶
Bases:
MultiGridCompoundModel- create(network: monee.model.network.Network, gas_node: monee.model.core.Node, heat_node: monee.model.core.Node, heat_return_node: monee.model.core.Node)[source]¶
Add sub-components (nodes, branches, children) to network.
- class monee.model.multi.GasToHeatControlNode(gas_mass_flow_kgs, efficiency_heat, hhv, regulation=1, **kwargs)[source]¶
Bases:
MultiGridNodeModel,Junction
- class monee.model.multi.GasToHeatHG(heat_energy_mw, efficiency, regulation=1)[source]¶
Bases:
MultiGridBranchModelTwo-endpoint Gas→Heat coupling (gas withdrawal at from-end, q_mw_heat injection at to-end). Junction heat balance picks up
q_mw_heatdirectly.
- class monee.model.multi.GasToPower(efficiency, p_mw_setpoint, q_mvar_setpoint=0, regulation=1)[source]¶
Bases:
MultiGridBranchModel
- class monee.model.multi.GenericTransferBranch(flow_init_kgs: float = 1.0, p_init_mw: float = 1.0, **kwargs)[source]¶
Bases:
MultiGridBranchModel
- class monee.model.multi.PowerToGas(efficiency, mass_flow_setpoint_kgs, consume_q_mvar_setpoint=0, regulation=1)[source]¶
Bases:
MultiGridBranchModel
- class monee.model.multi.PowerToHeat(heat_energy_mw, diameter_m, temperature_ext_k, efficiency, q_mvar_setpoint=0, regulation=1)[source]¶
Bases:
MultiGridCompoundModel- create(network: monee.model.network.Network, power_node: monee.model.core.Node, heat_node: monee.model.core.Node, heat_return_node: monee.model.core.Node)[source]¶
Add sub-components (nodes, branches, children) to network.
- class monee.model.multi.PowerToHeatControlNode(load_p_mw, load_q_mvar, efficiency, regulation=1, **kwargs)[source]¶
Bases:
MultiGridNodeModel,Junction,Bus
- class monee.model.multi.PowerToHeatHG(heat_energy_mw, efficiency, q_mvar_setpoint=0, regulation=1)[source]¶
Bases:
MultiGridBranchModelTwo-endpoint Power→Heat coupling (p_from_mw at from-end, q_mw_heat at to-end). Junction heat balance picks up
q_mw_heatdirectly.
- class monee.model.multi.SubHE(q_mw, mass_flow_design_kgs=None, T_delta_design_K=30, regulation=1)[source]¶
Bases:
HeatExchangerSubordinate heat exchanger used inside compound models (CHP, G2H, P2H).
- class monee.model.multi.SubHG(**kwargs)[source]¶
Bases:
NoVarChildModelSubordinate node-based heat generator used inside
CHPHG.Like HeatGenerator but with q_mw_heat as a Var constrained by the parent compound’s control-node equations. Two-endpoint HG variants (GasToHeatHG / PowerToHeatHG) don’t use this - they carry q_mw_heat directly on the branch.