Physical models¶
monee uses steady-state models for each energy carrier. Select a tab to see the governing equations, key variables and modelling conventions for that domain. How to select between the formulations described here (default MISOCP-shaped, piecewise-linear, smooth NLP) is covered in Formulations.
AC power flow
The standard nonlinear AC power-flow equations are used, with voltage magnitude V and voltage angle δ as the node decision variables.
Active and reactive power injected at bus i:
where G and B are the conductance and susceptance entries from the nodal admittance matrix Y.
Variable |
Symbol |
Unit |
|---|---|---|
Voltage magnitude |
V |
per unit |
Voltage angle |
δ |
radians |
Active power injection |
P |
MW |
Reactive power injection |
Q |
Mvar |
MISOCP Branch-Flow relaxation
The MISOCP relaxation (EL_MISOCP_FORMULATION) uses the Branch-Flow
Model: the bilinear voltage products are replaced by the lifted variables
W = V² (squared voltage) and ℓ = |I|² (squared current), and the
nonlinear coupling is relaxed into the rotated second-order cone
yielding a convex problem solvable globally by a MISOCP solver such as Gurobi or SCIP. Two cone encodings are available. The first is the rotated cone above. The second is a Lorentz-cone form: with \(s = (W_i + \ell_{ij})/2\) and \(d = (W_i - \ell_{ij})/2\) the same constraint becomes \(P_{ij}^2 + Q_{ij}^2 + d^2 \le s^2\), which survives inside otherwise non-convex MIQCPs. A gap expression \(W_i \, \ell_{ij} - (P_{ij}^2 + Q_{ij}^2)\) is provided for diagnostics: a near-zero gap at the optimum certifies that the relaxation is exact.
Weymouth pipe flow
Pressure drops along a gas pipe are governed by the Weymouth equation. Pressure is modelled as pressure-squared p² to keep the equation quadratic:
with f the Darcy friction factor (see Friction models in the Water / Heat tab; the same modes apply to gas pipes). The pipe constant C encodes the physical properties of the pipe and gas:
where D is the inner diameter, L is the pipe length, R is the specific gas constant, T_gas is the gas temperature, and Z is the compressibility factor. Gas density along each pipe is computed from the ideal-gas law using the average pressure between the two endpoints.
Variable |
Symbol |
Unit |
|---|---|---|
Pressure squared |
p² |
per unit (of p²_ref) |
Mass flow |
ṁ |
kg/s |
Note: The pressure state is the squared per-unit pressure (
pressure_squared_pu, scaled by the grid’s reference pressure). Using p² as the primary variable avoids the square root that would otherwise appear in a direct pressure formulation, keeping the problem structure quadratic and easier for NLP solvers; the SI value is recovered after the solve as a report-only quantity.
In the MISOCP-shaped default (GAS_CONVEX_MIQCQP_FORMULATION) the flow
is split into two non-negative variables \(\dot{m}_{ij}\) / \(\dot{m}_{ji}\)
(mass_flow_pos_kgs / mass_flow_neg_kgs) gated by a direction binary; by
convention direction == 0 means forward flow, carried by
mass_flow_neg_kgs. The squared flows enter through a convex epigraph relaxation
kept tight by a small objective term, so MIQCP solvers recognise the problem
as a MISOCP.
Each pipe’s flow is capped by the tighter of the grid-wide limit and a velocity cap,
where the gas \(v_\text{max}\) defaults to 20 m/s, the erosional velocity limit for gas pipelines. This per-pipe bound tightens every big-M constraint.
Smooth (binary-free) hydraulics
The direction binary and the pos/neg split do not survive a pure NLP
relaxation. The smooth Weymouth variant
(GAS_NLP_FORMULATION) therefore uses a single signed mass
flow ṁ and the smooth identity
with the smoothing scale ε (smoothing_eps) defaulting to 10⁻³ kg/s. The
pressure drop becomes C∞, monotonic and odd in the flow: no binaries, no
epigraph. The equation is additionally row-normalised by the per-pipe
coefficient \(C^2 \, p_\text{ref}^2\):
Since \(C^2 \propto D^5\) spans roughly six orders of magnitude across a wide-diameter network, dividing through gives every pipe a unit coefficient on the (dimensionless) squared-pressure difference. This materially improves IPOPT’s scaling and conditioning while leaving the solution unchanged. See Formulations for how to apply the smooth formulations.
Darcy-Weisbach hydraulic flow
Hydraulic pressure drops along water pipes follow the Darcy-Weisbach equation:
where the hydraulic resistance R_m is:
with f the Darcy friction factor, L the pipe length, D the inner diameter, ρ the fluid density, and A the cross-sectional area.
As in the gas domain, the default formulation splits the flow into
mass_flow_pos_kgs / mass_flow_neg_kgs gated by a direction binary
(direction == 0 ⇒ forward flow via mass_flow_neg_kgs), and each pipe’s flow
is capped by \(\min\!\left( f_\text{max},\; \tfrac{\pi}{4} D^2 \rho \, v_\text{max} \right)\)
using the water grid’s velocity limit v_max_mps.
Friction models
The friction factor f is selectable via the friction_model option of the
smooth NLP gas and water/heat formulations (GAS_NLP_FORMULATION,
HEAT_NLP_FORMULATION). Four modes exist:
Mode |
Friction factor |
When to use |
|---|---|---|
|
Per-pipe constant: the turbulent Swamee-Jain asymptote \(f = 0.25 / \log_{10}\!\big(\tfrac{\epsilon}{3.7 D}\big)^2\) |
Turbulent networks (Re ≳ 10⁴), where it is accurate to within a few percent |
|
Hagen-Poiseuille laminar term (\(64/\mathrm{Re}\), linear in flow) plus the fully-rough turbulent term; matches pandapipes’ default Nikuradse law and stays QCQP-representable |
Mixed laminar/turbulent networks where a closed-form variable friction is enough |
|
Piecewise function of the flow: a cubic-spline interpolation of the full drop term over log-spaced breakpoints |
Laminar-heavy networks needing a variable friction without a Reynolds closure |
|
Smooth sigmoid blend of the laminar law and Swamee-Jain, Reynolds-coupled |
Laminar-heavy networks solved as pure NLPs |
The constant mode depends only on relative roughness ε/D, so friction, Reynolds number and the friction-flow bilinear all drop out of the solver model. The price is accuracy at low flow: in the laminar regime (Re < 2 300) it under-estimates the pressure drop.
The pwl mode restores variable friction as one odd cubic spline \(\psi(\dot{m}) = f\!\big(\mathrm{Re}(\dot{m})\big) \cdot \dot{m} |\dot{m}|\) of the full drop term, over log-spaced breakpoints. A zero-anchor keeps a no-flow branch feasible and collinear breakpoints are dropped automatically. Around 12 breakpoints suffice.
The nonlinear mode replaces the non-smooth if Re < 2300 regime switch
with a single continuously differentiable blend of the laminar law 64/Re and
the Swamee-Jain correlation:
with \(\mathrm{Re}_\text{crit} = 2300\) and sharpness \(s = 400\), plus a Reynolds closure equation per pipe.
Note: Reynolds-number variables are stored scaled by 10⁻⁶ (
REYNOLDS_SCALE), so breakpoints and bounds sit in [0, 10] rather than [0, 10⁷], keeping the coefficient range of the solver matrix manageable.
Smooth (binary-free) hydraulics
As in the gas domain, the smooth Darcy-Weisbach variant
(HEAT_NLP_FORMULATION) replaces the pos/neg split and
the direction binary with one signed flow ṁ and the smooth identity
(ε = smoothing_eps, default 10⁻³ kg/s), so the pressure drop
\(p_i - p_j = -R_m \, \dot{m} |\dot{m}|\) is C∞, monotonic and odd. Temperature
upwinding is likewise expressed through the smooth flow split instead of the
direction binary, keeping the heat model a pure NLP. See
Formulations for how to select the smooth formulations.
Temperature propagation
Temperatures are modelled per-unit, scaled by the grid’s reference temperature T_ref. The outlet temperature accounts for insulation losses and the ambient temperature:
The attenuation factor α depends on the UA product of the insulation layer and the specific heat capacity of water:
with λ the insulation conductivity and r_o, r_i the outer and inner insulation radii. This rational form is the first-order equivalent of the exponential decay law and stays well-defined at zero flow.
Variable |
Symbol |
Unit |
|---|---|---|
Node pressure |
p |
per unit (of p_ref) |
Mass flow |
ṁ |
kg/s |
Inlet / outlet temperature |
T_in, T_out |
per unit (of T_ref) |
External temperature |
T_ext |
K |
Scaling conventions at a glance¶
Several states are deliberately stored in scaled form; raw SI values are recovered after the solve.
Quantity |
Stored as |
Scale |
|---|---|---|
Gas pressure |
Squared per-unit ( |
p²_ref |
Water pressure |
Per-unit ( |
p_ref |
Heat temperatures |
Per-unit ( |
T_ref |
Reynolds number |
Re / 10⁶ ( |
10⁶ |
Voltage |
Per-unit (V, or W = V² in the MISOCP) |
base voltage |
Pipe flow cap |
\(\min\!\left( f_\text{max},\; \tfrac{\pi}{4} D^2 \rho \, v_\text{max} \right)\) |
gas: v_max = 20 m/s (erosional); water: grid |